Proposal to improve cell voltage measurement

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Proposal to improve cell voltage measurement

Post by QuadBow »

In MW 2.4 the measurement of cell voltages have been realised. In my view it is a good approach to monitor cell voltages, which can be forwarded to the transmitter via telemetry. However setting up the related configuration is quite complicated and the result sticks to a one decimal format like vbat.

Firstly:
Well, for the total voltage it is not a big issue if you have 14.4 V or 14.43V. However, for a single cell it would be interesting to see the difference between 3.71V and 3.79V. So, I propose to make use of the 16 bit wide variables vbatcells[VBAT_CELLS_NUM] and to expand the format to a 2 decimal approach in order to get values like 3.79 V.

Secondly:
The cell voltages are calculated with a constant offset. Well, the cells are connected in serie. So, if the first cell lowers its voltage, the constant offset has gone and the voltages of the other cells are impacted. My proposal is to measure the differences of voltages in order to retrieve a better result. In this case the VBAT_CELLS_OFFSETS are not required any longer. Of course, different resistor dividers have to be taken into consideration by VBAT_CELLS_DIVS. But, in total the configuration would be easier.

Thirdly, a smaller point of consideration:
In the functiion annexCode is the switch(analogReader) instruction with

Code: Select all

#if defined(VBAT) && !defined(VBAT_CELLS)
for case 1 and

Code: Select all

#if defined(VBAT) && defined(VBAT_CELLS)
for default. Both conditions can not occur together. So, you can put them under one case and save the default case for further add-ons.

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

Re: Proposal to improve cell voltage measurement

Post by Hamburger »

I am all ears.
Same question as with current measurement - how exact is the value you get as result of analogRead()?
Like I said earlier, the true resolution is surprisingly bad - there is a reason we have an averaging function smoothing the value.
Do you use the adc of a 328p or mega? Then how many bits are noisy when you test with a constant input?

QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Re: Proposal to improve cell voltage measurement

Post by QuadBow »

Hi Hamburger,

I think, this topic differs from the amperage question. The current is very noisy because of the PWM for the motors, whereas the cell voltages are quite constant.
The only common factor is the unsure state of the least significant bits of the ADC. But, the resolution of the voltage amounts to 5mV per ADC step instead of 100mA per ADC step for the current. So, 0.1 V (20 steps) is not the same like 0.1 A (1 step) ! It is worth to consider a higher resolution. If we applied an average filter like for the measurement of the other analog values, we could obtain values with only the least significant bit toggling. In the worse case that would mean a flickering between a value like 3.94 V and 3.95 V.

I tested that approach for my own use at MW 2.3 with good results. Since the cell voltages do not change fast, a slower sub-loop was sufficient in order to do the oversampling. Please, find my code (for MW 2.3) and the test results attached.

http://www.multiwii.com/forum/viewtopic.php?f=7&t=1929&start=200#p48920

Post Reply