Experimental Physics and Industrial Control System
Hi Rob,
I see the source of the 20ms delay. It is in modbusInterpose.c:
static asynStatus writeIt(void *ppvt, asynUser *pasynUser,
const char *data, size_t numchars,
size_t *nbytesTransfered)
{
modbusPvt *pPvt = (modbusPvt *)ppvt;
asynStatus status = asynSuccess;
...
epicsThreadSleep(0.02);
...
That delay was added in this commit to the code:
------------------------------------------------------------------------
r9770 | rivers | 2009-11-27 10:36:51 -0600 (Fri, 27 Nov 2009) | 1 line
Move slave address from interpose layer to modbus packet layer, allowing multiple slave address per asyn IP or serial port; add 20 ms delay per Modbus spec; changes made by Yves Lussignol
------------------------------------------------------------------------
I made the commit, but the changes were actually done by Yves Lussignol when he got Modbus RTU running with multiple slave addressess on a single serial line. His comment says that the 20ms delay is "per Modbus spec".
I have not actually tried to find that in the Modbus spec. Can Rob or Yves you have a look and see if it is in the spec for all transports (TCP, RTU, ASCII) or perhaps just for the RTU and/or ASCII? If the spec says it is transport dependent it is easy to make that change in modbusInterpose.c. The Modbus specs are in the documentation in the module, I just don't have time to work on it today.
Thanks,
Mark
________________________________
From: Mark Rivers
Sent: Tue 3/8/2011 6:10 PM
To: 'Robert Emery'; [email protected]
Subject: RE: Asyn/Modbus Delay
This is the first I have heard of this.
Here is the first thing to do. Set the asynTraceMask to 0x9 on the underlying asyn TCP port (AcromagDO1), and send the asyn output to a file with asynSetTraceFile. Then look at the timestamps to see if you learn anything. You can also then set the asynTraceMask on the asyn Modbus port (CCC:ACROMAGDO1:Modbus:Output) and send its output to a file. By sending the asynTrace output to a file you hopefully won't mess up the timing too much, though 20ms is still a pretty short delay to be tracking down.
Mark
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Robert Emery
Sent: Tuesday, March 08, 2011 6:01 PM
To: [email protected]
Subject: Asyn/Modbus Delay
We are using Modbus/Asyn to talk to a Acromag ES2113 digital I/O
device. Since updating our controller software (Linux 2.6.24 to 2.6.32,
EPICS 3.14.8.2 to 3.14.12, Asyn 4.8 to 4.15, Modbus 1.1 to 2.1) the
Modbus/Asyn communication has slowed down. There is now a .02 sec delay
in messages sent out (see below). To illustrate this I ran a simple db
with 4 linked longout records writing to the Modbus/Asyn port and looked
at the timing with wireshark.
Any ideas why the delay and how I can get around it?
Thanks
Rob Emery
UW Medical Center
Original Timing
Time Source Destination Protocol Info
0.000000 .0.33 .0.31 Modbus/TCP query
0.002218 .0.31 .0.33 Modbus/TCP response
0.002229 .0.33 .0.31 TCP 53105 > 502 [ACK]
0.002288 .0.33 .0.31 Modbus/TCP query
0.005003 .0.31 .0.33 Modbus/TCP response
0.005166 .0.33 .0.31 Modbus/TCP query
0.007680 .0.31 .0.33 Modbus/TCP response
0.008171 .0.33 .0.31 Modbus/TCP query
0.010342 .0.31 .0.33 Modbus/TCP response
New Timing
Time Source Destination Protocol Info
0.000000 .0.33 .0.31 Modbus/TCP query
0.002168 .0.31 .0.33 Modbus/TCP response
0.003864 .0.33 .0.31 TCP 59583 > asa-appl-proto
[ACK]
0.024044 .0.33 .0.31 Modbus/TCP query
0.026214 .0.31 .0.33 Modbus/TCP response
0.046431 .0.33 .0.31 Modbus/TCP query
0.048319 .0.31 .0.33 Modbus/TCP response
0.068693 .0.33 .0.31 Modbus/TCP query
0.071181 .0.31 .0.33 Modbus/TCP response
Port Configuration
## Create the Asyn IP ports
drvAsynIPPortConfigure("AcromagDO1","192.168.0.31:502",0,0,1)
## Apply The Modbus Configuration to the IP ports
modbusInterposeConfig("AcromagDO1",0,1000)
## Create Test Port
drvModbusAsynConfigure("CCC:ACROMAGDO1:Modbus:Output","AcromagDO1",0,6,59,
6, 0, 0, "Acro Test")
Test db
record(longout, Tuning:Asyn:Timing:Test:LongOut) {
field(SCAN, "Passive")
field(DTYP, "asynUInt32Digital")
field(FLNK, "Tuning:Asyn:Timing:Test:LongOut2")
field(OUT, "@asynMask(CCC:ACROMAGDO1:Modbus:Output 0 0xFFFF)")
field(OMSL, "supervisory")
field(VAL, "101")
}
record(longout, Tuning:Asyn:Timing:Test:LongOut2) {
field(SCAN, "Passive")
field(DTYP, "asynUInt32Digital")
field(FLNK, "Tuning:Asyn:Timing:Test:LongOut3")
field(OUT, "@asynMask(CCC:ACROMAGDO1:Modbus:Output 1 0xFFFF)")
field(OMSL, "supervisory")
field(VAL, "102")
}
record(longout, Tuning:Asyn:Timing:Test:LongOut3) {
field(SCAN, "Passive")
field(DTYP, "asynUInt32Digital")
field(FLNK, "Tuning:Asyn:Timing:Test:LongOut4")
field(OUT, "@asynMask(CCC:ACROMAGDO1:Modbus:Output 2 0xFFFF)")
field(OMSL, "supervisory")
field(VAL, "103")
}
record(longout, Tuning:Asyn:Timing:Test:LongOut4) {
field(SCAN, "Passive")
field(DTYP, "asynUInt32Digital")
field(OUT, "@asynMask(CCC:ACROMAGDO1:Modbus:Output 3 0xFFFF)")
field(OMSL, "supervisory")
field(VAL, "104")
}
- Replies:
- Re: Asyn/Modbus Delay Robert Emery
- References:
- RE: Asyn/Modbus Delay Mark Rivers
- Navigate by Date:
- Prev:
Re: question about previous value of ai Ralph Lange
- Next:
Re: question about previous value of ai Steven M. Hartman
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
<2011>
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
RE: Asyn/Modbus Delay Mark Rivers
- Next:
Re: Asyn/Modbus Delay Robert Emery
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
<2011>
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024