Variables
The scopes of the
- This means that their names can be re-used in other parts without any conflict, eliminating another source of errors, e.g. the scratchpad.
- If the variables have global scope, they must be declared as such.
- Parameters can be assigned an initial value to have the right setting at start up and cold restart.
Retain Variables
A retain variable is a PLC variable which:
- Is non-volatile: stored in non-volatile controller memory (AKD PDMM or PCMM).
- When using KAS Simulator the retain variables are stored in a normal disk file.
- Is known by all programs (when its content is changed, the change is propagated to all equations in which this variable is used)
- Normally does not contain real-time critical data.
-
-
- Retain variables are saved when you stop the PLC.
- The next time the PLC is started the retained values are used.
- Retains are auto-saved every two seconds.
- This applies to both the AKD PDMM and PCMM models.
- Changed variables stored in non-volatile memory are updated every two seconds.
- Unchanged variables are not updated.
Such a variable is used to store application specific data.
Example: To count a cutting-edge cycle to stop for its blade replacement after a specific number of iterations.
- On an application Start, KAS initializes the retain variables with the value stored in the NVRAM.
- On an application Cold Start, KAS initializes the retain variables with their default value.
- If the declaration of the retain variables is different between the non-volatile memory and the project, the retain variables are also reset to their default value.
Two parameters are checked to identify if the declaration changed:
- The number of variables of each type
- The length of a STRING type variables
-
-
The non-volatile memory size is hardware dependent.
If the size of the retained variables is larger than the non-volatile storage space, an error is logged.
The data is not stored in non-volatile memory.
See NVRAM.
For the KAS Runtime Simulator, the retained variables are saved in a file in the project repository.
-
-
These actions reset retained values to their Initial values:
- Change the type of a retain variable.
- Change the length of a string retain variable
- Change the size of an array variable
- Change any element of a structure variable





