I am looking for support for my Codesys application. I am using persistent variables however I am no longer able to add more due to an error when trying to upload changes. The error is below
[ERROR]Default:PersistentVars[PCT_Assem_Mach: PLC Logic: Application](Line229):C0415:Outofpersistentmemory:Variable'R314TPEdges1',1208bytes(Largestcontiguousmemorygap488).Editingpersistantvariablelistsmayproducefragmentedmemory.Perform"Declarations, Reorder list and clear gaps"tocompactpersistentvariablelists.Buildcomplete-- 1 errors, 103 warnings : no download possible!
I have done as per the error recommendations. This did help initially however now I am out of space even with the 'gaps cleared'.
How do I go about increasing the memory capacity for the persistent variables?
Thanks in advance
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm not sure how to increase the persistent memory, but a few tips to make maximum use of the memory you have:
Use the attribute pragma {attribute 'pack_mode' := '0'} . This ensures that each byte in the memory is used without skipping or re-aligning to even numbered bytes with data larger than 1 byte.
Boolean values use a full byte of memory. You can declare structures to use bit values for boolean values, or bitmap to words to save room.
Make sure you aren't declaring any function blocks in persistent, it will save the entirety of the function block into the memory area.
I think declaring all of the persistent memory together will ensure it ends up as a continuous memory area with as few gaps as possible. If different global variable lists use the persistent flag, it may split things up? I'm not 100% sure about this.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Thanks for the response. Using the attribute you have suggested should indeed help utilising all the available data however, for this project it will still be inefficient.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't known what kind of project you are working and what is a structure of your code but take a look at my post here: https://forge.codesys.com/forge/talk/Engineering/thread/ed30e6d1a1/.
I'm using Wago PFC200 in my home automation project and in order to save me from such kind of issues I'm not storing whole function blocks in persistent memory. Even though, my data is rather small (for now, who knows how it will grown...).
I've extracted all variables which needs to be stored in persistent memory area into structures and I'm passing those structures to my function blocks from main program (as in/out parameters).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In concept I understand the approach you are taking to reduce the use of persistent to only that is required. That is a good approach to reduce the usage.
The basis for the original question is because my experience is with asked Bradley PLC which by default all tags are non volitile and the smallest storage in the compactlogix range is 600kB program and data storage. I was running out of persistent memory at 2kB so it didn't make any sense that this could not be increased.
After discussing further with the local SEW Eurodrive engineers we found that the Movi-C controller has 2kB of persistent memory and 32kB of retain storage. A long way from what U was expecting. However, being new to this platform I was not aware of the retain data area and fortunately it is large enough to store the 11kB of data I need.
I still use the persistent data for variables I need to keep during a download but The majority of the retain variables are just proceed variables that need to be retained in the event of a power cycle.
Thanks for taking the time to respond.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The hint lies in "(Largest contiguous memory gap 488). Editing persistant variable lists may produce fragmented memory."
You have changed too many blocks, data structures or something else that fragmented the PVL. Go to "Build" menu and run a "Clean" to de-fragment your project, this will however require a new download in PLC.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes I indeed have done this on many occasions to defragment the memory. However, the issue lies in trying to assign 11kB of data into a 2kB memory area.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It sounds like you may have a solution to your issue by using the VAR RETAIN for the values that aren't necessary to hold on to through downloads. A few more tips in case you or someone else needs them:
As of ~3.5.16 Ethernet/IP libraries have made their values retained by default within the libraries. This can burn up space quick on devices with limited memory area. The setting is tricky to find.... I'll let you know when I find it again...
You can use a method to back up your settings and restore them after downloads using Recipes, or your own file read/write commands. Definitely not as convenient as throwing the persistent tag on, but not too bad once it is set up. You can even use a trigger of some sort in the program to write the values. Usually I think this is how persistent values work anyway, when power goes down, it is detected and it writes the values to a special part of memory that holds on to them. For example, instead of cutting power directly, you could put a switch with a timer relay that would give a moment to write all your critical values to a file before power goes down.
Or just save them periodically (be careful of read/write cycles to flash storage!)
Sometimes you may find you can take advantage of storage on networked components, maybe rather than storing all the settings for a networked component, just read the value and display it, then if the user changes the value write the change. That way, when you download a new program the remote device will hold on to the value.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the reply. I wasn't aware of the Ethernet/IP using retains by default.
Good idea with regard to using the recipes to store the retains in the event of download. It wouldn't be a big deal to detect the loss of power and trigger the save command.
Thanks for the tips
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi All,
I am looking for support for my Codesys application. I am using persistent variables however I am no longer able to add more due to an error when trying to upload changes. The error is below
I have done as per the error recommendations. This did help initially however now I am out of space even with the 'gaps cleared'.
How do I go about increasing the memory capacity for the persistent variables?
Thanks in advance
I'm not sure how to increase the persistent memory, but a few tips to make maximum use of the memory you have:
Use the attribute pragma {attribute 'pack_mode' := '0'} . This ensures that each byte in the memory is used without skipping or re-aligning to even numbered bytes with data larger than 1 byte.
Boolean values use a full byte of memory. You can declare structures to use bit values for boolean values, or bitmap to words to save room.
Make sure you aren't declaring any function blocks in persistent, it will save the entirety of the function block into the memory area.
I think declaring all of the persistent memory together will ensure it ends up as a continuous memory area with as few gaps as possible. If different global variable lists use the persistent flag, it may split things up? I'm not 100% sure about this.
Hi Thanks for the response. Using the attribute you have suggested should indeed help utilising all the available data however, for this project it will still be inefficient.
I don't known what kind of project you are working and what is a structure of your code but take a look at my post here: https://forge.codesys.com/forge/talk/Engineering/thread/ed30e6d1a1/.
I'm using Wago PFC200 in my home automation project and in order to save me from such kind of issues I'm not storing whole function blocks in persistent memory. Even though, my data is rather small (for now, who knows how it will grown...).
I've extracted all variables which needs to be stored in persistent memory area into structures and I'm passing those structures to my function blocks from main program (as in/out parameters).
In concept I understand the approach you are taking to reduce the use of persistent to only that is required. That is a good approach to reduce the usage.
The basis for the original question is because my experience is with asked Bradley PLC which by default all tags are non volitile and the smallest storage in the compactlogix range is 600kB program and data storage. I was running out of persistent memory at 2kB so it didn't make any sense that this could not be increased.
After discussing further with the local SEW Eurodrive engineers we found that the Movi-C controller has 2kB of persistent memory and 32kB of retain storage. A long way from what U was expecting. However, being new to this platform I was not aware of the retain data area and fortunately it is large enough to store the 11kB of data I need.
I still use the persistent data for variables I need to keep during a download but The majority of the retain variables are just proceed variables that need to be retained in the event of a power cycle.
Thanks for taking the time to respond.
The hint lies in "(Largest contiguous memory gap 488). Editing persistant variable lists may produce fragmented memory."
You have changed too many blocks, data structures or something else that fragmented the PVL. Go to "Build" menu and run a "Clean" to de-fragment your project, this will however require a new download in PLC.
Yes I indeed have done this on many occasions to defragment the memory. However, the issue lies in trying to assign 11kB of data into a 2kB memory area.
Trevor,
It sounds like you may have a solution to your issue by using the VAR RETAIN for the values that aren't necessary to hold on to through downloads. A few more tips in case you or someone else needs them:
As of ~3.5.16 Ethernet/IP libraries have made their values retained by default within the libraries. This can burn up space quick on devices with limited memory area. The setting is tricky to find.... I'll let you know when I find it again...
You can use a method to back up your settings and restore them after downloads using Recipes, or your own file read/write commands. Definitely not as convenient as throwing the persistent tag on, but not too bad once it is set up. You can even use a trigger of some sort in the program to write the values. Usually I think this is how persistent values work anyway, when power goes down, it is detected and it writes the values to a special part of memory that holds on to them. For example, instead of cutting power directly, you could put a switch with a timer relay that would give a moment to write all your critical values to a file before power goes down.
Or just save them periodically (be careful of read/write cycles to flash storage!)
Sometimes you may find you can take advantage of storage on networked components, maybe rather than storing all the settings for a networked component, just read the value and display it, then if the user changes the value write the change. That way, when you download a new program the remote device will hold on to the value.
Thanks for the reply. I wasn't aware of the Ethernet/IP using retains by default.
Good idea with regard to using the recipes to store the retains in the event of download. It wouldn't be a big deal to detect the loss of power and trigger the save command.
Thanks for the tips