- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need code to check battery. I opened "BLE_Battery_Level" example and run it. When I connected input to real pair of 1.5V batteries (2.56V) it measure 0 voltage. Are this example is working ?
Where I can get real working example for check battery ?
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The example should work but you have to remove ADC input the from Vref to another GPIO pin then apply your batteries to it. I would add a resistor divider to insure you don't exceed the input max of 3.3 Volts. Also this is a simulate battery reading example and at Main.c at line 300 the simulated battery part of the code is called and the actual reading code is not called. I am sending you a 6 channel voltmeter program to see how to make a voltmeter. This code is made for a PSoC 4 CY8CKIT-049-42XX so you would need to modify it for the PSOC Ble. But the ADC code should work for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The example should work but you have to remove ADC input the from Vref to another GPIO pin then apply your batteries to it. I would add a resistor divider to insure you don't exceed the input max of 3.3 Volts. Also this is a simulate battery reading example and at Main.c at line 300 the simulated battery part of the code is called and the actual reading code is not called. I am sending you a 6 channel voltmeter program to see how to make a voltmeter. This code is made for a PSoC 4 CY8CKIT-049-42XX so you would need to modify it for the PSOC Ble. But the ADC code should work for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As I said before "I connected input to real pair of 1.5V batteries" to analog input and voltage was 2.56V ( no need insure resistor).
And you can see in main.c real MeasureBattery called too :
if(CyBle_GetState() == CYBLE_STATE_CONNECTED)
{
/*******************************************************************
* Periodically simulate Battery level charging.
*******************************************************************/
SimulateBattery();
CyBle_ProcessEvents();
MeasureBattery();
In this project exist 2 BAS. One for real measure ( if I connect to VREF it always 100 % ) and simulated (always less 20 %).
I used real and it`s not worked. Example you provided very complicated and based on specific hardware so I can`t even run it.
And I think that need correct Cypress example because other customers need it too.
- 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
Code exist in c:\Program Files (x86)\Cypress\PSoC Creator\3.3\PSoC Creator\examples\sampleprojects\BLE_Battery_Level\
I connected battery to P3[0] as in example instead of Vref. If you have Pioner kit you can check it yourself.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Also what kind of batteries are you using?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have to jumper pins on the Pioneer board to make this work check this in the instructions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I used Ni-MH . What a limits to battery exist ? Can you check how it work for you ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OMG, I told that I made it. I jumper P3(0) to Vref and it display 100 % . Right now everything is OK.
After that I removed Vref and connected P3(0) to real battery and it`s not worked.
- 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
Yes, Please take Kit and do it too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Okay I have tried the program and the first thing I did was to leave the pin open and then it reads about 5% and the blue led is lit that means that the Battery level is less than 10%. I then jumped the pin to the 3.3 volt pin on J1 on the Pioneer board. Then it reads 100% and the blue led is not on. If you look at the program code in the bas.c at lines 133-138 it says that the program is looking for 3V=100% and 2.8 V =29% and less than 2.0V 0%. As you are using a 2.2V battery in series then your battery level would be 2.4 V max and that would be reading around 0% to 10 %. The button cell is near discharged at less than 2.8V that is the way it was designed. You can also look at the raw data with the Ble Dongle.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I changed it to this :
#define MEASURE_BATTERY_MAX (3000) /* Use 3V as battery voltage starting */
#define MEASURE_BATTERY_MID (2000) /* Use 2.0V as a knee point of discharge curve @ 29% */
#define MEASURE_BATTERY_MID_PERCENT (50)
#define MEASURE_BATTERY_MIN (1000)
When I connected battery with 2.8V it was 9% ?? As you explained it must be 70-80 % ...
Why you not connected to real battery ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I just needed a voltage supply so I used the one on the board. I don't have your batteries so That is why I used it. How are you connecting the battery to the circuit? Also if the battery is 2.2 Volts each how are you getting 2.8 V? Is the Blue led on?
- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Don`t worry about GND . All gnd pins connected to same plain in layer 2
believe me I know about it.
- 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
Ok , where is right pin ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Okay you can also use J3-7 which is gnd. Have you pressed the Read on the CySmart App? Also did you start with a Green led where it is looking for the CYSmart app. Also you don't have a blue LED in the picture so you are not below 10%.Battery level. If you where using a 3 Volt battery it would be reading 100%. Please send your code so I can check it on my boards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I told you before but again : this is not my code but standard example exist in c:\Program Files (x86)\Cypress\PSoC Creator\3.3\PSoC Creator\examples\sampleprojects\BLE_Battery_Level.
If you don`t have it I attached it. And instead of explain what I didn`t right just make yourself this example with real battery. I mean that less then 3V . In datasheet I see :"The PSoC 4XX7_BLE device can be supplied from batteries with a voltage range of 1.9 V to 5.5 V".
So range of battery need be on minimum 2V.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"So range of battery need be on minimum 2V"
This is not what normally is done. A battery, rechargeable or not, can be destroyed when discharged too deep. A revert current flow (due to differences in the cell characterization) with one cell of a multi-cell battery as you have got might set the device on fire.
What is done in industry with battery design:
Dependent on the battery type used there is a correlation between Ubatt and charge level. In the above example, that correlation is expressed by a linear curve and a safe low discharge level is taken as the minimum. This will operate the battery cells in safe range, although it does not use the complete charge of the cells.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May be you forget that rechargeable batteries is not destroyed when it`s fully empty. BTW in cellular phone it`s recommendation on new batteries use it to empty for help to controller understand minimum.
Battery voltage ~ 1.2 -1.5 V so if we limit to 2V for couple of batteries ( 1V to each) - it very far from full empty ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want you to send your program. I have the example.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think I found a problem. We can argue about values and percent but all decision made from measured voltage.
I added print value string :
mvolts = (1024 * 2048) / adcResult;
DBG_PRINTF("mvolts: %2ld \r\n",mvolts);
and received this values :
As you can see first I connected to VREF pin and we see 3.3V and 100% of battery but when I just unconnected pin we see that value about 1.3 V ! I see in ADC settings and it need measure from 0 to 3.3 V :
Something wrong with voltage measuring.
Can you provide some example of voltmeter with ADC on BLE chips.
- 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