I have a FB with PERSISTENT RETAIN variables.
I cannot seem to get the instances of this FB into the persistentVars list without C0244 warnings.
Has anyone solved this? Do you just live with the warnings?
Codesys V3.5 SP13 Patch 2 + (64-Bit)
Below is the code and a copy of the warning message
///RetentiveTimer///Ifyouwishtoretainthevalueafterareboot,
///puttheFBinstanceinaPERSISTENTVARIABLESLISTFUNCTION_BLOCKRTOVAR_INPUT
  In : BOOL;
  Reset : BOOL;
  PT : LTIME;END_VARVAR
  FirstScan: BOOL :=TRUE;
  Previous_Time: LTIME;
  Current_Time: LTIME;END_VARVARPERSISTENTRETAIN
  internalET : LTIME;END_VARVAR_OUTPUT
  Q : BOOL;
  ET : LTIME;END_VARCurrent_Time :=LTIME(); //LTIME() Produces the current system time in nsIFFirstScanTHEN//Ifthecontrollerhasbeenreset
  Previous_Time :=Current_Time;
  FirstScan :=FALSE;END_IFIFResetTHEN
  internalET :=LTIME#0NS;ELSIFInANDNOT(ET>=PT)THEN
  internalET :=internalET+Current_Time-Previous_Time;END_IFQ :=(internalET>=PT);ET :=internalET;Previous_Time :=Current_Time;
PROGRAMMainVARPERSISTENTRETAINÂ Â me:RTO;END_VAR
{attribute'qualified_only'}VAR_GLOBALPERSISTENTRETAIN    //Generatedinstancepathofpersistentvariable  Main.me.internalET:LTIME;  //Generatedinstancepathofpersistentvariable  Main.me:RTO;END_VAR
Zitat: [WARNING] Untitled2: RTO CODESYS: PLC Logic: Application: C0244: No matching instance path in VAR_PERSISTENT-list found for variable PersistentVars.__m1.internalET. Use the command "Add all instance paths" to add all instance paths to the VAR_PERSISTENT-list. (see Online help for details).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would declare persistent variable outside function block. You can declare your current variable as VAR_IN_OUT and then put your persistent variable to this input. Also I don't how VAR PERSISTENT RETAIN works. Usually I declare them as VAR RETAIN or as VAR PERSISTENT
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
MaraP hat geschrieben:
Also I don't how VAR PERSISTENT RETAIN works. Usually I declare them as VAR RETAIN or as VAR PERSISTENT
In Codesys V2.3 VAR RETAIN PERSISTENT kept the variable in more scenarios than just persistent or just retain.
In Codesys V3, VAR PERSISTENT is treated the same as VAR PERSISTENT RETAIN.
Codesys V2.3 Remanent variables:
x = value will be retained - = value gets reinitialized
+--------------------+---+----------+--------------+---------------------+|afterOnlinecommand|VAR|VARRETAIN|VARPERSISTENT|VARRETAINPERSISTENT||          |  |     |       |VARPERSISTENTRETAIN|+--------------------+---+----------+--------------+---------------------+|Reset        |-|x    |-      |x          |+--------------------+---+----------+--------------+---------------------+|Resetcold     |-|-    |-      |-          |+--------------------+---+----------+--------------+---------------------+|Resetorigin    |-|-    |-      |-          |+--------------------+---+----------+--------------+---------------------+|Download      |-|-    |x      |x          |+--------------------+---+----------+--------------+---------------------+|OnlineChange    |x|x    |x      |x          |+--------------------+---+----------+--------------+---------------------+
Codesys V3.x Remanent variables:
x = value will be retained - = value gets reinitialized
+--------------------+---+----------+--------------+---------------------+|afterOnlinecommand|VAR|VARRETAIN|VARPERSISTENT|VARRETAINPERSISTENT||          |  |     |       |VARPERSISTENTRETAIN|+--------------------+---+----------+--------------+---------------------+|Resetwarm     |-|x    |x      |x          |+--------------------+---+----------+--------------+---------------------+|Resetcold     |-|-    |x      |x          |+--------------------+---+----------+--------------+---------------------+|Resetorigin    |-|-    |-      |-          |+--------------------+---+----------+--------------+---------------------+|Download      |-|-    |x      |x          |+--------------------+---+----------+--------------+---------------------+|OnlineChange    |x|x    |x      |x          |+--------------------+---+----------+--------------+---------------------+
You will note also that V3 does not reset presistent variables on reset cold.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I have a FB with PERSISTENT RETAIN variables.
I cannot seem to get the instances of this FB into the persistentVars list without C0244 warnings.
Has anyone solved this? Do you just live with the warnings?
Codesys V3.5 SP13 Patch 2 + (64-Bit)
Below is the code and a copy of the warning message
I would declare persistent variable outside function block. You can declare your current variable as VAR_IN_OUT and then put your persistent variable to this input. Also I don't how VAR PERSISTENT RETAIN works. Usually I declare them as VAR RETAIN or as VAR PERSISTENT
In Codesys V2.3 VAR RETAIN PERSISTENT kept the variable in more scenarios than just persistent or just retain.
In Codesys V3, VAR PERSISTENT is treated the same as VAR PERSISTENT RETAIN.
Codesys V2.3 Remanent variables:
x = value will be retained - = value gets reinitialized
Codesys V3.x Remanent variables:
x = value will be retained - = value gets reinitialized
You will note also that V3 does not reset presistent variables on reset cold.