Link to home
Start Free TrialLog in
Avatar of Rama Tito
Rama TitoFlag for Malaysia

asked on

Raspberry PI as Master Serial and Slave Serial communication

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.
Avatar of Dr. Klahn
Dr. Klahn

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.
Avatar of Rama Tito

ASKER

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.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.