Voltage sensor with improved resolution for MultiWii

Post Reply
User avatar
sigor
Posts: 2
Joined: Sun Oct 21, 2012 7:37 pm
Location: Espoo, Finland

Voltage sensor with improved resolution for MultiWii

Post by sigor »

Hello all,

Recently I have got a MultiWii FC board from HobbyKing and was very satisfied with its performance on my tricopter. :D So, I decided to try all features available. :)
The first thing to try was the battery voltage sensor. Searching a bit on this forum I found this topic useful http://www.multiwii.com/forum/viewtopic.php?f=16&t=2490#p23255 which I then followed. After a bit of soldering and editing "config.h" I managed to get it working. :)

The idea behind voltage sensor is pretty simple: construct circuit of two resistors with proper values and get voltage divider.
Image
Then the voltage at the output of circuit i expressed as:

Vout = Vbat * R2/(R1+R2).

The proposed values for resistors are R1 = 33k and R2 = 51k. Easy, isn't it?

However, reality is such that the battery voltage is typically fall within the range of [9 ... 12.6] Volts (Li-Po 3S) which in turn related to Vout in range [3.54 ... 4.95] V. The Vout is then measured by 10-bit ADC tuned for range of [0 ... 5] V giving 289 ADC counts which is about 28% of acceptable ADC range. :cry:
In other words the battery voltage is measured with resolution of

12.6/1024 = 0.012 V

or even less if accounted for rounding errors in calculation by MultiWii code. Also, the resolution is getting even worse for 4S-6S battery packs, so does the accuracy of measurement of mAh consumed by aircraft.

Improvement
Here, I propose an improved voltage sensor circuit still preserving its simplicity. Keeping in mind that realistic battery voltage can be written as

Vbat = Vc + [9 ... 12.6].

The idea is to use Zener diode to subtract constant amount Vz from battery's voltage and measure the rest. So the sensor output is given as:

Vout = (Vbat - Vz)*R2/(R1+R2)

In such way it is possible to fully utilize ADC resolution. Please note that now the values for R1 and R2 are different from that said above!

The circuit:
Image

R3 is intended to protect MCU (in case of an accident :?:)

I have made a simple MATLAB code which can find the best combinations of required D1, R1, R2 values utilizing list of standard values of real components. Here is the input data and result for 3S Li-Po.

Code: Select all

% Battery params
Bat_cells = 3;        % Number of cells in battery
Bat_Vcell_min = 3;    % [V] Min cell voltage
Bat_Vcell_max = 4.2;  % [V] Max cell voltage

% ADC Params
ADC_Vmin = 0;         % [V] Min ADC input voltage
ADC_Vmax = 4.9;       % [V] Max ADC input voltage. Safe margin allowed (Real Vmax = 5V)
ADC_bit = 10;         % Bit depth of ADC

% Zenner diode params
Dz_Imin = 5e-3;     % [A] Minimal Zenner diode current
Dz_Imax = 40e-3;    % [A] Maximal Zenner diode current

... CODE OMITTED ...

****************************************** RESULTS **************************************************
Some combinations.
Vbat range: [9.00 => 12.60 V]. Cells: 3S

   R1    R2    Vz    I range           Vout range         ADC range        Resol      [dVa/dVb]   Pow dissipated on D1
    8    200   7.5  [  7 =>  24 mA]   [1.44 => 4.90 V]   [ 300 => 1023]    4.98 [mV]   0.96        [ 54 .. 184 mW] << the best
... some results omitted
   10    240   7.5  [  6 =>  20 mA]   [1.44 => 4.90 V]   [ 300 => 1022]    4.98 [mV]   0.96        [ 45 .. 153 mW]
...
   12    270   7.5  [  5 =>  18 mA]   [1.44 => 4.88 V]   [ 299 => 1019]    5.00 [mV]   0.96        [ 40 .. 136 mW]
    7    150   7.5  [ 10 =>  33 mA]   [1.43 => 4.88 V]   [ 299 => 1019]    5.00 [mV]   0.96        [ 72 .. 244 mW]
   10    220   7.5  [  7 =>  22 mA]   [1.43 => 4.88 V]   [ 299 => 1018]    5.00 [mV]   0.96        [ 49 .. 166 mW]
    9    200   7.5  [  7 =>  24 mA]   [1.43 => 4.88 V]   [ 299 => 1018]    5.00 [mV]   0.96        [ 54 .. 183 mW]
    8    180   7.5  [  8 =>  27 mA]   [1.43 => 4.88 V]   [ 299 => 1018]    5.00 [mV]   0.96        [ 60 .. 203 mW]
   11    240   7.5  [  6 =>  20 mA]   [1.43 => 4.88 V]   [ 299 => 1018]    5.00 [mV]   0.96        [ 45 .. 152 mW]
...
   10    200   7.5  [  7 =>  24 mA]   [1.43 => 4.86 V]   [ 298 => 1014]    5.02 [mV]   0.95        [ 54 .. 182 mW]
   11    220   7.5  [  6 =>  22 mA]   [1.43 => 4.86 V]   [ 298 => 1014]    5.02 [mV]   0.95        [ 49 .. 166 mW]
   12    240   7.5  [  6 =>  20 mA]   [1.43 => 4.86 V]   [ 298 => 1014]    5.02 [mV]   0.95        [ 45 .. 152 mW]
...
   33    130   7.5  [  9 =>  31 mA]   [1.20 => 4.07 V]   [ 249 =>  849]    6.00 [mV]   0.80        [ 69 .. 235 mW]
   33    130   6.8  [ 13 =>  36 mA]   [1.75 => 4.63 V]   [ 366 =>  966]    6.00 [mV]   0.80        [ 92 .. 242 mW]
   56    220   6.8  [  8 =>  21 mA]   [1.75 => 4.62 V]   [ 365 =>  965]    6.00 [mV]   0.80        [ 54 .. 143 mW]
   56    220   7.5  [  5 =>  18 mA]   [1.20 => 4.07 V]   [ 249 =>  849]    6.00 [mV]   0.80        [ 41 .. 139 mW]
...
  360    330   2.7  [  9 =>  14 mA]   [3.01 => 4.73 V]   [ 629 =>  988]   10.01 [mV]   0.48        [ 25 ..  39 mW]
  240    220   2.7  [ 14 =>  22 mA]   [3.01 => 4.73 V]   [ 629 =>  988]   10.01 [mV]   0.48        [ 37 ..  58 mW]
  360    330   3.0  [  9 =>  14 mA]   [2.87 => 4.59 V]   [ 599 =>  958]   10.01 [mV]   0.48        [ 26 ..  42 mW]
  360    330   3.9  [  7 =>  13 mA]   [2.44 => 4.16 V]   [ 509 =>  869]   10.01 [mV]   0.48        [ 29 ..  49 mW]
  120    110   5.6  [ 15 =>  30 mA]   [1.63 => 3.35 V]   [ 339 =>  699]   10.01 [mV]   0.48        [ 83 .. 170 mW]
  240    220   5.6  [  7 =>  15 mA]   [1.63 => 3.35 V]   [ 339 =>  699]   10.01 [mV]   0.48        [ 41 ..  85 mW]
  120    110   6.2  [ 12 =>  28 mA]   [1.34 => 3.06 V]   [ 279 =>  639]   10.01 [mV]   0.48        [ 75 .. 173 mW]
  240    220   6.2  [  6 =>  14 mA]   [1.34 => 3.06 V]   [ 279 =>  639]   10.01 [mV]   0.48        [ 38 ..  86 mW]
 ...
  120    110   6.8  [ 10 =>  25 mA]   [1.05 => 2.77 V]   [ 219 =>  579]   10.01 [mV]   0.48        [ 65 .. 171 mW]
  120    110   7.5  [  7 =>  22 mA]   [0.72 => 2.44 V]   [ 149 =>  509]   10.01 [mV]   0.48        [ 49 .. 166 mW]
  360    330   5.1  [  6 =>  11 mA]   [1.87 => 3.59 V]   [ 389 =>  749]   10.01 [mV]   0.48        [ 29 ..  55 mW]
  240    220   2.5  [ 14 =>  22 mA]   [3.11 => 4.83 V]   [ 649 => 1008]   10.01 [mV]   0.48        [ 35 ..  55 mW]
  240    220   2.8  [ 13 =>  21 mA]   [2.97 => 4.69 V]   [ 619 =>  978]   10.01 [mV]   0.48        [ 38 ..  60 mW]
  360    330   3.3  [  8 =>  13 mA]   [2.73 => 4.45 V]   [ 569 =>  929]   10.01 [mV]   0.48        [ 27 ..  44 mW]


