I'm trying to find a cheap implementation/circuit to monitor the remaining capacity of a non-rechargeable battery to be specific Lithium thionyl chloride LiSOCI2 batteries. I am aware of TI and Maxim's solutions but i feel they are expensive, i found several coulomb counter projects but AFAIK they fully discharge the batteries to finish the test which for LI-ion (rechargeable) this is not a problem. I was thinking if it was possible to do with simple components (Transistors/Mosfets) and software using a microcontroller to do ? I would really appreciate if someone would point to the right direction. For the curious out there, it's going to be inlcuded in an energy/electricity meter. Thanks in advance.
In a nutshell, measure the current periodically with an IC like INA219 and integrate it over time to know the battery consumed.
Using a shunt resistor based current monitor like INA219 you can get about 1kHz of load current sampling rate. Only situations where this approach might be less accurate is if you have many magnitudes of dynamic range of current to measure (A to uA) or if you have short bursts (few us) of high current consumed you.
If you're measuring every ms, then keep accumulating the current up measured in A in variable, say
charge_count. You can now check
charge_count against the battery capacity to see how much capacity is left.
To calculate the battery capacity, let's take an example of a 1 Ah battery, which means you can draw 1A for an hour. So it means 1A for 3600000 ms. So you can check
charge_count against 3600000 value to see how much battery is left.
Measuring the current in A requires you to convert the sampled value to float, you can change the entire calculations to use integers if you use appropriate scaling.