Skip to content

epics-modules/twincat-ads

Repository files navigation

EPICS TwinCAT-ADS

EPICS Module to communicate with TwinCAT controllers over ADS protocol.

Install

  1. Clone recursively:
$ git clone --recursive https://github.com/epics-modules/twincat-ads
  1. Create a configure/RELEASE.local file with:
EPICS_BASE=<path-to-your-base>
ASYN=<path-to-asyn>
  1. Build and install:
make
make install

Note: This module depends on Beckhoff ADS library, which is submoduled here and built from source.

Prepare communication between IOC and TwinCAT Controller

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:

  1. 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.

  2. 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).

  3. Use TwinCAT XAE. Click Solution -> SYSTEM -> Routes and add the route through the popup window.

Usage

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/ or TIMEBASE=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.
  • [? | =]: 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.

License information

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/.

About

No description, website, or topics provided.

Resources

License

LGPL-3.0, GPL-3.0 licenses found

Licenses found

LGPL-3.0
COPYING.LESSER
GPL-3.0
COPYING

Stars

Watchers

Forks

Packages

No packages published

Contributors 14