Measuring CR-2032 Voltage

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

We followed the BLE_Battery_Level example project available with PSoC Creator closely. We have also looked at the excellent blog on this topic (http://www.cypress.com/blog/psoc-hacker-blog/measuring-vdd-battery-volts-psoc4). But I am not getting correct battery measurements. We are using CYBLE-022001-00 on our board and placed an 1uF capacitor between the ground and P0[5]. I am not able to paste the schematic here but attach the file.

   

I am using the following firmware to measure VDD:

   

      int16 adcResult;

   

      int32 mvolts;

   

      uint32 sarControlReg;

   

      ADC_Start();

   

      sarControlReg = ADC_SAR_CTRL_REG & ~ADC_VREF_MASK;

   

      ADC_SAR_CTRL_REG = sarControlReg | ADC_VREF_INTERNAL1024BYPASSED;

   

      CyDelay(25);            

   

      sarControlReg = ADC_SAR_CTRL_REG & ~ADC_VREF_MASK;

   

      ADC_SAR_CTRL_REG = sarControlReg | ADC_VREF_VDDA;

   

      CyDelay(1);

   

      ADC_StartConvert();

   

      ADC_IsEndConversion(ADC_WAIT_FOR_RESULT);

   

      adcResult = ADC_GetResult16(ADC_BATTERY_CHANNEL);

   

      mvolts = (1024 * 2047) / adcResult;

   

I am getting adcResults close to 0 (-20 to 5 in my tests). What am I doing wrong?

   

Thanks.

   

Alex

0 Likes
10 Replies
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Azheng: Using P0[5] is not the best pin for this use the Program advised you of this by making it in Yellow.  I have moved the Pin to P3[4] and it removed the warning.  Please try the attached program and see how it works. I have not tried this program but it compiled with out errors.

0 Likes
Anonymous
Not applicable

Hi Bobgoar, thank you very much. I will definitely try the change and report the results later tonight. I have one question though: On my board, I physically soldered a 1uF capacitor connecting to the Ground and P0[5]. Would the change ignore this capacitor? If yes, does that mean I do not need the capacitor?

   

Alex

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

You will still need the Cap I believe.  So I would move it to the new pin.

0 Likes
Anonymous
Not applicable

Thank you, bobgoar!

0 Likes
Anonymous
Not applicable

Did a bunch of tests last night and now the ADC reading is around 110 for a fully charged battery, resulting in 20V for CR2032. Is it possible that the formula is incorrect? Of course, it is also possible that my hardware wiring is incorrect.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Alex, can you post your complete project, so that we all can have a look at all of your settings? To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi Bob, I am attaching the file here. Thanks.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I cannot follow why

   

        mvolts = (1024 * 2048) / adcResult;

   


will give you the voltage in mV. Are you following any AN to measure the batt voltage?

   

I would suggest to use a resistive divider to get 1V out of 3.3V, one side GND, the other to a pin drawing  < 1mA.

   

You need to use internal Vref with 1.024V

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hi Bob, thanks for your comments. The project is based on a sample battery measurement project available in PSoc Creator. I just changed the device type and updated some pins to correspond to my board. The interval Vref is not supported for the chip I am using. I tried "internal 1.024 volts" and "internal 1.024 volts, bypassed" and got ADC readings ranging from -8 to 8.

0 Likes
Anonymous
Not applicable

I ended up taking out the capacitor and putting in two resistors to get the battery measurement to work.

0 Likes