Retain Variables

yue-qi-qi
2015-06-09
2015-06-20
  • yue-qi-qi - 2015-06-09

    We can define retain variables in global variable list.
    Is there a way or a function to explicitly save retain variables to EEPROM or Flash memory that the CoDeSys application can call so that the program can save retain variables anytime when needed?

     
  • yue-qi-qi - 2015-06-09

    By the way, in CoDeSys v2.3, there is SysRestoreRetains() and SysSaveRetains() functions to call.

     
  • TimvH

    TimvH - 2015-06-09

    "CmpApp.library":
    AppStoreRetainsInFile() and
    AppRestoreRetainsFromFile()

    Save should always be done after change of a retain value, restore after boot up.


    Another option is to use the Application Composer for this.
    It takes some time to configure, but when this is done, you have a very flexible solution to store and restore variables to/from various files.

     
  • yue-qi-qi - 2015-06-18

    TimvH hat geschrieben:
    "CmpApp.library":
    AppStoreRetainsInFile() and
    AppRestoreRetainsFromFile()
    Save should always be done after change of a retain value, restore after boot up.


    Another option is to use the Application Composer for this.
    It takes some time to configure, but when this is done, you have a very flexible solution to store and restore variables to/from various files.

    ==========================================
    Yes, it works! Thank!

     
  • yue-qi-qi - 2015-06-18

    TimvH hat geschrieben:
    "CmpApp.library":
    AppStoreRetainsInFile() and
    AppRestoreRetainsFromFile()
    Save should always be done after change of a retain value, restore after boot up.


    Another option is to use the Application Composer for this.
    It takes some time to configure, but when this is done, you have a very flexible solution to store and restore variables to/from various files.

    ============================================
    I wander whether it works in a PLC in which there is no OS system such as WinCE or linux,that is no file system.

     
  • yue-qi-qi - 2015-06-19

    How to store or restore retain variables in a PLC target where there is no such Os system as WinCE or linux,that is there is no file system?

     
  • TimvH

    TimvH - 2015-06-20

    Just use the Persistent variable list (add it to your application). This will write it to the battery backup memory.
    The vendor of the PLC can tell you the details about the size and whether this is supported.

     

Log in to post a comment.