Modbus Communication with Wago PLC's about persistent variables

yigit
2023-07-27
2023-07-29
  • yigit - 2023-07-27

    Hello,
    I am writing the PLC program for Wago's (752-8303/8000-0002 EC) using Codesys and using Modbus communication. While writing the program, I want certain values to be stored permanently in the PLC's memory. For this purpose, I am assigning my values to the "Persistent Variables" program. I define my values to the Modbus Slave using the format "Application.PersistentVariables.". However, when I stop and restart the PLC, the persistent values inside the Modbus Slave get reset. Additionally, when I perform the "run" and "stop" operations in the Codesys simulation mode, the assigned values remain unchanged and continue from where they left off. What could be the reason for this?

     
    • rajshaswat - 2023-07-29

      you can check how to to achieve the peristant at below link
      https://youtu.be/LmuEPjcI604

       
  • snhatton - 2023-07-27

    Hi There,

    The workflow with persistent vars object is to first declare variables either in a POU or a global variable list with the option PERSIST, RETAIN, and PERSIST RETAIN. After the variables are declared, then in the persistent vars object, you would activate the "Add all instance paths" command by right-clicking in the declaration area of the persistence vars object. Alternatively, you can use the Application Composer - Persistence Manager module. Here is the help file: https://content.helpme-codesys.com/en/CODESYS%20Application%20Composer/ac_pm_overview.html. Persistence Manager is a little less performant because it works by modifying an external file. However, it also provides configuration options such as storing on change, time-based, event-based, etc. You can add variables to a persistence channel with an attribute such as:

    VAR 
        {attribute 'ac_persist':='PersistenceChannel'}
        a : REAL;
    END_VAR    
    

    In this example, the variable will be added to the 'PersistenceChannel' - channel and will update to the persistence file based on the channel's configuration. I hope this helps!

    -Shawn

     

Log in to post a comment.