-

Variables

According to the IEC 61131-3 standard, the application program logic in PLCnext Engineer is developed using variables instead of directly addressing inputs/outputs or using flags. Each variable and each function block instance that is used in the project must be declared.

Variables are declared in the:

Variables can be declared either while inserting them into the code (via the context menu of the undeclared variable) or before using them in the code by manually entering the declaration into the table.

This topic contains the following sections:

Scope of variables

The scope of a variable determines in which POU(s) it is valid, i.e., where it can be used. Possible scopes are local and global. The scope of each variable is defined by the location where it is declared (local variables table or Data List of the 'IEC 61131-3' node) and by the variable keyword used in the declaration.

Standard and safety-related variables

Safety-related and standard (non-safety-related) code is strictly distinguished in PLCnext Engineer. Therefore, also safety-related and standard variables, or more precise, data types, are distinguished.

For easier distinction of standard and safety-related variables, all safety-related variables are displayed with a yellow color marking in safety-related SNOLD code worksheets and variables grids. Variables of standard data types are shown without color marking. While programming safety-related FBD/LD code in SNOLD worksheets, the continuous data flow analysis in the SNOLD code highlights the leading safety-related signal paths of a network by displaying them as thick yellow lines. Refer to the topic "Mixing Safety-related and Standard Variables in the Code" for details.

Further Info
Refer to the topic "Data Types" for further information on the properties of safety-related and standard data types.

Exchange variables and reading safety signals in the standard controller

Exchange variables enable the communication between the standard controller and the Safety PLC. An exchange variable is created by assigning a global controller variable to a standard variable of the Safety PLC. This way, both controllers can exchange information.

Furthermore, the standard controller can read the status of signals in the safety application. However, such a threefold mapping of a Safety PLC variable, a controller variable and a process datum is not referred to as exchange variable.

The creation of exchange variables as well as the assignment of process data items have to be done in the Data List of the standard controller or the Safety PLC (role mapping).

For details refer to the topics "Exchanging Data between Controller and Safety PLC" and "Role Mapping in Data Lists: I/O Variables and Exchange Variables".

Feedback variables

In FBD/LD function block and program POUs, implicit feedbacks can be programmed by connecting an output back to an input. A variable which is inserted into a feedback connection line is considered as feedback variable. It provides two connection points (in/out). The menu item 'Toggle Feedback Variable' in the context menu of such a variable is marked as selected. Feedback variables must be connected on both sides.

Further Info
Refer to the topic "Feedback variables in FBD/LD" for details.

System variables for diagnostic/monitoring purposes

System variables are provided by the runtime. They allow access to, for example, the system state, CPU performance etc. System variables have fixed memory addresses and can be used by the controller program to get this information.

System variables are automatically declared as global variables in the Data List of the controller. The name and properties of a system variable are predefined by default and cannot be modified.

As each system variable is a global variable, an 'External' declaration must be inserted in the local variables table of the POU where it is used.

Note
If a Safety PLC is included in your project, specific safety-related (Profisafe) system variables may be provided in the Data List of the 'Safety PLC' PLANT node. The creation of these Profisafe system variables can be enabled/disabled in PLCnext Engineer. They can be used for communication/F-Device state diagnostics in the Profisafe system.

Further Info
For a description of the available system variables, refer to the PLCnext Info Center and the user manual of the controller involved.

Ports for PLCnext Technology controllers

For controllers of the PLCnext Technology generation, input and output ports can be used in addition to or instead of resource-global variables. Programs communicate using ports, i.e., data can be read from and written to programs via ports.

Via ports, communication is even possible between IEC 61131-3-compliant programs and programs developed with a non-IEC 61131-3 programming language such as C++.

For that purpose, input and output ports can be assigned to each other using the role mapping function in the GDS Port List. Port Lists are available on the 'PLCnext' PLANT node and on program instance nodes. A Port List contains the ports which are relevant for the respective PLANT node. All port connections are stored in the Global Data Space of the PLCnext Technology controller.

Further Info
Further information can be found in the topic "PLCnext Technology controller generation".