Skip to main content
Associate
June 24, 2025
Solved

STC3100 Current register nonsense values

  • June 24, 2025
  • 1 reply
  • 410 views

Hi, 

I am having the same issue as this previous forum post, but the question was never answered. 

 

Voltage and temperature sense give expected readings. 

REG_VOLTAGE_LOW: 29; REG_VOLTAGE_HIGH:6 --- VOLTAGE: 3818mV

REG_TEMPERATURE_LOW: 186; REG_TEMPERATURE_HIGH:0 --- TEMP: 23 deg

 

from the datasheet ---> current (mA) = current_code* 11.77 / Rsense (mΩ)

REG_CURRENT_LOW: 203; REG_CURRENT_HIGH: 54 --- CURRENT: 15429mV

Where the actual current for my application is 2.5A. I am using a 10mOhm current sense resistor. Indeed a multimeter reveals 25mV drop across it. 

 

Could somebody please tell me if this is a hardware issue? I have followed all recommendations in the datasheet closely, but cannot find a reason that current is this high. Furthermore, when my application draws only 3.5mA, the current reads 18018mA

 

Thank you very much. 

 

 

Best answer by Peter BENSCH

I noticed something else besides the missing type casting mentioned before:

Your example values are probably due to negative currents, i.e. current from the cell towards the load, right?
Let's take your values of REG_CURRENT:

  • Low=203; High=54, i.e. 0x36CB
  • according to the data sheet, section 6.1.4 the value is represented in two's complement (of 14-bit), which results for your values in a negative 0x16CB
  • 0x16CB * 5.88µV/LSB = 34.3098mV

This value is much closer to the 25mV you measured externally, isn't it?

However, I am also not sure that the 5.88µV in the data sheet is correct: the measuring range of the STC3117 is ±40mV, which corresponds to a resolution of 4.88µV at 14-bit (16384 steps). With these 4.88µV we would arrive at 28.4748mV.

Regards
/Peter

1 reply

Peter BENSCH
Technical Moderator
June 24, 2025

Welcome @rs231, to the community!

If the maximum current to be measured is 2.5A, you should use a shunt of 80mV/2.5A = 32mohms, maybe only 30mohms to have some margin at the top.

Can you insert some schematics as a picture and please also the part of the programme that reads out the STC3100 so that both can be checked?

Regards
/Peter

rs231Author
Associate
June 25, 2025

Hi Peter, 

Thanks for getting back to be quickly!

I noticed that the max voltage is +/- 80mV. Since 2.5A corresponds to 25mV with the 10mOhm shunt, I thought this should be alright? 

I will post the code for the working temperature, vs the non-working current. Note unsigned integers are used for now but both values are positive. The environment is C in Zephyr RTOS. 

 

void read_current(void)
{
 uint8_t buf[2] = {0};

 int ret = i2c_burst_read_dt(&i2c_fuel_gauge, REG_CURRENT_LOW, buf, 2);
 if (ret == 0)
 {
 printk("raw current lower: %d\n", buf[0]);
 printk("raw current upper: %d\n", buf[1]);

 uint16_t raw_current = (buf[1] << 8) | buf[0];
 printk("raw current total: %d\n", raw_current);

 int current_mA = raw_current * (1177 / 100) / SENSE_RESISTOR_MILLI_OHMS;
 printk("current_mA: %d mA\n", current_mA);

 }
 else
 {
 printk("Failed to read battery current: %d\n", ret);
 }
}

 

void read_temp(void)
{
 uint8_t buf[2] = {0};
 int ret = i2c_burst_read_dt(&i2c_fuel_gauge, REG_TEMPERATURE_LOW, buf, 2);
 if (ret == 0)
 {
 printk("raw temp lower: %d\n", buf[0]);
 printk("raw temp upper: %d\n", buf[1]);

 uint16_t raw_temp = (buf[1] << 8) | buf[0];

 int temp_deg = raw_temp * 125 / 1000;
 printk("Fuel Gauge temp %d deg\n", temp_deg);
 }
 else
 {
 printk("Failed to read fuel gauge temp: %d\n", ret);
 }
}

 

The schematic is as follows: 

rs231_0-1750818474441.png

rs231_1-1750818492334.png

 

 

Thanks for your help.