This programm allows to use your Arduino as a Fieldbus Coupler over Modbus TCP. This means you can Read/Write Digital and Analog In/Outputs from a higher level controller. For example a PLC or PC.
*Update the file "boardDefines.h" according to your Arduino board and your needs.
- Change your IP, MAC, ...
- Update the arrays "pinsArrayDI" & "pinsArrayDO" with the pin_numbers of your board. You can use all of them as DI or DO. Or any combination such as:
*Then build and upload into the arduino board. Start serial monitor. It shows something like this:
*Use any ModbusTCP-Client to connect from your PC / PLC to the Arduino. Serial monitor should say "new client"
*Watch inputs and set outputs from the corresponding registers (1x, 2x, 3x, 4x). For example:
*Set Coils (0x) to Arduino Digital Outputs
*Read Arduino Digital inputs into Discrete Inputs registers (1x)
*Modbus Input Registers (3x)
*Modbus Holding Registers (4x)
Analog values are scaled from 0 to 100,0% using an integer with 10x Gain. For Example:
- 1000 Modbus = 100% in Arduino
- 855 Modbus = 85,5% in Arduino
- 151 Modbus = 15,1% in Arduino
Arduino MEGA 2560
Ethernet Shield W5100 for Arduino
Microsoft Visual Studio 2013 using Arduino IDE v1.6/1.8
Arduino Libraries:
- ArduinoRS485 1.0.0
- ArduinoModbus by Arduino 1.0.0
- SPI Master library for arduino (built-in)
- Ethernet library for arduino (built-in)