EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Scan problem when the ioc behave as client
From: Tasaddaq Khan <[email protected]>
To: Mark Rivers <[email protected]>
Cc: "[email protected]" <[email protected]>
Date: Wed, 16 Mar 2016 10:29:29 +0500
Hi Mark

The device is sending a stream in 500ms that requests to send the data. But it also send a stream to just update the data of my records in this case it does not require the acknowledge means in response no stream and during this time it does not send the stream to send the data means interrupt stream to update my records also comes in 500ms.

MAIN problem is that I can see the updating stream from my device in my terminal means my protocol file receives the data but it is not updating my records. Secondly,  mostly it misses the interrupt stream. 

My st.cmd file is:

#!../../bin/linux-x86_64/newtest

## You may have to change newtest to something else
## everywhere it appears in this file

< envPaths

cd "${TOP}"

## Register all support components

dbLoadDatabase "dbd/newtest.dbd"
newtest_registerRecordDeviceDriver pdbbase

epicsEnvSet("STREAM_PROTOCOL_PATH", "/home/omar/epics/support/newtest/db")

drvAsynSerialPortConfigure("L0","/dev/ttyS0",0,0,0)
asynSetOption("L0", -1, "baud", "9600")
asynSetOption("L0", -1, "bits", "8")
asynSetOption("L0", -1, "parity", "none")
asynSetOption("L0", -1, "stop", "1")


## Load record instances
#dbLoadRecords("db/xxx.db","user=omar")

dbLoadRecords("db/ccr-.db")


#asynOctetSetInputEos("L0",0,"")
#asynOctetSetOutputEos("L0",0,"")
asynSetTraceIOMask("L0",0,0x4)
asynSetTraceMask("L0",0,0x9)

cd "${TOP}/iocBoot/${IOC}"
iocInit

## Start any sequence programs
#seq sncxxx,"user=omar"

and my database file is :

record (ai, "cmd-to-read"){
    field(DESC, "Command to read value from PLC")
    field(DTYP, "stream")
    field(SCAN, ".1 second")
    field(INP, "@ccr-cri.proto data-to-plc L0")
}

record (ai, "rod-addr"){
    field(DESC, "Command to increase the position")
    field(DTYP, "stream")
    field(SCAN, ".1 second")
    field(INP, "@ccr-cri.proto data-to-plc L0")
}

record (ai, "rod-status"){
    field(DESC, "Command to decrease the position")
    field(DTYP, "stream")
    field(SCAN, ".1 second")
    field(INP, "@ccr-cri.proto data-to-plc L0")
}

record (ao, "cmd-to-send"){
    field(DESC, "Current Step A1G1")
    field(DTYP, "stream")
    field(PINI, "YES")
    field(SCAN, ".1 second")
    #field(OMSL, "closed_loop")
    field(DOL, "cmd-to-read")
    field(OUT, "@ccr-cri.proto data-to-plc L0")
}

record (ao, "DPAO1014"){
    field(DESC, "Current Step A1G1")
    field(DTYP, "stream")
    field(PINI, "YES")
    field(SCAN, ".1 second")
    #field(OMSL, "closed_loop")
    field(DOL, "AO1014")
    field(OUT, "@ccr-cri.proto data-to-plc L0")
}

The protocol file is:

data-to-plc {
   
    MaxInput=14;

    in 0x01 "%(cmd-to-read.VAL)r" 0x08 "%(rod-addr.VAL)r" "%(rod-status.VAL)r" 0x00 0x00 0x00 0x00 0x00 0x00 0x00 "%#<modbus>";

    out 0x01 0x05 0x80 0x00 "%(DPAO1014.VAL)#.2r" 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 "%#<modbus>";
}


On Wed, Mar 16, 2016 at 3:02 AM, Mark Rivers <[email protected]> wrote:

Hi Tasaddaq,

 

My suggestion is to obtain the asynTrace output of your drvAsynIPPort driver and the debug output from StreamDevice.

 

