hello,
Our customer would like to use python program to read the external signal from X2 connector, is there any manual and sample code on it?
Many thanks in advance!
how to read the value come from X2 connector of RevPi Connect
Re: how to read the value come from X2 connector of RevPi Connect
Hello Wang create a pictory configuration. Then have a look at this tutorial:
https://revolution.kunbus.com/tutorials ... n-connect/
Bit 6 of the RevPiStatus variable in the process image contains 0 or 1, depending on whether 0V or 24V are applied to the input.
In theory it works like that:
Here an example implementation:
https://revolution.kunbus.com/tutorials ... n-connect/
Bit 6 of the RevPiStatus variable in the process image contains 0 or 1, depending on whether 0V or 24V are applied to the input.
In theory it works like that:
Code: Select all
pi@RevPi:~ $ piTest -r RevPiStatus
1 Byte-Value of RevPiStatus: 1 dez (=01 hex)
1 Byte-Value of RevPiStatus: 65 dez (=41 hex)
Code: Select all
#!/usr/bin/env python3
# CheckConnectInput.py
# Check the digital input pin of RevPi Connect
import revpimodio2
import time
rpi = revpimodio2.RevPiModIO(autorefresh=True)
while True:
if rpi.io.RevPiStatus.value & (1 << 6):
print('Hi')
else:
print('Lo')
time.sleep(1)
Re: how to read the value come from X2 connector of RevPi Connect
Hello Dirk,
Thank you very much for your reply.
It really helps a lot.
Best regards,
WANG
Thank you very much for your reply.
It really helps a lot.
Best regards,
WANG
dirk wrote: ↑27 Aug 2021, 11:35 Hello Wang create a pictory configuration. Then have a look at this tutorial:
https://revolution.kunbus.com/tutorials ... n-connect/
Bit 6 of the RevPiStatus variable in the process image contains 0 or 1, depending on whether 0V or 24V are applied to the input.
In theory it works like that:Here an example implementation:Code: Select all
pi@RevPi:~ $ piTest -r RevPiStatus 1 Byte-Value of RevPiStatus: 1 dez (=01 hex) 1 Byte-Value of RevPiStatus: 65 dez (=41 hex)
Code: Select all
#!/usr/bin/env python3 # CheckConnectInput.py # Check the digital input pin of RevPi Connect import revpimodio2 import time rpi = revpimodio2.RevPiModIO(autorefresh=True) while True: if rpi.io.RevPiStatus.value & (1 << 6): print('Hi') else: print('Lo') time.sleep(1)