Arduino Master Modbus RTU (RS232)
This time we will test our Arduino board by making a configuration as master modbus RTU via RS232, there is a great range of equipment that have this communication protocol from PLC, PID controllers, PAC, HMI OPC, SCADA, Meters, counters between other equipment.
Tests
As in the previous test of Arduino configured as Slave Modbus RTU, We have a Arduino Mega 2560 R3, this board has been selected since it has several serial ports, we have made a series of modifications to the original libraries to use the second serial port ( Serial1) of arduino for the modbus protocol, and the main port (Serial) is only for programming and debugging according to the case.
We will use an additional Max232 chip to convert the modbus protocol of ttl voltages to 5v to RS232, although this converter is sold normally we have decided to assemble it (MAX232 DIY) in order not to lose the tradition of making PCB ships.
Initially our Arduino will be connected to a modbus Simulator that will work as a Master via RS232.
Arduino Mega 2560 Master Modbus RTU (RS232)
Arduino MAX232 Connection
Arduino Mega 2560 R3
Conclusions
By performing this assembly on your arduino board you could create monitoring and control applications in most cases to request data from Modbus slave meters.
We recommend not to set a speed higher than 9600 in modbus.
In this case the modifications in the library were made so that the protocol modbus functions in the port 2 (Serial1) of arduino, if they can modify the library replace Serial1 by Serial and the board will use the main port for modbus, but they will not be able Debug or display values as shown in the previous example.
As we advance in our tests we will perform integrations with PLC, HMI, SCADA and IoT (Node-RED).
References
Downloads