RevPi Connect 4 - firing script with digital input

Topics about the Software of Revolution Pi
Post Reply
noobingo
Posts: 1
Joined: 02 Oct 2024, 08:09

RevPi Connect 4 - firing script with digital input

Post by noobingo »

Hi everybody,
this is going to be a real noob question, but maybe somebody can point me in the right direction.

Here's my story:
I've got a Connect 4 and would like to fire a script as soon as a push-button "closes" the digital input.
The push-button is connected to the +24V side of the power supply, and the X2-3 "IN+" connector terminal.
I powered the thing up, went to PiCtory and dropped a Connect 4 to the "DIN rail", saved it as start configuration and restarted.
My expectation now was, that there should be a variable for the digital input somewhere in PiCtory, but I cannot find it.
After three days of try and error I learned how to operate the LEDs, the integrated "OUT relay", but the digital in is still a riddle to me.

Can somebody give me a hint?
Can the digital in be used at all for this purpose?

Many thanks!
User avatar
dirk
KUNBUS
Posts: 2132
Joined: 15 Dec 2016, 13:19

Re: RevPi Connect 4 - firing script with digital input

Post by dirk »

Hello noobingo, I read your request with interest.

I am dismayed that you have been searching for two days and have not been able to find an answer yet. We are trying to prepare our knowledge in the best possible way and are working daily to improve it.

Take a look at this page of our knowledge base: Revolution Pi Python Introduction.

You have already come a long way, created PiCtory configuration, etc... Now only the connection is missing and there you can look at the "BitMirror" example and customize it:

Code: Select all

import revpimodio2
import time
rpi = revpimodio2.RevPiModIO(autorefresh=True)
while True:
	if rpi.io.RevPiStatus.value & (1 << 6):
		rpi.io.RevPiOutput.value=1
	else:
		rpi.io.RevPiOutput.value=0
	time.sleep(1.00)
revpi.cleanup()
This code mirrors the RevPi Connect 4 digital inputs (1) to the relays contact (2):
RevPi Connect 4 Digital Inputs - Relais
RevPi Connect 4 Digital Inputs - Relais
The locations of the variables in the process image for RevPi Connect 4, which I hacked into the code, come from here:
Then you can use RevPiPyLoad to automatically start and monitor your Python script using a Linux daemon.
Post Reply