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

Negative values get discarded #4

Open
userx14 opened this issue Oct 27, 2019 · 0 comments
Open

Negative values get discarded #4

userx14 opened this issue Oct 27, 2019 · 0 comments

Comments

@userx14
Copy link

userx14 commented Oct 27, 2019

The code in ADS1256.py seems to destroy negative values with an 'and filter'.

        if (read & 0x800000):
            read &= 0xF000000




Probably this should have been

        if (read & 0x800000):
            read |= 0xFF000000

so that the output value is compatible with int32



My code for differential readout conversion in python with the fix is:

#v_ref must be float e.g. 5.0
def convert2float(raw_val,v_ref):
    if(raw_val>0x7fffff):
        return ((raw_val-0x100000000)*v_ref/0x7fffff)
    else:
        return (raw_val*v_ref/0x7fffff)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant