Question:
How can you fix communication issues with Modbus and multiple slaves with a RS-485 converter? I have a Modbus Master driver (Modbus-TCP) protocol connected to an Ethernet/RS485 converter; the RS-485 network has two slave devices (Modbus-RTU protocol).
Often times, some of the tags will fail or go into timeout, and this issue only happens when both slaves communicate simultaneously.
Solution:
In many cases, the Ethernet/RS485 or Serial/RS485 converter will need a delay between TX/RX transactions; this happens in order to be able to communicate with multiple slaves on the RS-485 network, and by default this is not the case.
The option Inter-frame delay on Serial and Ethernet tab (IOKit v2.0.125), which sets up a waiting time between packets that are either sent to or received from IOKit in milliseconds (1000 = 1 second), can introduce this delay.
For previous versions of the IOkit, when converting RS485 to Serial or RS485 to Ethernet, you can use a Modbus driver parameter; this parameter is hidden in the Properties dialog and it will delay TX/RX transactions when slaves exchange their IDs.
To set it up, you could start the driver offline (Start driver OFFLINE option on Setup tab), and then add this script at the driver’s AfterStart event:
Sub Modbus1_AfterStart() ' Habilita a funcao Swap Address Delay Write -1, 0, 0, 3, Array("ModiconModbus.UseSwapAddressDelay", 1) ' Configura o atraso (por exemplo, 300 milisegundos) Write -1, 0, 0, 3, Array("ModiconModbus.SwapAddressDelay", 300) 'Online Write -1,0,0,4,1 End Sub
Related articles:
The articles below all refer to common issues faced by the Modbus driver: