Notes on the documentation

This description is only intended for the use of trained specialists in control and automation engineering who are familiar with the applicable national standards.
It is essential that the following notes and explanations are followed when installing and commissioning these components.

The responsible staff must ensure that the application or use of the products described satisfy all the requirements for safety, including all the relevant laws, regulations, guidelines and standards.

Disclaimer

The documentation has been prepared with care. The products described are, however, constantly under development.
For that reason the documentation is not in every case checked for consistency with performance data, standards or other characteristics.
In the event that it contains technical or editorial errors, we retain the right to make alterations at any time and without warning.
No claims for the modification of products that have already been supplied may be made on the basis of the data, diagrams and descriptions in this documentation.

Trademarks

Beckhoff®, TwinCAT®, EtherCAT®, Safety over EtherCAT®, TwinSAFE® and XFC® are registered trademarks of and licensed by Beckhoff Automation GmbH.
Other designations used in this publication may be trademarks whose use by third parties for their own purposes could violate the rights of the owners.

Patent Pending

The TwinCAT Technology is covered, including but not limited to the following patent applications and patents:
EP0851348, US6167425 with corresponding applications or registrations in various other countries.

Copyright

© Beckhoff Automation GmbH & Co. KG, Germany.
The reproduction, distribution and utilization of this document as well as the communication of its contents to others without express authorization are prohibited.
Offenders will be held liable for the payment of damages. All rights reserved in the event of the grant of a patent, utility model or design.


OPC General

OPC Definition

OPC stands for "Openess Productivity and Collaboration" and describes an initiative for standardisation of data exchange in automation.

Beckhoff is a active member of the OPC Foundation. (More information about OPC may be obtained under www.opcfoundation.org )

OPC Interface

Formerly, applications such as operating and monitoring software were forced to use the differing access procedures of each controller manufacturer.
OPC is the specification of a universal software interface that is totally independent of the manufacturer. This opens up the possibility of gaining access in a unified manner to process data from any manufacturer.

OPC Server

An OPC server is a software component that offers a specified OPC interface to other applications.


Overview

  • OPC Specification 1.0a and 2.0
  • Free choice of TwinCAT devices (ADS devices): PLC / IO / NC / CAM / ...
  • Access via TwinCAT PLC / TwinCAT I/O or bus controller to all the fieldbusses supported by TwinCAT (Lightbus / Profibus DP / Interbus-S / CANopen / DeviceNet / ...)
  • Access to TwinCAT variables by address / by name / by generic ADS IndexGroup and IndexOffset
  • Optimal access to data from the OPC server on TwinCAT variables
  • Simulation mode (sinus, ramp, random) for variables
    (i.e. testing an OPC client/server communication without access to physical I/O)
  • Easy, one-time only configuration by XML

Features of the evaluation version

The evaluation version is a fully functional version with a 30 days time limitation. The OPC server then switches to its internal simulation mode. All the process values are then simulated, and there is no longer any access to the ADS devices.

The time limit in the evaluation version can be removed by purchasing a TwinCAT OPC software licence, and by the entry of a valid registration key.

Integration into the TwinCAT system

The OPC server creates the connection to the TwinCAT system as a gateway via ADS, and offers OPC clients the specified OPC-DA / AE interface.

System requirements

  • Microsoft Windows NT 4 / Windows 2000 / XP / CE (MIPS / ARM / X86)
  • TwinCAT v2.6 (or higher)

Please use the latest Service Packs.

What is included

The installation version includes

  • TwinCAT OPC server (DataAccess and Alarm & Events)
  • Documentation
  • OPC Test client (for local access to the OPC server)


Übersicht

TS6120 | TwinCAT OPC Server

Installation

This part of the documentation gives a step-by-step explaination of the TwinCAT OPC setup process for Windows XP based operating systems. The following topics are part of this document:

  • Downloading the setup file
  • Starting the installation

Downloading the setup file

Like many other TwinCAT Supplement products, TwinCAT OPC is available for download via the Beckhoff homepage. The download represents the most current version, which can be licensed either as a 30-Day Demo or as a full version. To download the setup file, please perform the following steps:

  • Navigate on www.beckhoff.com to "Download" TwinCAT Supplement and select "TS61020 TwinCAT OPC Server".
  • Select "Start Download", "Download as Guest".
  • (Optional) Transfer the downloaded file to the TwinCAT runtime system, where you would like to install the Supplement

Starting the installation

To install the Supplement, please perform the following steps:

  • Double-click the downloaded setup file "TcOpcSvr410.exe". Please note: Under Windows 7 32-bit/64-bit, please start the installation with "Run as Administrator" by right-clicking the setup file and selecting the corresponding option in the context menu.
  • Select an installation language
  • Click on "Next" and accept the license agreement

  • Enter your user information. All fields are mandatory. If you would like to install a 30-Day demo, please enter "DEMO" as a license key.

  • The currently available Setup installs by default all TwinCAT OPC components. This also includes the feature TwinCAT OPC XML DA, which needs the IIS Server. However, if this service is not available, the Setup generates a corresponding warning message. If you don't want to use OPC XML DA, you can safely accept this error message by clicking on "Yes". Otherwise, select "No" and install IIS before starting the Setup again.


Licensing

The following information applies to the OPC server running on a PC platform. This information is not relevant when running on a CE platform.

TwinCAT OPC can be used free of charge as an evaluation version without a registration key for 30 days. Registration is necessary for general use. A licence for use of the software is obtained with this registration.

Registration instructions

During the installation

When installing TwinCAT OPC, the registration key (e.g. K123-4567-8901) can be entered into the appropriate field in the setup program. This removes the time restrictions placed on the evaluation version.

If no key is available at the time of installation, please enter "DEMO" as the key. The time-limited (30 days) evaluation version of the TwinCAT OPC will be installed.

Subsequent registration of an evaluation version

Start the program TwinCAT OPC Configurator TcOpcCfg.exe and select tab "Registration".
Please enter a valid registration number into the appropriate field and pree "Register". The time limit is removed from the evaluation version.


OPC XML DA CE Server : Installation

TS6120 | TwinCAT OPC Server

Install TwinCAT OPC XML DA on a PC (here: Windows XP)

This chapter describes the IIS configuration required for OPC XML DA for operating system XP. (Note : For other Windows-OS the configuration can differ in details).

Requirements :

The TwinCAT OPC XML DA server has to be installed on the PC. This chapter describes how to configure the Microsoft IIS.

Step 1: Create "Virtual Directory" in IIS (Internet Information Service)

  • Open "Internet Information Services" (under "Control Panel/Administrative Tools/").
  • Right click on "Default Web Site"
  • Select "New" and "Virtual Directory..."

Everybody is welcome, so just click next.

Please enter the alias "TcOpcXmlDa" and click "Next"

With "Browse..." you have to specify the folder which contains the TwinCAT OPC Xml DA Server. By default the folder should be like "C:\TwinCAT\OPC\Server XMLDA".

Select "Next" to proceed.

Check options "Read", "Run scripts" and "Execute" and click "Next".

Select "Finish" to finish the configuration of TwinCAT OPC XML DA Server.

Step 2 : Test

The URL of the OPC-XML-DA server on the PC system can be checked locally or from a remote PC: In both cases open the Internet explorer and enter the URL of the OPC Server XML DA on PC system like :
http://<ip-adress or name of PC device>/tcopcxmlda/tcopcxmlda.dll

Sample :
http://192.16.17.5/tcopcxmlda/tcopcxmlda.dll
or
http://localhost/tcopcxmlda/tcopcxmlda.dll

The TcOpcXmlDa server will reply with a status page containing the product version :

HINT :
In case of problems (like receiving no HTML status data) please check if a proxy server is activated on your host PC.
After deactivating the proxy and reloading the URL the Opc XML DA server should reply with status info.


OPC XML DA CE Server : Installation

TS6120 | TwinCAT OPC Server

Install TwinCAT OPC-XML DA on a PC (here: Windows 7)

This chapter describes the IIS configuration required for OPC XML DA running on Windows 7. (Please note: The configuration can differ for other Windows operating systems).

Requirements :

The TwinCAT OPC XML DA server has to be installed on the PC. This chapter describes how to configure Internet Information Service 7.

Step 1: Installing IIS7

By default, IIS7 is not part of the Windows 7 installation. Therefore you need to add this functionality manually. For more information see http://technet.microsoft.com/de-de/library/cc725762%28v=ws.10%29.aspx.

Please note: When installing IIS7, the following extensions need to be activated:

  • ISAPI Extensions
  • ISAPI Filters

Step 2: Create "Virtual Directory" in IIS7 (Internet Information Service)

Usually this step will be performed automatically by the Setup.

  • Open "Internet Information Service (IIS) Manager" which can be found under "Control Panel\Administrative Tools\"
  • Right click on "Default Web Site"
  • Select "Add Virtual Directory..."

  • Please enter the alias "TcOpcXmlDa" and the physical path to your TwinCAT OPC XML DA Server installation. By default, this folder should be under C:\TwinCAT\OPC\Server4\Server XMLDA. Click on "OK".

  • Double-click the "Authentication" icon, select "Anonymous Authentication" and click on "Edit". Instead of specifying a user account, select the "Application pool identity" and click on "Ok".

  • Next, you need to set execute permissions on that virtual directory. Select the added directory and double-click on "Handler Mappings"

  • Click on "Edit Feature Permissions" and select the "Execute" permission. Click on "OK".

  • As a next step you need to create an ISAPI allowance. Please select the root node in IIS Manager (named after your computername) and then double-click "ISAPI and CGI Restrictions".
  • Click on "Add" to create a new enabled extensions. In the "ISAPI or CGI path" textbox, please specify the path to TcOpcXmlDa.dll, which normally is "C:\TwinCAT\OPC'Server4\Server XMLDA\TcOpcXmlDa.dll". Also select the checkbox "Allow extension path to execute".

  • Restart your system.

Please note: If you use Windows 7 64-bit, you need to explicitely enable 32-bit ISAPI-DLLs in IIS. In this case, please perform the following steps:

  • Open "Internet Information Service (IIS) Manager" which can be found under "Control Panel\Administrative Tools\"
  • Click on "Application Pools"
  • Select the "DefaultAppPool" and click on "Advanced Settings..." from the Actions panel
  • Set the entry "Enable 32-bit Applications" to "True", then click on "OK" to commit the changes

Step 3: Testing OPC-XML DA configuration

The URL of the OPC-XML DA Server on the PC system can be accessed locally or from a remote computer. In both cases, open the web browser (e.g. Internet explorer) and enter the URL of the OPC-XML DA Server, for example:
http://<ip-adress or name of PC device>/tcopcxmlda/tcopcxmlda.dll

Examples:

http://192.16.17.5/tcopcxmlda/tcopcxmlda.dll
http://localhost/tcopcxmlda/tcopcxmlda.dll

The OPC-XML DA Server will reply with a status page containing the product version. If you see this page, the installation and configuration of OPC-XML DA has been successful.

HINT :
In case of problems (like receiving no HTML status data) please check if your system uses a proxy server.
After deactivating the proxy and reloading the URL, the OPC-XML DA Server should reply with the status info above.


TwinCAT OPC Server CE for MP370 : Installation und Konfiguration

TS6120 | TwinCAT OPC Server

TwinCAT OPC Server : Optimisations

In case of trouble with OPC-Server performance please check following steps :