Some shortcuts explained
I range: Range of current flowing in circuit
Vout range: Range of sensor output values
ADC range: Range of ADC counts
Resol: mV per one ADC count
dVo/dVb = (Vout_max - Vout_min)/(Vbat_max - Vbat_min)
Pow dissipated on D1: Range of power converted to heat on Zener diode. Should not exceed maximal ratings of the diode used.


The result shows that D1, R1 and R2 can be selected to maximize voltage measurement resolution. Also, resolution can be selected for easy calculation, say 5mV or 10mV per ADC count.
One more example, this time for 6S Li-Po. The result shows that even for 6S it is possible to get 10mV resolution. Also more powerful Zener diode required.

Code: Select all

Vbat range: [18.00 => 25.20 V]. Cells: 6S
  R1     R2   Vz    I range           Vout range         ADC range        Resol        [dVa/dVb]   Pow Dz
  160    180  16.0  [  6 =>  27 mA]   [1.06 => 4.87 V]   [ 220 => 1017]    9.04 [mV]   0.53        [ 94 .. 433 mW]
...
  240    220  15.0  [  7 =>  22 mA]   [1.43 => 4.88 V]   [ 299 => 1018]   10.01 [mV]   0.48        [ 98 .. 333 mW]


One of the drawbacks of this sensor is increased current consumption in comparison with original sensor. Wasted power on sensor when using 6S Li-Po is about 0.7 Watts.

Huuuh. Enough theory :x

I will update the post once I try it on experiment. I have ordered all needed components and now waiting for them shipped.



NEW :arrow: Results of experiment

Now I finally received the set of different Zener diodes so I did experiment with the proposed circuit.
The setup consists of Adruino nano board, used for voltage measurement, PC controlled power supply and the proposed circuit with Zener diode assembled on a breadboard.
The measurement procedure is very simple and consists of setting the voltage of power supply and simultaneously recording Arduino ADC output. The results presented in the next 3 figures which are showing input voltage in Volts vs output voltage in terms of ADC counts (Vbat and Vout, respectively). I experimented with voltages typical for 3S and 6S LiPo batteries.


Image
Image
Image

All measurements show linear response of the circuit. So I did linear fit of the measured values, with fit expression shown in each figure. In fact, these expressions are the ones to use for conversion ADC counts into real voltage. First coefficient (one multiplied with "x") in the fit expression shows achieved resolution while the second term shows minimal measurable voltage defined by Zener voltage. Small steps on experimental curves is due to the way my power supply changes the voltage and is not inherent to the circuit under test.
I noticed some some issues which lead to slight nonlinearity of the circuit response resulting in limited accuracy of battery voltage measurement. The reason is in slight dependence of Zener voltage on current flowing through the diode. The changes in case of 6S battery and 18v diode was about 0.1V within nominal battery voltage range (18V ... 25.2V). In case of 6S and 16v diode the Zener voltage was changed only about 0.05V, which explained by higher current through diode and well known Voltage-Current characteristic of Zener diode. :ugeek:

Conclusion

To conclude, the proposed circuit allows to obtain higher resolution than with the simple resistive divider. The gain in the resolution of voltage measurement is more significant for higher voltage batteries like 6S batteries. However, the presence of Zener diode, which always have non ideal properties, may limit accuracy of voltage measurement with this accuracy dependent on the diode and current in the circuit. I would personally consider to use such circuit with 4S-6S batteries and I will be already satisfied with the simple divider in case of 3S battery. There is no reason at all to use proposed circuit with 1S or 2S batteries where is the simple divider is the right solution.
Attachments
6S_Dz=18v_R1=1000_R2=1100_PSU-corrected.png
Bat: 6S, Dz=18v, R1=1000, R2=1100.
(11.28 KiB) Not downloaded yet
6S_Dz=16v_R1=1000_R2=1100_PSU-corrected.png
Bat: 6S, Dz=16v, R1=1000, R2=1100.
(10.73 KiB) Not downloaded yet
3S_Dz=8v2_R1=100_R2=1000_PSU-corrected.png
Bat: 3S, Dz=8v2, R1=100, R2=1000
(11.08 KiB) Not downloaded yet
VoltSensorForMultiWii_Orig.png
Original battery voltage sensor. Schematic diagram.
(2.45 KiB) Not downloaded yet
VoltSensorForMultiWii.png
Battery voltage sensor with improved resolution. Schematic diagram.
(3.19 KiB) Not downloaded yet
Last edited by sigor on Sat Dec 01, 2012 10:46 am, edited 6 times in total.

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Voltage sensor with improved resolution for MultiWii

