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

INA237 Sensor Driver Power Calculation Wrong #60722

Closed
EricNRS opened this issue Jul 23, 2023 · 2 comments · Fixed by #60717
Closed

INA237 Sensor Driver Power Calculation Wrong #60722

EricNRS opened this issue Jul 23, 2023 · 2 comments · Fixed by #60717
Assignees
Labels
area: Sensors Sensors bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@EricNRS
Copy link
Contributor

EricNRS commented Jul 23, 2023

Describe the bug
The INA237 power calculations are incorrect and show overflow issues and are 1000x too small.

Incorrect value seems to imply overflow in calculation since it doesn't follow the off-by-1000 issue seen later.

DEBUG   - OUTPUT: START - test_power
DEBUG   - OUTPUT: 
DEBUG   - OUTPUT:     Expectation failed at WEST_TOPDIR/zephyr/tests/drivers/sensor/ina237/src/ina237_test.c:137: test_power: (power_expected_W not within power_actual_W +/- 1e-6)
DEBUG   - OUTPUT: Expected 855.637965 C, got 0.426141 C
DEBUG   - OUTPUT: 

Off by a factor of 1000:

DEBUG   - OUTPUT:     Expectation failed at WEST_TOPDIR/zephyr/tests/drivers/sensor/ina237/src/ina237_test.c:137: test_power: (power_expected_W not within power_actual_W +/- 1e-6)
DEBUG   - OUTPUT: Expected 3.342285 C, got 0.003342 C
DEBUG   - OUTPUT: 
DEBUG   - OUTPUT:     Expectation failed at WEST_TOPDIR/zephyr/tests/drivers/sensor/ina237/src/ina237_test.c:137: test_power: (power_expected_W not within power_actual_W +/- 1e-6)
DEBUG   - OUTPUT: Expected 1.671117 C, got 0.001671 C
DEBUG   - OUTPUT: 
DEBUG   - OUTPUT:     Expectation failed at WEST_TOPDIR/zephyr/tests/drivers/sensor/ina237/src/ina237_test.c:137: test_power: (power_expected_W not within power_actual_W +/- 1e-6)
DEBUG   - OUTPUT: Expected 0.051000 C, got 0.000051 C
DEBUG   - OUTPUT: 
DEBUG   - OUTPUT:     Expectation failed at WEST_TOPDIR/zephyr/tests/drivers/sensor/ina237/src/ina237_test.c:137: test_power: (power_expected_W not within power_actual_W +/- 1e-6)
DEBUG   - OUTPUT: Expected 0.005100 C, got 0.000005 C
DEBUG   - OUTPUT: 
DEBUG   - OUTPUT:     Expectation failed at WEST_TOPDIR/zephyr/tests/drivers/sensor/ina237/src/ina237_test.c:137: test_power: (power_expected_W not within power_actual_W +/- 1e-6)
DEBUG   - OUTPUT: Expected 0.000051 C, got 0.000000 C
DEBUG   - OUTPUT:  FAIL - test_power in 0.000 seconds

To Reproduce
I have written a new test case for this while I was debugging it and will upload this with the fix.

./scripts/twister -vv -p native_posix -T tests/drivers/sensor/ina237

@EricNRS EricNRS added the bug The issue is a bug, or the PR is fixing a bug label Jul 23, 2023
@github-actions
Copy link

Hi @EricNRS! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙

@EricNRS
Copy link
Contributor Author

EricNRS commented Jul 23, 2023

Fixes for the issue uploaded and ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Sensors Sensors bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants