Receiving data from the TwinCAT PLC 2.8 and higher

1st Step TwinCAT PLC

TwinCAT 2.8 (or higher):

With TwinCAT 2.8 or higher an TwinCAT OPC-Server 4.1.0.79 (or higher) the OPC-configuration has become very easy and has to be done just once.

After the PLC project has been compiled, there is always a file in the PLC project directory with the name structured as "<project name>.tpy".

2nd step: Configuration of TwinCAT OPC Server - to be done just once

Start the TwinCAT-OPC-Configurator "Start - All Programs - TwinCAT System - TwinCAT OPC - TwinCAT OPC Configurator"

Receiving data from the TwinCAT PLC 2.8 and higher 3:

Select "I/O Devices" with right click and then menu "New".

Receiving data from the TwinCAT PLC 2.8 and higher 4:

For "Name" please enter a name for this alarm definition.
This name has to be OPC conform, no special characters allowed.

Sample: The TwinCAT-PLC runtime-system 1 has a PLC variable "temperatur".
Definition of devicename with "Plc1" will publish the PLC variable via OPC as "Plc1tTemperatur" later for OPC-Clients.

Receiving data from the TwinCAT PLC 2.8 and higher 5:

After applying with "OK" you see the next dialog with settings of the new device "Plc1"
For option "AutoCfg" select option "8 Link and filter to generic TwinCAT symbol file"
For option "AutoCfgFile" click to "Search-buton" and navigate to e.g. "C:\TwinCAT\Boot\CurrentPLC_1.tpy"

If you work on a small PLC project and all PLC variables should be available for OPC you can select option "AutoCfg" "7 Link to generic TwinCAT symbol file"

In this case all PLC variables are imported, the filter comment in the PLC Control is ignored.

Following settings have to be checked:

Requirements

Type

Req./Opt.

Description

Name

Req

Name for device like "PLC1". OPC-Client browse this name

Description

Optional

 

AutoCfg

Optional

1 : Include sym-file of TwinCAT-PLC defined under <AutoCfgSymFile>
2 : Include sym-file of TwinCAT-BCxxxx-project defined under <AutoCfgSymFile>

7 : Include tpy-file of TwinCAT28-project defined under <AutoCfgSymFile>

8 : Include tpy-file of TwinCAT28-project defined under <AutoCfgSymFile>, but import only symbols with symbol-property "OPC=1"

AutoCfgSymFile

Optional

full path and name of symbol-file to be included like
"

C:\Test\demo.sym" or "

\\User1\Test\demo.sym" or "C:\TwinCAT\Boot\CurrentPLC_1.tpy"

 

 

 

AdsPort

Req

Number of ADS-PortID, like
801 for first PLC-runtime system
811 for first PLC-runtime system

821 for first PLC-runtime system
831 for first PLC-runtime system

800 for PLC-runtime system on BC

AdsNetId

Optional

specific ADS-NetId, like "174.12.15.45.1.1"

If not specified or like "0.0.0.0.0.0", the OPC-Server will always communicate to AdsNetId of local ADS-router.

AdsTimeout

Optional

ADS timeout in ms for this ADS device. If ADS device will not replay within this time, the OPC-Server will set the requested variables to "BAD QUALITY"

AdsTimeSuspend

Optional

ADS suspend time in ms for this ADS device, if the ads communication fails. If an ADS device is running, it does not make sense to communicate with high frequence to that device. In case of ads-communication trouble the OPC-Server will wait till next ads-request to that device.

 

 

 

Disable

Optional

Disables this device. OPC-Server will ignore this device.

See detailed description in appendix.

3 rd step : Check and save configuration

Save the configuration unter current name or select menu "File - Save As..." to insert a new name.

The OPC-Configurator will save the XML based file.

After saving the OPC-configurationfile we get the option to activate this configuration to be the configuration for next startup of OPC-Server.

Receiving data from the TwinCAT PLC 2.8 and higher 6:

After selecting "Yes" this current configuration will be the start-configuration of the opc-server. With next start of OPC-Server this new configuration will be active.

Receiving data from the TwinCAT PLC 2.8 and higher 7:
Receiving data from the TwinCAT PLC 2.8 and higher 8:

If you activated a new OPC-configuration, but the OPC-Server still has old namespace and settings the reason is that the OPC-Server was not stopped and restarted.