Gateway Modbus TCP - How to read the data from the PIRevCore3

Topics about the Hardware of Revolution Pi
Post Reply
User avatar
rikybiky
Posts: 2
Joined: 15 Sep 2020, 13:37

Gateway Modbus TCP - How to read the data from the PIRevCore3

Post by rikybiky »

Hi there,
I've setup a PI RevCore3 to request ModbusTCP data from a PILZ PLC every 1s. I have confirmed that the PI is making requests to the PSS4000 and receiving a response using PiTest through Putty. However, I now want to read registers through via the attached Gateway Modbus TCP units IP address. I have a connection but the values are zero. It’s as if The PI Core is not forwarding on the data to the gateway. What am I not understanding or missing? I've spent time on all the manuals and have come to a stop. Anything obvious that stands out?

Cheers,

Rich
Attachments
IMG_4029.jpg
IMG_4029.jpg (66.39 KiB) Viewed 3510 times
4.PNG
4.PNG (221.91 KiB) Viewed 3510 times
1.png
1.png (272.08 KiB) Viewed 3510 times
Control System Engineer at STFC
User avatar
dirk
KUNBUS
Posts: 2174
Joined: 15 Dec 2016, 13:19

Re: Gateway Modbus TCP - How to read the data from the PIRevCore3

Post by dirk »

Hi Rich,
thank you for your great material. Ok first of all the PiCtory configuration does not match the hardware configuration.
Please open PiCtory, move the Gateway Modbus TCP Slave to the left side of the RevPi Core 3. Save and Resatart driver.
With

Code: Select all

piTest -d
you can check the configuration.

So I understood that the PLC acts as a Modbus TCP Slave. With QModMaster you are able to query it using function codes like "read coils".
Ok and now you are stuck by the question how can I read data with the RevPi, right? You can use a Virtual Module Modbus TCP Master.
Then right-click the Module and select "Extended Data". There you can i.e. say "Read Coils" from Register 1 every 100ms ...
Have a look at the Tutorial 20 – Modbus TCP Master
User avatar
rikybiky
Posts: 2
Joined: 15 Sep 2020, 13:37

Re: Gateway Modbus TCP - How to read the data from the PIRevCore3

Post by rikybiky »

Hi Dirk,

I'm still not seeing a change of data at the Gatway Modbus TCP RJ45 port. Have moved the Modbus TCP Master virtual device to the left like you said. I don't have a Modbus TCP Slave virtual device included.
Anything else I've missed? I already have the Modbus TCP Master working and talking to the PLC. I now want to use another PC to read the collected modbusTCP data within the PI RevCore device.

Cheers,

Rich
Attachments
xx.png
xx.png (195.24 KiB) Viewed 3464 times
3.PNG
3.PNG (59.02 KiB) Viewed 3464 times
2.PNG
2.PNG (187.12 KiB) Viewed 3464 times
Control System Engineer at STFC
User avatar
dirk
KUNBUS
Posts: 2174
Joined: 15 Dec 2016, 13:19

Re: Gateway Modbus TCP - How to read the data from the PIRevCore3

Post by dirk »

Dear Rich, so I have some ideas. The RevPis´ process image is the hart of the data. Each device owns input and output data.
Your idea is maybe to separate the shop-flor network from the rest of the system, right?

Anyway - you just have to copy the data from the Input_Bit_1 ... Input_Bit_16 to the Output_1 of the Gateway ModbusTCP Slave.

Code: Select all

import revpimodio2
import time

rpi = revpimodio2.RevPiModIO(autorefresh=True)
tmp = 0

while true:	
	tmp = rpi.io.Input_Bit_1.value  << 0
	tmp = rpi.io.Input_Bit_2.value  << 1
	tmp = rpi.io.Input_Bit_3.value  << 2
	tmp = rpi.io.Input_Bit_4.value  << 3
	tmp = rpi.io.Input_Bit_5.value  << 4
	tmp = rpi.io.Input_Bit_6.value  << 5
	tmp = rpi.io.Input_Bit_7.value  << 6
	tmp = rpi.io.Input_Bit_8.value  << 7
	tmp = rpi.io.Input_Bit_9.value  << 8
	tmp = rpi.io.Input_Bit_10.value << 9
	tmp = rpi.io.Input_Bit_11.value << 10
	tmp = rpi.io.Input_Bit_12.value << 11
	tmp = rpi.io.Input_Bit_13.value << 12
	tmp = rpi.io.Input_Bit_14.value << 13
	tmp = rpi.io.Input_Bit_15.value << 14
	tmp = rpi.io.Input_Bit_16.value << 15
	rpi.io.Output_Word_1.value = tmp
	time.sleep(0.002)


And there is an enhancement idea to simplify your ModbusTCP Master extended data configuration:
Extended Data Simplified
Extended Data Simplified
2020-09-29 15_46_40-Window.jpg (29.98 KiB) Viewed 3303 times
Post Reply