-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Bus voltage error grows linearly up to 0.5V when measuring 35V #30
Comments
Thanks for the issue, will try to handle it this week. |
(got some thoughts, so a quick share) Dont know what causes the offset, the only explanation I can come up with is a (systematic) deviation of the shunt. Can you do a measurement without anything connected? So no voltage at all? It could indicate some noise. Can you print the measurements with 4 decimals, especially to get see if the error is linear over the range or not. Thinking out loud to prevent it? Another option could be to add correction factors in the library to be able to adjust the precision of the library. For that we need to know if the error is (almost) linear. |
The included resistor in the module is 0.1Ohms (R100), I left that detail out as I wasn't attempting to measure current. I wasn't passing any current through the shunt resistor, I was only applying the 0-35V voltage at the Vbus pin when performing those measurements, no loads connected. Nevertheless, I just tried measuring current. The load in the circuit is a 100 Ohm 1/4W resistor, power supply voltage varied between 0.5 and 4.5V. For instance, at 3V, multimeter measured 29.2mA while the sensor reports 32.05mA. The shunt resistor is quite close to the rated value. I measured 2.9mV (multimeter) across it while 29.2mA were flowing, so R=2.9/29.2=0.0993Ohms, almost 0.1Ohms. I also used someone's library and the reported currents get very close to the expected ones by using a 0.90918 correction factor. It also has the same 1.5% error on the Vbus measurements. |
Given that the other library gives same/ similar error is a sign that the (systematic) error is in the hardware. As the sensor makes measurements it needs to have a reference voltage. This is often based upon the voltage the sensor gets to power up. What is the voltage the sensor gets? 5.000V ? |
I was powering it from the host MCU's LDO 3.3V output (FireBeetle 2 ESP32-E) I just tried powering it from a separate power supply using 3.3V. |
OK, that indicates the sensor uses an internal reference, so we can exclude that as source of the deviation.
Note that 0,0993 Ohm and 0.1 Ohm differ a vert little in absolute terms, but relative it is still about 0.7% |
But the shunt resistor is not used at all when measuring the Vbus voltage... Or is it? |
Looking at the diagram in the datasheet (Texas Instruments august 2015) it is not.
Don't know if your China board uses a genuine TI sensor or some replica with other specs. Thinking out loudWith your Riden RD6006P precise power supply, what is the smallest step you can set? The INA226 should be able to see 36V in 65536 steps ==> steps of about 0.5 mV |
FYI, there are quite a bit of tech docs - https://www.ti.com/product/INA226#tech-docs |
Can you set setAverage(7) to see if readings get better? (probably slower). |
Have you tried setBusVoltageConversionTime(7) ? |
Thanks for al these measurements, really appreciated. |
Note to myself: |
I deleted my previous message as I was announcing good news because I had tried a third library and thought it was finally giving the correct bus voltage. But it was just an old sketch running with a correction factor applied, sorry about that! |
Maybe the 1.5% deviation is a accuracy problem and not a precision one. Suppose I will implement corrections, how many would the library need?
These have typical the form of y = ax + b for linear correction. For power two linear corrections, I times V, will generate a quadratic one. |
Pasted your measurements of the first post in spreadsheet to determine the correction formula. f(x) = 0.98529147 * x - 0.00633941587; The maximum error is at 0 == 0.0231 As the b offset is rather small, (with some trial an error) this formula is almost equally good. f(x) = 0,98495 * x; drawback of both formulas is that they "fail around zero" (notice that 0.9845 +0.0151 =~100% so there is a clear relation with your 1.51% |
Dived into the datasheet, and section 7.4.1 Averaging and Conversion Time Considerations and beyond describes how to optimize the measurements and minimize noise. |
@zalexzperez |
Well, I asked Wolfgang Ewald (owner of another INA226 library) about the issue and he replied his modules don't have such error. He also suggested I may have a fake one. Nevertheless, since I'll build a custom PCB, I'll definitely get the genuine sensor and we'll find out if the error's still there or not. Anyway, using a correction factor of 0.98525, 16 averages with 8244us bus conversion time gives me a good-enough precision of 5mV lower than the actual voltage in the use range that I will use this for (car battery voltage reading). I still have to see how it behaves inside of a car, though. Since you asked about other questions, I hope you don't mind my asking here about something else. The datasheet states: "The highest resolution for the Current Register (04h) can be obtained by using the smallest allowable Current_LSB based on the maximum expected current" So I started using the formulas trying to see how a lower expected current could give a higher current resolution, but didn't see how that was possible: Ohm's law dictates that the minimum measurable current increment should only depend on the shunt voltage LSB and the shunt resistor value: 2.5uV/R_shunt. If the shunt resistor is 0.1Ohms, the minimum current increment will be 2.5E-6/0.1=25uA. Now, we'll see if a lower "expected current" gives a higher current resolution or not with an example with two "maximum expected current" values and a real load current of 200.025mA.
Current_LSB is rounded to 25uA/bit (0.8/2^15), giving a CAL register = 2048.
Current_LSB is rounded to 12.5uA/bit (0.4/2^15), giving a CAL register = 4096. As seen, both max expected current values result in the same measured current value. So I'm wondering what is the purpose of current_LSB parameter. edit: I also found that using a lower expected current value can even give a worse precision. I observed Current_LSB must be a number such that the resulting CAL register ends up being a multiple of 2048, otherwise the current register will not be a whole number. |
When making a measurement with any device you have a number of specifications
The calibration value of the INA226 defines the step size of the measurements a.k.a. the current_lsb (precision). Suppose you have a 20A sensor and you know that you will never have more than 6 A. |
Your example (0.8A and 0.4 A) misses the point as the real value is a multiple of the highest currentLSB Use a real load current of 200.015mA. Max A = 0.8 Max A = 0.4 you could do the math for A = 250 mA and it might be even closer. |
https://github.com/wollewald/INA226_WE
But how exactly can the current register be 16001? |
From datasheet:
Your math is correct if there was only a single measurement, however the sensor can make multiple and average them. I also don't know if the internal math is 16 bit or 32 bit as your calculation assumes. |
@zalexzperez |
Nothing else to report. |
@zalexzperez |
Hello, yes, and it's good news! The problem is gone. No more need to use a correction factor. Here's the genuine INA226 chip from LCSC: And here's the INA226 from the AliExpress module: I even went and desoldered the fake chip and put a good one in its place, to be able to test the module with an older ESP32-E microcontroller and the results are good, just like with the S3 board. |
Good to hear the issue is solved, Thanks for reporting and the images! |
Hi guys, I have to confirm the issue. I have 4 pieces from China, ordered each from different seller and on different date... Each piece reports different voltages, with pretty obvious error. I've been already asking on TI forum, but just here I found the final confirmation those are really fakes :( Thanks for your efforts... we should spread this info... |
Thanks for your addition. |
Just got an INA226 board from China.
Used the demo plotter file and edited it to only display bus voltage measurements.
Riden RD6006P precise power supply to apply voltages from 0 to 35V at the Vbus pin. UNI-T multimeter confirms the accuracy of the power supply (down to 0.01V at all applied voltages).
Here's a table with the measurements:
What causes this offset error? Is there a way to prevent it?
Edit: on further analysis, the measured values correspond to a +1.51% error.
Thanks
The text was updated successfully, but these errors were encountered: