Moderator: RevPiModIO

 
Theo
Topic Author
Posts: 8
Joined: 19 Feb 2020, 17:27

Manage inputs/outputs with RevpPi Connect+ and DIO module

06 Aug 2020, 10:10

Hi,

I would like to retrieve information from a sensor with my RevPi connect and DIO module. I try to use the library RevPiModio2 but it doesn't work..
My DIO module is correctly configured, I check with the piTest -d

I tried first to swich on the LED on the Connect device to check the good functioning of my device. I haven't error message but the LED doesn't light up..
import revpimodio2
import time

rpi = revpimodio2.RevPiModIO(autorefresh=True)
rpi.core.a2green.value = True
How to make the connection with the revpi connect and the DIO module in the code?
Then, I would like use this library to check the status of 2 inputs every 10sec. I need to use with library between the mainloop, cycle loop, reg event?
 
User avatar
RevPiModIO
Posts: 243
Joined: 20 Jan 2017, 08:44
Contact:

Re: Manage inputs/outputs with RevpPi Connect+ and DIO module

08 Aug 2020, 07:05

Hi Theo!

If you use autorefresh=True, the internal buffer will be synced automatically in the given cycletime. Your Python program will destroy itself after the change of a2green (it is the last line) and will never sync the new value to the process image!
In your case, just add the line "rpi.exit()" as last line to force a last sync of changed IOs.

If you want to check values in a interval of time, than you should use the .cycleloop. The cycle loop will run every 50 milliseconds in default. So count the runs to check 10 Seconds and read the input values.
Have a look at this: https://revpimodio.org/en/cyclic-with-python/

The .mainloop and reg_event are the other method to program the RevPi. They belongs together, but are event driven. So your functions will be executed after your inputs change value.

Sven
python3-RevPiModIO - https://revpimodio.org/ || Der RevPi ist das Beste, was passieren konnte!
 
Theo
Topic Author
Posts: 8
Joined: 19 Feb 2020, 17:27

Re: Manage inputs/outputs with RevpPi Connect+ and DIO module

12 Aug 2020, 15:09

Hi,
Thank you for your answer. It works!

Who is online

Users browsing this forum: No registered users and 2 guests