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

Monday,November 25, 2024, 12:28:22

Login with username, password and session length

Shoutbox

Bad Raven:
12 May 2024 08:13:51
 I have some F1 Abusemark boards going spare,,,,,,,,,,,,,    ;)    :azn
DarkButterfly:
11 May 2024 22:12:29
And with oldskool parts  :D
DarkButterfly:
11 May 2024 22:11:57
I must be the only one doing tricopters right now  :laugh:
DarkButterfly:
11 May 2024 22:09:30
 :D
Gaza07:
11 May 2024 21:15:16
Domain has been renewed closure has been cancelled  :D
Gaza07:
02 May 2024 08:07:52
Who are most people ??? I think the person you are referring to has put in a lot of effort to keep things moving  :rolleyes:
hoverfly:
01 May 2024 10:16:12
Most people I have spoken to are pizzed off with the yellow peril  flooding the forum,go figure. :whistling:
Gaza07:
23 Apr 2024 08:09:45
The Domain expires for the forum in 60 days, I'm not going to renew it this time unless I see any activity  :beer2:
Gaza07:
20 Apr 2024 18:02:50
Is there anyone who would like to see this forum stay open ? :shrug:
hoverfly:
17 Apr 2024 17:15:13
 :rolleyes:
Members
Stats
  • Total Posts: 201,498
  • Total Topics: 20,274
  • Online today: 16
  • Online ever: 530
  • (Tuesday,June 26, 2012, 08:34:46 )
Users Online
Users: 0
Guests: 15
Total: 15

Theme Changer





3d - Printworx

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;

http://youtu.be/U9EULgVXox8

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

#2
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

#3
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

#4
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 )