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 signedness handling for EL3XXX and EL4XXX terminals #67

Merged
merged 3 commits into from
Aug 1, 2024

Conversation

JJL772
Copy link
Member

@JJL772 JJL772 commented Jul 18, 2024

For analog input terminals, 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.

For analog output terminals, signed behaves as described above, but unsigned has the full range you would expect: 0-65k. To improve support for this, I've chosen a middle ground-- bipolar terminals will assume the PDO is signed and unipolar terminals will assume it is unsigned. Since unipolar terminals with the signed PDO can only have values 0-32k, it is safe to treat them as uint16.

The one drawback here is the unsigned PDO type will not behave correctly if it's set on a bipolar terminal. I suspect this is a rare use-case anyways, though.

More context on #45

JJL772 added 2 commits July 17, 2024 14:42
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 JJL772 added this to the R1.7.3 milestone Jul 18, 2024
@JJL772 JJL772 mentioned this pull request Jul 22, 2024
@JJL772
Copy link
Member Author

JJL772 commented Aug 1, 2024

Confirmed working in TMO. With the help of Tong, tested negative temperatures on EL3314 and pos/neg output on bipolar analog output terminals.

@JJL772 JJL772 merged commit f86effe into pre-release Aug 1, 2024
22 checks passed
@JJL772 JJL772 deleted the pr-fix-signedness branch August 1, 2024 22:10
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.

2 participants