Skip to content

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

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

Merged
merged 1 commit into from
Jul 1, 2019

Conversation

gamix25
Copy link
Contributor

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
@gamix25gamix25 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 ADCJun 30, 2019
@nseidle
Copy link
Member

Excellent. Thank for the this fix!

@nseidlenseidle merged commit 8e3a0c7 into sparkfun:masterJul 1, 2019
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
@gamix25@nseidle
close