Understanding System Variables

Introduction

This section describes how system variables are implemented. System variables:

oallow you to access general system information, perform system diagnostics, and command simple actions.

oare structured variables conforming to IEC 61131-3 definitions and naming conventions. You can access the system variables using the IEC symbolic name PLC_GVL. Some of the PLC_GVL variables are read-only (for example, PLC_R) and some are read/write (for example, PLC_W).

oare automatically declared as global variables. They have system-wide scope and can be accessed by any Program Organization Unit (POU) in any task.

Naming Convention

The system variables are identified by:

oa structure name that represents the category of system variable. For example, PLC_R represents a structure name of read-only variables used for the controller diagnostic.

oa set of component names that identifies the purpose of the variable. For example, i_wVendorID represents the controller vendor ID.

You can access the system variables by typing the structure name of the variables followed by the name of the component.

Here is an example of system variable implementation:

VAR
   myCtr_Serial : DWORD;
   myCtr_ID : DWORD;
   myCtr_FramesRx : UDINT;
END_VAR

myCtr_Serial := PLC_GVL.PLC_R.i_dwSerialNumber;
myCtr_ID := PLC_GVL.PLC.R.i_wVendorID;
myCtr_FramesRx := SERIAL_R[0].i_udiFramesReceivedOK

NOTE: The fully-qualified name of the system variable in the example above is PLC_GVL.PLC.R. The PLC_GVL is implicit when declaring a variable using the Input Assistant, but it may also be entered in full. Good programming practice often dictates the use of the fully-qualified variable name in declarations.

System Variables Location

2 kinds of system variables are defined for use when programming the controller:

olocated variables

ounlocated variables

The located variables:

ohave a fixed location in a static %MW area: %MW60000 to %MW60199 for read-only system variables.

oare accessible through Modbus TCP, Modbus serial, and EtherNet/IP requests both in RUNNING and STOPPED states.

oare used in EcoStruxure Machine Expert programs according to the structure_name.component_name convention explained previously. %MW addresses from 0 to 59999 can be accessed directly. Addresses greater than this are considered out of range by EcoStruxure Machine Expert and can only be accessed through the structure_name.component_name convention.

The unlocated variables:

oare not physically located in the %MW area.

oare not accessible through any fieldbus or network requests unless you locate them in the relocation table, and only then these variables can be accessed in RUNNING and STOPPED states. The relocation table uses the following dynamic %MW areas:

o%MW60200 to %MW61999 for read-only variables

o%MW62200 to %MW63999 for read/write variables

oare used in EcoStruxure Machine Expert programs according to the structure_name.component_name convention explained previously. %MW addresses from 0 to 59999 can be accessed directly. Addresses greater than this are considered out of range by EcoStruxure Machine Expert and can only be accessed through the structure_name.component_name convention.