Post by Hamburger »

interesting.
Please post results, especially about the true resolution you get out of those ADC.

User avatar
sigor
Posts: 2
Joined: Sun Oct 21, 2012 7:37 pm
Location: Espoo, Finland

Re: Voltage sensor with improved resolution for MultiWii

Post by sigor »

Now I have added some experimental data.

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Voltage sensor with improved resolution for MultiWii

Post by Hamburger »

sigor wrote:Now I have added some experimental data.

interesting findings.
And a welcome confirmation too (for we are not doing too bad for typical 3S setups).

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by copterrichie »

Question, any suggestions as to which Zener diode is good for this application?

Thank you.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by copterrichie »

I assume the following would be a good kit to have on-hand for experimenting.

Zener Diode, Voltage-Regulator Diode Components Package, voltage stabilizing diode.

The value list:

1/2W 0.5W:
2V 2.2V 2.4V 2.7V 3V 3.3V 3.6V 3.9V 4.3V 4.7V 5.1V 5.6V 6.2V 6.8V 7.5V 8.2V 9.1V 10V 11V 12V 13V 15V 16V 18V 20V 22V 24V 27V 30V 39V



http://www.ebay.com/itm/1-2W-2V-39V-Zen ... 2ec4ac38f6

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by copterrichie »

I built my first one and will put it to the test today. I did not have a 100 ohm resistor on-hand, so I used a 1K and a 10K resistor with a 8.2 volt Zener . So far, this is great. Very precision measurements on the bench!

Kudos!

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by copterrichie »

FYI: I tested this Zener measurement technique under REAL load and it is VERY ACCURATE!!

Kudos. Sad that others are not using this very powerful and useful tool. I can see having additional circuity to detect if the voltage drop below the rated Zener, it would set an alarm or trigger a host of events.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by copterrichie »

Image

VoltageReading.png
(5.7 KiB) Not downloaded yet


Added a small cap to the circuit.

User avatar
Leon11t
Posts: 38
Joined: Thu Sep 27, 2012 12:24 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by Leon11t »

What is the model of Zener diode?
What type and nominal of capacitor do you use (ceramic, electrolytic...)?
By the way, good job!

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by copterrichie »

I am using a 1N4738 Zener for a 3S battery, R1 = 1K and R2= 10K (did not have a 100ohm on hand). The Capacitor is just an Electrolytic 1uf, could be any size, just not to large, take to long to charge and discharge. :)

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Voltage sensor with improved resolution for MultiWii

Post by Hamburger »

copterrichie wrote:Image

VoltageReading.png


Added a small cap to the circuit.

You run that without Zener diode?

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by copterrichie »

Hamburger wrote:
copterrichie wrote:Image

VoltageReading.png


Added a small cap to the circuit.

You run that without Zener diode?


Sorry, with a Zener. Don't recall what happened to the symbol.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by copterrichie »

I know now, I copied the wrong file. LOL,


This is the correct one with the cap not shown.

Image

realpastaman
Posts: 93
Joined: Thu Jan 12, 2012 1:10 am

Re: Voltage sensor with improved resolution for MultiWii

Post by realpastaman »

I'm from an electronics background. This type of circuit is also used with simple analog meters to give a more accurate /detailed display of battery voltage since we are only interested in a limted range of voltages.

I like the idea very much.

I'm guessing that a change in the MultiWii code is required because of the offset voltage of the zener diode? If that is the case, has anyone produced any code?

I'm interested to get this working with my new MinimOSD :)

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by copterrichie »

I have it working on my OSD very well, but having problems with the 8bit vbat in the current code. :(

rjgrubisa
Posts: 4
Joined: Wed Jan 23, 2013 10:09 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by rjgrubisa »

excuse the basic question, but which is the polarity of the electrolytic capacitor? Negative to gnd?

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by copterrichie »

rjgrubisa wrote:excuse the basic question, but which is the polarity of the electrolytic capacitor? Negative to gnd?



the strip is negative.

rjgrubisa
Posts: 4
Joined: Wed Jan 23, 2013 10:09 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by rjgrubisa »

tnx for your quick response! i know that, but in the circuit? negative to ground or to arduino pin? sorry, but my english is terrible!

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by copterrichie »

let me do a better diagram.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by copterrichie »

Here is a better diagram I hope. :)