1. Minimise OPC-Namespace in TwinCAT-OPC-Server :

  • OPC-Server should provide required variables in his namespace which are requested by an opc-client.

    It makes no sense to provide 700.000 PLC variables in the OPC-namespace but the opc-client just exchange values from 10.000 variables.

    The size of OPC-namespace will cause a longer opc-server-startup-time and will cause a high memory consumption .

    Option 1 :
    Export just part of PLC variables required for OPC :

    In the TwinCAT PLC programming environment, select "Project"->"Option"->"Symbolconfiguration". Activate "Create Symbol", and use the mouse to select under "Configure Symbolfile..." the areas that you want to export (e.g. POUs and global variables).

    After compiling the PLC-project the new symbolfile "<yourProjectName>.sym" will be in the same folder as your plc-project.

    REMARK:

    • Each compiling of the PLC-project will automatically update the symbolfile.
    • The OPC-Server imports structure and array-elements out of *.SYM files.

    Option 2 :
    Mark PLC-variables in the PLC-code to be relevant for OPC
    This way is based on the TwinCAT export file *.tpy.
    Detailed info

2. OPC-Server : Running as EXE or DLL ?

  • Arguments for working with EXE :
    - One single OPC-client will access data from TwinCAT-OPC-Server
    - The OPC-Client is installed on a different PC , the network has to be crossed via DCOM.
  • Arguments for working with DLL :
    - More than one OPC-Client will communicate with the OPC-Server : Instead one single OPC-Server shares his CPU time to multiple opc-clients, the OPC-Server should work as a DLL : As a result each OPC-Client will have "his personal" instance of the OPC-Server with each opc-server having a separate ADS-communication channel into the ADS-device like the PLC.

3. OPC-Server via DCOM

  • The installation of BECKHOFF OPC-components consist of two parts : The native OPC-Server from Beckhoff and so called "OPC common components" which comes from the OPC-Foundation.

    The installation of BECKHOFF-OPC-products have been redesigned to integrate the official OPC-components and install them in the recommended way.

    Change of installation : 07/2004, new installation for TwinCAT OPC-Server V4.1.0.37


Overview

TS6120 | TwinCAT OPC Server

OPC Server as EXE / DLL (out-of-process / in-process)

The following information applies to the OPC server running on a PC platform. This information is not relevant when running on a CE platform

TwinCAT OPC V4.1 is available in the form of an "out-of-process" server (with EXE as the file extension) and as an "in-process" server (with DLL as the file extension).

ProgID
The OPC client requires the ProgID to startup communication with TwinCAT-OPC-Server.
For TwinCAT-OPC-Server V4.1 this ProgID is "BECKHOFF.TwinCATOpcServerDA".
The ProgID is identical for both types, the EXE or the DLL version.

Diagnose : Which type (EXE or DLL) is active ?

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

Select the tab "OPC Server settings". See current active type of "Server Mode" .

Activating the TwinCAT OPC server as an in-process server (DLL)

Select "Server Mode" "Inproc (DLL)" and press "Apply".

Result :
The TwinCAT OPC server now runs as a DLL in the process space of the respective OPC client. The TwinCAT OPC server is therefore not visible as an independent process in the task manager.

The main advantage of this version is seen when a number of OPC clients are working at the same time with TwinCAT OPC server. In that case, each OPC client is given its own OPC server for its "personal use". Each OPC client then has its own independently operating OPC channel to the TwinCAT devices. Most advantage will be noticed for write-requests via OPC-Server into ADS-device.

Please note: When using Windows 7 and a OPC-Client which runs as a Windows Service, you need to disable User Account Control (UAC) for the OPC-Server to run properly.

Activating the TwinCAT OPC server as an out-of-process server (EXE)

Select "Server Mode" "Out-of-Process (EXE)" and press "Apply".

Result :
The TwinCAT OPC server now operates as an EXE program, and each OPC client works with the single, shared instance of the OPC server.
In this version the TwinCAT OPC server is visible as an independent process in the task manager.

If a number of OPC clients are working at the same time with the TwinCAT OPC server, all the queries are handled by a single instance of the OPC server.
This single instance eliminates or minimize double requests of variables for one single ADS device.

DCOM:
1. We do not advise the use of DCOM connections.
2. If, however, a DCOM connection is essential, it is implemented with the type "Out-of-process" OPC server.


Auto update Cache

TS6120 | TwinCAT OPC Server

Automatic Cache Update

The following information applies to the OPC server running on a PC platform. This information is not relevant when running on a CE platform

This option causes the OPC Server to automatically update its cache after write operations.

According to OPC Specification an OPC Server shall not update its cache automatically after writing a new value. After a successful write operation the cached value remains the same and is not updated until the next scan cycle. As this behaviour causes problems in some applications the Beckhoff OPC Server provides an option to change this behaviour.

This option is turned off by default, so that the Beckhoff OPC Server operates correctly according to OPC Specification. To change the cache update behaviour start the TwinCAT OPC Configurator, Open the "OPC Server Settings" tab and check "AutoUpdateWriteCache"


Description of the TwinCAT-OPC-Server XML configuration

Schemes

Namespace

Devices

Device <see Device-Parameters>

Device <see Device-Parameters>

SimulationSignals

Simulation <see Signal-Parameters>

Simulation <see Signal-Parameters>

Simulation <see Signal-Parameters>

Simulation <see Signal-Parameters>

...

Conversions

Conversion <see Conversion-Parameters>

Conversion <see Conversion-Parameters>

Conversion <see Conversion-Parameters>

Conversion <see Conversion-Parameters>

...

Device-Parameters

Type | Req./Opt. | Description
Name | Req | Name for device like "PLC1". OPC-Client browse this name
Description | Optional |
AdsPort | Req | Number of ADS-PortID, like 801 for first PLC-runtime system
AdsNetId | Optional | specific ADS-NetId, like "174.12.15.45.1.1" Note: 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
AdsTimeSuspend | Optional | ADS suspend time in ms for this ADS device, if the ads communication fails
AutoCfg | Optional | 0 : do not include symbol-file defined under <AutoCfgSymFile> 1 : Include sym-file of TwinCAT-PLC defined under <AutoCfgSymFile> 2 : Include sym-file of TwinCAT-BCxxxx-project defined under <AutoCfgSymFile> 5 : Upload symbolic from ADS-device 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:\User1\Test\demo.tpy"

Signal-Parameters

Type | Req./Opt. | Description
SignalID | Req | unique ID-number which identifies this simulation-signal
SignalDesc | Optional
SignalType Req 0 : Read Count

1 : Write Count
2 : Random
3 : Ramp
4 : Sine
5 : Square
6 : Triangle
7 : Step
8 : Reserver
9 : Step

Read Count : incremented by one every time when the item is read

Write Count : incremented by one every time when the item is written

Random: generates random value within the Amplitude range starting with Position

Ramp, Sine, Square, Triangle, Step: (periodical signals) Their time behavior is influenced by Period and Phase parameters. Period specifies the signal frequency, while Phase moves the signal origin on the time axis

Square and Triangle signal types have one more parameter: Ratio. Ratio defines Triangle signal steepness, or Square signal H/L proportions. NumSteps parameter of the Step signal defines a number of steps signal amplitude will be divided into.
NumSteps | Optional, depends on <SignalType>
Amplitude | Optional, depends on <SignalType>
Period | Optional, depends on <SignalType>
Phase | Optional, depends on <SignalType>
Position | Optional, depends on <SignalType>
Ratio | Optional, depends on <SignalType>

Conversion-Parameters

Type | Req./Opt. | Description
ConversionID | Req | unique ID-number which identifies this conversion
ConversionDesc | Optional |
ConversionType | Req | 0 : NoConversion 1 : LinearConversion
Clamping | Optional | 0 : No clamping 1 : Clamp on EU 2 : Clamp as specified If clamping is active, the data value will be limited to its High clamp/EU value, when it exceeds the upper limit, and similarly with Low clamp parameter.
HighClamp | Optional, depends on <ConversionType>/<Clamping> | 1.0 (Default)
LowClamp | Optional, depends on <ConversionType>/<Clamping> | 0.0 (Default)
HighEU | Optional, depends on <ConversionType>/<Clamping> | engineering unit (client scale) 1.0 (Default)
LowEU | Optional, depends on <ConversionType>/<Clamping> | engineering unit (client scale) 0.0 (Default)
HighIR | Optional, depends on <ConversionType>/<Clamping> | instrument range (device scale) 10000 (Default)
LowIR | Optional, depends on <ConversionType>/<Clamping> | instrument range (device scale) 0 (Default)


Overview

An OPC server represents a standardised interface for the management of process data. The process data available in the TwinCAT system must therefore be known to the OPC server, or must be made known to it at the time of configuration.
To represent this "hierarchical process space" clearly, the "Devices" are subdivided into subsidiary items.

The OPC client can browse through this representation and use it for the server's actual configuration. The TwinCAT OPC server supports the optional browser OPC interface.

Note:
This hierarchical display is not to be confused with the configuration of the OPC server that exists at run-time. The run-time configuration of the OPC server, i.e. the creation of groups, specification of the refresh time, the insertion of tags etc. is performed dynamically by the OPC client.

General

The advantage of configuration via XML with links to the symbols of the ADS devices is that this configuration only has to be carried out once. Even if, for instance, the PLC project changes (e.g. if variables are deleted, or if new variables are defined) it is not necessary to change the configuration in the OPC server: each time the OPC service starts, the namespace of the OPC server is correctly built up.

Device Definition

A device represents a TwinCAT ADS device (e.g. a PLC run-time system) that is uniquely identified by the <AdsAmsServerNetID> and the <AdsAmsPortID>.
Further information about the concept of devices in TwinCAT can be found in the general TwinCAT ADS documentation.

Configuration of the TwinCAT OPC server

  • Receiving data from the TwinCAT PLC: Configuration by variable import from TwinCAT PLC control
  • Receiving Data from the TwinCAT I/O task: Configuration by variable upload from the TwinCAT I/O task

Configuration of the TwinCAT OPC Server CE

In general, the configuration of the TwinCAT OPC Server CE is similar to the configuration of the TwinCAT OPC Server. The most important information is given here:

  • Set the active OPC XML configuration:
    PC: The TcOpcStartup.exe tool saves the current OPC XML configuration file in the registry
    CE: By default, the file "\hard disk\TwinCAT\OPC\CurrentConfigOpc.xml" is entered in the registry as the current OPC XML configuration file
  • The OPC XML file for CE works with the same XML scheme
  • The OPC XML file must allow for the fact that paths are written using a different notation under CE:
    PC example: <AutoCfgFile>C:\Project123\Test.tpy</AutoCfgFile>
    Example CE: <AutoCfgFile>\hard disk\project\Test.tpy</AutoCfgFile>


Receiving data from the TwinCAT PLC

TS6120 | TwinCAT OPC Server

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".

NOTE:

  • The *.tpy file is automatically replaced each time the PLC project is compiled.
    In the PLC Control navigate to "Projects.. Options... TwinCAT" and select "Download symbol description". With each compile the <projectname>.typ file is now transported to target system and stored as e.g. "\TwinCAT\Boot\CurrentPLC_1.tpy" for first PLC-runtime system, or "\TwinCAT\Boot\CurrentPLC_2.tpy" for second PLC-runtime system etc.
  • Which PLC variable is available via OPC ?
    With adding simple information done by the declaration of the PLC-variable you can mark a PLC variable to be known by the OPC-Server. This helps to reduce the OPC-namespace.

    The OPC-DA Server will automatically connect to PLC runtime and provide PLC-variables which are marked for OPC-DA within the PLC-Control.

    Mark the PLC-variables with a comment to enable them beeing accessed by OPC-DA Server.

    Extra comments in PLC-IEC1131 Editor will modify the configuration of opc-server:

    Sample1:
    PLC variable "bMemAlarm"1 will not be available via OPC-DA-Server

    Sample2:
    Two instances fbTest and fbTest2 of FB_BLOCK1.
    Due to fbTest is marked with (OPC:1), all members of FB_BLOCK1 are available via OPC-DA
    Instance fbTest2 is not marked, but three member variables (ni1 / no1/ nx1) are marked to be available in all instances - the OPC-DA clent will browse only that three variables.

  • To configure a PLC variable for readonly-access, the comment needs to be set with OPC_PROP[0005], as shown above for the variable iReadOnly. Please make sure to write this property exactly as shown above!

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"

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

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.

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"

Note:

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 :

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" Note: 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 apendix.

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.

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.

NOTE:
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 restartet.


Receiving data from the TwinCAT PLC

TS6120 | TwinCAT OPC Server

Receiving Data from the TwinCAT I/O task

1st Step TwinCAT I/O task configuration

In the TwinCAT System Manager navigate through "System configuration ->Additional tasks -> Task x". Once there, activate "Create symbol entry".

.

2nd Step Import into the TwinCAT OPC server

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

In the left navigationtree please select "I/O Devices" with a right click the menu item "New".

Enter a name for that ADS device in field "Name".

The name has to be OPC conform. Special characters are not allowed.

The device-name will be part of the ItemID later.
Sample: TwinCAT-PLC was defined with a variable "Temp". Choosing the devicename as "IO1" the opc-server present the variable as "IO1.Temp".

With click on "OK" we get the new dialog for further settings of device :

Following settings have to be checked :

Type | Req./Opt. | Description
Name | Req | Name for device like "IO1". OPC-Client browse this name
Description | Optional |
AutoCfg | Optional | 5 : Upload symbolic from ADS-device
AutoCfgFile | Optional | will be ignored
AdsPort | Req | Number of ADS-PortID, like 301 for first IO task 302 for next IO task ...
AdsNetId | Optional | specific ADS-NetId, like "174.12.15.45.1.1" Note: 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 apendix.

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.

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.

NOTE:
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.


OPC Server : Configuration of conversions

TS6120 | TwinCAT OPC Server
html>

Configuration OPC conversions

The OPC server offers the feature to online convert process data.

The OPC-Server takes care of online-conversion in both communication directions : :

  • Processvalue --> Communication to OPC-Server --> convertion within OPC-Server --> Communication to OPC-Client --> OPC-Client
  • OPC-Client --> Communication to OPC-Server --> convertion within OPC-Server --> Communication to process --> Processvalue

Sample :
- KL3202 offers process value of temperatures in unit 1/10 Grad Celsius, e.g. 200.
- The opc-server is configured with a conversion "Factor 10" which is linked to this plc-variable.
- The opc-client gets the process value 20 Grad.
- If opc-client writes a new value 25 Grad celsius to OPC-server, the server will convert this to 250 and writes this value to the PLC.

Sample
The complete sample contains a PLC project and an OPC conversion definition.

NOTE:
OPC-Server presents a converted variable as Datatyp "VT_R8 / Double" to OPC-client - independend of numerical datatyp in the PLC.

1. Step: Configuration of conversion for TwinCAT OPC Server

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

Navigate to "Conversions", right click and select menue "New".

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

With "OK" you see the dialog to configure in detail your new "Conversion".

Following settings can be done :

Type | Req./Opt. | Description
Conversion ID | Required |
Type | Required |
Claming |  |
High EU | Req |
Low EU | Optional |
High IR | Optional |
Low IR | Optional |
H Clamping |  |
L Clamping |  |
Disable | Optional | Disables this conversion. OPC-Server will ignore this conversion.

Step: Check and save configuration

Save new configuration by selecting menue "File - Save As...".

After successfully creating and saving of new OPC-configurationfile the next dialog offers to activate this new configuration.

Select "OK" to activate the configuration. With next startup the OPC-Server will work with new settings.

NOTE:
In case of opc server offers old previous configuration to opc-clients but a new configuration was activated this means, that OPC-server was not restarted to load fresh configuration.

3. Step: Link of PLC-Variable with Conversion-template

With previous steps we defined a "conversion-Template" with detailed information about conversion handling.
Now we define, which PLC variable should be handled with conversion.
This link is configured in PLC-Control as and additional information for IEC1131-variable declaration.

Take care on following settings :
Add a comment behind PLC-variable declaration. This comment will be interpreted by the opc-server and links this plc-variable to a previous defined conversion-template.
The conversion-template with the unique conversion-ID was configured in step 1.

NOTE:
Today just global PLC-variables can be linked to conversion-templates. Elements of structures or arrays can not be configured as an OPC-conversion.
Future versions of OPC-Server will not have this limitation.

Sample :

  • PLC-Variable of Typ INT intMemCounterConversion is an OPC-DA variable which is converted by the opc-server as defined in conversion template 102.

Note, the syntax is important :

intMemCounterConversion : INT;    (* ~
                                    (OPC : 1 : available for
OPC-clients)
                                    (OPC_PROP[6010] : 1     :
OPC_PROP_CONV_ENABLE)
                                    (OPC_PROP[6011] : 102   :
OPC_PROP_CONV_ID)
                                  *)

Each time compiling the PLC-project the PLC-Control will create the file <PLC-projectname>.tpy. This XML based file contains information about PLC-variables and their link to the OPC-server.
The OPC server will analyze this information of the TPY file., so configure the OPC-Server to know the file <PLC-projectname>.tpy Details


Datenübernahme aus TwinCAT PLC

TS6120 | TwinCAT OPC Server
html>

Configuration OPC Simulation

The OPC-Server offers to simulate process-values. In this case no communication to the ADS-device (like PLC) is done instead simulated values are send to OPC-client.
Different simulation templates like sinus, ramp, random etc. are available to be configured with detailed behaviour (amplitude, start /stop values).

The feature "Simulation" ist available in OPC Server version V4.0.x.x.
OPC-Server version V4.1.x.x offers a multiple more performant access to TwinCAT-devices, the simulation-mode is under construction andnot supported today.

The OPC-Server offers

  • simulation of all process values
  • simulation of some specific process values

It is not possible to combine both simulated and real-process values.

Sample
The complete sample contains both, the PLC project and the definition of OPC-simulation.

1. Step: Configuration of simulation-templates for TwinCAT OPC Server

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

Navigate to "Simulations", right click and select menue "New".

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

With "OK" you get into the dialog to configure in details your new "Simulations Signal".

Following settings can be done :

Signal Type | Req./Opt. | Description
0 : ReadCount | Optional |
1 : WriteCount | Optional |
2 : Random | Optional |
3 : Ramp | Optional |
4 : Sine | Optional |
5 : Square | Optional |
6 : Triangle | Optional |
7 : Stepp | Optional |
Disable | Optional | Disables this signal. OPC-Server will ignore this signal.

2. Step: Check and save configuration

Save new configuration by selecting menue "File - Save As...".

After successfully creating and saving of new OPC-configurationfile the next dialog offers to activate this new configuration.

Select "OK" to activate the configuration. With next startup the OPC-Server will work with new settings.

NOTE:
In case of opc server offers old previous configuration to opc-clients but a new configuration was activated this means, that OPC-server was not restarted to load fresh configuration.

3. Step: Link of PLC-Variable with Alarm-Type

With previous steps we defined a "simulation-template" with detailed information about simulation behaviour.
Now we define, which PLC variable should be handled like an simluation.

This link is configured in PLC-Control as and additional information for IEC1131-variable declaration.

Take care on following settings :

Add a comment behind PLC-variable declaration. This comment will be interpreted by the opc-server and links this plc-variable to a previous defined simulation-template.
The simulation-template with the unique Simulation-ID was configured in step 1.

NOTE:
Today just global PLC-variables can be linked to Simulation-Templates. Elements of structures or arrays can not be configured as an simulated variable.
Future versions of OPC-Server will not have this limitation.

Sample :

  • PLC-Variable of Typ LREAL dblMemAlarmCounter is a OPC variable linked to simulation template 6.
    The OPC-Server will not access this PLC variable, but instead give simulated values back to OPC-client.

Note, the syntax is important :

dblMemAlarmCounter     :     LREAL;   (* ~
                                        (OPC             : 1 :
available for OPC-clients)
                                        (OPC_PROP[6006]  : 1 :
OPC_PROP_SIMU_ENABLE)
                                        (OPC_PROP[6007]  : 6 :
OPC_PROP_SIMU_ID)
                                      *)

Each time compiling the PLC-project the PLC-Control will create the file <PLC-projectname>.tpy. This XML based file contains information about PLC-variables and their link to simulation templates.
The OPC server will analyze this information of the TPY file., so configure the OPC-Server to know the file <PLC-projectname>.tpy Details


Configuration OPC Property IDs

OPC-specification allows to add additional information to single OPC-items (opc-item means : a TwinCAT variable). These optional functionality is named "OPC-Item-Properties" in the OPC-spec and allows an opc-client to browse and read these additional properties.

Sample :
As an option the PLC variable "temperature" can hold addition informaton like comment (OPC-Property-ID 101) and also UNIT (OPC-Property-ID 100) which can be offered by the opc-server.

Configuration of OPC Propery ID in the PLC

Add a comment behind PLC-variable declaration. This comment will be interpreted by the opc-server and will define OPC-Item-Properties.

NOTE:
Today just global PLC-variables can be hold item-properties. Elements of structures or arrays can not be configured.
Future versions of OPC-Server will not have this limitation.

Sample of PLC variable-declaration:
NOTE : All item-properties are optional.

lTemperatur : DWORD;
                    (* ~
                        (OPC : 1 : Make variable visible for
OPC-Server)
                        (OPC_PROP[0005] : 3                    :
OPC_PROP_RIGHTS, here Read AND Write Access)
                        (OPC_PROP[0100] : Grad F               :
OPC_PROP_UNIT)
                        (OPC_PROP[0101] : Demovariable         :
OPC_PROP_DESC)
                        (OPC_PROP[0205] : We are the champions :
OPC_PROP_SND)
                        (OPC_PROP[0206] : ..\..\info.html      :
OPC_PROP_HTML)
                        (OPC_PROP[0207] : ..\..\service.avi    :
OPC_PROP_AVI)
                    *)

Each time compiling the PLC-project the PLC-Control will create the file <PLC-projectname>.tpy. This XML based file contains information about PLC-variables and their link to the OPC-server.
The OPC server will analyze this information of the TPY file., so configure the OPC-Server to know the file <PLC-projectname>.tpy Details

List of supported OPC-item properties of OPC-Specification :

Property ID laut OPC Spec | Req./Opt. | Description
OPC_PROP[0005] | Optional | OPC_PROP_RIGHTS 1 : OPC-Server will publish this variable with access : OPC_READABLE 2 : OPC-Server will publish this variable with access : OPC_WRITEABLE 3 : OPC-Server will publish this variable with access : OPC_READABLE AND OPC_WRITEABLE Default : 3 : ReadWrite Zugriff
OPC_PROP[0100] | Optional | OPC_PROP_UNIT : Unit
OPC_PROP[0101] | Optional | OPC_PROP_DESC : Description
OPC_PROP[0102] | Optional | OPC_PROP_HIEU
OPC_PROP[0103] | Optional | OPC_PROP_LOEU
OPC_PROP[0106] | Optional | OPC_PROP_CLOSE
OPC_PROP[0107] | Optional | OPC_PROP_OPEN
OPC_PROP[0200] | Optional | OPC_PROP_DSP
OPC_PROP[0201] | Optional | OPC_PROP_FGC
OPC_PROP[0202] | Optional | OPC_PROP_BGC
OPC_PROP[0203] | Optional | OPC_PROP_BLINK
OPC_PROP[0204] | Optional | OPC_PROP_BMP
OPC_PROP[0205] | Optional | OPC_PROP_SND
OPC_PROP[0206] | Optional | OPC_PROP_HTML
OPC_PROP[0207] | Optional | OPC_PROP_AVI
OPC_PROP[6007] | Optional | BECKHOFF Defined : Simulation ID
OPC_PROP[6008] | Optional | BECKHOFF Defined : Alarm enabled
OPC_PROP[6009] | Optional | BECKHOFF Defined : Alarm ID
OPC_PROP[6010] | Optional | BECKHOFF Defined : Conversion enabled
OPC_PROP[6011] | Optional | BECKHOFF Defined : Conversion ID


Network via client protocol

Visualisation systems sometimes offer their own protocol to bridge the network. An OPC client from the visualisation system supplier is also installed on the TwinCAT controller PC for this purpose.

The data flow proceeds as follows:

Performance advantage

The primary advantage of this configuration is that considerably less loading is placed on the network, since only the process values that have altered are exchanged there: the OPC server checks the whole process cyclically, but only passes the changes in the process on to the OPC client.


Network via TwinCAT ADS

The TwinCAT OPC server performs the communication with the TwinCAT components (PLC run-time systems, bus terminal controllers etc.) via TwinCAT ADS. Since these services are also available in the network, the TwinCAT OPC server can also communicate with TwinCAT components that exist in the network.

You will find the settings needed for ADS communication over a network in the ADS Reference.

Settings in the OPC server

An ADS communication partner is always specified by two parameters: These are what is known as the "AdsAmsNetId" (e.g. 1.2.3.4.5.6) and the "PortId" (e.g. 801 for the first PLC run-time system).

If ADS is to be used to exchange data with, for example, the first PLC run-time system on another PC, then the AdsAmsNetId of the target PC, and "801" as the PortId, must be entered in the OPC server under "Device settings".

Note

If possible, the option of using the "Network via client" protocol should be selected for performance reasons.


Network via DCOM

If you wish (or need) to allow data exchange between an OPC client and the TwinCAT OPC server over a network via DCOM, this DCOM access type must be configured beforehand.

The data flow is then as follows:

The following steps describe the necessary settings for the PC on which the TwinCAT OPC server is installed.
(Use step 1 for the PC on which the OPC client is installed.)

Requirement

It is assumed that all the PCs which are to participate via DCOM in an OPC client/server connection are already set up for network operation (i.e. they have configured network cards running the TCP/IP protocol)


OPC XML DA PC Server : Configuration

TS6120 | TwinCAT OPC Server

Configuration

This chapter describes how to configure the OPC XML DA Server on BECKHOFF PC based systems.

Summary :

The OPC-XML DA server is configured with default xml-configuration file. Just activate once a checkbox in PLC-Control to download the symbol information to target device.

With TwinCAT 2.10 Build 1240 (or higher) there is no manual configuration required. Please refer to section "Zero configuration" on this page.

With previous TwinCAT versions please refer to section "Manual or specific configurations" on this page.

Zero configuration (requires TwinCAT 2.10 on host PC)

Details :

  • The OPC-XMLDA configuration file "...\wwwroot\TcOpcXmlDa\TcOpcXmlSvrCfg.xml" contains the list of ADS-devices which are available via OPC-XML-DA interface.
  • By default this list is pre-configured for one local PLC-runtime system (first PLC runtime-system on ADS-port 801)
  • By default the required symbol-information is linked to C:\TwinCAT\Boot\CurrentPlc_1.tpy
<?xml version="1.0"
encoding="utf-8" standalone="no"?>
<TcOpcXmlSvrConfiguration>
<Namespace>
    <Devices>
        <Device>
            <Name>PLC1</Name>
            <AdsNetId>0.0.0.0.0.0</AdsNetId>
            <AdsPort>801</AdsPort>
            <AdsTimeout>2000</AdsTimeout>

<AdsTimeSuspend>20000</AdsTimeSuspend>
            <AutoCfg>7</AutoCfg>
            <!-- NOTE: CurrentPlc_1.tpy will be downloaded from
PLC-Control -->

<AutoCfgSymFile>C:\TwinCAT\Boot\CurrentPlc_1.tpy</AutoCfgSymFile>

            <Disabled>0</Disabled>
        </Device>
    </Devices>
</Namespace>
</TcOpcXmlSvrConfiguration>

With TwinCAT Version 2.10 Build 1240 the PLC Control allows to download the symbol file <plc-project-name>.TYP to the target TwinCAT machine. The TPY file contains information about all available PLC-variables in the PLC-project.
OPC-XML DA CE Server requires this TPY-information.

To download the current symbol information in a TPY file navigate in the PLC-Control to "Project-->Options-->TwinCAT" and check the option "Download Symbol description"

With each download of the PLC-code now also the <project-name>.TPY file is downloaded as "C:\TwinCAT\Boot\CurrentPlc_1.tpy" containing information about symbols of first run time system.
(Second runtime system would be "C:\TwinCAT\Boot\CurrentPlc_2.tpy" etc.)

Summary:

The OPC-XML DA server is configured with default xml-configuration file. Just activate the checkbox to download the symbol information within PLC-Control environment.

NOTE:
OPC-XML DA Server checks configuraton on startup. See notes to reload configuration today (without reboot)

Optional manual or specific configurations ?

If the default configuration is not available you have to configure the opc-xml-da configuration file "...\wwwroot\TcOpcXmlDa\TcOpcXmlSvrCfg.xml" manual.

  • If required the opc-xml configuration file can be done with TwinCAT OPC COnfigurator

Sample for OPC XML DA server accessing multiple ADS devices

<?xml version="1.0"
encoding="utf-8" standalone="no"?>
<TcOpcXmlSvrConfiguration>
<Namespace>
    <Devices>
        <Device>
            <Name>PLC1</Name>
            <AdsNetId>0.0.0.0.0.0</AdsNetId>
            <AdsPort>801</AdsPort>
            <AdsTimeout>2000</AdsTimeout>

<AdsTimeSuspend>20000</AdsTimeSuspend>
            <AutoCfg>7</AutoCfg>
            <!-- NOTE: CurrentPlc_1.tpy will be downloaded from
PLC-Control -->

<AutoCfgSymFile>C:\TwinCAT\Boot\CurrentPlc_1.tpy</AutoCfgSymFile>

            <Disabled>0</Disabled>
        </Device>
        <Device>
            <Name>PLC2</Name>
            <AdsNetId>0.0.0.0.0.0</AdsNetId>
            <AdsPort>811</AdsPort>
            <AdsTimeout>2000</AdsTimeout>

<AdsTimeSuspend>20000</AdsTimeSuspend>
            <AutoCfg>7</AutoCfg>
            <!-- NOTE: CurrentPlc_2.tpy will be downloaded from
PLC-Control -->

<AutoCfgSymFile>C:\TwinCAT\Boot\CurrentPlc_2.tpy</AutoCfgSymFile>

            <Disabled>0</Disabled>
        </Device>
    </Devices>
</Namespace>
</TcOpcXmlSvrConfiguration>

NOTE:
OPC-XML DA Server checks configuraton on startup. Reconfiguration might require a new start today.


OPC XML DA Server : Nice to know

TS6120 | TwinCAT OPC Server

Nice to know

This chapter describes nice helpful hints for OPC-XMLDA server (XP and CE)

OPC specification descripes the interfaces which an OPC-XMLDA server have to (MUST) implement.

As an addOn the TwinCAT OPC-XMLDA server provides additional "nice to have" functionalities..

These additional functions are initiated via the URL of the OPC-XML-DA server.
Open the Internet explorer and enter the URL of the OPC Server XML DA on target system like :

http://<ip-adress or name of device>/TcOpcXmlDa/TcOpcXmlDa.dll<Services>

<Services> could be like this :

  • Status information
  • Log information
  • Reload configuration
  • Display configuration
  • Restart server
  • Stop server

1. Status information

<Services> = "" (nothing)

SAMPLE : http://<ip-adress or name of device>/TcOpcXmlDa/TcOpcXmlDa.dll

The TcOpcXmlDa server will reply with a status page containing the product version :

2. Log information

<Services> = ?info=log

Sample : http://<ip-adress or name of device>/TcOpcXmlDa/TcOpcXmlDa.dll?info=log

3. Reload configuration file

<Services> = ?info=reload

Sample : http://<ip-adress or name of device>/TcOpcXmlDa/TcOpcXmlDa.dll?info=reload

4. Display configuration

<Services> = ?info=config

Sample : http://<ip-adress or name of device>/TcOpcXmlDa/TcOpcXmlDa.dll?info=config

NOTE : not implemented now, under construction

1. Restart of OPC-XMLDA server

<Services> = ?action=restart

Sample : http://<ip-adress or name of device>/TcOpcXmlDa/TcOpcXmlDa.dll?action=restart

2. Stop of OPC-XMLDA server

<Services> = ?action=stop

Sample : http://<ip-adress or name of device>/TcOpcXmlDa/TcOpcXmlDa.dll?action=stop

NOTE : not implemented now, under construction


TwinCAT OPC Server CE : Optimisation

TS6120 | TwinCAT OPC Server

TwinCAT OPC Server CE : Optimization

This article describes how to minimize the OPC-namespace of TwinCAT-OPC-Server CE.

Take care to NOT load all PLC variables into OPC-Server namespace but instead load that smaller list of PLC variables which are required via OPC in the OPC-client.

Note :
CE is designed for small systems with limited resources like CPU and memory. Due to this the optimization of namespace is highly recommended for OPC-Servers running on CE.

NOTE

In general the opc-server is configured by the OPC-XML configuration file to find the detailed symbol information for each ADS device.

  • The option <AutoCfg>7</AutoCfg> is designed to import all variables defined in TPY files
    OPC DA : Limitation today : Only global variables (Strings / ints / Bools..) are imported. Today no structures are imported.
    OPC XMLDA : No limitation
  • The option <AutoCfg>8</AutoCfg> is designed to import just a subset of PLC variables marked in the PLC-code to be available for OPC..
    OPC DA : Limitation today : Only global variables (Strings / ints / Bools..) are imported. Today no structures are imported.
    OPC XML : No limitation

    In this sample the PLC variable "bMemAlarm"1 will not be available via OPC-Server.
    The variable "iReadOnly" is marked to be an OPC-variable and is available for OPC-clients. Additional the OPC-Item Property 5 (defined by OPC-Foundation) is set to "1" which means, the opc-server will handle this variable as "Read-Only" . OPC-Server will take care, that OPC-clients can not write to that PLC-variable.

    Extra comments in PLC-IEC1131 Editor will modify the configuration of opc-server:


OPC .NET client : API sample for read / write

Download complete VS2005 Solution

