Negative Values

Moderator: RevPiModIO

Post Reply
mtgstuber
Posts: 2
Joined: 18 Jan 2023, 20:51
Answers: 0

Negative Values

Post by mtgstuber »

I'm using an encoder with a RevPiCore, a RevPiDIO, and RevPiModIO. It appears that ct.io.MyEncoder.value returns an unsigned 32 bit, such that when I turn the encoder past zero, instead of getting -1, I get 4294967295. Is there a signed version of .value, or do I need to do my own conversion?
User avatar
RevPiModIO
KUNBUS
Posts: 322
Joined: 20 Jan 2017, 08:44
Answers: 0
Contact:

Re: Negative Values

Post by RevPiModIO »

Hi!

You can configure the IO in your Python program. Just set the signed value of your input to True.

Code: Select all


your_revpi_mod_io.io.your_input.signed = True

# Now the value will show negative values
print(your_revpi_mod_io.io.your_input.value)

Sven
python3-RevPiModIO - https://revpimodio.org/ || Der RevPi ist das Beste, was passieren konnte!
mtgstuber
Posts: 2
Joined: 18 Jan 2023, 20:51
Answers: 0

Re: Negative Values

Post by mtgstuber »

Thank you!
Post Reply