how to read the value come from X2 connector of RevPi Connect

Topics about the Software of Revolution Pi
Post Reply
Wang
Posts: 44
Joined: 12 Nov 2020, 14:28

how to read the value come from X2 connector of RevPi Connect

Post by Wang »

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!
User avatar
dirk
KUNBUS
Posts: 2174
Joined: 15 Dec 2016, 13:19

Re: how to read the value come from X2 connector of RevPi Connect

Post by dirk »

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:

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)
Here an example implementation:

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)
Wang
Posts: 44
Joined: 12 Nov 2020, 14:28

Re: how to read the value come from X2 connector of RevPi Connect

Post by Wang »

Hello Dirk,

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:

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)
Here an example implementation:

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)
Post Reply