nanakl
Hi,

We installed Open PLC on Debian Linux Environment ,

We connected 2 nos of Modbus Slave IO Modules Via on USB to RS 485 to Open PLC(Debian Linux) it is working well with Baud rate on 4800,9600,19200,38400.

We connected Same 2 nos of Modbus Slave IO Modules Via on UART to Open PLC(Debian Linux) it is working well with Baud rate on 4800, 9600. When we tried to connect Higher baud rates(19200,38400) we start getting Timeout error on second slave device as
"Modbus Read Holding Registers failed on MB device".

in modbus_master.cpp 
Nanosleep is declared as "ts.tv_nsec = (1000*1000*1000*28)/mb_devices[i].rtu_baud;"
Can I know How 1000*1000*1000*28 is derived , to adjust this delay.
Reply 0 0
thiagoralves
It seems that whoever did that implementation did it wrong. According to Modbus Serial Line Protocol and Implementation Guide V1.02 at page 13, at the bottom you will find a remark explaining the inter-character time-out (t1.5) and inter-frame delay (t3.5) values. For baud rates over 19200 values should fixed (50 us for inter character time out and 1.75 ms for a frame delay). For slower baud rates they need to be calculated as 16500000/baud for inter-character time-out and 38500000/baud for frame delay.

As far as I know, libmodbus should have taken care of it automatically, without the need to explicitly delay OpenPLC code with those timeouts.

Also, it could be possible that your UART circuit is wrong at some point. RS485 over UART requires more than just RX/TX pins.
Reply 0 0
nanakl
Thanks Thiagoralves,

In some cases we are in situation to integrate Non standard Modbus slave Devices, Just to know where in Open PLC those delays are configured. When we try to integrate non standard Modbus slaves it may help us adjust , test and validate.

We manage to get data on 180 to 200 ms timeout and 1000 ms polling interval for 19200 with some timeout error while testing. 

In parallel let us validate UART to RS485 circuit too.
Reply 0 0
Reply