Persistent Values
Last updated:  December 20, 2001

Introduction (Capture Mode)
Often times you need to maintain the value of a variable through a power failure. There is only one mechanism to do this - with a properly configured Constant instruction. If you select the "Capture" mode, then the values in the constant table are written to the Constant instruction's variable array at program startup. After startup, anytime a value in the Constant instruction's variable array is changed, either from an HIM variable object write operation initiated by the user or another program statement changed the value, this new value is captured into the Constant instruction's table array and also written back onto flash disk. Thus these new values become the starting values written from the table to the variable the next time the program restarts after a Load.

General parameters:
Variable: persistent_values
Data type: Float
Mode: Capture

Table parameters:
Value 1: 10
Value 2: 20
Value 3: 30

When the program first starts the variable is set as follows:

persistent_values=10
persistent_values[1]=20
persistent_values[2]=30

Now, if during running the user changes the value of persistent_values[1] to 40, this value will be updated in the table of the Constant instruction and in the program icon.icn on the flash disk. The next time the program is loaded and executed, either after a power failure or after a manual load operation by the user, the variable will be initialized as follows:

persistent_values=10
persistent_values[1]=40
persistent_values[2]=30

Important note: This function only works when not in programming mode. This is because the program on flash disk may be different than the version in memory that is currently being edited. Hence the program would not know where in flash memory to do the update. So after changes are made to the program, the new program must be saved. Then the programmer must log off and log back in with any password but the programming password. This then selects an HMI run time mode. Now the capture mode will function properly

Startup Mode
A related operation can be configured by setting the Constant instruction's "Mode" to "Startup". For this case, the values in the table are written to the Constant instructions variable array as described above at startup. From then on the user or the program can change these values and the constant instruction will do nothing. Only at the next startup of the program after a load, will the values from the Constant's table be written to the variable to initialize values.