Declaring a new Persistent/Retain Variable in Local POU

It is also possible to declare a persistent/retain variable in a local POU and not in the global list of persistent variables.

Note

It is not recommended to declare a large number of persistent variables locally, due to the potentially effect to performance.

../_images/3bd46d4905e8fb8b0a317f3432b4b1d0

The auto-declare mechanism declares always a persistent variable locally and not in the global list. If the program will be executed, the following warning appears in the message window:

../_images/dfe51107fa4e7d1b0a317f34721f6463

The locally declared persistent variable has to be added to the global list.

Attention

For the initialization of a Retain/Persistent variable the value of the global list is used NOT the value of the local declaration.

For further information see “RetainPersistentExample.project”.

  1. Right-click in window “PersistentVars”.

  2. Select option “Add all instance paths”.

    Afterwards the persistent variables are added.

../_images/06514dd205e8f8fc0a317f3437838e2f

The application can be downloaded to the PLC

Note

It is NOT recommended to declare a new persistent variable in the application due to performance problems.

For example PM5650-2ETH:

1000 DWORD ≈ 600µs additional cycle time of task.