Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Shuntvoltage() is always returning positive values #19

Closed
aguilerabr opened this issue Aug 7, 2024 · 2 comments · Fixed by #20
Closed

Shuntvoltage() is always returning positive values #19

aguilerabr opened this issue Aug 7, 2024 · 2 comments · Fixed by #20
Assignees
Labels
bug Something isn't working

Comments

@aguilerabr
Copy link
Contributor

Variable definition inside getShuntVoltage() should be type int16_t instead uint16_t for value.

@RobTillaart RobTillaart self-assigned this Aug 7, 2024
@RobTillaart RobTillaart added the bug Something isn't working label Aug 7, 2024
@RobTillaart
Copy link
Owner

Thanks for this issue,

As I am busy it will take several days maybe weeks to dive into the datasheet and code. Labelled the issue as bug as it could be one and give it priority it needs.

Saw you created a PR which is appreciated! Will enable the build asap.

@RobTillaart RobTillaart linked a pull request Aug 7, 2024 that will close this issue
@RobTillaart
Copy link
Owner

@aguilerabr
Had a quick look in the datasheet and you are right, the register is signed so your fix makes sense.

Please note there are some open ends with the shunt voltage.
Especially table 7 indicates that depending on the GAIN set the max shunt voltage differs. (out of range gray area).
A function bool shuntVoltageOverflow() that returns true if last measurement is in gray area. This needs a private bool flag to indicate (possible) overflow when reading the shunt voltage register. To determine this overflow one needs to have the gain factor (or a derived value).

A function int getMaxShuntVoltage() returning 40 80 180 or 320 depending on gain, could be useful in this context.

@RobTillaart RobTillaart changed the title Shutvoltage() is always returning positive values Shuntvoltage() is always returning positive values Aug 14, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants