New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible error with INA226 #66
Comments
I am looking at the library and can't locate an error. The "getBusMicroWatts()" function will read the next computed value, so if the current changes very quickly then you might get a value that doesn't correspond to the BusmA * BusVoltage. Could this be the case for you? Is the problem reproduceable? |
Today I tried to use the library "INA226" ,everything works well there. When I use the "INA" library, the power is incorrect, the error is 80% A 0.1348 V 19.118 W_ina 2.0618 W=V*A 2.5771 % 80.01 |
Since the Amps and Volts are the same in both cases, the problem lies in the computation of the Watts. Are you initializing both libraries with the same begin() statement? |
"INA226.begin " and "INA.begin" |
I meant the parameters to the begin() - are they identical, especially the values for expected maximum amps |
all the same |
How comfortable are you to make some small changes to your version of the library? I would like you to change the library by adding the following after line 634 "(int64_t)readWord(INA_POWER_REGISTER, ina.address) * (int64_t)ina.power_LSB / (int64_t)1000;" The lines are:
|
According to the INA226 datasheet, page 16, for INA 226, the power LSB should be 25 * Current_LSB: However, it's set to 20x in INA.cpp, line 27: And 20/25 is exactly 80%. |
Good sleuthing - I am re-installing my PC this weekend (Thank You, Mr. Gates) but once all the software is installed I'll check this out. |
|
As the datasheet explains,
Below is my theory about this. The current and bus voltage are both stored in 16-bit registers. If you directy multiply them together, you'll need a 32-bit register to store the result. To put it into a 16-bit register, scaling is necessary(of course there's a loss in precision), and the scale factor should be somewhere near 2^(32-16)=65536, intuitively. |
I see the differences in the DataSheets, but before I commit the changes, I will need to hook up a INA219 and INA226 and test the changes. Still downloading MS-Studio, VisualMicro and need to install doxygen, clang-format, gitKraken, etc.
…-Arnd.
From: Gallium70 <notifications@github.com>
Sent: Sunday, October 25, 2020 10:24
To: SV-Zanshin/INA <INA@noreply.github.com>
Cc: Arnd <zanshin_github@sv-zanshin.com>; Assign <assign@noreply.github.com>
Subject: Re: [SV-Zanshin/INA] Possible error with INA226 (#66)
Согласно таблице данных INA226 <https://www.ti.com.cn/lit/ds/symlink/ina226.pdf> , стр. 16, для INA 226 младший разряд мощности должен быть равен 25 * Current_LSB:
.
Why is this necessary?
P.S. Installed the library INA226 ,everything works fine.
As the datasheet explains,
This ratio is internally programmed to ensure that the scaling of the power calculation is within an acceptable range.
Below is my theory about this. The current and bus voltage are both stored in 16-bit registers. If you directy multiply them together, you'll need a 32-bit register to store the result. To put it into a 16-bit register, scaling is necessary(of course there's a loss in precision), and the scale factor should be somewhere near 2^(32-16)=65536, intuitively.
TI chooses a scale factor of 20000, since the LSB for the bus voltage is fixed at 1.25mV/bit (equivalent to 800x scaling), then the power LSB should be 20000/800=25x current LSB.
As for why it's exactly 20000 (not some other number), maybe only TI knows.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub <#66 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AFT5DRF57QSRGSEZGL5WSEDSMPVD5ANCNFSM4QPQVW6A> . <https://github.com/notifications/beacon/AFT5DRA2QCT677KO6CXXY5DSMPVD5A5CNFSM4QPQVW6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFKXRNMQ.gif>
|
First test looks good :) |
…esults in power values that are 20% off.
Fixed in Development version 1.0.13, which should be promoted to a new master version in the next couple of weeks. |
Taras sent in the following:
Hi there. I used your library for INA226. Found an error. In the example DisplayReadings.ino
power is not calculated correctly. I add a screen.
V = 8,843 V
A = 35.736 mA
V * A = 8.843 * 35.736 = 316mW
, and in the example it turns out 253 mW.
Could this be a library error? Maybe it's my fault?
--
The Shunt is 0.1Ohm and the original DisplayReadings.ino settings were used.
The text was updated successfully, but these errors were encountered: