Welcome to Multi-Rotor UK. Please login or sign up.

Sunday,November 17, 2019, 07:11:36

Login with username, password and session length

Shoutbox

ched:
18 Oct 2019 11:25:16
Sounds good yama. Would love to see some images. 3d models sound cool too
yama:
18 Oct 2019 10:32:38
i might have to do a review. the 21mp camera is excellent at producing high quality 3d models for mapping.
ched:
10 Oct 2019 16:56:16
Show us some picys and maybe post a review in a thread?
yama:
09 Oct 2019 14:13:10
must admit this anafi is tiny and looks like a toy in a lunchbox but performs like a professional product.
yama:
09 Oct 2019 14:11:52
went ahead and bought one. about to find out if the 21mp camera improves photogrammetry surveys.
ched:
08 Oct 2019 17:14:17
Not tried a parrot anafi but I thought parrot were stopping 'drone' production?
yama:
07 Oct 2019 13:25:37
anyone tried a parrot anafi?
Gaza07:
26 Sep 2019 11:33:59
We know a song about that dont we  :D
Andy7:
26 Sep 2019 08:38:34
 :laugh:
Bad Raven:
26 Sep 2019 07:10:39
Adopts Australian accent "Black, that's not Black, its a dirty grey, THIS is Black........"   :D
Members
Stats
  • Total Posts: 197131
  • Total Topics: 19877
  • Online Today: 39
  • Online Ever: 530
  • (Tuesday,June 26, 2012, 08:34:46 )
Users Online
Users: 0
Guests: 42
Total: 42

Theme Changer





thumbnail

3d - Printworx

Printing 3d Forum

Setting up Voltage Monitoring on a multiwii crius AIOP

Started by teslahed, Sunday,June 23, 2013, 18:08:10

Previous topic - Next topic

teslahed

I am currently trying to set up the battery voltage monitoring feature on my Crius All in one Pro (v1 addition with no USB port).

Here is a diagram of a voltage divider circuit;



where R1 goes to your main lipo + connection and R2 goes to the ground connection and the centre tap goes to the analog V_BATPIN on the crius all in one pro.

For R1 i have used a 68kohm resistor and for R2 i have used a 44kohm resistor so that more voltage will be dropped across R1 than R2. The idea is to limit the current and only measure a fraction of the total voltage - because the crius can only measure up to 5V before it';s in danger of frying (WARNING - YOU COULD FRY YOUR BOARD IF YOU GET THIS WRONG).

The ratio of R1 to R2 sets the voltage at the centre point so it';s important to pick values for R1 and R2 that produce a voltage of less than 5V between the centre point and ground. Multiwii code gives values for R1 and R2 as R1=51k and R2=33k. I didn';t have these exact values so used R1 = 68Kohms and R2 = 44Kohms which gives the same ratio so works just as well as a voltage divider.

So R1 has to be larger so that more volts are dropped across that than R2.

So far so good. I';ve made up the voltage divider circuit with some resistors and wired it into my crius via the analogue input pin and am looking at the code;

/********************************************************************/
  /****           battery voltage monitoring                       ****/
  /********************************************************************/
    /* for V BAT monitoring
       after the resistor divisor we should get [0V;5V]->[0;1023] on analog V_BATPIN
       with R1=33k and R2=51k
       vbat = [0;1023]*16/VBATSCALE
       must be associated with #define BUZZER ! */
    #define VBAT              // uncomment this line to activate the vbat code
    #define VBATSCALE       122  // (*) change this value if readed Battery voltage is different than real voltage
    #define VBATNOMINAL     126 // 12,6V full battery nominal voltage - only used for lcd.telemetry
    #define VBATLEVEL_WARN1 107 // (*) 10,7V
    #define VBATLEVEL_WARN2  99 // (*) 9.9V
    #define VBATLEVEL_CRIT   93 // (*) 9.3V - critical condition: if vbat ever goes below this value, permanent alarm is triggered
    #define NO_VBAT          16  // (*) Avoid beeping without any battery


To get the crius measuring voltage correctly it looks like i need to alter #define VBATSCALE.

I did some googling and found this website;

http://panoramaic.se/configurator/2.0/

which has a ';VBATSCALE'; calculator near the bottom. It tells me that to get the VBATSCALE value i need to measure the voltage drop between the centre tap and the ground connection. I have done this using my multimeter and get a voltage drop of 4.8 volts between the centre of the resistors and ground when the total voltage is 12.4 volts across the lipo. I';ve put these values into the calculator and i get #define VBATSCALE       125 .

My first few attempts using analogue pin 3 failed. I got nonesense results back like 4.something volts.

Then in despiration i decided to try analogue pin 0.

IT WORKS!

This confuses me a little because;

/**************************************************************************************/
  /********                      override default pin assignments    ********************/
  /**************************************************************************************/

  /* only enable any of this if you must change the default pin assignment, e.g. your board does not have a specific pin */
  /* you may need to change PINx and PORTx plus #shift according to the desired pin! */
  //#define OVERRIDE_V_BATPIN                   A0 // instead of A3    // Analog PIN 3