To read or write variables from Beckhoffs TwinCAT OPC-DA-Server via an C# application perform the following simple steps

  • Download and install the Opc.NET Api from the OPC Foundation website
  • Start VisualStudio 2005 and create a new C# console application
  • Go to the Solution Explorer, and add references to
    1. OpcNetApi.dll
    2. OpcNetApi.Com.dll
  • Use the following code to read and write variables

static void Main( string [] args)
{
 // Create a server object and connect to the TwinCATOpcServer
 Opc. URL url = new Opc. URL ( "opcda://localhost/BECKHOFF.TwinCATOpcServerDA" );
Opc.Da. Server server = null ;
OpcCom. Factory fact = new OpcCom. Factory ();
server = new Opc.Da. Server (fact, null );
server.Connect(url, new Opc. ConnectData ( new System.Net. NetworkCredential ()));

 // Create a group
 Opc.Da. Subscription group;
Opc.Da. SubscriptionState groupState = new Opc.Da. SubscriptionState ();
groupState.Name = "Group" ;
groupState.Active = false ;
group = (Opc.Da. Subscription )server.CreateSubscription(groupState);

 // add items to the group
 Opc.Da. Item [] items = new Opc.Da. Item [3];
items[0] = new Opc.Da. Item ();
items[0].ItemName = "PLC1.Value1" ;
items[1] = new Opc.Da. Item ();
items[1].ItemName = "PLC1.Value2" ;
items[2] = new Opc.Da. Item ();
items[2].ItemName = "PLC1.Value3" ;
items = group.AddItems(items);

 // write items
 Opc.Da. ItemValue [] writeValues = new Opc.Da. ItemValue [3];
writeValues[0] = new Opc.Da. ItemValue ();
writeValues[1] = new Opc.Da. ItemValue ();
writeValues[2] = new Opc.Da. ItemValue ();
writeValues[0].ServerHandle = group.Items[0].ServerHandle;
writeValues[0].Value = 0;
writeValues[1].ServerHandle = group.Items[1].ServerHandle;
writeValues[1].Value = 0;
writeValues[2].ServerHandle = group.Items[2].ServerHandle;
writeValues[2].Value = 0;
Opc. IRequest req;
group.Write(writeValues, 321, new Opc.Da. WriteCompleteEventHandler (WriteCompleteCallback), out req);

 // and now read the items again
 group.Read(group.Items, 123, new Opc.Da. ReadCompleteEventHandler (ReadCompleteCallback), out req);
 Console .ReadLine();
}

 static void WriteCompleteCallback( object clientHandle, Opc. IdentifiedResult [] results)
{
 Console .WriteLine( "Write completed" );
 foreach (Opc. IdentifiedResult writeResult in results)
{
 Console .WriteLine( "\t{0} write result: {1}" , writeResult.ItemName, writeResult.ResultID);
}
 Console .WriteLine();
}

 static void ReadCompleteCallback( object clientHandle, Opc.Da. ItemValueResult [] results)
{
 Console .WriteLine( "Read completed" );
 foreach (Opc.Da. ItemValueResult readResult in results)
{
 Console .WriteLine( "\t{0}\tval:{1}" , readResult.ItemName, readResult.Value);
}
 Console .WriteLine();
}


OPC .NET client : API sample for subscriptions

Download complete VS2005 Solution

To create a subsription from your C# applicatopn perform the following steps:

  • Downlaod the Opc .Net Api from the OPC Foundation website
  • Starte Visual Studio 2005 and create a new C# console applikation
  • Navigate to the Solution Explorer and add references to the
    1. OpcNetApi.dll
    2. OpcNetApi.Com.dll
  • Use the following code to create your subscriptions.

static void Main(string[] args)

{

// Create a server object and connect to the TwinCATOpcServer

Opc.URL url = new Opc.URL("opcda://localhost/BECKHOFF.TwinCATOpcServerDA");

Opc.Da.Server server = null;

OpcCom.Factory fact = new OpcCom.Factory();

server = new Opc.Da.Server(fact, null);

server.Connect(url, new Opc.ConnectData(new System.Net.NetworkCredential()));

// Create a group

Opc.Da.Subscription group;

Opc.Da.SubscriptionState groupState = new Opc.Da.SubscriptionState();

groupState.Name = "Group";

groupState.Active = true;

group = (Opc.Da.Subscription)server.CreateSubscription(groupState);

// add items to the group.

Opc.Da.Item[] items = new Opc.Da.Item[3];

items[0] = new Opc.Da.Item();

items[0].ItemName = "PLC1.dyn_R8[1]";

items[1] = new Opc.Da.Item();

items[1].ItemName = "PLC1.dyn_R4[1]";

items[2] = new Opc.Da.Item();

items[2].ItemName = "PLC1.dyn_I4[1]";

items = group.AddItems(items);

group.DataChanged += new Opc.Da.DataChangedEventHandler(OnTransactionCompleted);

Console.ReadLine();

}

static void OnTransactionCompleted( object group, object hReq, Opc.Da.ItemValueResult[] items)

{

Console.WriteLine("------------------->");

Console.WriteLine("DataChanged ...");

for (int i = 0; i < items.GetLength(0); i++)

{

Console.WriteLine("Item DataChange - ItemId: {0}", items[i].ItemName);

Console.WriteLine(" Value: {0,-20}", items[i].Value);

Console.WriteLine(" TimeStamp: {0:00}:{1:00}:{2:00}.{3:000}",

items[i].Timestamp.Hour,

items[i].Timestamp.Minute,

items[i].Timestamp.Second,

items[i].Timestamp.Millisecond);

}

Console.WriteLine("-------------------<");

}


OPC client : AJAX (Asynchronous Java XML)

Download complete Sample


Lizensierung

TS6120 | TwinCAT OPC Server

OPC Compliance Certification

The OPC foundation offers members of the organisation an compliance test tool. This tool tests the functionalities and interfaces of the OPC server. For OPC clients is no test tool available.

Testing a server should be done by competent personal only, besides the results could be forged.

Example:
In one test case, the OPC compliance tool writes variables in the OPC Server, reads them afterwards back and compares the values.
If these test variables would be PLC variables, which changes cyclically in the PLC, these test case would be failed.

Compliance certification

These and further current OPC certificates are listed on the web site of the OPC foundation:

http://www.opcfoundation.org


Overview

This Help File was designed to give the user of component's commmunication through DCOM (specially OPC users) an idea on possible settings in an industrial environment. This Help File just showes possible settings of DCOM security that will make the system running. If the manufacturers or vendors of OPC products provide their own manuals, this manuals should be used instead of this Help File.

Important Notes

Before changing any settings of DCOM security, a system recovery procedure should be prepared. All settings described in this documentation should be tested in a laboratory environment, before changing machines in production.
  • Save system partition including Windows Registry (Image Software)
  • Only local administrators are allowed to change DCOM settings
  • Test all settings in a laboratory environment before changing the production machine

This documentation deals with COM components that should comunicate with each other. There are tree different types of COM -Servers known, depending on their operational environment.

  • INPROG- Server
    The COM-Server runs in the memory area of the Client, the Server is a DLL and runs local on the same machine and in the same process.
  • LOCAL-Server
    The COM Server runs in it's own memory area, the Server is a EXE and runs local on the same machine, but in it's own process
  • REMOTE-Server
    The COM Server runs in it's own memory area, the Server is a EXE and runs remotely on a different machine and (of course) in it's own process as the Client

The communication between Client and Server process followes the rules of COM. Whenever the Client is located on one machine and the Server on an other, DCOM (Distributed COM) comes into place. The function calls between Client and Server process are checked for correct security by the operating system. The security settings for DCOM have NOTHING to do with sharing folders between two machines or network shares across a network. When it comes to DCOM-Security we talk about "inter process communication", in other words: the right to start or access a certain component.

To keep configuration simple it is assumed that two machines have the same operating system installed, are both in the same Workgroup and have the same user accounts (same person/PWD actually logged on). On the Server Machine an OPC Server is located and on the Client Machine an OPC Client was installed.


Operating System

Depending on the operating system of the OPC-Server and OPC-Client computer, the user accounts which are used for communication will be identified differently.

Windows 2000

This section describes the required settings for Windows 2000 operating system. On Windows 2000 SP 1, there are some known bugs related to proper callback operation. DCOM servers installed on a Win2k SP1 machine sporadically stop sending callbacks (e.g. OnDataChange) after days or weeks. The error code 0x80010108 (RPC_E_DISCONNECTED) is returned by the DCOM Server when trying to fire a callback. All other calls form the Client to the Server still work fine.

There are three ways to overcome this problem:

  • release the callback object and subscribe again (recreate the callback object)
  • install COM + Rollup Package 18.1 (Post Service Pack 2)
  • install Service Pack 3 (or higher) for Windows 2000

Windows XP

This section describes the required settings for Windows XP operating system only. The default installation for XP forces remote users to authenicate as Guest. This means that DCOM clients cannot connect to a server running on an XP machine unless the Guest account is enabled and has enough rights to launch the server. On the other hand when a DCOM server fires a callback to a remote Client installed on an XP machine, the authentification will be "changed back" to the Guest account (which is mostly disabled by default). Thus, the callback (e.g. OnDataChange) will never get though to the Client. To force an XP machine to "behave" like a Windows 2000 computer the Network Access should be changed to Classic

Open the Security Options dialog with: START >> Control Panel >> Administrative Tools >> Local Security Policy >> Local Policies >> Security Options . Find the following entry: Network access: Sharing and security model for local accounts and change this setting to: Classic - users authenicate as themselves

Please note: in a mixed configuration (e.g. Client installed on XP and Server installed on Windows 2k) the XP machine automatically "changes" to the classic Win2k bevavior when lauching and accessing the DCOM Server, but there will be no callbacks comming through.

Windows 7

This section describes the required settings for Windows 7 operating system only. The default installation for Windows 7 forces remote users to authenicate as "Guest". This means that DCOM clients cannot connect to a server running on an Windows 7 computer unless the Guest account is enabled and has enough rights to launch the server. On the other hand, when a DCOM server fires a callback to a remote Client installed on an Windows 7 machine, the authentification will be "changed back" to the Guest account (which is mostly disabled by default). Thus, the callback (e.g. OnDataChange) will never get though to the Client. To force a Windows 7 computer to "behave" like a Windows 2000 computer, the Network Access should be changed to Classic

Please perform the following steps on the Windows 7 computer:

  • Open the Security Options dialog with: START >> Control Panel >> Administrative Tools >> Local Security Policy >> Local Policies >> Security Options .

  • Find the following entry: Network access: Sharing and security model for local accounts and change this setting to: Classic - users authenicate as themselves

Please note: In a mixed configuration (e.g. a client installed on Windows 7 and the server installed on Windows 2000), the Windows 7 machine automatically "changes" to the classic Win2k bevavior when lauching and accessing the DCOM Server, but there will be no callbacks comming through.


Network Configuration

Depending on the configuration of the network different identification of Users will be performed by the operating system. Considerations regarding this issues are divided into the following topics.

  • Workgroup
  • Domain


Workgroup

For proper DCOM security settings it is essential to identify the configuration of the Client and the Server machine. If both machines are members of the same workgroup there will be no central point for user authentification. This means that every single machine must have all information on all users that should be able to remote access this node (local identification). The administrative effort will increase imensely when adding new users.

  • Workgroup
    The Client and Server Machine should be member of the same Workgroup.
  • Users Accounts
    As authentification is performed locally on every single machine, the User Accounts (Name and PWD) should be identical on the Client and the Server Machine.
  • Operation System
    The Operation System on the Client and the Server Machine should be from the same family (all NT, all 2K or all XP). When doing "mixed configuration" certain (OS specific) settings have to be taken into account.

