in fuel gauge, State of Charge is wrong until a power cycle

On a custom board based on the nrf52833-dk, I brought the fuel gauge project into mine and am printing out the values in fuel_gauge_update(), including State of Charge (SOC).

I unplugged the charging cable and ran the board under a 120mA load for several hours, and the SOC was displayed as over 95% the whole time. Then I power cycled the board and the SOC started displaying around 50%. 

D: V: 4.165, I: 0.043, T: 27.60, SoC: 99.91, TTE: nan, TTF: nan
D: V: 4.165, I: 0.050, T: 27.51, SoC: 99.88, TTE: nan, TTF: nan
D: V: 4.165, I: 0.048, T: 27.51, SoC: 99.86, TTE: nan, TTF: nan
D: V: 4.165, I: 0.044, T: 27.51, SoC: 99.84, TTE: nan, TTF: nan
D: V: 4.169, I: 0.045, T: 27.51, SoC: 99.81, TTE: nan, TTF: nan
D: V: 4.165, I: 0.048, T: 27.51, SoC: 99.79, TTE: nan, TTF: nan
D: V: 4.165, I: 0.042, T: 27.51, SoC: 99.76, TTE: nan, TTF: nan
D: V: 4.082, I: -0.018, T: 25.00, SoC: 99.00, TTE: nan, TTF: 47
D: V: 4.165, I: 0.084, T: 25.26, SoC: 99.00, TTE: nan, TTF: nan
D: V: 4.169, I: 0.076, T: 25.52, SoC: 98.95, TTE: nan, TTF: nan
D: V: 4.169, I: 0.076, T: 25.86, SoC: 98.92, TTE: nan, TTF: nan
D: V: 4.165, I: 0.073, T: 25.95, SoC: 98.88, TTE: nan, TTF: nan
D: V: 4.165, I: 0.072, T: 26.21, SoC: 98.84, TTE: nan, TTF: nan
D: V: 4.169, I: 0.069, T: 26.29, SoC: 98.81, TTE: nan, TTF: nan
D: V: 4.165, I: 0.071, T: 26.55, SoC: 98.77, TTE: nan, TTF: nan
D: V: 4.165, I: 0.057, T: 26.64, SoC: 98.73, TTE: nan, TTF: nan
D: V: 3.710, I: -0.149, T: 25.60, SoC: 99.00, TTE: nan, TTF: 9476
D: V: 3.959, I: 0.158, T: 26.47, SoC: 99.00, TTE: nan, TTF: 9495
D: V: 3.969, I: 0.157, T: 26.99, SoC: 99.00, TTE: nan, TTF: 9512
//power cycle
D: V: 3.745, I: -0.083, T: 32.17, SoC: 50.31, TTE: nan, TTF: nan
D: V: 3.964, I: 0.156, T: 32.17, SoC: 50.40, TTE: nan, TTF: 9758
D: V: 3.842, I: 0.014, T: 27.25, SoC: 53.68, TTE: nan, TTF: nan
D: V: 3.984, I: 0.156, T: 27.77, SoC: 53.78, TTE: nan, TTF: 5746
D: V: 3.989, I: 0.157, T: 28.21, SoC: 53.87, TTE: nan, TTF: 4610
D: V: 3.994, I: 0.156, T: 28.48, SoC: 53.97, TTE: nan, TTF: 4156
Can you please tell me why a power cycle is required for the correct SOC value to be returned?
Thank you
Parents Reply
  • Hi

    Your symptoms are consistent with an issue in NCS v3.1.0, where an upstream change inverted the current polarity reported by the PMIC driver. Because of this, the fuel gauge sample in that version feeds the wrong sign into the fuel‑gauge algorithm.

    When the sign is flipped, the FG interprets discharge current as charging, which keeps the SOC near 100% even while the device is under load.
    A PMIC power‑cycle resets the internal FG state, so the SOC suddenly jumps to the correct value — this matches exactly what you are seeing.

    This was corrected in NCS v3.1.1.

    If you use v3.1.0, you must manually flip the sign of the measured current before calling
    nrf_fuel_gauge_init() and nrf_fuel_gauge_process().


    You can also see how this is handled in the updated sample here:

    https://github.com/nrfconnect/sdk-nrf/blob/main/samples/pmic/native/npm13xx_fuel_gauge/src/fuel_gauge.c#L191-L193

    After applying the correct sign, the SOC will behave normally without requiring a PMIC power cycle.

    Let me know if you need any help further. 

    Regards 

    Tharaka

Children
No Data
Related