The Zener is not the one suggestion, for a 3S you want the breakdown voltage at about 8.2 etc.

Image
Attachments
ZenerVoltage_schem.png

rjgrubisa
Posts: 4
Joined: Wed Jan 23, 2013 10:09 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by rjgrubisa »

Again, thanks! I will make it the next weekend and post the results...

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by copterrichie »

rjgrubisa wrote:Again, thanks! I will make it the next weekend and post the results...


Just noticed, the Battery symbol is reverse.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by copterrichie »

Here is my fix for using a Zener to measure a more accurate voltage without any major modifications to the existing code. I am presently using a Zener with a breakdown voltage of 8.2V however, all that is required for a 4S or greater battery, is to select a Zener of a higher breakdown voltage.

Code: Select all

/********************************************************************/
  /****           battery voltage monitoring                       ****/
  /********************************************************************/
   
    #define VBAT              // uncomment this line to activate the vbat code
    #define VBATSCALE       1 // (*) change this value if readed Battery voltage is different than real voltage
    #define VBATNOMINAL     40 // 4.0V full battery nominal voltage - only used for lcd.telemetry
    #define VBATLEVEL_WARN1 23 // (*) 2.3 Volts
    #define VBATLEVEL_WARN2  15 // (*) 1.5 Volts
    #define VBATLEVEL_CRIT   10 // (*) 1.0V - critical condition: if vbat ever goes below this value, permanent alarm is triggered
    #define NO_VBAT          0  // (*) Avoid beeping without any battery


Code: Select all

#if defined(VBAT)
      static uint8_t vbatTimer = 0;
      static uint8_t ind = 0;
      static uint16_t vbatRaw = 0;
      if (! (++vbatTimer % VBATFREQ)) {
        vbatRaw = (analogRead(V_BATPIN) / 21);
        vbat = uint8_t(vbatRaw);
      }
    #endif

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by copterrichie »

Ever have one of those DUH! Moments when something that seemed so hard was in reality, very simple. Well. Ha. :)

Code: Select all

#if defined(VBAT)
      static uint8_t vbatTimer = 0;
      static uint8_t ind = 0;
      static uint16_t vbatRaw = 0;
      if (! (++vbatTimer % VBATFREQ)) {
        vbatRaw = (analogRead(V_BATPIN) / 21);
        if (vbatRaw >> 1)
        vbat = uint8_t(vbatRaw * 1.1 + 82); //82 = voltage drop of the Zener 8.2 and the 1.1 is the ratio of R1 and R2
        else
        vbat = uint8_t(vbatRaw);
      }
    #endif

thebgrian
Posts: 47
Joined: Sun Mar 27, 2011 4:46 am

Re: Voltage sensor with improved resolution for MultiWii

Post by thebgrian »

copterrichie, great idea for better voltage reading :)
I have a question, trying to understand this better - aren't R1 and R2 working as a voltage divider. Shouldn't the ratio in the case with R1=1k and R2=10k be R2/(R1+R2), or 0.9 instead of 1.1?

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by copterrichie »

thebgrian wrote:copterrichie, great idea for better voltage reading :)
I have a question, trying to understand this better - aren't R1 and R2 working as a voltage divider. Shouldn't the ratio in the case with R1=1k and R2=10k be R2/(R1+R2), or 0.9 instead of 1.1?


yes but 1.1 is the reciprocal of .9 (1 / .9) :)

thebgrian
Posts: 47
Joined: Sun Mar 27, 2011 4:46 am

Re: Voltage sensor with improved resolution for MultiWii

Post by thebgrian »

Got it. We need the voltage between D1 and R1 (the measured voltage at A3*1/the ratio of the voltage divider) plus the Zener drop.
Did the capacitor improve quality of the the readings significantly?

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by copterrichie »

Significantly, there is no need for the averaging routine in my opinion which amounts to memory saved and also processing time.

mabaka
Posts: 21
Joined: Thu Oct 17, 2013 12:03 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by mabaka »

