- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You will still need the Cap I believe. So I would move it to the new pin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you, bobgoar!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I ended up taking out the capacitor and putting in two resistors to get the battery measurement to work.