Skip to content

Data Acquisition with Beckhoff ADS Plugin

In this tutorial, we introduce how to collect data from Beckhoff software PLCs using the Neuron ADS plugin.

Environment Setup

We use two PCs connected to a local area network in this tutorial.

PC 1PC 2
Operating SystemLinuxWindows
IP address192.168.1.152192.168.1.107
AMS Net ID192.168.1.152.1.1192.168.1.107.1.1
SoftwareNeuronTwinCAT 3
NetworkConnectedConnected

Configure TwinCAT

Before Neuron and the TwinCAT PLC can communicate with each other, we first need to add a static route for Neuron in TwinCAT. We also need to find the AMS Net ID of the TwinCAT PLC and the index group and index offset of the variables.

Add Static Route in TwinCAT

  1. Open the TwinCAT Static Routes dialog box.
Open the TwinCAT static routes dialog
Fig.1 - Open the TwinCAT static routes dialog
2. Click **Add**.
TwinCAT static routes dialog
Fig.2 - TwinCAT static routes dialog
3. Provide the information as highlighted in the following image. Note that the **AmsNetId** is the IP address of the Neuron PC appended with ".1.1".
TwinCAT add route dialog
Fig.3 - TwinCAT add route dialog
  1. A successfully added route is shown as follows.
TwinCAT static routes dialog updated
Fig.4 - TwinCAT static routes dialog updated

Get AMS Net ID and Port Number

  1. Open the TwinCAT System dialog to show the AMS Net ID.
TwinCAT system dialog
Fig.5 - TwinCAT system dialog
2. By default, TwinCAT PLC port number is 851.
TwinCAT PLC project tab
Fig.6 - TwinCAT PLC project tab

Get Index Group and Index Offset of Variables

We use the following TwinCAT PLC program, which defines enough variables for testing in this tutorial.

TwinCAT PLC project main program
Fig.7 - TwinCAT PLC project main program

Find the Index Group

The Beckhoff index group/offset page lists the index group to access the PLC memory range. For the %MW field, the index group is 0x4020. For the %MX field, the index group is 0x4021. For the variables b、i8、u8、i16、u16、i32、u32、i64、u64、f32、f64、str defined in the main program, the index group is 0x4040.

TwinCAT index group table
Fig.8 - TwinCAT index group table

Find the Index Offset

Open the TwinCAT PLC data area tab to find the index offset of the variables.

TwinCAT PLC data area tab
Fig.9 - TwinCAT PLC data area tab

Get the Index Group/Offset by TPY File

We could also find the index group and index offset through the TPY file.

  1. Ensure TPY File is enabled.
TwinCAT PLC project setting tab
Fig.10 - TwinCAT PLC project setting tab
  1. Open the TPY file in the TwinCAT project directory.
TwinCAT PLC project tpy file path
Fig.11 - TwinCAT PLC project TPY file path
  1. The TPY file contains the index group and index offset of each variable defined in the PLC program.
TwinCAT PLC project tpy file content
Fig.12 - TwinCAT PLC project TPY file content

Configure Neuron

Add ADS South Node

In the Neuron dashboard, click South Devices -> Add Device to add an ADS node.

Add ADS south device in Neuron dashboard
Fig.13 - Add ADS south device in Neuron dashboard

Configure ADS Node

Click the node configuration icon to configure the newly created ADS node.

Configure ADS node in Neuron dashboard
Fig.14 - Configure ADS node in Neuron dashboard

Add Tags to the ADS Node

For each variable in the aforementioned TwinCAT PLC program, we add a corresponding tag to the Neuron ADS node. The [Beckhoff data types] page lists the size of the data types. Together with the program source code we could derive the data types of the tags.

TwinCAT PLC main program
Fig.15 - TwinCAT PLC main program

For tag addresses, the index offset component is shown in the TwinCAT PLC data area tab.

TwinCAT PLC data area tab
Fig.16 - TwinCAT PLC data area tab

The following figure shows all added tags in the ADS node.

Neuron version 2.3.0 upload topic setting
Fig.17 - ADS node tags in Neuron dashboard

Monitor Data

Read Tags

Once the TwinCAT PLC is in running mode, we could see the variable values in the interface.

TwinCAT variable values in running mode
Fig.18 - TwinCAT variable values in running mode

In the Neuron dashboard, click Monitoring -> Data Monitoring, check whether the tag values are read correctly.

Neuron data monitoring tab
Fig.19 - Neuron data monitoring tab

Write Tags

In the Neuron Data Monitoring tab, click Write on the main.MXtest1 tag to write a true value.

Neuron write main.MXtest1
Fig.20 - Neuron write main.MXtest1

Click Write on the main.MWtest1 tag to write the value 6666.

Neuron write main.MWtest1
Fig.21 - Neuron write main.MWtest1

After a successful write, we could see that variable values do update in TwinCAT.

TwinCAT variable values updated
Fig.22 - TwinCAT variable values updated