WAGO CC100 Persistent Variables Codesys 3.5 Troubles

Hi everyone,

I’ve been struggling the whole day trying to get persistent variables to work properly on a WAGO CC100 controller using CODESYS 3.5, but without success.

After rebooting or power-cycling the controller, all values of my variables marked with PERSISTENT or RETAIN are lost.

This is in my GVL variables:
VAR_GLOBAL RETAIN PERSISTENT
Power_Cmd: REAL := 100;
END_VAR

And this is in my GVL.PERSISTENT section:
{attribute ‘qualified_only’}
VAR_GLOBAL PERSISTENT RETAIN
GVL.Power_Cmd: REAL;
END_VAR

I am using this variable in my main task:
IF TO_WORD(GVL.Power_Cmd) <> GVL.SetLoggerActivePower THEN
GVL.SetLoggerActivePower := TO_WORD(GVL.Power_Cmd);
END_IF;

Those are the last changes.

Am I missing something specific for the WAGO CC100 hardware or its runtime configuration?
Is there a working method or configuration to reliably store persistent variables on this controller?

Any help, advice, or working example would be greatly appreciated. Thanks in advance!

It’s unclear what you mean by your “GVL.PERSISTENT section”. Did you add a PersisentVars object to your project, and then use the right-click menu to Add All Instance Paths? That is generally the best way to define persistent variables.

(Once created, you don’t need to reference the PersistentVars object in your POUs, just keep it updated as you add new variables. You have done it correctly with the GVL.Power_Cmd reference.)

1 Like

This was exactly what I did.
Will try again tomorrow.

Thanks!