How to Safely Preserve Parameter Data in Codesys: Upload and Save Techniques

Question:

Transitioning from Rockwell to Codesys, I am accustomed to saving and uploading current parameter data in one step, ensuring that the logic is downloaded as well during the process. In my quest to grasp the system in Codesys, I have noted the importance of maintaining values, especially during power loss scenarios such as analog scaling parameters. Furthermore, I am keen on commissioning a system and preserving both the program and parameters for potential download into a similar system or a replacement controller. It appears that utilizing VAR RETAIN and PERSISTENT is necessary for data retention, but it appears to only be applicable at the controller level. I am curious if the actual data will be saved with the project file, or if additional logic is required to initialize hard-coded values for critical parameters within the system.

Top Replies

To preserve data outside the PLC, you must create a file in external memory storage. While some PLC types allow for the use of internal memory, it is crucial to store the file separate from the compiled program.

If these values are indeed constants, it may be best to hard code them. However, if they are subject to change through another method such as an HMI (Human-Machine Interface), an alternative approach will be needed. Which controller are you utilizing? You may need to allocate a specific section of memory to ensure the variables are reliably retained.

Depending on the type of hardware you have, you may have the capability to save data to a FTP location or a memory card. By creating a script, you can easily transfer all the necessary information to the card. Conversely, another script can be utilized to load the saved data back into the system.

Having grown up in the Rockwell world, I am familiar with the importance of saving data. In CoDeSys, I manage this by saving set-points and other data to a file stored in the PLC flash memory. This allows me to access the information automatically upon power up or manually when needed. The key commands for this process are sysfilewrite and sysfileread. Best of luck to you in your data saving endeavors. -Yosi

It is important to note that continuously writing to a flash card can cause it to break over time. Consumer grade devices typically have a limited number of erase/write cycles per block, ranging from 500 to 3,000, while industrial grade devices offer higher durability, with potentially 10 to 50 times more cycles. To prolong the lifespan of your flash card, consider only writing data when power is diminishing (a feature found in Beckhoff systems) or when the data actually changes. Additionally, wear-leveling technology can help by distributing data across different blocks to reduce wear and tear on specific areas of the card.

Your observations are definitely on point. It's important to understand that the retained and persistent variables in Codesys are not saved within the project file itself. Instead, they are stored within the controller memory - hence they can withstand a power loss. So if you're aiming to duplicate or transfer the system, you'll need to initialize your critical parameters using separate logic or manually document and input them into the new system. Some engineers use CSV or XML files to back up these parameters; this gives an ability to restore the system quickly. So yes, additional steps are needed but it adds a layer of flexibility in how you manage your system data. Hope this helps!

From my understanding and experience with Codesys, it's quite different from Rockwell since it doesn't save changes directly to the PLC. By using VAR RETAIN or PERSISTENT, data values do generally persist after a power outage, but these variables don't get saved to the project file. Instead, they only reside in the controller memory, which why they seem to only be applicable at the controller level. As for critical parameters or hard-coded values, you'd need to manually initialize them in your program logic. That makes them reusable for other controllers or projects without the need to write them again. The process is a bit intricate, but once you are accustomed to it, it will become second nature.

Yes, you are correct about using VAR RETAIN and PERSISTENT in Codesys for data retention at the controller level. However, it won't save this data along with your project file. If your goal is to safeguard specific parameters along with your program, creating a separate configuration file might be the way to go. That file could store your critical parameter values in a readable and easily manageable format. Then, you could write a startup script that reads this config file and sets appropriate values during initialization. It adds an additional step to your deployment process but ensures that your critical parameters are always configured correctly.

More Replies →

Streamline Your Asset Management
See How Oxmaint Works!!

✅   Work Order Management

✅   Asset Tracking

✅   Preventive Maintenance

✅   Inspection Report

We have received your information. We will share Schedule Demo details on your Mail Id.

To add a comment, please sign in or register if you haven't already..   

Frequently Asked Questions (FAQ)

FAQ: 1. How can I safely preserve parameter data in Codesys to ensure it is retained during power loss scenarios?

Answer: Answer: To preserve parameter data in Codesys, you can utilize VAR RETAIN and PERSISTENT to ensure data retention at the controller level. This helps maintain values such as analog scaling parameters even during power loss situations.

FAQ: 2. Can I save both the program and parameters in Codesys for potential downloading into a similar system or replacement controller?

Answer: Answer: While Codesys allows for saving and uploading parameter data, it is primarily focused on the logic itself. To ensure parameters are saved along with the program, additional steps may be required such as initializing hard-coded values for critical parameters within the system.

FAQ: 3. Is the actual parameter data saved with the project file in Codesys?

Answer: Answer: In Codesys, the actual parameter data may not be saved directly with the project file. It is essential to use mechanisms like VAR RETAIN and PERSISTENT to store critical parameter values at the controller level for data retention and system integrity.

Ready to Simplify Maintenance?

Join hundreds of satisfied customers who have transformed their maintenance processes.
Sign up today and start optimizing your workflow.

Request Demo  â†’