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)
Code: Select all
#if defined(VBAT) && defined(VBAT_CELLS)