Adding new instances to persistent list causes reinitialization

Adding new instances to persistent list causes reinitialization
none 0.0 0

Hello,

We are working on a project that includes several GVLs. These GVLs contain both persistent and non-persistent variable sections. For example:

GVL “HMI”:

{attribute 'qualified_only'}
VAR_GLOBAL PERSISTENT RETAIN
	xSBAutoTurnOff: BOOL := TRUE;
END_VAR
VAR_GLOBAL 
	xPBTurnOn: BOOL;
END_VAR

In the project tree, we have added the PersistentVars object, which contains all the persistent variable instances. This setup has worked reliably for years.

PersistentVars:


{attribute 'qualified_only'}
VAR_GLOBAL PERSISTENT RETAIN
    // Generated instance path of persistent variable
    HMI.xSBAutoTurnOff: BOOL := TRUE;
END_VAR

Recently, we introduced some updates to the project, adding new variables to the persistent sections of various GVLs—without modifying the existing ones. After compiling the project and executing the “Add all instances” command, all new variables are appended to the end of the PersistentVars list.

When we load the project directly from CODESYS to the PLC, the persistent variables are retained correctly. However, if we execute the “Create boot application” command while the PLC is still connected, the entire list of persistent variables is reinitialized upon reboot. The same issue occurs when updating an older project using Application.app and Application.crc.

Our question is:

Why does appending new variables to the end of the PersistentVars list cause the entire list to reset? This is a major issue for us, as maintaining compatibility with existing machines is critical.

Environment:

  • CODESYS: SP17 Patch 3

  • Weintek Package: 1.2.400

Thank you.

Hi @v.fotescu ,

Thank you for contributing to our forum.

We would first like to ask how you are loading the project. If you are loading it via USB, does this issue only occur when you first load it via USB?

The tests I conducted were performed on a test HMI running an OS firmware from 2022, which does not support loading CODESYS projects via USB. Unfortunately, I currently don’t have the possibility to test USB loading. I plan to try it during the next commissioning.

The issue occurs when loading the project either through EasyWeb or Utility Manager—both methods require the *.crc file in addition to the *.app file (apparently along with executing the “Create boot application” command in CODESYS IDE and restarting the panel).

When loading from a USB stick, does the system still require the *.crc file?

I’m trying to determine whether the issue is related to this file.

Hi @v.fotescu ,

Could you try adding a new persistent variable, then downloading the project to the HMI. The option selected should be “Login in with download” and “Update boot project” during login.
After this is successful please then create your boot application.

Please note that this was tested on Codesys 3.5.15.50.

Please let us know if this works or any other issues occur.

Thank you!