Skip to main content

ADS Overview

The ADS connector enables communication with Beckhoff TwinCAT PLCs and systems using the ADS (Automation Device Specification) protocol. It supports automatic symbol discovery, bidirectional communication, and complex data types including arrays and structures.
ADS provides direct, high-performance access to TwinCAT variables. The AutoDiscovery feature can automatically find and expose all PLC symbols as MQTT topics.
The ADS connector is on beta testing. It is planned for a future release.

Basic Syntax

Set the PLC’s AMS Net ID, IP, and ADS port in ADS_CONFIG. The broker connects through the AMS router on the broker host, so create that route on the router or the PLC. See AMS route setup.

AMS Net ID Basics

ADS uses an AMS Net ID for the broker host and one for the PLC. Set the broker host’s id on the AMS router. An AMS Net ID is typically the IP address followed by .1.1.
You can find your TwinCAT system’s AMS Net ID in TwinCAT XAE under SYSTEM → Connectors or by running adsInfo on the target.

Connection Configuration

ADS_CONFIG Parameters

string
Not required. Accepted and not used yet.
string
Not required. Accepted and not used yet.
string
Local host name (optional).
string
required
Target PLC’s AMS Net ID (format: x.x.x.x.x.x).
string
required
Target PLC’s IP address.
integer
ADS port. Typically 851 for TwinCAT 3, 801 for TwinCAT 2.
string
Not required. Accepted and not used yet.
string
Not required. Accepted and not used yet.
string
Not required. Accepted and not used yet.
The broker connects through the AMS router on the broker host. Create the AMS route on the router or the PLC yourself. LOCAL_NET_ID, LOCAL_ROUTE_TO_TARGET, TARGET_ROUTE_TO_LOCAL, TARGET_USER, and TARGET_PASSWORD do not create that route.
integer
Limit for each ADS request, in milliseconds. Default: 5000. A value of 0 or below falls back to 5000.
A SYMBOL read is 1 request by name. A SYMBOL write takes 3 round trips (create handle, write, release handle), so it can take up to 3 × TIMEOUT plus a margin of at least 1 s. INDEX reads and writes are 1 request. When an ADS error means the PLC is unreachable, such as a timeout or target not found, the route goes to Reconnecting instead of staying Connected with BAD tags. See Connection status.

Connection Example


AutoDiscovery

AutoDiscovery automatically finds all PLC symbols and exposes them as MQTT topics.

AutoDiscovery Parameters

boolean
Enable automatic symbol discovery. Default: false.
string
Base MQTT topic for discovered symbols. Default: ads/discovery.
integer
Default QoS for discovered symbols (0-2). Default: 0.
boolean
Default retain flag for discovered symbols. Default: false.
integer
Default trigger mode:
  • 0 - OnStart (read once at connection)
  • 1 - OnChange (publish on value change)
  • 2 - Cyclic (poll at interval)
Default: 2.
integer
Default polling cycle in milliseconds. Default: 1000.
string
Include patterns (comma-separated, * wildcard). Default: * (all symbols).
string
Exclude patterns (comma-separated, * wildcard).
integer
Structure expansion depth. Default: 3.
boolean
Enable parallel reading for large projects. Default: false.
integer
Batch size for parallel reading. Default: 50.

AutoDiscovery Example


TwinCAT Data Types

String sizing

For STRING tags, WITH LENGTH is the total size in bytes, including the ADS length byte. It defaults to 256 bytes for reads; writes use an 80-byte default when no size is supplied. STRING_SIZE is accepted as an alias for the same field. ARRAY_ELEMENT_LENGTH is a separate setting for ARRAY tags whose elements are STRING or STRUCT — it does not replace LENGTH on scalar string tags. Read a TwinCAT STRING symbol with an explicit read size (256 bytes here; writes default to 80 bytes when LENGTH is omitted):

TAG Configuration

Symbol-Based Addressing

Index-Based Addressing

For direct memory access using index group and offset:

Array Handling

string
Array element type (required for ARRAY): BOOL, INT, REAL, STRING, STRUCT, etc.
integer
Number of elements in the array.
integer
Length of each element in bytes (for STRING/STRUCT arrays).
integer
Offset in bytes to skip before array data. Default: 0.
integer
Header bytes to skip per element. Default: 0.

Structure Handling

string
Structure field definitions in format: name:offset:type:size (comma-separated).

String sizing parameter

integer
Total string size in bytes, including the ADS length byte. Default: 256 for reads; 80 for writes when omitted. Alias: STRING_SIZE.

Event-Based Operations

For on-demand ADS operations (not polling), use the EVENT syntax. Publish a message to SOURCE_TOPIC to trigger the operation; the connector executes it and publishes the result to DESTINATION_TOPIC.

Supported Operations

Query Parameters

Read Example

Read a process variable on demand:

Write Example

Write a setpoint on demand:

Complete Examples

Read PLC variables using symbol names:

AMS route setup

The broker connects through the AMS router on the broker host. It does not create the route. Add the AMS route on the router or the PLC yourself.

On the TwinCAT system

  1. Open TwinCAT XAE
  2. Go to SYSTEM → Connectors
  3. Add a static route to the broker host:
    • AMS Net ID: the broker host’s AMS Net ID
    • Transport Type: TCP/IP
    • Address: the broker host’s IP address
LOCAL_NET_ID, LOCAL_ROUTE_TO_TARGET, TARGET_ROUTE_TO_LOCAL, TARGET_USER, and TARGET_PASSWORD are not required and are not used yet.

Troubleshooting

  • Verify the target AMS Net ID and the route on the router or the PLC
  • Ensure TARGET_PORT is correct (851 for TC3, 801 for TC2)
  • Verify the firewall allows the ADS port (typically 48898)
  • Verify symbol path matches exactly (case-sensitive)
  • Check symbol exists in PLC project
  • Ensure PLC is in RUN mode
  • Use AutoDiscovery to find correct symbol names
  • Check DISCOVERY_FILTER_INCLUDES patterns
  • Verify DISCOVERY_MAX_DEPTH is sufficient
  • For large projects, enable DISCOVERY_PARALLEL_READING
  • Check PLC project is compiled and deployed
  • Ensure WRITABLE is set to “true”
  • Verify PLC variable is not constant
  • Check value is within MIN_VALUE/MAX_VALUE
  • Verify PLC is in RUN mode
  • Increase TIMEOUT value
  • Check network connectivity
  • Verify TwinCAT runtime is running
  • Reduce DISCOVERY_BATCH_SIZE if using AutoDiscovery

Next Steps

Allen-Bradley

Connect to Rockwell Automation PLCs.

OPC UA Client

Cross-platform OPC UA communication.
Last modified on October 22, 2026