var streamDebug 1

asynSetTraceIOMask myIPPort 0 4

asynSetTraceMask myIPPort 0 9

 

myIPPort is the name you gave to your drvAsynIPPort.  4 means ASYN_TRACEIO_HEX and 9 means ASYN_TRACE_ERROR | ASYN_TRACEIO_DRIVER.

 

That will give you time-stamped messages telling you when you sent and receiving information from the device, and what StreamDevice did with that information.

 

Your original message said you were using SCAN=I/O Intr, but your second message said SCAN=1 second.

 

Please explain how the PLC works: does it ever send “unsolicited” data, i.e. it sends a message without sending it a message requesting data?  Or does it only send a message as a reply when you send it an inquiry message?

 

Please send the complete database and protocol file you are actually using.

 

Mark

 

 

From: Tasaddaq Khan [mailto:[email protected]]
Sent: Tuesday, March 15, 2016 4:46 PM


To: Mark Rivers
Cc: [email protected]
Subject: Re: Scan problem when the ioc behave as client

 

Company has provided us the equipment that is not the standard modbus module. It is just calculating the crc of modbus. I have never used the modbus module, is it possible to suggest me how to improve my above protocol to overcome delay in sending and updating the data of the records.

 

On Wed, Mar 16, 2016 at 12:21 AM, Mark Rivers <[email protected]> wrote:

I now see that you are sending a Modbus read request and then reading the response.

 

My question is why are you trying to do this with StreamDevice?  Why not use the EPICS Modbus driver that others are using?

 

http://cars.uchicago.edu/software/epics/modbus.html

http://cars.uchicago.edu/software/epics/modbusDoc.html

https://github.com/epics-modules/modbus

 

It can poll very quickly.  The input records can all be I/O Intr scanned and only get processed when the Modbus register changes, etc.

 

Mark

 

 

From: Tasaddaq Khan [mailto:[email protected]]
Sent: Tuesday, March 15, 2016 2:08 PM
To: Mark Rivers
Cc: [email protected]
Subject: Re: Scan problem when the ioc behave as client

 

My protocol file is neither updating my record nor receiving the data on time. I miss many packets.My PLC is sending the standard data. e.g. When I update my record, the stream gets the value after 3 seconds almost. Similarly, I can see the data coming on my terminal means my protocol is receiving the data but my records are not updating so I miss the data.

I am facing the same problem with my other stream that has the following protocol file. Secondly, the protocol file does not send the continuous stream sometimes the DI packet is sent four consecutive times and sometimes DO is sent for three times etc.

DI {
    out 0x01 0x01 0x00 0x00 0x00 0x38 "%#<modbus>";
    in 0x01 0x01 0x07 "%(first-DI.VAL)r" "%(second-DI.VAL)r" "%(third-DI.VAL)r" "%(fourth-DI.VAL)r" "%(fifth-DI.VAL)r" "%(sixth-DI.VAL)r" "%(seventh-DI.VAL)r" "%#<modbus>";
}

DO {

    out 0x01 0x0F 0x03 0xE8 0x00 0x54 0x07 "%(first-DO.VAL)r" "%(second-DO.VAL)r" "%(third-DO.VAL)r" "%(fourth-DO.VAL)r" "%(fifth-DO.VAL)r" "%(sixth-DO.VAL)r" "%(seventh-DO.VAL)r" "%(eighth-DO.VAL)r" 0x00 "%(tenth-DO.VAL)r" "%(eleventh-DO.VAL)r" "%<modbus>";
    in 0x01 0x0F 0x00 0x00 0x00 0x54 "%#<modbus>";
}

I feel there is some timing mismatch. All of my records have SCAN time .1 second for above case.

regards,

Tasaddaq

 

On Mon, Mar 14, 2016 at 8:06 PM, Mark Rivers <[email protected]> wrote:

