Giter VIP home page Giter VIP logo

Comments (18)

RobTillaart avatar RobTillaart commented on August 26, 2024

Thanks for reporting the issue, might take a few days

from ina226.

RobTillaart avatar RobTillaart commented on August 26, 2024

Will start investigating today.

from ina226.

RobTillaart avatar RobTillaart commented on August 26, 2024

No setup to test. Your analysis is looks correct.

from ina226.

RobTillaart avatar RobTillaart commented on August 26, 2024

@morrowwm
Created a PR - see develop branch. Can you check this branch?

from ina226.

morrowwm avatar morrowwm commented on August 26, 2024

It looks good. The current calculated by the INS226 is very close to that measured by my multimeter.

from ina226.

morrowwm avatar morrowwm commented on August 26, 2024

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.

RobTillaart avatar RobTillaart commented on August 26, 2024

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.

morrowwm avatar morrowwm commented on August 26, 2024

from ina226.

RobTillaart avatar RobTillaart commented on August 26, 2024

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.

RobTillaart avatar RobTillaart commented on August 26, 2024

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.

morrowwm avatar morrowwm commented on August 26, 2024

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.

morrowwm avatar morrowwm commented on August 26, 2024

from ina226.

RobTillaart avatar RobTillaart commented on August 26, 2024

So the new version works and still mayches your multimeter?

from ina226.

morrowwm avatar morrowwm commented on August 26, 2024

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.

RobTillaart avatar RobTillaart commented on August 26, 2024

You might need to check the datasheet if you can get much better than 1 in 400 in terms of precission.

from ina226.

morrowwm avatar morrowwm commented on August 26, 2024

from ina226.

RobTillaart avatar RobTillaart commented on August 26, 2024

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)

image

from ina226.

RobTillaart avatar RobTillaart commented on August 26, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.