This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

INA219 Current Calculations

Other Parts Discussed in Thread: INA219

Hi,
I am looking for some guidance in fully understanding the INA219. I have 4 INA’s hooked up to 4 shunts that have the following parameters:

Shunt max amps: 300A
Shunt voltage max: .075V
Shunt resistance: .00025Ohms

The configuration for the INA’s is all the same:
Rst (bit 15) = 1
Unused (bit 14) = 0
Bring (bit 13) 16V FSR: 0

Shunt gain (Bit 12-11): is /2: PG1 = 0, PG0 = 1
Bus ADC Resolution (bits 10 - 7) 68.1/128 samples: BADC4 = 1, BADC3 = 1, BADC2 = 1, BADC 1 = 1
Shunt ADC Resolution (bits 6 - 3) 68.1/128 samples SADC4 = 1, SADC3 = 1, SADC2 = 1, SADC 1 = 1
Mode is Shunt and Bus Continuos (bits 2 - 0): mode3 = 1, mode2 = 1, mode1 = 1

Therefore the config register value is (from above)

0b1000 1111 1111 1111 or 0x8FFF

The calibration value as per the documentation (Equation 1) is:

.04096/(Current_LSB x Rshunt)

So first the Current_LSB (as per the documentation, Equation 2):
Current_LSB = Max Current/2^15 = 300/32768 = .009155

Therefore the calibration value is .04096/(.009155 * .00025) = 17,895

*******

I have run a simple loop pulling the register values under a small load (approx 5 amps), a larger load (approx 60 amps), and when the batteries were charging (about 5-6 amp rate). The values were read when the conversion ready flag was set and all register values were read into 16 bit signed variables before any calculations were done. These were shunt voltage, bus voltage, current, and power. The conversion ready flag was reset last by the read of the power register.

What I was primarily attempting to do is validate the read values to the measured values for voltage and current. During the observation period the bus voltages were always correct but I had problems with the current and shunt voltages. Following is an example:

                                    Hex                Decimal

shunt voltage register: 18                 24
raw bus voltage:          6C72            27762
raw current:                 FFFFFFCC  -52
--

By calculation:
shunt voltage is number of .010 mVolts = register value/100000 = 24/100000 = 0.00024 V
bus voltage is register >> 3 = number of 4 mVolts = 3470.25 x .004 = 13.881 V

*Note: the 2 values above appear to be correct

The value of -52 in current register should equal (as per equation 4 in documentation):

Current Register = Shunt voltage Register x Calibration Register / 4096

Therefore:
24 x 17,895/4096 should = -52 but it obviously doesn’t as this actually equals a value of 104.8.

Needless to say when the actual value of the current register is multiplied by the Current_LSB the amperage value comes out to -0.476A. When the calculated value of 104 is use the value comes out to 0.955A.

In this case the batteries were being charged so I would assume that both the shunt and current register values would be negative but clearly they are not.

In other cases where the shunt and current values are both negative the difference in the 2 values can be about 35 amps (-3.39 vs -38.2).

At higher currents, 75 to 100amps, I will still see negative shunt voltage values and again a large disparity in amperages.

*****

To sum this up: I am getting inconsistent Current Register values that don’t match the document calculations. I can’t see if I am missing anything or my calculations are just plain wrong. Any guidance or suggestions would be very helpful.

  • Hi Kent,

    Thanks for using TI E2E forums. We will get back to you on Monday.

    Regards
  • Hi Kent,

     

    Mayrim is out of office temporarily, I’ll try to assist you.

     

    If the part must be reset by RST bit, I suggest use two separate commands, ie, (1) reset the part first with RST bit=’1’, (2) configure the part with desired settings, but leave RST bit to be ‘0’.

     

    If you haven’t done so, please give it a try and let me know if it makes a difference.

     

    BTW, thank you for the detailed description.

     

    Regards,

    Guang-Apps CS Products

  • As you suggested I separated the configuration into two steps. The first step was just to do the chip reset and then on the second write only the config bits with the rst = 0. I ran one set of tests, so far, and it has made a huge difference in that the values are much more consistent and the amperages can be verified now by calculation.

    I noted that the calculated values are not exact but usually within a few one hundredths. For example the current from the register will be -5.03555 A and the current by equation 4 is -5.03995.

    I need to do some more testing but it is looking much better. I will update this after I get some more info. Thank you so much for your help so far.

    Kent
  • The reset by itself and then the config seems to have resolved the problems. Testing with low, high, and charging conditions all appear to be correct. Thanks again for the suggestion.