Is your PLC sending Modbus protocol data, but without a read request, i.e. it is sending unsolicited Modbus data?  If so, that is not valid Modbus protocol.

 

Mark

 

 

From: [email protected] [mailto:[email protected]] On Behalf Of Tasaddaq Khan
Sent: Monday, March 14, 2016 10:02 AM
To: [email protected]
Subject: Scan problem when the ioc behave as client

 

Hi

My IOC (as client) is communicating with the PLC (as master). PLC is continuously requesting to send data after 500ms with cmd-to-read=0x05 but it can request to update the data any time with cmd-to-read=0x01 or 0x02 or 0x03, in this case rod-status value is also updated. My Protocol file and records are following:

ExtraInput = Ignore;
data-to-plc {
   
    MaxInput=14;

    in 0x01 "%r" 0x08 "%(\$1)r" "%(\$2)r" 0x00 0x00 0x00 0x00 0x00 0x00 0x00 "%#<modbus>";

# in 0x01 "%(cmd-to-read.VAL)r" 0x08 "%(rod-addr.VAL)r" "%(rod-status.VAL)r" 0x00 0x00 0x00 0x00 0x00 0x00 0x00 "%#<modbus>";
}

record (ai, "cmd-to-read"){
    field(DESC, "Command to read value from PLC")
    field(DTYP, "stream")
    field(SCAN, ".5 second")

# field(SCAN, "I/O Intr")

    field(INP, "@ccr-cri.proto data-to-plc(rod-addr,rod-status,) L0")

 #  field(INP, "@ccr-cri.proto data-to-plc L0")

}

record (ai, "rod-addr"){
    field(DESC, "Command to increase the position")
#    field(DTYP, "stream")
#    field(SCAN, "Passive")

#    field(SCAN, "I/O Intr")

#    field(INP, "@ccr-cri.proto data-to-plc L0")
#    field(FLNK, "cmd-to-read")
}

record (ai, "rod-status"){
    field(DESC, "Command to decrease the position")
#    field(DTYP, "stream")
#    field(SCAN, "Passive")

#    field(SCAN, "I/O Intr")

#    field(INP, "@ccr-cri.proto data-to-plc L0")
#    field(FLNK, "cmd-to-read")
}

I use different combination to SCAN the records and face following problem:

1. When I use SCAN "I/O Intr" for all the records and all the records(as active), when plc sends one variable then I read 14 bytes at my terminal, but when my plc sends two variables (like cmd-to-read and rod-addr) then my terminal shows 28 bytes, and when the stream contains all the three variables then I got stream of 42 bytes and ioc stops and message displays (core dump). In this case sometimes my records are updated and sometimes not.

2. Since my plc is continuously sending data after 500ms, so I adjust the scan rate of all of my records as 500ms. But in this case I got the right stream of 14bytes and any change in data from the plc I can see on my terminal but none of my record is updating.

3. When I use one of my record active and the other two as passive then sometimes my records are updating and sometimes they miss the data. My records are updated when my terminal got the 28 bytes. But in this case when I got change in stream my terminal shows the data of multiple of 14.

Please suggest me how to handle the situation of PLC (as master) and my IOC (as slave).

Tasaddaq

 

 

 



Replies:
RE: Scan problem when the ioc behave as client peter.owens
References:
Scan problem when the ioc behave as client Tasaddaq Khan
RE: Scan problem when the ioc behave as client Mark Rivers
Re: Scan problem when the ioc behave as client Tasaddaq Khan
RE: Scan problem when the ioc behave as client Mark Rivers
Re: Scan problem when the ioc behave as client Tasaddaq Khan
RE: Scan problem when the ioc behave as client Mark Rivers

Navigate by Date:
Prev: RE: Question about softioc "Connection refused" problem Mark Rivers
Next: FW: Question about softioc "Connection refused" problem lzfneu
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: Scan problem when the ioc behave as client Mark Rivers
Next: RE: Scan problem when the ioc behave as client peter.owens
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 15 Jul 2016 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·