Hi.
I'm recently verifying the performance of a fuel gauge (see attached picture) and I wanted to share with you a script (also attached) that I wrote for the Keithley 2450 SMU.
You can charge or discharge a lithium battery in CC/CV mode, the script does this, and counts mAh (charge - that would be coulombs if it is As).
The idea is that if you have a fairly big battery, say 1000mAh but you want to use it with a small load let's say 10mA, you can't measure the batterys capacity by discharging with a high current since you will get a wrong discharge curve. You will reach the cutoff voltage to soon, see:
https://batteryuniversity.com/article/bu-501a-discharge-characteristics-of-li-ionOn the other hand, discharging with 10mA takes forever.
The attached script helps.
Example: You have a 1000mA battery, you use a linear regulator with 3.3V and 100mV drop, so your cutoff voltage will be 3.4V. Your device uses 10mA constantly.
You start the script and set:
* Voltage to 3.4V
* current limit to 500mA (this is safe, since it is 1/2 C)
* charge end current 10mA
The battery will discharge at first with 500mA. Then eventually goes into CV mode, when the SoC falls and the internal resistance rises. It stops discharging when you can get no more than 10mA out of the cell without dropping below 3.4V. Then you can read the registered capacity in mAh. For charging, its the same but with 4.2V (for 1S lithium battery) and a smaller end current (maybe 1mA?).
Rename the attached .txt file to .tsp