i haven';t commented in the section of code that over rides the default analogue pin 3 and assigns the voltage monitoring to analogue pin 0.

So a bit of a mystery there, and it took me the best part of 3 days to get this far, but i';m happy  :smiley:
One circlip short of a quadcopter.
 1 lobe short of an antenna.

teslahed

Here is a quick test of the voltage monitor via my MinimOSD - recorded remotely;



The voltage readout responds sensibly and sags under load when i throttle up the way it should - so i';m confident it';s working properly.
One circlip short of a quadcopter.
 1 lobe short of an antenna.

teslahed

Tuesday,June 25, 2013, 21:39:50 #2 Last Edit: Tuesday,October 22, 2013, 18:34:49 by Jumpy07
I have been made aware of a better (safer) way of setting up voltage monitoring on a multiwii board like this.

Firstly - fit a 5.2 volt zener diode from the input of the crius and ground. The zener will conduct at 5.2 volts and effectively clip any high voltage spikes on the supply. Anything much higher than 5.4 volts will KILL the crius.

The second thing is you may be better off using a variable resistor like a volume control, but a version known as a multi turn. Instead of the usual 270 degrees of a standard volume control type resistor, these have 10 turns, this way you can get a better adjustment.

In addition to what i mentioned before, i would fit a 1.5K resisttor in the connection that goes to the battery.

If in the event thast someone turns the control right up, the zener wouldnt handle the higher voltage and would burn out. Without the safety of the series resistor, once the zener dies, the Crius will follow.

I cant stress to much that its a simple matter to overload the Crius and at worst, kill it.



My approach has worked fine for me - the simplest method that works. It would be VERY easy to fry the crius by making a mistake with my setup.
One circlip short of a quadcopter.
 1 lobe short of an antenna.

teslahed

Thursday,July 04, 2013, 13:25:57 #3 Last Edit: Tuesday,October 22, 2013, 18:32:06 by Jumpy07
I';ve rebuilt my voltage divider to try and make it a bit safer. I have used a small piece of veroboard to neated it up, still using fixed resistors values for simplicity.

The main differences are the addition of the zener diode and 10uF capacitor.





In order to get this working with a Multiwii crius all in one Pro flight controller I';ve soldered the positive and negative wires to the main lipo solder points (12.6V, 0V) and the white centre divider wire to analogue pin 0 on the multiwii board.

The relevent bit of code is in the Multiwii config section;

/********************************************************************/
  /****           battery voltage monitoring                       ****/
  /********************************************************************/
    /* for V BAT monitoring
       after the resistor divisor we should get [0V;5V]->[0;1023] on analog V_BATPIN
       with R1=33k and R2=51k
       vbat = [0;1023]*16/VBATSCALE
       must be associated with #define BUZZER ! */
    #define VBAT              // uncomment this line to activate the vbat code
    #define VBATSCALE       92  // (*) change this value if readed Battery voltage is different than real voltage
    #define VBATNOMINAL     126 // 12,6V full battery nominal voltage - only used for lcd.telemetry
    #define VBATLEVEL_WARN1 105 // (*) 10,7V
    #define VBATLEVEL_WARN2  100 // (*) 9.9V
    #define VBATLEVEL_CRIT   95 // (*) 9.3V - critical condition: if vbat ever goes below this value, permanent alarm is triggered
    #define NO_VBAT          16  // (*) Avoid beeping without any battery


The main variable that needs settings is #define VBATSCALE 

In order to get multiwii to display voltages correctly you need to set VBATSCALE correctly and this is done by taking measurements.

Hook a 3 cell lipo up to the multirotor and measure the main lipo voltage (12.46 Volts in my case).

Then measure the voltage between the center divider and the ground (3.46 Volts for me).

Put the values into the Voltage divider calculator found here;

http://www.multiwii.com/forum/viewtopic.php?f=18&t=3495

And it will give you a value of VBATSCALE to use. I am now using 92.



One circlip short of a quadcopter.
 1 lobe short of an antenna.

teslahed

Thursday,July 04, 2013, 15:55:41 #4 Last Edit: Thursday,July 04, 2013, 16:00:50 by teslahed
Here is a photo of the final version of my voltage divider;



I';ve taken out the zener diode as it was doing something strange to the circuit. I am not sure what yet.

I';ve left the capacitor in there to help filter out noise and stuck a ferrite ring on there as well - then rebuilt the circuit as small as possible on a little bit of circuit board and covered it all in transparent heatshrink.

It seems to work fine and doesn';t take up much space on the FPV Hex.

I measure 4.6 volts at the central divide when the battery voltage is 12.17 volts total. Vbat is set to 124;

#define VBATSCALE       124  // (*) change this value if readed Battery voltage is different than real voltage

Multiwii GUI returns sensible values.
One circlip short of a quadcopter.
 1 lobe short of an antenna.

peter_a

I use 22k and 47k resistors, so as a top scale voltage of 15 volts down to 5 volt for the adc  ( 3:1 )