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

FIX: interpret analog input values as int16 #45

Closed
wants to merge 1 commit into from

Conversation

JJL772
Copy link
Member

@JJL772 JJL772 commented Jun 22, 2023

Both signed and unsigned representations behave like a signed 16-bit integer. In the case of unsigned, the value is limited to the range 0-32767, the former is limited to -32768-32767. As such, treating the values from the device as int16 (and thus sign extending it when assigning to RVAL) is the correct way of doing things.

MSB representation is still not handled in this PR.

Leaving as draft until I can find and test with a bipolar terminal!

@JJL772 JJL772 changed the base branch from master to pre-release April 11, 2024 22:59
@JJL772
Copy link
Member Author

JJL772 commented Jul 16, 2024

EL331X

Signed representation and absolute value w/MSB sign are the only two representations mentioned in the docs.

image

EL30XX, EL31XX

This covers bipolar terminals like EL3174, too.

Signed, unsigned and absolute w/MSB sign are supported.

Ranges specified in docs:

  • signed: -32768 to 32767
    image

  • unsigned: 0 to 32767
    image

  • absolute MSB sign: 0 to 32767, sign 0 or 1, so -32767 to 326767 total
    image

Absolute w/MSB sign seems to only exist to provide a symmetrical range

tldr; this is safe to merge after testing :)

@JJL772 JJL772 added this to the R1.7.3 milestone Jul 16, 2024
Both signed and unsigned representations behave like a signed 16-bit
integer. In the case of unsigned, the value is limited to the range
0-32767, the former is limited to -32768-32767. As such, treating the
values from the terminal as int16 (and thus sign extending them when
assigning to RVAL) is the correct way of doing things.

This does not handle the MSB representation properly however. That will
require more work down the line if we ever decide to support it. For
now, users will need to use the unsigned or signed representations for
the data to be correctly read.
@JJL772
Copy link
Member Author

JJL772 commented Jul 18, 2024

Closing because I renamed the branch.

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

Successfully merging this pull request may close these issues.

1 participant