Codesys

CODESYS – Global and Persistent Variables

Pinterest LinkedIn Tumblr

In this article we are going to explain the types of Global and Persistent (retentive) variables that can be created in CODESYS.

Global variables are variables that we declare and that we can use anywhere in the program, that is, they can be used in any POU.

Persistent variables are implicitly Global variables but with the important characteristic that when power is removed from the PLC, this variable maintains its value. If, for example, we are making a totalizing counter of manufactured parts, the variable that we are increasing each time the machine makes a part must be Persistent.

Type of data

Variables in CODESYS (both Global and Permanent) can be of the following data types:

Global Variables

To create Global variables in CODESYS:

From «Application» Right click the mouse and select from the menu «Add Object» – «Global Variable List …»

A window opens where we can edit the name of the list of global variables, by default the name «GVL» appears

Now we can add the Global variables, in our case we have added a BOOL variable and another LINT variable

Variables Persistentes

Para crear variables Persistentes en CODESYS:

Desde «Application» Botón derecho del ratón y seleccionamos del menú «Add Object» – » Persistent Variables …»

A window opens where we can edit the name of the list of global variables, by default the name «PersistentVar» appears

Now we can add the Persistent variables that will maintain their value or state when power is removed from the automaton, in our case we have added a LINT variable

Add

Comments are closed.