Symbol server interface

Since product version 1.1.4, the S7 protocol driver implementation includes an ADS symbol server interface that allows ADS read/write access to configured S7 variables. There can be many different use cases for this kind of access. Such use cases can be, but are not limited to:

Symbol server interface 1:

The symbol server is available as a separate TcCOM object that will be added to an S7 Connector device.

Symbol server interface 2:

Symbol server interface 3:

The symbol server object does not define any process image. Instead all S7 variables are configured within the Symbol Variables window. Within that window you will find the server port of the ADS symbol server in the top right corner.

Symbol server interface 4:

Symbol server interface 5:

Multiple symbol servers

Please note that you can configure more than one symbol server, e.g., if you want to access multiple S7 controllers. In that case, all symbol servers share the same ADS server port. The individual symbol servers are then sorted under that ADS server port. The following screenshot shows an example of such a configuration – two S7 connectors each with its own symbol server object. The TwinCAT Target Browser connects to the ADS server port and displays the symbol server namespace.

Symbol server interface 6:

The following table lists all currently available ADS commands on the symbol server interface.

Command

Description

AdsGetHandle

Acquire an ADS handle via the variable’s symbol name.

AdsReleaseHandle

Release ADS handle.

AdsReadByHandle

Read operations on the acquired handle. Also supports sum commands.

AdsWriteByHandle

Write operations on the acquired handle. Also supports sum commands.

AdsRead

Read operations via direct communication with IndexGroup/IndexOffset. Also supports sum commands.

AdsWrite

Write operations via direct communication with IndexGroup/IndexOffset. Also supports sum commands.

Please note that ADS notifications are currently not supported by the symbol server.

Example: Connect to symbol server with TwinCAT OPC UA Server

In the previous chapter you have seen how to activate the symbol server interface on an S7 Connector device and browse through its namespace by using the TwinCAT Target Browser. As an additional example, we now want to configure the TwinCAT OPC UA Server to access the symbol server interface and make the configured S7 variables available via its OPC UA server address space.

After the TwinCAT OPC UA Server has been installed, open its Data Access configuration (TcUaDaConfig.xml) to configure the symbol server connection details. You can edit the Data Access configuration either by using the TwinCAT OPC UA Configurator or a text editor of your choice.

Add a new Data Access device using the following required parameters:

Parameter

Description

Name

Unique name for the device. Will be used as entry point on the OPC UA server’s address space.

AdsPort

ADS server port of the symbol server, e.g. 20100.

AdsNetId

NetID of the system on which the TwinCAT S7 Communication product runs.

AutoCfg

Value 5: switches the TwinCAT OPC UA Server to “symbol server access” mode.

The following excerpt of TcUaDaConfig.xml shows an example of such a configuration.

<UaNodeManager>
  <Name>S7</Name>
  <AdsPort>20100</AdsPort>
  <AdsNetId>127.0.0.1.1.1</AdsNetId>
  <AdsTimeout>2000</AdsTimeout>
  <AdsTimeSuspend>20000</AdsTimeSuspend>
  <AutoCfg>5</AutoCfg>
  <AutoCfgSymFile></AutoCfgSymFile>
  <IoMode>1</IoMode>
  <MaxGetHandle>100</MaxGetHandle>
  <ReleaseAdsVarHandles>1</ReleaseAdsVarHandles>
  <Disabled>0</Disabled>
</UaNodeManager>

Once this configuration has been activated, the TwinCAT OPC UA Server will connect to the symbol server and import its namespace. An OPC UA Client can then connect to the server and access the variables.

Symbol server interface 7:

Example: Connect to symbol server with custom ADS client

Our samples repository on GitHub includes a .NET Core project that demonstrates the different ways an ADS client can access the symbol server.