Variables

The scopes of the variables are normally limited to the organizational unit in which they are declared, e.g. local. 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.

About Retain Variables

A retain variable is a PLCClosed"Programmable Logic Controller" A Programmable Logic Controller, PLC, or Programmable Controller is a digital computer used for automation of industrial processes, such as control of machinery on factory assembly lines. Used to synchronize the flow of inputs from (physical) sensors and events with the flow of outputs to actuators and events 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. Additionally, retains are auto-saved every two seconds. This applies to both the AKD PDMM and PCMM models.
    • Variables stored in non-volatile memory that have changed will be updated every two seconds. Unchanged variables are not updated.

Such a variable is used to store application specific data, like for instance to count a cutting-edge cycle in order to stop for its blade replacement after a specific number of iterations.

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 will be logged and the data will not be stored in non-volatile memory. See NVRAM for more information.

For the KAS RuntimeClosedIn computer science, runtime (or run-time) describes the operation of a computer program, the duration of its execution, from beginning to termination (compare compile time). Within KAS, runtime also refers to the virtual machine that manage the program written in a computer language while it is running Simulator, the retained variables are saved in a file in your project repository.


  • The following actions will reset retained value(s) to their Init value(s):

    • Changing the type of a retain variable
    • Changing the length of a string retain variable
    • Changing the size of an array variable
    • Changing any element of a structure variable

Concept Link IconSee Also