To keep configuration simple it is assumed that two machines have the same operating system installed, are both in the same Workgroup and have the same user accounts (same person/PWD actually logged on). On the Server Machine an OPC Server is located and on the Client Machine an OPC Client was installed.


Domain

TS6120 | TwinCAT OPC Server

Domain Controller

For proper DCOM security settings it is essential to identify the configuration of the Client and the Server machine. If both machines are members of the same domain there will be one central point for user authentification. If both machines are in different domains, these domains must trust each other. The administrative effort will decreases because new users will only be added to the domain.

  • Domain
    The Client and Server Machine should be member of the same Domain. Different domains must should be trust eachother.
  • Users Accounts
    Authentification is performed on the domain machine, the User Accounts (Name and PWD) or groups are used in the DCOM settings of the Client and the Server Machine.
  • Operation System
    The Operation System on the Client and the Server Machine should be from the same family (all NT, all 2K or all XP). When doing "mixed configuration" certain (OS specific) settings have to be taken into account.

To keep configuration simple it is assumed that two machines have the same operating system installed, are both in the same Domain and have different user accounts logged on. The different users are members of one User Group. This for this User Group access is granted in the DCOM settings of the Client and the Server Machine.

Note: In a mixed configuration (e.g. Server Machine in a Domain and Client Machine in a Workgroup) the so called doubble identification should be done. This means to add User Accounts to the Workgroup Machine which are identically (Name and PWD) the same as the User Accounts on the Domain. By this function calls to the Workgroup Machine can (locally) be identified and granted without "asking" the Domain Controller.


Client Machine

This section describes the required settings on the client's side. The client is the computer on which the OPC-Client application, e.g. a visualization, is running. Usually the OPC-Server is also located on this computer. However, in some environments it may be necessary that OPC-Client and OPC-Server need to be installed on different computers. Both, the OPC-Server's and OPC-Client's DCOM settings need to be configured, so that a remote communication between client and server is possible.

Please note: The following settings have been tested on Windows 2000, Windows XP and Windows 7 computers.

Step 1: General network configuration

Depending on the client's operating system, some additional network settings need to be taken. Basically, the same settings must be performed. However, some "operating system specific" settings must be done to get the DCOM security runing.

Please refer to our Article about Operating Systems for more information.

Step 2: DCOM configuration

To configure DCOM for a remote OPC communication, please perform the following steps on the computer running the OPC-Client.

Please note: Only local administrators are allowed to open and change the DCOM security.

  • Open Start --> Run --> dcomcnfg.exe to start the DCOM configuration dialog.

  • Navigate to Console Root --> Component Services --> Computers --> My Computer
  • Select "My Computer", right click it and select Properties

  • On the "General" tab no changes have to be made. The default settings will be correct for OPC Client side security settings

  • On the "Options" tab no changes have to be made. The default settings will be correct for OPC Client side security settings.

  • On the "Default Protocols" tab the Connection-oriented TCP/IP protocol should be moved to the top position. This setting forces the use of TCP/IP for DCOM connections. All other protocols can be removed if the are not used with DCOM. The timeout will be reduced if DCOM tries to connect only on TCP/IP connections.

  • On the Default Properties Tab the Enable Distributed COM on this computer must be checked. The Authentification Level and the Impersonation Level are set to Connect and Identify by default. If the client machine runs in a Workgroup the level should be changed

    • Authentification Level = None
    • Impersonation Level = Anonymous
  • If the client machine runs in a Domain the level remains to default settings
    • Authentification Level = Connect
    • Impersonation Level = Identify
  • If the client machine runs in a mixed configuration (e.g. the Client machine in a Workgroup and the Server machine in a Domain) the level should be changed. The machine being part of the Domain must be able to identify the security context without "asking" the Domain. Therefore the machine must "know" the users (they must have a local Login).
    • Authentification Level = None
    • Impersonation Level = Anonymous

Please note: not all possible combinations of setting these two levels make sense.

Known Bugs: on Windows 2000 operating systems the Network Configuration Icon disapears when setting DCOM security levels to None and Anonymous. The network still works but the IP-Address of the NIC can not be changed anymore. Change temporarely to default settings to change IP Address or use None and Delegate.

  • On the Default COM Security Tab the Access- and Launch permission for all COM-Objects can be changed. As the OPC Client is nothing else than a COM Client, the security setings should be changed to grant access to the Client application. Specially when the OPC Server sends callbacks (e.g. OnDataChange) to the OPC Client the server's process must have access permission on the Client.
    • The Default Access Permission should be granted for
      • Administrators
      • Interactive User
      • System
      • Network
      • "OPC Server's Security Context"
    • The Default Launch Permission should not be changed on the Client machine.

  • On the MSDTC Tab no changes have to be done. The default settings will be correct for OPC Client side security settings.


Server Machine

This section describes the required settings on the server's side. The server is the computer on which the TwinCAT OPC-Server application is running. Usually the OPC-Client is also located on this computer. However, in some environments it may be necessary that OPC-Client and OPC-Server need to be installed on different computers. Both, the OPC-Server's and OPC-Client's DCOM settings need to be configured, so that a remote communication between client and server is possible.

Please note: The following settings have been tested on Windows 2000, Windows XP and Windows 7 computers.

Step 1: General network configuration

Depending on the server's operating system, some additional network settings need to be taken. Basically, the same settings must be performed. However, some "operating system specific" settings must be done to get the DCOM security runing.

Please refer to our Article about Operating Systems for more information.

Step 2: DCOM configuration

To configure DCOM for a remote OPC communication, please perform the following steps on the computer running TwinCAT OPC-Server.

Please note: Only local administrators are allowed to open and change the DCOM security.

  • Open Start --> Run --> dcomcnfg.exe to start the DCOM configuration dialog.

  • Navigate to Console Root --> Component Services --> Computers --> My Computer --> DCOM Config to display all DCOM server applications.
  • Select the TwinCAT OPC-Server (or one of its Clones), right click it and select Properties to change the DCOM security for this specific DCOM Server only.

  • On the "General" tab no changes have to be made. The default settings will be correct for OPC Server's security settings. The Authentification Level set to Default will overtake the settings from the Default Properties Tab valid for all COM Objects on this machine (Connect by default).

  • On the "Location" tab no changes have to be made. The default settings will be correct for the OPC Server's security settings.

  • On the "Security" tab the Access- and Launch permission for this specific COM-Server can be changed. As the OPC Server is nothing else than a COM Server, the security setings should be changed to grant access and lauch permission to the Server application.

  • The Server Specific Access Permission should be granted for
    • Administrators
    • Interactive User
    • System
    • Network
    • "OPC Client's Security Context"
  • The Server Specific Launch Permission should be granted for
    • Administrators
    • Interactive User
    • System
    • Network
    • "OPC Client's Security Context"
  • The Server Specific Configuration Permission should not be changed on the Server machine.

  • On the "Endpoints" tab the default settings should remain. In the Default Protocols Tab for all COM-Objects Connection-oriented TCP/IP protocol should be moved to the top position.

  • On the "Identity" tab no changes have to be made. By default, the Interactive User will be selected. This means that the server will be Lauched with the security context of the interactive user (the user that is actually logged on). As this security context changes if somebody else is logged on, in most cases a specific person should be selected i.e even if nobody is logged on to the machine (after reboot) the server can be launched having always the same security context.

    The prefered setting should be the third selection.

    • The interactive user = default
      The interactive user depends on the person that is logged on, thus it can be different each time and only exists if somebody is logged on.
    • The launching user = should NEVER be used
      The launching user will have the security context of the Client application (the OPC Client lauches/connects the OPC Server). When having different Clients in the network, several instances of the Server will be lauched having different security context each.
    • This user = Server will overtake the security context of this person
      By selecting This user it will be guaranteed that always the same person's security context is used when the server is started. On the Client side only for this person the Access Permission must be granted.


Access Permission

For granting access permission (accessing the application) to a certain user the Edit... button must be clicked opening the following dialog.

For selecting users click the Add.. button:

Selecting Users


Launch Permission

For granting launch permission (starting the application) to a certain user the Edit... button must be clicked opening the following dialog.

For selecting users click the Add.. button:

Selecting Users


Select User

A filter on object types can be set to reduce the listing of all user names. The location states the machine name where the user account is stored, this can be the local workstation or the central domain controller machine. The edit box below the names can be typed in and verified afterwards by pressing the Check Names button.

All users known by the machine selected in Location can be displayed by pressing the Advanced... button.

The list of all known users will be displayed after clicking the Find Now button.


Receiving data from the TwinCAT PLC

1st Step TwinCAT PLC

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".

NOTE:

  • The *.tpy file is automatically replaced each time the PLC project is compiled.
  • With adding simple information done by the declaration of the PLC-variable you can mark a PLC variable to be known by the OPC-Server. This helps to reduce the OPC-namespace.
  • Today the OPC server only imports global variables and does not import structures. Requiring structures and non-global variables please work on symbol-file <project name>.sym".

2nd step: Configuration of TwinCAT OPC Server

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

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

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.

After applying with "OK" you see the next dialog with settings of the new device "Plc1"

Following settings have to be checked :

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:\User1\Test\demo.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" Note: 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 apendix.

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-configuration file we get the option to activate this configuration to be the configuration for next startup of OPC-Server.

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.

NOTE:
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.


TwinCAT OPC Server CE for MP370 : Installation and configuration

TwinCAT OPC Server CE for MP370

TwinCAT OPC Server CE for MP370

This document describes the option of a data link between a Siemens ProTool / WinCC Flexible on an MP370 Panel via Ethernet with a BECKHOFF TwinCAT device.

The TwinCAT OPC Server CE (for MIPS) is installed on the Siemens MP370 Panel via the ProSave software from Siemens. ProTool / WinCC Flexible operates as an OPC client and locally communicates on the MP370 with the TwinCAT OPC Server CE. The OPC server collects the TwinCAT variables via Ethernet and the ADS protocol from Beckhoff from the TwinCAT devices.

Installation and configuration

Ensure that the MP370 and the projecting computer are properly connected with each other. For testing the network connection the program "ping.exe" can be executed via the prompt. Further information about ping.exe can be displayed via the command "ping /?". .

1. Installation of the TwinCAT OPC server for MP370 on the projecting computer with integration in the Siemens ProSave environment

A prerequisite is proper installation of Simatic ProTool 6.0 SP2 on the projecting computer.

The TwinCAT OPC server MP370 is installed in < installation directory \ MP370 (MIPS) \ TwinCAT_OPC_CE_MP370.exe >.
Follow the installation instructions for installing the TwinCAT OPC Server CE in the ProSave environment on the PC.

2. Transfer of the TwinCAT OPC server for MP370 with Siemens ProSave to the MP370 device

Start ProSave via "Start - Simatic - ProSave" and configure your connection to Simatec MP370 according to your communication criteria.
In this example communication is via a serial connection:

To transfer the TwinCAT OPC Server CE to the Siemens MP370 please select the "Options" tab in ProSave. In the available options window you will find the entry "TwinCAT OPC Server CE for MP370". To enable data transfer between the projecting computer and Siemens MP370 first start the transfer mode on the Siemens MP370 via the Transfer button in the loader.
The installation can then be started by clicking on the "»" button in ProSave. The TwinCAT OPC Server CE is then installed on the MP370 in the directory \hard disk\simatic.

