EPICS Module to communicate with TwinCAT controllers over ADS protocol.
- Clone recursively:
$ git clone --recursive https://github.com/epics-modules/twincat-ads- Create a configure/RELEASE.local file with:
EPICS_BASE=<path-to-your-base>
ASYN=<path-to-asyn>- Build and install:
make
make installNote: This module depends on Beckhoff ADS library, which is submoduled here and built from source.
To enable communication between the IOC and TwinCAT Controller, an ADS route needs to be setup. This can be done in at least three different ways:
-
Login to the PLC remotely. Click on the TwinCAT runtime icon (in the field by the Windows clock) -> Router -> Edit Routes. Add the route through the popup window.
-
Login to the PLC remotely. Edit the C:\TwinCAT\3.1\Target\StaticRoutes.xml manually.
<Route> <Name>epics</Name> <Address>192.168.114.129</Address> <NetId>192.168.114.129.1.1</NetId> <Type>TCP_IP</Type> <Flags>32</Flags> </Route>Note 1: Update with the correct IP address and AMSNETID.
Note 2: for TwincCAT 4024.0, this is the required method (see Beckhoff/ADS#98).
-
Use TwinCAT XAE. Click Solution -> SYSTEM -> Routes and add the route through the popup window.
This module allows access to ADS symbols through the following syntax:
@asyn(<PORT>,<ADDR>,<TIMEOUT>)<OPTIONS>/<PLC_SYMBOL>[? | =]
Where:
-
<PORT>,<ADDR> and <TIMEOUT>: Standard asyn parameters, see asyn docs; -
<OPTIONS>: Zero or more slash-separated parameters:-
ADSPORT=<port>/: ADS port (typically 851). -
TS_MS=<sample_time_ms>/: PLC sampling period in milliseconds. -
T_DLY_MS=<max_delay_ms>/: Maximum buffering time before transmission (ms). -
TIMEBASE=PLC/orTIMEBASE=EPICS/: Select timestamp source. -
POLL_RATE=<seconds>/: Value poll rate in seconds.
-
-
<PLC_SYMBOL>: PLC variable name;- Note: A special case for this is
.AMSPORTSTATE., that can be used instead of a PLC symbol to read / write the current ADSPORT state.
- Note: A special case for this is
-
[? | =]:End symbol with?for read access (input or output with readback) or=for write access.
A database with several example records can be found in adsExApp/Db/adsTestAsyn.db.
The corresponding startup script with necessary configurations is available in startup/adsOnlyIO.cmd.
twincat-ads is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
twincat-ads is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with twincat-ads. If not, see https://www.gnu.org/licenses/.