This is short note for new users to CODESYS on how to use local, retain, and persistent retain variables.
Local or Global Vars - Values that will be re-initialized when the PLC is rebooted or turned on and off. An example could be speed feedback from a VFD, or variable for the current temperature.
Retain Vars - Used for variables where only a cold reset will re-initialize these values. This might be a user configured setpoint where a maintenance tech could perform a cold reset to return a value to a factory state.
Persistent Retain Vars - Used for variables like system configuration, that should not re-initialize. The user could use a persistent variable for the number of run hours since the machine was last serviced.