If no data exchange is established check your connection to the Siemens MP370.
Further assistance can be obtained from Siemens support.

3. Configuration of the OPC server

In the previous step you successfully installed the Beckhoff OPC Server CE on the Siemens MP370. Two further steps are required. These are to be executed once:

  • For communication between the TwinCAT OPC server on the MP370 and a TwinCAT device (e.g. a CX1000) these communication partners now have to be introduced to each other.
    This is done on the MP370 via the program TwinCAT AMS Remote Manager.
  • The TwinCAT OPC Server CE must be configured to know which data (from which PLC ..) are available for OPC.

TwinCAT AMS Remote Manager

An MIPS-compatible version of the program "TcAmsRemoteMgr.exe" the Simatic MP370 can be found in the OPC installation directory "\flash\simatic". On the TwinCAT device this dialog can be found either in the TwinCAT system service or, on the CX1000, for example, an associated x86 version in the directory "\Hard disk\System" .

Figure 3

Start the TwinCAT AMS Remote Manager both on the CX1000 and on the MP370 (see Fig. 3). New remote computers can be configured on the CX1000/MP370 by clicking on the Add button. Enter the associated data in the following window:

Name
Symbolic name of the "Remote Computer". This name can be chosen freely.

AMS Net Id
AMS Net ID of the "Remote Computer". The AMS Net ID can be found under "Local Computer" in the TwinCAT Remote Manager.

Address
IP address of the "Remote Computer".

Transport
Transport layer used for carrying AMS messages. The default setting for the transport layer is TCP/IP. Further variants may be supported depending on the hardware used.

In this example the following configuration is available:

TcAMs Remote Manager on the PC/CX:

  • PC/CX with AMSNetId : 192.6.100.142.1.1
  • The MP370 device with the AMSNetId 192.168.0.163.1.1 is entered on the PC/CX under "Remote Computer"

TcAMs Remote Manager on the MP370:

  • MP370 with AMSNetId : 192.168.0.163.1.1
  • The PC/CX with the AMSNetId 192.6.100.142.1.1 is entered on the MP370 under "Remote Computer"

TwinCAT OPC server: Namespace configuration

The so-called OPC namespace now has to be configured on the TwinCAT OPC Server CE. The configuration determines which variables are accessible for the OPC server on which ADS device and are therefore available for ProTool via OPC. The TwinCAT OPC Server CE is configured via the file "CurrentConfigOPC.xml". In addition, a <PLC project name>.tpy file must be available for each ADS device (e.g. each PLC).

In this example is an export file from a TwinCAT PLC project is copied to the MP370. To this end the entry "TwinCAT OPC Configuration Update for MP370" can be found in your Simatic ProSave. To copy your configuration to the MP370 the following steps are required:

1st step

  • Create a TwinCAT PLC project with the variables you want to use in ProTool. A <project name>.tpy file is generated during compilation.
    Copy the <PLC project name>.tpy file into the directory Simatic ProTool installation path\Common\PTProSave\Addon\TcOPCSvr_Config\mips.

    WARNING:
    The ProSave project file assumes that a "Plc1.tpy" file is available. If your PLC project has a different name,
    either rename the TPY file for transport to the MP370 (from <project name.tpy> to "Plc1.tpy")
    or adapt OPCconfig.pii by changing the entry (from "Plc1.tpy" to <project name.tpy>)

2nd step

  • In same directory an XML document CurrentConfigOPC.xml can be found. Open this file with a text editor (e.g. Notepad.exe) and adjust the file according to your configuration as follows:
XML Tag | Description
<Name> | Symbolic name of the OPC connection
<AdsNetId> | AMS Net ID of the device from which the data are received (e.g. from CX1000)
<AdsPort> | ADS port of the device from which the data are received (e.g. from CX1000-PLC : 801)
<AutoCfg> | 7 : Import of all global variables from the TPY file 8 : Import of the identified variables from the TPY file. This version is highly recommended, since not all PLC variables are loaded, but only the variables required for OPC (thus saving memory)
<AutoCfgSymFile> | Path to the tpy file on the MP370 (default: OPC installation directory)

  • Save the changes in file CurrentConfigOPC.xml and copy the new configuration to the MP370 via Simatic ProSave.

Configuration example:

Configuration is complete, the TwinCAT OPC Server is configured on the MP370 and can exchange data with the configured ADS device.

4. OPC activation for ProTool

Copy the files and folders contained in directory ... \Beckhoff OPC CX1000 -- MP370\Installation Siemens\patch_regdat to the ProTool directory and start the file "_patch_ptreg_dat.bat". Confirm all four dialog boxes with OK.

Complete the file Protool.ini in the ProTool directory as follows:

[Device List ] / at the start of the file
ReInit=1

[OPC] / at the end of the file
ServerOnMP=0
DCOM/DeviceCOM=1
[Protocol Exclude List]
[Recent File List]

The [Protocol Exclude List] must be empty.
The [Recent File List] may contain entries.

Configuration is complete, the TwinCAT OPC Server is configured on the MP370 and can exchange data with the configured ADS device.

5. Updating the TwinCAT OPC Server CE for MP370

To install an update for the TwinCAT OPC Server CE for MP370 on the panel, copy the new "TcOpcSvrInprocServer.dll" file into the following folder: ...SIEMENS\Common\PTProSave\AddOn\TcOPCSrvCE\mips

Please repeat step 2 for transferring the changes to the panel.


TwinCAT OPC Server CE for MP370 : Installation und Konfiguration

TwinCAT OPC Server CE for MP370

TwinCAT OPC Server CE für MP370

This description shows the possibility of data coupling of a Siemens ProTool / WinCC-Flexibel on a MP370 Panel via Ethernet with a BECKHOFF TwinCAT device.

The TwinCAT-OPC-Server-CE (for MIPS) has to be installed on the Siemens-MP370 Panel with the aid of the Siemens-Software ProSave. ProTool / WinCC Flexibel works as OPC-Client and communicates on the MP370 local with the TwinCAT-OPC-Server-CE.
The OPC-Server collects the TwinCAT Variables via Ethernet with the Beckhoff Protocol ADS from the TwinCAT devices.

Installation and Configuration

Make sure that the MP730 is connected in a proper style with the development PC. For testing the network connection the program "ping.exe" can be executed via the prompt. Further information about ping.exe can be displayed via the command "ping /?" .

1. Installation of TwinCAT OPC Server for MP370 on the development PC with Integration in the Siemens-ProSave Environment

A prerequisite is proper installation of Simatic ProTool 6.0 SP2 on the projecting computer.

The TwinCAT OPC server MP370 is installed in < installation directory \ MP370 (MIPS) \ TwinCAT_OPC_CE_MP370.exe >.
Follow the installation instructions for installing the TwinCAT OPC Server CE in the ProSave environment on the PC.

2. Transfer of the TwinCAT OPC server for MP370 with Siemens ProSave to the MP370 device

Start ProSave via "Start - Simatic - ProSave" and configure your connection to Simatec MP370 according to your communication criteria.
In this example communication is via a serial connection:

To transfer the TwinCAT OPC Server CE to the Siemens MP370 please select the "Options" tab in ProSave. In the available options window you will find the entry "TwinCAT OPC Server CE for MP370". To enable data transfer between the projecting computer and Siemens MP370 first start the transfer mode on the Siemens MP370 via the "Transfer" button in the loader.
The installation can then be started by clicking on the "»" button in ProSave. The TwinCAT OPC Server CE is then installed on the MP370 in the directory \hard disk\simatic.

If no data exchange is established check your connection to the Siemens MP370.
Further assistance can be obtained from Siemens support.

3. Configuration of the OPC server

In the previous step you successfully installed the Beckhoff OPC Server CE on the Siemens MP370. Two further steps are required. These are to be executed once:

  • For communication between the TwinCAT OPC server on the MP370 and a TwinCAT device (e.g. a CX1000) these communication partners now have to be introduced to each other.
    This is done on the MP370 via the program TwinCAT AMS Remote Manager.
  • The TwinCAT OPC Server CE must be configured to know which data (from which PLC ..) are available for OPC.

TwinCAT AMS Remote Manager

An MIPS-compatible version of the program "TcAmsRemoteMgr.exe" the Simatic MP370 can be found in the OPC installation directory "\flash\simatic". On the TwinCAT device this dialog can be found either in the TwinCAT system service or, on the CX1000, for example, an associated x86 version in the directory "\Hard disk\System" .

Figure 3

Start the TwinCAT AMS Remote Manager both on the CX1000 and on the MP370 (see Fig. 3). New remote computers can be configured on the CX1000/MP370 by clicking on the "Add" button. Enter the associated data in the following window:

Name
Symbolic name of the "Remote Computer". This name can be chosen freely.

AMS Net Id
AMS Net ID of the "Remote Computer". The AMS Net ID can be found under "Local Computer" in the TwinCAT Remote Manager.

Address
IP address of the "Remote Computer".

Transport
Transport layer used for carrying AMS messages. The default setting for the transport layer is TCP/IP. Further variants may be supported depending on the hardware used.

In this example the following configuration is available:

TcAMs Remote Manager on the PC/CX:

  • PC/CX with AMSNetId : 192.6.100.142.1.1
  • The MP370 device with the AMSNetId 192.168.0.163.1.1 is entered on the PC/CX under "Remote Computer"

TcAMs Remote Manager on the MP370:

  • MP370 with AMSNetId : 192.168.0.163.1.1
  • The PC/CX with the AMSNetId 192.6.100.142.1.1 is entered on the MP370 under "Remote Computer"

TwinCAT OPC server: Namespace configuration

The so-called OPC namespace now has to be configured on the TwinCAT OPC Server CE. The configuration determines which variables are accessible for the OPC server on which ADS device and are therefore available for ProTool via OPC. The TwinCAT OPC Server CE is configured via the file "CurrentConfigOPC.xml". In addition, a <PLC project name>.tpy file must be available for each ADS device (e.g. each PLC).

In this example is an export file from a TwinCAT PLC project is copied to the MP370. To this end the entry "TwinCAT OPC Configuration Update for MP370" can be found in your Simatic ProSave. To copy your configuration to the MP370 the following steps are required:

1st step

  • Create a TwinCAT PLC project with the variables you want to use in ProTool. A <project name>.tpy file is generated during compilation.
    Copy the <PLC project name>.tpy file into the directory Simatic ProTool installation path\Common\PTProSave\Addon\TcOPCSvr_Config\mips.

    WARNING:
    The ProSave project file assumes that a "Plc1.tpy" file is available. If your PLC project has a different name,
    either rename the TPY file for transport to the MP370 (from <project name.tpy> to "Plc1.tpy")
    or adapt OPCconfig.pii by changing the entry (from "Plc1.tpy" to <project name.tpy>)

2nd step

  • In same directory an XML document CurrentConfigOPC.xml can be found. Open this file with a text editor (e.g. Notepad.exe) and adjust the file according to your configuration as follows:

XML Tag

Description

<Name>

Symbolic name of the OPC connection

<AdsNetId>

AMS Net ID of the device from which the data are received (e.g. from CX1000)

<AdsPort>

ADS port of the device from which the data are received (e.g. from CX1000-PLC : 801)

<AutoCfg>

7 : Import of all global variables from the TPY file
8 : Import of the identified variables from the TPY file. This version is highly recommended, since not all PLC variables are loaded, but only the variables required for OPC (thus saving memory)

