MODBUS RTU 1ms inter-byte delay ISSUE
-
modbus ascii works just fine
19200,8,N,1 - NORMAL
19200,8,N,1 - MANGO115200,8,N,1 - NORMAL
115200,8,N,1 - MANGOHow can I fix this?
????
modbus4j/serial/rtu/RtuMaster.java -
can you give more detail information?
-
@xbastek said:
RtuMaster.jav
my test setup:
SERVER (debian+mango demo license) <-> (USB<->RS485) <-> PLC <-> (RS485<->USB) <-> PC (Docklight)Distributor ID: Debian
Description: Debian GNU/Linux 7.8 (wheezy)
Release: 7.8
Codename: wheezyPackage mango: 2.5.2.5
core 2.5.2 build 6 - *** unlicensed ***
modbus 1.5.4 - *** unlicensed ***
....i configured one data source "Modbus Serial" with one data point - just for test
MODBUS RTU 19200,8,N,1
...and...
...PLC do not respond... but Docklight read correct frame modbus rtu frame
i send the same frame from Docklight and plc respond correctly..
so i Hook-up scope and identified the problem...
delays between individual bytes in frame.
in ASCII mod there is no delays between bytes, works just fine...
but i need RTU mod..I particularly don't like modbus4j/serial/rtu/RtuMaster.java
it seam to by something with
Thread.sleep.........
this.characterSpacing.........
i have never heard about character spacing in modbus rtu before...????is mango useing this code?
-
xbastek,
Thanks for the in-depth information.
From the Modbus spec here: http://www.modbus.org/docs/Modbus_over_serial_line_V1_02.pdf
On page 13 at the bottom there is a remark about RTU that states:
For baud rates greater than 19200 Bps, fixed values for the 2 timers should be used: it is recommended to use a value of 750μs for the inter-character time-out (t1.5) and a value of 1.750ms for inter-frame delay (t3.5).In the past we have had some issues with timing on some systems so we added a larger inter-character space.
However your scope is showing spacing greater than the 750μs maximum which is causing the problem.
To answer your question:
is mango useing this code?
Yes that is the code we use.Proposed solution:
-
Add an additional constructor to the Modbus4j library that allows passing in the spacing.
-
Add an additional constructor to the Modbus4j library that allows choosing to use 0 spacing or let the library compute the spacing based on the serial settings.
-
Keep the existing constructor that defaults to computing the spacing.
-
Expose the option to set the spacing in the Mango Modbus Data Source module.
-
-
my english is poor, i may don't understand it well enough..
loock at libmodbus libmodbus-3.1.2/src/modbus-rtu.c
-
@terrypacker said:
xbastek,
Thanks for the in-depth information.
From the Modbus spec here: http://www.modbus.org/docs/Modbus_over_serial_line_V1_02.pdf
On page 13 at the bottom there is a remark about RTU that states:
For baud rates greater than 19200 Bps, fixed values for the 2 timers should be used: it is recommended to use a value of 750μs for the inter-character time-out (t1.5) and a value of 1.750ms for inter-frame delay (t3.5).In the past we have had some issues with timing on some systems so we added a larger inter-character space.
However your scope is showing spacing greater than the 750μs maximum which is causing the problem.
To answer your question:
is mango useing this code?
Yes that is the code we use.
Proposed solution:Add an additional constructor to the Modbus4j library that allows passing in the spacing.
Add an additional constructor to the Modbus4j library that allows choosing to use 0 spacing or let the library compute the spacing based on the serial settings.
Keep the existing constructor that defaults to computing the spacing.
Expose the option to set the spacing in the Mango Modbus Data Source module.
Each proposed solution is good enough..
You made the RTU timing settings configurable. :)
But i don't know how to update this files in my mango installation... -
xbastek,
You say:
But i don't know how to update this files in my mango installation...
It will be far easier for you to upgrade to Mango 2.6.0 that has all the work done for you. It will be pre-released very soon.
Thanks,
Terry