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.
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:
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”.
Right-click in window “PersistentVars”.
Select option “Add all instance paths”.
- ⇒
Afterwards the persistent variables are added.
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.