<AutoCfgSymFile>

Path to the tpy file on the MP370 (default: OPC installation directory)

  • Save the changes in file CurrentConfigOPC.xml and copy the new configuration to the MP370 via Simatic ProSave.

Configuration example:

Configuration is complete, the TwinCAT OPC Server is configured on the MP370 and can exchange data with the configured ADS device.

4. OPC activation for ProTool

Copy the files and folders contained in directory ... \Beckhoff OPC CX1000 -- MP370\Installation Siemens\patch_regdat to the ProTool directory and start the file "_patch_ptreg_dat.bat". Confirm all four dialog boxes with OK.

Complete the file Protool.ini in the ProTool directory as follows:

[Device List ] / at the start of the file
ReInit=1

[OPC] / at the end of the file
ServerOnMP=0
DCOM/DeviceCOM=1
[Protocol Exclude List]
[Recent File List]

The [Protocol Exclude List] must be empty.
The [Recent File List] may contain entries.

Configuration is complete, the TwinCAT OPC Server is configured on the MP370 and can exchange data with the configured ADS device.

5. Updating the TwinCAT OPC Server CE for MP370

To install an update for the TwinCAT OPC Server CE for MP370 on the panel, copy the new "TcOpcSvrInprocServer.dll" file into the following folder: ...SIEMENS\Common\PTProSave\AddOn\TcOPCSrvCE\mips

Please repeat step 2 for transferring the changes to the panel.


OPC XML DA CE Server : Overview

TwinCAT OPC XML Server CE

Overview

Prerequisites

TwinCAT OPC-DA-CE requires a BECKHOFF CE device (like CX1000, CX1020, CX9000...) with large memory.

TwinCAT OPC DA CE does not support DCOM.


TwinCAT OPC Server CE for MP370 : Installation und Konfiguration

TwinCAT OPC XML Server CE

Installation

This document describes how to install the TwinCAT OPC XML DA Server on BECKHOFF embedded PC Controller based on CE operating system like CX1000, CX1020, CX9000 or EthernetPanels.

Prerequisites

TwinCAT OPC-XML-DA-CE requires a BECKHOFF CE device like CX1000, CX1020, etc with large memory. The Microsoft IIS (Internet Information Server) web server is required.

Step1 : Installation on PC

Install TwinCAT supplement product "TwinCATOPCServerCE.exe" on your host PC.

License : During installation a license number will be checked. Note that OPC-CE products cost royalties per CPU.

With a correct license number the product will be installed into folder C:\TwinCAT\CE\OPC

This folder will contain a number of different CE-installation files :

  • TcOpcXmlSvrCe.I586.CAB : OPC Server XML DA (XML based) for X86 based CPUs (like CX1000)
  • TcOpcSvrCe_I586.cab : OPC Server DA (COM based) for X86 based CPUs (like CX1000)
  • TcOpcSvrCe_StrongARM.cab : OPC Server DA (COM based) for ARM based CPUs with OS PocketPC (like IPAQ)
  • TcOpcSvrCe_MIPS.cab : OPC Server DA (COM based) for MIPS based CPUs (like Siemens Panels)
  • MIPS_MP370\TwinCAT_OPC_CE_MP370.exe : Seperat installation for installation on Siemens panels with ProSave

Step 2 : Deploy installation to CE device

Deploy the file TcOpcXmlSvrCe.I586.CAB onto the CF card of the Beckhoff-CE device, this can be done

  • via shared folder (Public folder)
  • via FTP
  • via ActiveSync
  • via a CF adapter

Step 3 : Installation on CE device

The installation file "TcOpcXmlSvrCe.I586.CAB" is to be executed via regular double-click on it.

NOTE:

  • As target directory, the pre-selected (default) directory "\hard disk\www\TcOpcXmlDa" has to be confirmed with "OK"!
  • After installation of the component into the correct target folder "\hard disk\www\TcOpcXmlDa" the installation file TcOpcXmlSvrCe.I586.CAB gets removed automatically.

After confirmation with "OK", the installation into the correct target folder "\hard disk\www\TcOpcXmlDa" gets executed.

  • There is no need for a restart of the CE device.

Step 4 : Test

The URL of the OPC-XML-DA server on the CE system can be checked from host PC. Open the Internet explorer and enter the URL of the OPC Server XML DA on CE system like :
http://<ip-adress or name of CE device>/tcopcxmlda/tcopcxmlda.dll

Sample :
http://cx_0027e8/tcopcxmlda/tcopcxmlda.dll

The TcOpcXmlDa server will reply with a status page containing the product version :

HINT :
In case of problems (like receiving no HTML status data) please check if a proxy server is activated on your host PC.
After deactivating the proxy and reloading the URL the Opc XML DA server should reply with status info.


OPC XML DA CE Server : Configuration

TwinCAT OPC XML DA CE server: Configuration

Configuration

This chapter describes how to configure the OPC XML DA Server on BECKHOFF CE based systems.

Summary :

The OPC-XML DA server is configured with default xml-configuration file. Just activate once a checkbox in PLC-Control to download the symbol information to target device.

TwinCAT Version :

  • With TwinCAT 2.10 Build 1240 (or higher) there is no manual configuration required, just acticate one check box.
  • With previous TwinCAT versions please refer to section "Manual or specific configurations" on this page.

Activate one check box

To download the current symbol information in a TPY file navigate in the PLC-Control to "Project-->Options-->TwinCAT" and check the option "Download Symbol description"

With each download of the PLC-code now also the <project-name>.TPY file is downloaded as "\hard disk\TwinCAT\Boot\CurrentPlc_1.tpy" containing information about symbols of first run time system.
(Second runtime system would be "\hard disk\TwinCAT\Boot\CurrentPlc_2.tpy" etc.)

Summary:

The OPC-XML DA server is configured with default xml-configuration file. Just activate the checkbox to download the symbol information within PLC-Control environment.

NOTE:
OPC-XML DA Server checks configuraton on startup. See notes to reload configuration today (without reboot)

Previous TwinCAT 2.10 Build 1240 / Manual or specific configurations ?

If the default configuration is not available you have to configure the opc-xml-da configuration file "\hard disk\www\TcOpcXmlDa\TcOpcXmlSvrCfg.xml" manual.

  • The <plc-project-name>.tpy file has to be deployed to the CE device. Deplayment can be done via Shared (public) folder / FTP server / ActiveSync connection / CF adapter
  • If required the opc-xml configuration file can be edited with help of "\hard disk\system\Notepadce.exe"

Sample for OPC XML DA CE server accessing multiple ADS devices

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<TcOpcXmlSvrConfiguration>
<Namespace>
<Devices>

<Device>
<Name>PLC1</Name>
<AdsNetId>0.0.0.0.0.0</AdsNetId>
<AdsPort>801</AdsPort>
<AdsTimeout>2000</AdsTimeout>
<AdsTimeSuspend>20000</AdsTimeSuspend>
<AutoCfg>7</AutoCfg>
<!-- NOTE: CurrentPlc_1.tpy will be downloaded from PLC-Control -->
<AutoCfgSymFile>\hard disk\TwinCAT\Boot\CurrentPlc_1.tpy</AutoCfgSymFile>
<Disabled>0</Disabled>
</Device>

<Device>
<Name>PLC2</Name>
<AdsNetId>0.0.0.0.0.0</AdsNetId>
<AdsPort>811</AdsPort>
<AdsTimeout>2000</AdsTimeout>
<AdsTimeSuspend>20000</AdsTimeSuspend>
<AutoCfg>7</AutoCfg>
<!-- NOTE: CurrentPlc_2.tpy will be downloaded from PLC-Control -->
<AutoCfgSymFile>\hard disk\TwinCAT\Boot\CurrentPlc_2.tpy</AutoCfgSymFile>
<Disabled>0</Disabled>
</Device>

</Devices>
</Namespace>
</TcOpcXmlSvrConfiguration>

NOTE:
OPC-XML DA Server checks configuraton on startup. See notes to reload configuration today (without reboot)


OPC XML DA CE Server : Installation

TwinCAT OPC XML Server CE

Installation

This document describes how to install the TwinCAT OPC XML DA Server on BECKHOFF embedded PC Controller based on CE operating system like CX1000, CX1020, CX9000 or EthernetPanels.

Prerequisites

TwinCAT OPC-XML-DA-CE requires a BECKHOFF CE device like CX1000, CX1020, etc with large memory. The Microsoft IIS (Internet Information Server) web server is required.

Step1 : Installation on host PC

Install TwinCAT supplement product "TwinCATOPCServerCE.exe" on your host PC.

License : During installation a license number will be checked. Note that OPC-CE products cost royalties per CPU.

With a correct license number the product will be installed into folder C:\TwinCAT\CE\OPC

This folder will contain a number of different CE-installation files :

  • TcOpcXmlSvrCe.I586.CAB : OPC Server XML DA (XML based) for X86 based CPUs (like CX1000)
  • TcOpcSvrCe_I586.cab : OPC Server DA (COM based) for X86 based CPUs (like CX1000)
  • TcOpcSvrCe_StrongARM.cab : OPC Server DA (COM based) for ARM based CPUs with OS PocketPC (like IPAQ)
  • TcOpcSvrCe_MIPS.cab : OPC Server DA (COM based) for MIPS based CPUs (like Siemens Panels)
  • MIPS_MP370\TwinCAT_OPC_CE_MP370.exe : Seperat installation for installation on Siemens panels with ProSave

Step 2 : Deploy installation to CE device

Deploy the file TcOpcXmlSvrCe.I586.CAB onto the CF card of the Beckhoff-CE device, this can be done

  • via shared folder (Public folder)
  • via FTP
  • via ActiveSync
  • via a CF adapter

Step 3 : Installation on CE device

The installation file "TcOpcXmlSvrCe.I586.CAB" is to be executed via regular double-click on it.

NOTE:

  • As target directory, the pre-selected (default) directory "\hard disk\www\TcOpcXmlDa" has to be confirmed with "OK"!
  • After installation of the component into the correct target folder "\hard disk\www\TcOpcXmlDa" the installation file TcOpcXmlSvrCe.I586.CAB gets removed automatically.

After confirmation with "OK", the installation into the correct target folder "\hard disk\www\TcOpcXmlDa" gets executed.

  • There is no need for a restart of the CE device.

Step 4 : Test

The URL of the OPC-XML-DA server on the CE system can be checked from host PC. Open the Internet explorer and enter the URL of the OPC Server XML DA on CE system like :
http://<ip-adress or name of CE device>/tcopcxmlda/tcopcxmlda.dll

Sample :
http://cx_0027e8/tcopcxmlda/tcopcxmlda.dll

The TcOpcXmlDa server will reply with a status page containing the product version :

HINT :
In case of problems (like receiving no HTML status data) please check if a proxy server is activated on your host PC.
After deactivating the proxy and reloading the URL the Opc XML DA server should reply with status info.


OPC XML DA CE Server : Overview

TwinCAT OPC XML Server CE

Overview

Prerequisites

TwinCAT OPC-XML-DA-CE requires a BECKHOFF CE device (like CX1000, CX1020, CX9000, ...) with large memory.
The Microsoft IIS (Internet Information Server) web server is required on that CE devices.


OPC XML DA PC Server : Overview

TwinCAT OPC XML Server PC

Overview

Prerequisites

TwinCAT OPC-XML-DA requires a PC operating system (Windows 2000 / XP / XPE)
The Microsoft IIS (Internet Information Server) web server is required on that PC.