fg71
When we use Modbus in OpenPLC_v3 and like to use more and 1 Client to connect to Server to read the state of a variable. We need to understand that OpenPLC is SoftPLC. In other words its running on SBC (general-purpose computer). This means the computer could do wide range of task compare to real-time system that only do specific task.
 
Lets take this example from OpenPLC IDE, we make a pulse and use set/reset latch block to set output coil (LED_State)
[203128%2F9292719%2Fmceclip0]
 
To be able to get stable read from Client we need to understand the Polling Period in ms.
You may have read that 100-250ms is a good value for Modbus. That is not working for a simple example above.
It could be that your setup need 500ms or more to get stable read for output variable.
 
[203128%2F9292720%2Fmceclip0]
 
What you see in OpenPLC monitor doesn't mean other device will do the same thing. There is a latency to connect to other device and make request and get respond. Human could blink a eye 100ms, a game fps need 30ms so 500ms maybe feel slow but on other hand you get a stable read from SoftPLC.
 
If you need a lower latency its properly better to use MCU as Modbus Server and OpenPLC as SoftPLC.
 
This testing have been done on Raspberry Pi running Docker. You may ask would it not be better to run OpenPLC directly on Raspberry Pi without Docker to get lower Polling Period. That is what I thought too and it show 100-250ms Polling Period is not stable. In other words stable reading with Modbus TCP couldn't be performed with less Polling Period and 500ms.
 
Is this normal for OpenPLC running on Raspberry Pi ??
 
To test you need to connect other Device as Client to communicate with OpenPLC (Server)
 
The Client I have been using is Siemens LOGO and connect to OpenPLC and using snap7 do not have any problem.
I tested other Modbus Client and it looks to be more stable. So maybe its Siemens LOGO problem....maybe not (not sure)
Reply 0 0
thiagoralves
Latencies on a Raspberry Pi running Linux should be in the order of microseconds, not milliseconds. Most likely the issues you’re facing are related to latencies of your network equipment and configuration, not OpenPLC, Linux or Raspberry Pi.
Reply 0 0
fg71
The reason I got Polling Period issue was I include Slave device, I remove it and only enabled modbus from the settings.
Now I could use 100ms for Pulling Period.
 
This test include Modbus Tcp and Snap7 and both are stable for 100ms Polling Period.
 
I believe I made slave device with the same IP as my Raspberry Pi and that was enough, to make it slow 😉
Reply 0 0
fg71
I had to watch your slave device video on youtube... when you said: you have to remove function code that you do not use (OpenPLC will complain). I stop the video and made this 🙂, its very clear to me now why you say (you could use Arduino compatible board with Raspberry Pi). This example use Modbus Server to write the state of variable LED_state_slave. It kind of do the same thing Arduino extension do
if I was upload to a MCU.
 
So I have 2 Modbus Client to read the state of %QX0.0, I have S7 Communication to read the state of Q0.0 and I have slave device to write the state of LED_state_slave. I could see the state of all 4 and its stable and I use 100ms Polling Period.
 
[203128%2F9293060%2Fmceclip0]
Reply 1 0
Reply