Parameter Aliasing

Navigation:  Device Features >

Parameter Aliasing

Previous pageReturn to chapter overviewNext page

Device parameters can be aliased so referring to them in code is more meaningful and helps developer create easy to debug applications. Below is a step by step tutorial on how to create parameter aliases and applies to both an Onboard application and an MCi2xx application:

 

Step 1 - Create a GVL
Step 2 - Add variables
Step 3 - Map the variables to drive / module parameters
Step 4 - Using the aliases in a POU

 

Step 1 - Create a GVL

 

Add a GVL with a name appropriate to the application being created, for this tutorial Line1 is going to be used:

 

ParamAlias_CreateGVL

 Adding a GVL object to the tree.

 

 ParamAlias_NameGVL

 Naming the GVL.

 

 

Step 2 - Add variables

As with a Structured Text POU declare any variables required of the correct data type between the VAR_GLOBAL tags. The correct syntax is "Name : <DatatType>".

 

ParamAlias_AddVar

 Adding variables.

 

Note: The data type of the variable must match that of the parameter being mapped - using different data types may result in values being read / written incorrectly. To easily check the require data type look in the library manager.

 

Step 3 - Map the variables to drive / module parameters

The next step is to map the created variables to a parameter on the device, this is achieved by using attributes in the GLV that call an underlying function when the variable is used in an IEC task.

 

 

Available Attributes

 

Attribute Name

Description

 

get_access

Function to call when a read of the variable is performed in a task.

 

e.g.

{attribute 'get_access' := 'ReadUserParameterDINT(00,18,001)'}

 

set_access

Function called when a write to the variable is performed in a task.

 

e.g.

{attribute 'set_access' := 'WriteUserParameterDINT(00,18,001,ControlWord)'}

 

get_bitaccess

This attribute allows individual bits of the variable to be accessed.

 

e.g

{attribute 'get_bitaccess' := 'ReadUserParameterBit(00,18,001,BITNR)'}

 

IF Line1.ControlWord.1 = True THEN

    // Do something

END_IF

 

set_bitaccess

This attribute allows individual bits of the variable to be set.

 

e.g

{attribute 'set_bitaccess' := 'WriteUserParameterBit(00,18,001,BITNR,ControlWord)'}

 

Line1.ControlWord.1 := True;

 

 

monitoring_instead

The function supplied in this attribute is called when an application is online in Machine Control Studio and being monitored in a POU editor.

 

e.g

{attribute 'monitoring_instead' := 'ReadUserParameterDINT(00,18,001)'}

 

 

Available Functions

 

The functions available to perform the read \ write features are available in the library CT User Programming Runtime.

 

Example

 

    // Value used internally to control the state machine in the application.

    {attribute 'get_bitaccess' := 'ReadUserParameterBit(00,18,001,BITNR)'}

    {attribute 'get_access' := 'ReadUserParameterDINT(00,18,001)'}

    {attribute 'set_bitaccess' := 'WriteUserParameterBit(00,18,001,BITNR,ControlWord)'}

    {attribute 'set_access' := 'WriteUserParameterDINT(00,18,001,ControlWord)'}

    {attribute 'monitoring_instead' := 'ReadUserParameterDINT(00,18,001)'}

    ControlWord : DINT;

 

ParamAlias_Example

Configured alias GVL

 

Using the ControlWord variable in a POU would perform a read \ write to drive menu 18 parameter 001.

 

Note: An Onboard application can not access parameters in an option module other than those in M15, 16 and 17.

 

Step 4 - Using the aliases in a POU

Once created the GVL can be referenced from all code editors and watch windows as a standard IEC 61131 variable.

 

Example

The code below will read the bool state of parameter 18.031.

 

IF Line1.Running THEN

 // Do something

END_IF

 

Input Assistant

In addition the variables will be visible from the input assistant:

 

ParamAlias_InputAss

 

See Also

 

Custom Menu
Cyclic Link Editor
Fast Access Parameters
Supported Data Types