Battery measurement questions

8 posts / 0 new
Last post
Joacimwe
Offline
Last seen:1 year 5 months ago
Guru
加入:2014-01-14 06:45
Battery measurement questions

Hello, I have a few questions regarding the battery driver/ ADC

首先我想to ask if you can explain how you came up with the method for measuring the battery level, particularly this line:
batt_lvl = (adc_sample - 1137)*100/568;

We are not planning on using a CR2032 battery so do you have any suggestions on battery measurement for different sizes of coin cells?

Lastly, what are your recommendations forwhento take the adc samples for battery measurements? What I mean with this is that you will get very different results depending on when you take the sample. For instance, taking a sample while a LED is turned on will give you a much lower sample than if you do it directly after waking up from a long sleep. So what would be the preferred way to get the most realistic battery level?

Thanks

Joacimwe
Offline
Last seen:1 year 5 months ago
Guru
加入:2014-01-14 06:45
A small clarification:

A small clarification:

I know that 1705-1137=568 so the code mentioned earlier just calculates the percentage (linearly) between 1137 and 1705. But my question about that was more in regards of how those values were calculated in the first place. And also why the sample is masked using:
adc_sample >>= 4;
adc_sample <<= 4;

JE_Dialog
Offline
Last seen:2 weeks 4 days ago
工作人员
加入:2013-12-05 14:02
Hello Joacimwe,

Hello Joacimwe,

I'm currently checking into this for you : awaiting feedback from the design team on how these values have been calculated from the outset. Apologies for delay,

BR JE_Dialog

Joacimwe
Offline
Last seen:1 year 5 months ago
Guru
加入:2014-01-14 06:45
Any news on this? All I

Any news on this? All I really wanted to know is whether there is any logic to the code below or if it was a matter of trial and error:

//1705=3.0V, 1137=2V
if(adc_sample >= 1137)
batt_lvl = (adc_sample - 1137)*100/568;
else
batt_lvl = 0;

JE_Dialog
Offline
Last seen:2 weeks 4 days ago
工作人员
加入:2013-12-05 14:02
Hello Joacimwe, yes, i just

Hello Joacimwe, yes, i just received the magic behind the numbers yesterday (vacation season meant an abnormal delay).

here is how the original was calculated :

batt_cal_cr2032() function converts a value measured in ADC module into a rough estimation of remaining life of a CR2032 battery. In function’s parameter a sum of two ADC samples (one in differential mode and one single ended mode) is passed. This method as well as the max/min limits (1705=3.0V, 1137=2V)

The rest of the numbers (1584 & 1360) are the values of ADC samples sum for 2.8 and 2.4 V respectively and used to calculate an estimation of the remaining battery life according to the discharging model of CR2032 .

BR JE_Dialog

Joacimwe
Offline
Last seen:1 year 5 months ago
Guru
加入:2014-01-14 06:45
Thanks!

Thanks!

yterasaki
Offline
Last seen:4 years 7 months ago
加入:2015-05-08 09:28
Dear Sirs,

Dear Sirs,

I'm now using D14580 evaluation board and relating to this mail chain, I would like to know the meaning of "sum up two times ADC output".
I think this comment comes from following codes. Could you tell me the purpose for adding two times ADC output by different adc_init(...)?

adc_init(GP_ADC_SE, GP_ADC_SIGN);
if (batt_type == BATT_AAA_SINGLE_ALKALINE)
adc_enable_channel(ADC_CHANNEL_VBAT1V);
else
adc_enable_channel(ADC_CHANNEL_VBAT3V);
adc_sample = adc_get_sample();

adc_init(GP_ADC_SE, 0);
if (batt_type == BATT_AAA_SINGLE_ALKALINE)
adc_enable_channel(ADC_CHANNEL_VBAT1V);
else
adc_enable_channel(ADC_CHANNEL_VBAT3V);
adc_sample += adc_get_sample();

Yama_Dialog (not verified)
Hello yterasaki,

Hello yterasaki,

The purpose to get two sample values is related with ADC calibration. Actually we should calculate the negative and positive calibration settings and config them to calibration HW registers.
For each calibration setting, we get a sample, then the average value of those two samples are most accurate. I hope this will answer your question

Best regards,

Yama_Dialog