Page 1 of 1

Modbus RTU & RevPi DIO manage in Python script

Posted: 20 Feb 2020, 16:04
by Theo
I'm a new user on the RevPI Forum.

I bought a RevPi connect+ and a RevPi DIO module. I would like to control my devices with a Python script.

Would it be possible to receive some examples of python programs: to control an actuator in modbus RTU ( write and read coil & write and read registers with some values) and to control I/O with the DIO module?

Thanks in advance
Theo

Re: Modbus RTU & RevPi DIO manage in Python script

Posted: 03 Mar 2020, 10:25
by dirk
Hi Theo, have a look at the RevPiModIO Python library. It makes it easy to access to the process image of the RevPi
Bit Mirror example
https://revolution.kunbus.de/forum/view ... rror#p6250
Documentation of the library
https://revolution.kunbus.de/forum/view ... 1026#p4198

Re: Modbus RTU & RevPi DIO manage in Python script

Posted: 28 Jul 2020, 15:37
by Theo
Hi Dirk, thanks for the reply and sorry for the delay.

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

When I tried to swich on the LED on the Connect device, it doesn't work also. So; I am not sure how to use this library.. can you help me please?

My code :
import revpimodio2
import time

rpi = revpimodio2.RevPiModIO(autorefresh=True)

rpi.Connect.A3 = revpimodio2.GREEN

Error :
Traceback (most recent call last):
File "DIO.py", line 6, in <module>
rpi.Connect.A3 = revpimodio2.GREEN
AttributeError: 'RevPiModIO' object has no attribute 'Connect'


Image[/img][/img][/img]

Re: Modbus RTU & RevPi DIO manage in Python script

Posted: 03 Aug 2020, 09:10
by nicolaiB
Hi Theo,

the correct io would be

Code: Select all

rpi.core.a3
For more details have a look into the documentation of revpimodio2: https://revpimodio.org/en/doc2/core/

Nicolai

Re: Modbus RTU & RevPi DIO manage in Python script

Posted: 03 Aug 2020, 09:41
by Theo
Hi Nicolai! Thanks for your answer.
I will try that.
For you, what is the best to control my DIO module and to monitor the status of my inputs and outputs instantly? The RevPiLoad?

Re: Modbus RTU & RevPi DIO manage in Python script

Posted: 03 Aug 2020, 11:29
by nicolaiB
Yes, RevPiLoad might be a good starting point. With the GUI it's possible to control the outputs and also upload a custom program which is written with revpimodio2. There are some cool examples on the website.

Nicolai

Re: Modbus RTU & RevPi DIO manage in Python script

Posted: 03 Aug 2020, 14:29
by Theo
Thank you! I try your recommandation but the LED doesn't light up

Code: Select all

import revpimodio2
import time

rpi = revpimodio2.RevPiModIO(autorefresh=True)
rpi.core.A3 = revpimodio2.GREEN
Then, I would like to read the status of my Input 1 without activate the Output 1. I read the examples on the website revpimodio with the mirror but I don't need that. Can you show me a little example to read the values of my input please ?