Revolution Pi Gateway Tutorial
You want to exchange data between different interfaces and wonder if this is possible and how? For example, between Modbus TCP and digital IO interfaces? Then you are right here.
Instructions
Create a concept
Create a hardware configuration
Convert the application into software
Take a test (yes, really)
It is important that your concept contains and specifies your requirements.
Implementation
Create a concept
It should be possible to switch 14 digital output channels via Modbus TCP
The first input register (16 bit) of a Modbus TCP Slave should be mapped to digital output channels
It should be possible to read the 14 digital input channels via Modbus TCP
The first output register (16 bit) of a Modbus TCP Slave should be mapped to digital input channels
Create a hardware configuration
A Revolution Pi Connect Module and a DIO module.
Convert the application into software
Create a PiCtory configuration
Create an application, i.e., a script which connects the I/O data
Take a test
We can use an interactive Modbus TCP master software
PiCtory configuration
RevPi DIO Module
RevPi Connect SE Module
Modbus TCP Slave Module
Variant 17 Outputs, 19 Inputs
Variable “Output” is a bit field for all the digital outputs
Don’t forget to save and reset driver to apply your configuration
Here is the RSC configuration file:
You can copy it to your RevPi device like soRevolution Pi Copy Files i.e., to /tmp/
Afterward, you have to activate this configuration like so on your device:
cp /tmp/GatwayModbusDIO.rsc /var/www/revpi/pictory/projects/_config.rsc
sudo chown www-data:www-data /var/www/revpi/pictory/projects/_config.rsc
piTest -x
Application
We decided to implement it in Python.
I like to use the IPython3 shell, which is really great for development. You may install it via:
sudo apt install ipython3
Afterward, you can start it via
ipython3
Copy this script, which covers all the code to perform this task. Yes, it really consists of seven (7) lines of code.
Application test
With the application QModMaster we can connect and write data to the Modbus TCP Slave.
We are writing a “7” to the first Modbus TCP Slave register. This equals “0b000 0111” which sets the first three digital output channels high. You have to apply the data after establishing a successful connection to the Modbus TCP slave.
We are receiving that value on the process image:
And that value is applied to the DIO:
Hints
Autostart the application on boot