Comments (18)
Thanks for reporting the issue, might take a few days
from ina226.
Will start investigating today.
from ina226.
No setup to test. Your analysis is looks correct.
from ina226.
@morrowwm
Created a PR - see develop branch. Can you check this branch?
from ina226.
It looks good. The current calculated by the INS226 is very close to that measured by my multimeter.
from ina226.
Alternatively, what do you think of this approach to forcing current_LSB to be an integer, i.e. normalized?
INA226.cpp.txt
Starting at line 217, calculate calib, forcing no fractional part with round(). Then recalculate current_LSB using that calib.
This approach does not change the max current allowed as much.
Initial current_LSB: 0.00015259
Normalized current_LSB: 0.00015255 uA / bit
Max current: 5.00 A
from ina226.
Then recalculate current_LSB using that calib.
why didn't I think of that!
Very good point as that way the internal variables stay way more consistent.
forcing current_LSB to be an integer
Would make sense to me if one could do the whole math in integer units.
Can you name some advantages?
I make a note in the future section in the readme,
from ina226.
from ina226.
Just pushed a new version of .cpp file.
I added some #ifdef
at the start of the function for switching on/off print statements.
furthermore it includes your suggestion to calculate current_LSB back from rounded calib.
give it a try.
from ina226.
Doing all the math in integer will need more testing and I have so HW nearby (and enough time)
Note in readme to keep the thought
from ina226.
give it a try.
I had to remove the old normalize lines, starting at about line 235. Then I defined printdebug and also added more digits to the _maxCurrent debug:
With normalize = false:
normalize: false
initial current_LSB: 0.00015259 uA / bit
factor: 1
Final current_LSB: 0.00015259 uA / bit
Calibration: 344
Max current: 5.00000000 A
Shunt: 0.09756356 ohm
BUS SHUNT CURRENT POWER
6.984 -4.600 -47.150 331.879
6.986 -4.600 -47.150 331.879
6.986 -4.600 -47.150 331.879
And with normalize = true:
normalize: true
initial current_LSB: 0.00015259 uA / bit
Prescale current_LSB: 0.00015255 uA / bit
factor: 1
Final current_LSB: 0.00015255 uA / bit
Calibration: 344
Max current: 4.99889278 A <--- no longer 5.0, but an integer multiple of current_LSB
Shunt: 0.09756356 ohm
BUS SHUNT CURRENT POWER
6.986 -4.603 -47.139 331.805
6.985 -4.600 -47.139 331.805
from ina226.
from ina226.
So the new version works and still mayches your multimeter?
from ina226.
So the new version works and still matches your multimeter?
Yes, it works well. Matches my multimeter to about 1 part in 400, both normalized and not.
I'll see if I can find a setup that will hold a stable, higher current and get more than three digits to measure.
from ina226.
You might need to check the datasheet if you can get much better than 1 in 400 in terms of precission.
from ina226.
from ina226.
You might need to check the datasheet if you can get much better than 1 in 400 in terms of precision.
The datasheet mentions several causes of small errors (see below) which in the end add up so a difference of 0.25% is not bad at all, given that most multimeters are in the 0.2% range themselves. You need a DMM with 0.02% or better to make better measurements (professional or lab equipment)
from ina226.
@morrowwm
Are there other (serious) bugs that must be fixed?
Otherwise I merge this version and start a new branch for other issues if they appear.
from ina226.
Related Issues (12)
- Should power reading be signed? HOT 3
- reset sets wrong bit HOT 4
- Higher current shunt issue HOT 14
- Incorrect current value for different shunt HOT 30
- Overflow current >= 32768 (int16) HOT 6
- Voltage and current reading wrong by large margin HOT 11
- Ina226 current read 0.00 random time HOT 3
- [Question] Which lib is most suitable for a given project? HOT 3
- external high current shunt HOT 10
- Some examples do not work properly HOT 1
- float INA226::getCurrent() does not handle negative values properly HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ina226.