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

Fixed the handling of the sign of values from the ADC #1

Merged
merged 1 commit into from
Jul 1, 2019

Conversation

gamix25
Copy link
Contributor

@gamix25 gamix25 commented Jun 29, 2019

Although the data sheet doesn't specify this clearly, the value from the ADC is actually a signed 24-bit integer value. However, the existing implementation wasn't handling the sign of this value correctly leading to overflow if the weight on the load cell ended up being less than the value during power up. Unfortunately, fixing this issue is not as simple as casting the uint32_t used to store the value from the ADC into a int32_t. My change fixes the code with the proper bit manipulations to handle the sign of the value from the ADC correctly throughout the library.

…e ADC

* updated all relevant methods to represent raw values correctly as signed integers
@gamix25 gamix25 changed the title * fixed the handling of the sign of the 24-bit integer coming from th… Fixed the handling of the sign of values from the ADC Jun 30, 2019
@nseidle
Copy link
Member

nseidle commented Jul 1, 2019

Excellent. Thank for the this fix!

@nseidle nseidle merged commit 8e3a0c7 into sparkfun:master Jul 1, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants