Raspberry Pi and Click PLC, Modbus TCP
I have been using the trial version of Rexygen with a Raspberry Pi 3B+. I use Studio on a Win10 machine.
I have successfully tried several examples with inputs/Outputs on the RPi.
I have run into a problem in getting the RPi to talk to a remote plc over Modbus TCP. The plc is an Automation Direct Click.
I designed the project on the Studio and downloaded to the RPi. Initially, I was reading two registers on the plc without a problem using the Watch.
Then, I went into Studio, and added two more registers to read. I downloaded to RPi and Watched. The original two registers read properly, but the two new ones show “0” on red banner.
If I go to Configure and change the register addresses, the original two tags will read correctly, but the other two show the red error banner.
Is there a limitation on the number of registers to read? I have attached screen captures in the hopes you can give me some other things to check.
jaroslav_sobota last edited by jaroslav_sobota
thanks for the detailed analysis and screenshots.
There is no limitation on the number of registers to read. At least not on the side of REXYGEN.
Which registers are the OK ones? 21 and 22? Did you try reading only the new ones? Is it still not working?
Can you please share both your REXYGEN and CLICK projects with me? I have the CLICK PLC here so I'll be able to test everything.
I did some additional checking and now believe it is a communication timeout issue. I tried playing with the modbus timeout numbers without much success.
However, it is now clear that the system will always read the first two registers in the Configure list. Sometimes it will read the first 3, never all 4.
The log file confirms the time out issue. You can see where DS23 was timing out, then I stopped and changed the register order, then DS23 was OK and DS22 was timing out.
I’ve included the CLICK project. It is only a few rungs long and is a bench test of this modbus communication system.
jaroslav_sobota last edited by
thanks for your projects. The problem is that the Click PLC is not able to process multiple Modbus commands at once. There are 2 possible approaches to overcome this limitation:
Limit the maximum number of Modbus commands to 1 in REXYGEN. Yes, I have observed communication problems even when only 2 Modbus packets were sent at once.
But it's even better to really squeeze all the data into one Modbus command and read all the 4 registers at once.
In your task, you'll then use the INQUAD function block to process the incoming data. You'll rename the block to MTM__readDS.
In this case you'll need to put all the registers in a row in the CLICK PLC, but I believe you can easily achieve it.
Hope this helps, let me know.
I knew it had to be a timing issue! Just not familiar enough with the system yet to know what to adjust. Will keep the forum updated.
I just wanted to confirm that reducing the "Max. requests" number to 1 allows multiple Modbus reads of the Click PLC.
I agree that reading registers in groups of 4 or 8 is more elegant and will try that next.