Raspberry PI as Master Serial and Slave Serial communication

Rama Tito
Rama Tito used Ask the Experts™
on
Hi,

I am trying to establish communication between HMI and PLC by using the Raspberry Pi. The existing setup between HMI directs to PLC via serial communication and protocol on Modbus RTU.

I am trying to put Raspberry Pi between HMI and PLC. Raspberry pi will be master serial to pull data from PLC via Serial Modbus RTU and be slave serial for HMI. HMI will be master to pull data from raspberry pi.

How I can achieve this? I am trying this to get some extra data from plc for monitoring purpose and didn't disturb the existing system.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Dr. KlahnPrincipal Software Engineer

Commented:
Assuming you are not also pushing data to the Modicon, then you need four things:

a) A task to pull all required information from the Modicon and put it into a memory common region.
b) A memory common region to hold Modicon data.
c) A task to emulate a Modicon such that (a) whenever the Modicon is read via Modbus, it responds via Modbus protocol to the host and also updates the memory common region.
d) A task to report the contents of the common region in human-readable form.

(c) sounds tough but is fairly simple if the process is written as a state machine.  Once that is done you can talk to the Modicon normally via the serial link and also inspect data in the common region.

If you must also push data to the Modicon then (c) becomes a bidirectional task and it must not commit outgoing data to the Modicon into the common region until the Modicon has responded and confirmed.
Rama TitoProgrammer

Author

Commented:
Hi, to get data from plc using raspberry pi on serial modbus rtu, I do managed. How to store this data in data memory therefore HMI should able to pull the data accordingly.


After googling for quite some time, i did come across on pymodbus. Can anyone assist me with this.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial