Modbus RTU Arduino <-> PLC

Hello,

Does anyone have experience with Modubus RTU communication between Arduino and PLC?
I would need help communicating between an Arduino Nano Every and a Siemens S7-1200 PLC (specifically the 1212C AC/DC/Rly) using the Modbus RTU protocol. I am using a TTL to RS485 converter (MAX485) at Arduino side and RS485 communication board (CB1241) at PLC side.
PLC as Master and Arduino as Slave. I have a total of 4 slave devices. Communication on the PLC side is somehow solved with a simple script. I'm not so sure about Arduino. I tried the ArduinoModbus.h example Kitchen Sink library, which worked 100% between two arduinos. After the modification, when I want to light the LED on pin 13 after a command from the PLC using the Coil or the value in the Holding register, it no longer works so well.
I checked the flow through an oscilloscope and the data is in the correct format in both directions. However, Arduino "doesn't want to scramble" the data in any way.
I tried different libraries but with exactly the same result. I've been messing with it for over a week now.
After solving the problem, I will share the working code to future generations in trouble.

Thank you
Regards
Jenda

Works that well between 2 arduino or is that changed after testing with the arduino?

You can snif the RS485 in the arduino seriƫl monitor with an RS485=>USB converter.

Hi buckfast_beekeeper,

Communication works well between two arduinos.
I ordered RS485 to USB converter now and I will test it.
I'll inform about testing.

Thank you and best regards

That's not the best choice for AVR and MegaAVR Arduinos (as the Nano Every) because it's quite wasteful with memory. That library is designed for the MKR series of Arduinos.
I recommend the library by smarmengol for the Modbus RTU on AVR/MegaAVR boards.

Many PLC manufacturers use a special register numbering to select the register type. So often a register number 30000 selects holding register 0. I don't know what Siemens does but from this company I would at least expect it to be documented.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.