IOC configuration
Everything that concerns the connection as a whole is configured in the IOC startup script. Per-record settings are described in Records.
Startup script
A minimal startup script, parameterised so that only the top block needs editing:
dbLoadDatabase "dbd/adsExApp.dbd"
adsExApp_registerRecordDeviceDriver pdbbase
epicsEnvSet("ASYN_PORT", "ADS_1")
epicsEnvSet("PLC_IP", "192.168.88.63")
epicsEnvSet("PLC_AMS_NET_ID", "$(PLC_IP).1.1")
epicsEnvSet("ADS_DEFAULT_PORT", "851")
epicsEnvSet("PARAM_TABLE_SIZE", "1000")
epicsEnvSet("PRIORITY", "0")
epicsEnvSet("DISABLE_AUTOCONNECT", "0")
epicsEnvSet("DEFAULT_SAMPLETIME_MS", "50")
epicsEnvSet("MAX_DELAY_TIME_MS", "100")
epicsEnvSet("ADS_TIMEOUT_MS", "5000")
epicsEnvSet("DEFAULT_TIME_SRC", "0")
adsAsynPortDriverConfigure(${ASYN_PORT},${PLC_IP},${PLC_AMS_NET_ID},${ADS_DEFAULT_PORT},${PARAM_TABLE_SIZE},${PRIORITY},${DISABLE_AUTOCONNECT},${DEFAULT_SAMPLETIME_MS},${MAX_DELAY_TIME_MS},${ADS_TIMEOUT_MS},${DEFAULT_TIME_SRC})
asynOctetSetOutputEos(${ASYN_PORT}, -1, "\n")
asynOctetSetInputEos(${ASYN_PORT}, -1, "\n")
asynSetTraceMask(${ASYN_PORT}, -1, 0x41)
dbLoadRecords("db/adsTestAsyn.db","P=ADS_IOC:ASYN:,PORT=${ASYN_PORT},ADSPORT=${ADS_DEFAULT_PORT}")
iocInit
The complete version is in
iocBoot/iocexample/st.cmd,
together with the matching database
adsExApp/Db/adsTestAsyn.db.
iocsh commands
Loading ads.dbd registers three commands.
adsAsynPortDriverConfigure
Creates one asyn port connected to one TwinCAT controller. Call it once per PLC,
before iocInit and before any dbLoadRecords that reference the port.
adsAsynPortDriverConfigure(
portName, ipAddr, amsAddr, defaultAmsPort, paramTableSize,
priority, disableAutoConnect, defaultSampleTimeMS, maxDelayTimeMS,
adsTimeoutMS, defaultTimeSource)
# |
Argument |
Type |
Example |
Description |
|---|---|---|---|---|
1 |
|
string |
|
asyn port name used in record |
2 |
|
string |
|
IP address of the TwinCAT controller. |
3 |
|
string |
|
AMS NetId of the controller. |
4 |
|
int |
|
Default ADS port of the runtime holding the symbols. Overridable per record with |
5 |
|
int |
|
Maximum number of PLC symbols (asyn parameters) for this port. |
6 |
|
int |
|
asyn port thread priority ( |
7 |
|
int |
|
|
8 |
|
int |
|
Default PLC-side notification sample period, overridable with |
9 |
|
int |
|
Default maximum time the PLC buffers notifications before sending, overridable with |
10 |
|
int |
|
Timeout for synchronous ADS requests. |
11 |
|
int |
|
|
Note
Records that take their timestamp from the driver must set field(TSE, "-2").
See Timestamps.
adsSetLocalAddress
adsSetLocalAddress("192.168.114.129.1.1")
Argument |
Type |
Description |
|---|---|---|
|
string |
AMS NetId the IOC presents to the PLC router, in |
Use this when the host has several network interfaces, or when the AMS NetId
registered on the PLC does not match the automatically derived one. The string
must be at least 11 characters long; shorter values are rejected with a message.
Call it before adsAsynPortDriverConfigure.
adsPollInfo
adsPollInfo("") # all polled symbols
adsPollInfo("fAmplitude") # only symbols whose name contains "fAmplitude"
Argument |
Type |
Description |
|---|---|---|
|
string |
Substring filter on the PLC symbol name, empty for all. |
Prints diagnostics for the bulk-read (polling) loop, see Troubleshooting.