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.