Skip to content
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

ina219: Overflow bit indicates a math overflow error #73

Open
mid-kid opened this issue Jun 3, 2024 · 0 comments
Open

ina219: Overflow bit indicates a math overflow error #73

mid-kid opened this issue Jun 3, 2024 · 0 comments

Comments

@mid-kid
Copy link

mid-kid commented Jun 3, 2024

Describe the bug
In ina219.go there's a check for the overflow flag respresented in the voltage register. This error reads bus voltage register overflow. This is a misnomer.

This register is documented in the datasheet as follows:

Math Overflow Flag

The Math Overflow Flag (OVF) is set when the Power or Current calculations are out of range. It indicates that
current and power data may be meaningless.

This flag indicates not an overflow in the voltage register, but an overflow in the power and current registers, which are read out later in the code.

This is unfortunate, because the data in the voltage register is completely valid in such a state. The problem would be a misconfiguration in the calibration register, causing the internal calculations from shunt voltage to current and power to fail. The sad thing about this, is that a lot of precision is lost in this conversion, as the registers the chip is working with are very small (16 bits). I'd like to retrieve the Voltage value, and do the calculations myself in the code instead of on the chip.

Expected behavior
I would like the library to clarify the error message, and ideally provide a way to retrieve the measured full-scale voltage and shunt voltage regardless of this calculation overflow.

Personally I also think this library would be more useful calculating the current/power itself instead of relying on the chip, but that's out of the scope of this specific request.

Additional context
Device datasheet: https://www.ti.com/lit/gpn/ina219

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant