Arduino with Raspberry + Codesys trought Modbus TCP/IP

Hi everyone,

I'm not new with Arduino, I made little things with UNO, but this is the first time that I register for join to this forum. So, thank you in advance.

I have a PLC based on Codesys + Raspberry pi 3 B, and I uses its GPIO (General Purpose I/O) for experiment. Now, I want add Arduino in this system.

I have read and investigated, and I see that one of protocol that i can use for this is ModBus TCP/IP. I read how to use this on Codesys, but my doubt is: how its the code that i must put on Arduino UNO, I'm reading ArduinoModbus.h documentation and ModBus Protocol (of modbus.org) but I'm not sure.

I believed that I could configure Arduino as a ModBus slave (general), but reading the documentation I dont sure how make it.

Have someone any idea how configure arduino modbus for control it via PLC raspberry?

Thank you, and sorry if my english is not quite correct.

I have read and investigated, and I see that one of protocol that i can use for this is ModBus TCP/IP. I read how to use this on Codesys, but my doubt is: how its the code that i must put on Arduino UNO, I'm reading ArduinoModbus.h documentation and ModBus Protocol (of modbus.org) but I'm not sure.

Using only an UNO you cannot because the UNO doesn't have any network interface.

I believed that I could configure Arduino as a ModBus slave (general), but reading the documentation I dont sure how make it.

The terminology of Modbus TCP is different to Modbus RTU. Modbus RTU has a master and slaves but Modbus TCP has a client and servers. You shouldn't use the ArduinoModbus library on AVR Arduinos as it wastes too much memory. It's designed to be used on ARM based Arduinos (which have much more RAM).

Have someone any idea how configure arduino modbus for control it via PLC raspberry?

Tell us what you're trying to achieve. You told us what you think is a (the best?) way technically (Modbus TCP) but there might be better options depending on the use case. What is the Arduino expected to do in your setup?

Thanks for your answer @pylon

Using only an UNO you cannot because the UNO doesn't have any network interface.

I have a shield ethernet for Arduino, sorry for not mencion it. Yes, I need a Raspberry as Client, and Arduino as Server.

You shouldn't use the ArduinoModbus library on AVR Arduinos as it wastes too much memory. It's designed to be used on ARM based Arduinos (which have much more RAM).

This is very interesting and help me a lot, thank you, dou you know other library? I'm thinking on Modbusino.h but not support Coils functions, and I think that I prefer have it.

Tell us what you're trying to achieve. You told us what you think is a (the best?) way technically (Modbus TCP) but there might be better options depending on the use case. What is the Arduino expected to do in your setup?

Yes, of course. I try to create a "micro" automatized factory, for educational purpose. With sensors, mini conveyor belt, alarms and that kind of things. I must use Codesys+Raspberry like PLC and Arduino like controller. But it's not necesary Modbus TCP or Arduino UNO. As ModBus is used in industry, and I have Arduino UNO, I want to used it, but it's not definitive.

thank for your answer again!

The Modbus TCP support for the AVR family of Arduinos isn't very mature.

Yes, of course. I try to create a "micro" automatized factory, for educational purpose. With sensors, mini conveyor belt, alarms and that kind of things. I must use Codesys+Raspberry like PLC and Arduino like controller. But it's not necesary Modbus TCP or Arduino UNO. As ModBus is used in industry, and I have Arduino UNO, I want to used it, but it's not definitive.

If you want to build that on an Arduino UNO base you should probably switch to Modbus RTU (serial).
I don't know that Codesys thing, Google says that it's a proprietary product so I have no interest in wasting time with it's documentation. If your setup only supports Modbus TCP you might want to change to the Arduino MKR platform and use the ArduinoModbus library.

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