Conversion

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

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

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.

Conversion 1:

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"

Conversion 2:

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

Conversion 3:

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

Conversion 4:

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.

Conversion 5:

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

Conversion 6:
Conversion 7:

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.

Conversion 8:

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 :

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