Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Communication Drivers

Global and local variables

  • Last UpdatedSep 16, 2024
  • 2 minute read

You can also access Global and Local Variables, but only on Windows-based runtimes (e.g., CX1000, CX1020, WinCE, WinXP, WinXPe).

For Global Variables on TwinCAT 2.x only, type a period and then the variable name (e.g., .engine, .speed, .counter): .<variable name>

For Global Variables on TwinCAT 3.x only, as well as for Local Variables on both TwinCAT 2.x and TwinCAT 3.x, type the POU name followed by the period and then the variable name:

<POU name>

.<variable name>

The following syntax diagram shows all of the possible options:

{ | POU name }.variable name{ | [index] }{ | :length }

where,

POU name: The name of the program organization unit (POU) that contains the variable.

index: Both Global and Local Variables support an optional array index, which is used to access arrays and structures. If you declare arrays in your TwinCAT PLC program as…

MyRealArray:ARRAY[0..10]OF REAL;

MyDINT:ARRAY[0..10]OF DINT;

the corresponding addresses (assuming the first position of each array) should be:

.MyRealArray[0]

.MyDINT[0]

variable name: The name of the Global or Local Variable.

length: Both Global and Local Variables also support an optional string length, which is used to predict the block size that will be necessary to create virtual groups that will not be bigger than allowed. If not set, no assumption about the length is made, and the Max Block Size setting in the communication settings will determine the number of tags on each block. The length is especially useful when reading several string variables that may or may not have its size determined on the TwinCAT program, and not setting its length on the address may lead to errors of Invalid Block Size. Also, if using the length, you must type the same length as used on the TwinCAT program.

If you declare string variables in your TwinCAT PLC program as…

string1:STRING; string2:STRING(150);

then the corresponding addresses should be:

.string1:80

.string2:150

In the first case the string length is taken as 80, which is the default value to ensure correct separation of virtual groups.

The length field syntax is also valid for members of arrays and structures.

Note: Length suffix for string is not supported on TwinCAT version 3.x.

TitleResults for “How to create a CRG?”Also Available in