C0244: warning when using persistent variables in FB

i-campbell
2019-04-25
2019-04-26
  • i-campbell

    i-campbell - 2019-04-25

    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

    ///Retentive Timer
    ///If you wish to retain the value after a reboot, 
    ///put the FB instance in a PERSISTENT VARIABLES LIST
    FUNCTION_BLOCK RTO
    VAR_INPUT
       In : BOOL;
       Reset : BOOL;
       PT : LTIME;
    END_VAR
    VAR
        FirstScan: BOOL := TRUE;
        Previous_Time: LTIME;
        Current_Time: LTIME;
    END_VAR
    VAR PERSISTENT RETAIN
       internalET : LTIME;
    END_VAR
    VAR_OUTPUT
       Q : BOOL;
       ET : LTIME;
    END_VAR
    Current_Time := LTIME();  //LTIME() Produces the current system time in ns
    IF FirstScan THEN //If the controller has been reset
       Previous_Time := Current_Time;
       FirstScan := FALSE;
    END_IF
    IF Reset THEN
       internalET := LTIME#0NS;
    ELSIF In AND NOT (ET >= PT) THEN
       internalET := internalET + Current_Time - Previous_Time;
    END_IF
    Q := (internalET >= PT);
    ET := internalET;
    Previous_Time := Current_Time;
    
    PROGRAM Main
    VAR PERSISTENT RETAIN
       me : RTO;
    END_VAR
    
    {attribute 'qualified_only'}
    VAR_GLOBAL PERSISTENT RETAIN
       
       // Generated instance path of persistent variable
       Main.me.internalET: LTIME;
       // Generated instance path of persistent variable
       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).

     
  • MaraP - 2019-04-26

    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

     
  • i-campbell

    i-campbell - 2019-04-26

    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

    +--------------------+---+----------+--------------+---------------------+
    |after Online command|VAR|VAR RETAIN|VAR PERSISTENT|VAR RETAIN PERSISTENT|
    |                    |   |          |              |VAR PERSISTENT RETAIN|
    +--------------------+---+----------+--------------+---------------------+
    |Reset               | - | x        | -            | x                   |
    +--------------------+---+----------+--------------+---------------------+
    |Reset cold          | - | -        | -            | -                   |
    +--------------------+---+----------+--------------+---------------------+
    |Reset origin        | - | -        | -            | -                   |
    +--------------------+---+----------+--------------+---------------------+
    |Download            | - | -        | x            | x                   |
    +--------------------+---+----------+--------------+---------------------+
    |Online Change       | x | x        | x            | x                   |
    +--------------------+---+----------+--------------+---------------------+
    

    Codesys V3.x Remanent variables:
    x = value will be retained - = value gets reinitialized

    +--------------------+---+----------+--------------+---------------------+
    |after Online command|VAR|VAR RETAIN|VAR PERSISTENT|VAR RETAIN PERSISTENT|
    |                    |   |          |              |VAR PERSISTENT RETAIN|
    +--------------------+---+----------+--------------+---------------------+
    |Reset warm          | - | x        | x            | x                   |
    +--------------------+---+----------+--------------+---------------------+
    |Reset cold          | - | -        | x            | x                   |
    +--------------------+---+----------+--------------+---------------------+
    |Reset origin        | - | -        | -            | -                   |
    +--------------------+---+----------+--------------+---------------------+
    |Download            | - | -        | x            | x                   |
    +--------------------+---+----------+--------------+---------------------+
    |Online Change       | x | x        | x            | x                   |
    +--------------------+---+----------+--------------+---------------------+
    

    You will note also that V3 does not reset presistent variables on reset cold.

     

Log in to post a comment.