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.
| 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. |
| 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.
None currently implemented - all read/write access goes through tag polling and ChangeData writes rather than on-demand commands.
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.
| Code | Type | Description |
|---|---|---|
| 1205 | Error | Beckhoff TwinCat device failed to connect |
| 1235 | Error | Error adding a tag's variable handle |
| 1305 | Error | Exception during a read cycle |
| 1415 | Error | Error writing a tag's value |
| 1510 | Error | RunMethod called with an unrecognised method name |
| 1999 | Error | Connect() threw an unhandled exception not caught anywhere else (last-resort catch) |
| 2100 | Info | Connector started |
| 2200 | Debug | Client connecting |
| 2210 | Info | Client connected |
| 2215 | Debug | Adding tag handles |
| 2220 | Debug | Adding a tag's variable handle |
| 2225 | Debug | Failed to add a tag's variable handle |
| 2230 | Debug | Cannot add a tag - ADS error code returned |
| 2241 | Info | N variable handles created |
| 2255 | Debug | Invoking Connected |
| 2260 | Debug | Invoking ConnectionLost |
| 2265 | Debug | Attempting to reconnect |
| 2270 | Debug | Handling disconnection |
| 2275 | Debug | Handling connection |
| 2280 | Debug | ADS connection state changed |
| 2300 | Debug | Unrecognised DataType for a tag - skipping |
| 2400 | Debug | ITag not present - ChangeData called for an unregistered tag name |
| 2405 | Debug | Cannot write a tag - not connected |
| 2410 | Debug | Cannot write a tag - no variable handle (tag not found on PLC at connect time?) |