Overview

The Beckhoff TwinCAT connector provides tag-based read and write access to a Beckhoff PLC over ADS, using the TwinCAT.Ads SDK.

Every poll cycle reads each subscribed In/InOut tag via ReadAny against a variable handle created once at connect time; Out/InOut tag writes go out immediately via WriteAny as soon as a tag's value changes.

The connector detects when the underlying ADS connection is lost and reconnects automatically without blocking the read cycle - reconnection runs on its own dedicated background thread, and the previous AdsClient is properly disposed before a new one replaces it.

Parameters

Name Values Description
Type BECKHOFFTWINCAT The connector type identifier.
NETID AMS Net ID, e.g. 192.168.0.2.1.1 The target PLC's AMS Net ID.
IP IP address The target PLC's IP address.
PORT integer The ADS port for the target PLC runtime. Defaults to 851 (the first PLC runtime system on a device; 852 for the second, and so on).
UpdateRate milliseconds (integer) How often the connector polls all subscribed tags. Defaults to 1000.
ReconnectDelay milliseconds (integer) Delay between reconnect attempts while the PLC is unreachable. Defaults to 5000.

Supported Tag Types:

Tag Type Address Behaviour
Any standard tag The full ADS variable path, e.g. MAIN.bStart or GVL.rTemperature Read every cycle (In/InOut). Out/InOut tags are written back to the PLC whenever their value changes.

The tag's own DataType (Int/Decimal/Bool/String/Object) determines the .NET type used for the underlying ReadAny/WriteAny call - a tag with an unrecognised DataType is skipped with a %DEBUG notice rather than attempted.

Connector Methods

None currently implemented - all read/write access goes through tag polling and ChangeData writes rather than on-demand commands.

Addressing

The Address field of a tag is the ADS variable's full path as it appears in the PLC project. A variable handle for each address is created once, at connect time - a variable that doesn't exist on the PLC (or a typo'd path) is reported via %DEBUG during connection setup rather than on every subsequent read.