Placing a zener seems to reduce the voltage, instead of dividing it, to me an excellent idea.

Zeners are not very precise. If you take several zeners of, say, 3.9V, probably they are all in a range 3.7V to 4.1V.

So a more precise solution can be place a reference voltage diode, which is moreless a precise zener. As far as I know there are of 1.235V and 2.5V, so for example placing two LM385-2.5V in series you can reduce precisely the lipo voltage in 5V.

Vlipo-2vref.png
Substract 5V with precision
(3.76 KiB) Not downloaded yet

mabaka
Posts: 21
Joined: Thu Oct 17, 2013 12:03 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by mabaka »

Sorry, I had in mind wrongly 2S lipos used in cars. For 3S and 4S, add voltage references in series or use aditionally voltage divider.
Attachments
Vlipo-2vref+red.png
Reduce and divide
(7.11 KiB) Not downloaded yet

mabaka
Posts: 21
Joined: Thu Oct 17, 2013 12:03 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by mabaka »

mabaka wrote:...As far as I know there are of 1.235V and 2.5V...


After a more exhaustive search, there are more values of voltage references. The LM4040 from Texas Instruments and others can be chosen with fixed output voltages of 2.048V, 2.5V, 3V, 4.096V, 5V, 8.192V, and 10V, so the most convenient one seems the 8.192V reference (LM4040x82I) for 3S and the 10V reference (LM4040x10I) for 4S and more.

Suppose one Lipo element which will swing from 4.2V to 3V. So for 3S you don't need a voltage divider, but for 4S and more you need it, so as to limit the voltage swing on the microprocessor analog input pin to less than 5V (really should be less in some boards; see below).

For a 3S Lipo, and not using a voltage divider, the maximum voltage will be moreless 3x4.235V-8.192V=4.513V. The minimum voltage will be 3x3V-8.192V=0.808V (it can go close to 0V if discharging under 9V). Suppose you supply the microprocessor at 5V (from the ESC) minus one diode drop, as happens in many boards: you are barely on the safe side (really the charger will limit the charge to 4.2V, but if you overcharge cells can go up to 4.235V). Note that the maximum voltage on an analog input can go up to VCC; if you want to be completely safe you can use a voltage divider on 3S. Another safety measure can be to supply the board from the ESC with highest 5V output (measure all to choose one).

The LM4040x82I can be found in TO-92 package (also in SOT23), so the best is to solder it and the resistor(s) on a small prototype board. The third pin is NC.

A fast test for 3S can be done with a 8.2V zener (BZX55C8V2).

handsomejackuk
Posts: 97
Joined: Mon Sep 08, 2014 12:25 am

Re: Voltage sensor with improved resolution for MultiWii

Post by handsomejackuk »

i hoping to crack this shortly as my voltage divider circuit does not operate accurately enough... so for a 3S battery we are selecting an 8.2v Zener ?

User avatar
baco
Posts: 13
Joined: Thu Mar 12, 2015 11:47 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by baco »

If now we reduce volts with zener diode, why a voltage divider done? Only with the resistance that will ground would is enough.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

Si ya reducimos los voltios con el diodo zener, ¿por que se hace un divisor de tensión? Solo con la resistencia que va a tierra es suficiente.

Image

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Voltage sensor with improved resolution for MultiWii

Post by Hamburger »

For lipos >3S the range between fully charged and depleted under load is > 5Volts. Therefore the need for a voltage divider behind the zener.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by copterrichie »

Also, the first resistor serves as a current limiter to prevent overloading the Arduino Pin.

TheBum
Posts: 35
Joined: Wed Dec 03, 2014 9:53 pm

Re: Voltage sensor with improved resolution for MultiWii

Post by TheBum »

copterrichie wrote:Also, the first resistor serves as a current limiter to prevent overloading the Arduino Pin.

The Arduino pin should have a very high impedance, so I don't see it getting overloaded. However, you need the first resistor after the Zener to form part of the low pass filter that removes noise (the cap forms the other part). Because the Arduino pin is at high impedance, you need the second resistor to provide reverse bias current to the Zener so it will operate properly.

For 3S (or lower), it just so happens that the two resistors form a voltage divider even though no voltage reduction is needed; the first resistor should be as small as possible, with a cap value sufficient to get the desired filtering, and the second resistor must be large, but not so large as to under-bias the Zener when combined with the first resistor.

Post Reply