0
\$\begingroup\$

I must have missed an article, lesson at uni, or something obvious because I'm struggling to work out how to write some firmware to use a gas gauge to get out a rough percentage of battery remaining, e.g. "56%".

I'm primarily hardware-focused by trade and so whenever I've integrated them into professional products, the firmware has been handled by either a colleague or a contracted company. Now I'm just doing a design at home by myself and because of reasons, I've gone straight to using this STM part (instead of using a Sparkfun Module or something with pre-written and easy firmware) - because I actually want to learn, not just get something working.

So basically I was just after some advice on how they generally work. Obviously each part is probably unique in their own way, but in general I know:

  1. They monitor the through-current with the shunt resistor
  2. They monitor the battery voltage by tapping off the + and - terminals
  3. They monitor charge/energy/power flowing in and out of the battery, by combining these two measurements and some math

My question is: how do I get a percentage read-out from this? Especially since batteries all have different capacities and there is surely no way the GG knows what size battery I have plugged in?

I'm guessing I have to plug in a fully-charged battery when the system first "fires up" (for example, 400mAh), and then work out the percentage myself in the firmware by constantly subtracting/adding the charge that has flown in/out from the total 400mAh. The bit that confuses me a little is that this then assumes a fully charged battery was first inserted into the system but this definitely isn't always the case - Li-Po/Li-Ion batteries are usually shipped at ~50% charge (if I'm not mistaken) and would be installed into products straight away before being fully charged, thus making all these calculations wrong and pointless.

Is there something I'm missing? I can't find any detailed information on how to actually "use" these chips. Any help is much appreciated :)

\$\endgroup\$
  • \$\begingroup\$ Remember---- do this right, or you cause a fire. \$\endgroup\$ – analogsystemsrf Jun 6 at 1:48
0
\$\begingroup\$

You need to initialize them somehow, and you're expected to know the capacity of the pack (and, if you want to be really nice to your users, you should update the capacity as the battery ages). At least in the past I've used products that came with notifications that the gas gauge is only good if you've run the battery down and charged it up again.

This is consistent with my knowledge of how LiPo cells work.

\$\endgroup\$
  • \$\begingroup\$ Alright, thank you. I figured this might be the case but like I said, it just seems impractical since at manufacturing charging 1000 Li-Ion batteries to 100% while trying to ship out 1000 assembled PCAs is a very hard-to-coordinate process. But I guess since the C rating can vary pack-to-pack, this has to be done. I just figured there might be some super smart way it can work out the C rating itself, by evaluating how much the voltage fluctuates with incoming/outgoing current. But I guess some of it has to be done manually :) \$\endgroup\$ – DSWG Jun 6 at 1:09
0
\$\begingroup\$

First you need to learn all about Li+ battery models. There are methods since all batteries have many C=QV and ESR values in parallel but you can simplify to a 2nd order approximation. R1C1//R2C2 . The different time constants are what changes battery capacity depending on C rate. However this IC being limited to 2.5A or about 1C max and batteries are optimally shipped at 1/2 to 2/3 SoC.

Search my many answers on LiPo capacity and lithium battery models.

Second, rather than reinvent the wheel, get the firmware for different kits from all suppliers and choose the best based on your criteria for what is best.

E.g. https://datasheets.maximintegrated.com/en/ds/MAX17048-MAX17049.pdf

Maxim here does not use Coulomb counting

Third, depending on your motivation to research, learn, improve, copy or define your goals and realize them with search and test skills, you will need to verify your design with all the variables of I, dV/dt , temp, mAh, mWh, V, chemistry , aging and calibration in your specs.

\$\endgroup\$
0
\$\begingroup\$

Gauging the level of battery charge is not trivial at all. Accurate gas gauges, for example from Texas Instruments, use a built-in powerful MCU to calculate the charge level based on particular (selectable) chemistry model, accurate charge-in and charge-out measurements, and also track impedance of cell to track battery aging and get more accurate results. Gauge architecture also varies depending on whether it is built into battery, or residing at system level. Start here, Accurate gauging products for any battery system overview.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.