Hi,
I use RPi and Persistent Vars and as you well know it doesn't work, so
It is possible manually form Codesys application save/update the Persistent Vars value ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't know if it's good practice, but I simply do this to manage the persistant variables in my program:
application_ptr:POINTERTOCmpApp.APPLICATION;res:DINT;// Get application pointerapplication_ptr:=CmpApp.AppFindApplicationByName('Application',ADR(res));// Restore the variablesCmpApp.AppRestoreRetainsFromFile(application_ptr,'/home/pi/retains.ret');// ...// Store the variablesCmpApp.AppStoreRetainsInFile(application_ptr,'/home/pi/retains.ret');
To answer your questions, sFilename should be something ending with ".ret" extension I think.
Also, be aware that those store and restore functions works on all your persistant variables at once (so you don't have to specifiy which one you want to store / restore).
Hope this helps
BR
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Please keep in mind, that there are also an CODESYS Persistence Manager, which could stores the persistence variables in a file. It's possible to control the persistence process.
I try this solution (Persistence Manager) but it do not work. I did as described:
1) In Codesy - View -> Modules
2) Add Toplevel Module Instance
3) Add Persistence Manager
4) Select the Application - Device.Application
5) Added group "Persistence1"
6) Added Submodule Instance "PersistenceChannel"
7) Setup the Persistence Parameter - xSaveOnChange on TRUE
8) Add Submodule Instance - and Select ASCIIFileStorage
9) Created GVL called "PersistentVars" in my project and add persistence variables with attribute:
~~~
VAR_GLOBAL
{attribute 'ac_persist':='PersistenceChannel'}
mem_trans: ARRAY[1..50] OF BYTE;
{attribute 'ac_persist':='PersistenceChannel'}
id_trans:BYTE;
END_VAR
~~~
Before "Generate" I choose only "Persistence generator". I didn't chose "Standard generator" because after that my environment is freeze., Why it doesn't work ?
therefore they are not generated tasks : HIGH and LOW ....
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am using Codesys 3.5 SP16 Patch 2.
Once difference I noticed is that in configuration (like in attachement) I have set HIGH and LOW task. I no have this task in my projekt. it could be the problem cause ?
For sure, your PM generator is pretty wrong.
The device tree should look like the attachment.
I use 3 persistence channels device, system and operating.
In new environment generator works good. But in new codesys Ido not have Build(F11) i Rebuild , why? Please find in attachement.
@josepmariarams I do Persistant Variables on file because my Rpi time to time isrestart by lack of power...- so I don't stopp Raspian normally.I hope it will work.
I think I have the same issue, it works if I declare the variables in PLC_PRG but doesn't work with GVL...
Did the same as here: https://forge.codesys.com/forge/talk/Engineering/thread/e837426615/#aa4c
Is that a bug?
UPDATE: not a bug, just needed to call the var from GVL in another program.
π
2
Last edit: spiritcore 2022-04-27
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I use RPi and Persistent Vars and as you well know it doesn't work, so
It is possible manually form Codesys application save/update the Persistent Vars value ?
more posts ...
I do not understand this code:
Where is my variables (in above code) which one are created "PersistentVars" in my project ?
The sFileName should be difference than my Application name to work properly ?
Last edit: damian177 2022-04-12
I don't know if it's good practice, but I simply do this to manage the persistant variables in my program:
To answer your questions, sFilename should be something ending with ".ret" extension I think.
Also, be aware that those store and restore functions works on all your persistant variables at once (so you don't have to specifiy which one you want to store / restore).
Hope this helps
BR
What should I change in /etc/CODESYSControl.cfg to properly work above example ?
What do you think about below solution :?
https://help.codesys.com/webapp/_rtslext_retains_in_shared_memory;product=CODESYS_Control_SL_Extension_Package;version=4.4.0.0
?
Please keep in mind, that there are also an CODESYS Persistence Manager, which could stores the persistence variables in a file. It's possible to control the persistence process.
https://help.codesys.com/webapp/ac_pm_persistencemanager_module;product=core_Application_Composer;version=3.5.17.0
I personnaly use the persistence manager. It works great and is very flexible. It is a bit of work to setup but once it is done, it is easy to use.
I try this solution (Persistence Manager) but it do not work. I did as described:
1) In Codesy - View -> Modules
2) Add Toplevel Module Instance
3) Add Persistence Manager
4) Select the Application - Device.Application
5) Added group "Persistence1"
6) Added Submodule Instance "PersistenceChannel"
7) Setup the Persistence Parameter - xSaveOnChange on TRUE
8) Add Submodule Instance - and Select ASCIIFileStorage
9) Created GVL called "PersistentVars" in my project and add persistence variables with attribute:
~~~
VAR_GLOBAL
{attribute 'ac_persist':='PersistenceChannel'}
mem_trans: ARRAY[1..50] OF BYTE;
{attribute 'ac_persist':='PersistenceChannel'}
id_trans:BYTE;
END_VAR
~~~
10)Generator configuration - Check only"Persistence generator"
11)Composer->Generate
Now in my project I have "PersistenceConfig" like in attachment.
But it do not works... What can be wrong ?
Last edit: damian177 2022-04-14
Any ideas ?
Before "Generate" I choose only "Persistence generator". I didn't chose "Standard generator" because after that my environment is freeze., Why it doesn't work ?
therefore they are not generated tasks : HIGH and LOW ....
What's the version of your CODESYS IDE? I worked at latest with the 3.5 SP17 Patch 0, where the persistence manager surely worked.
The instruction you described is fully correct and should work. Please contact CODESYS with your issue.
I am using Codesys 3.5 SP16 Patch 2.
Once difference I noticed is that in configuration (like in attachement) I have set HIGH and LOW task. I no have this task in my projekt. it could be the problem cause ?
For sure, your PM generator is pretty wrong.
The device tree should look like the attachment.
I use 3 persistence channels device, system and operating.
Last edit: ludecus 2022-04-22
Persistent vars works fine in Codesys for Raspberry. I am using ver 3.5.13 and it works.
CoDeSys saves the persistence file on Raspbian shut-down. Are you stopping Raspbian normally?.
If you save your persistent variables to a recipe, you can save and load via persistence utils, too.
Persistent vars works fine in Codesys for Raspberry. I am using ver 3.5.13 and it works.
CoDeSys saves the persistence file on Raspbian shut-down. Are you stopping Raspbian normally?.
If you save your persistent variables to a recipe, you can save and load via persistence utils, too.
Persistent vars works fine in Codesys for Raspberry. I am using ver 3.5.13 and it works.
CoDeSys saves the persistence file on Raspbian shut-down. Are you stopping Raspbian normally?.
If you save your persistent variables to a recipe, you can save and load via persistence utils, too.
Persistent vars works fine in Codesys for Raspberry. I am using ver 3.5.13 and it works.
CoDeSys saves the persistence file on Raspbian shut-down. Are you stopping Raspbian normally?.
If you save your persistent variables to a recipe, you can save and load via persistence utils, too.
Persistent vars works fine in Codesys for Raspberry. I am using ver 3.5.13 and it works.
CoDeSys saves the persistence file on Raspbian shut-down. Are you stopping Raspbian normally?.
If you save your persistent variables to a recipe, you can save and load via persistence utils, too.
Persistent vars works fine in Codesys for Raspberry. I am using ver 3.5.13 and it works.
CoDeSys saves the persistence file on Raspbian shut-down. Are you stopping Raspbian normally?.
If you save your persistent variables to a recipe, you can save and load via persistence utils, too.
Persistent vars works fine in Codesys for Raspberry. I am using ver 3.5.13 and it works.
CoDeSys saves the persistence file on Raspbian shut-down. Are you stopping Raspbian normally?.
If you save your persistent variables to a recipe, you can save and load via persistence utils, too.
Persistent vars works fine in Codesys for Raspberry. I am using ver 3.5.13 and it works.
CoDeSys saves the persistence file on Raspbian shut-down. Are you stopping Raspbian normally?.
If you save your persistent variables to a recipe, you can save and load via persistence utils, too.
Persistent vars works fine in Codesys for Raspberry. I am using ver 3.5.13 and it works.
CoDeSys saves the persistence file on Raspbian shut-down. Are you stopping Raspbian normally?.
If you save your persistent variables to a recipe, you can save and load via persistence utils, too.
Persistent vars works fine in Codesys for Raspberry. I am using ver 3.5.13 and it works.
CoDeSys saves the persistence file on Raspbian shut-down. Are you stopping Raspbian normally?.
If you save your persistent variables to a recipe, you can save and load via persistence utils, too.
Persistent vars works fine in Codesys for Raspberry. I am using ver 3.5.13 and it works.
CoDeSys saves the persistence file on Raspbian shut-down. Are you stopping Raspbian normally?.
If you save your persistent variables to a recipe, you can save and load via persistence utils, too.
In new environment generator works good. But in new codesys Ido not have Build(F11) i Rebuild , why? Please find in attachement.
@josepmariarams I do Persistant Variables on file because my Rpi time to time isrestart by lack of power...- so I don't stopp Raspian normally.I hope it will work.
I think I have the same issue, it works if I declare the variables in PLC_PRG but doesn't work with GVL...
Did the same as here:
https://forge.codesys.com/forge/talk/Engineering/thread/e837426615/#aa4c
Is that a bug?
UPDATE: not a bug, just needed to call the var from GVL in another program.
Last edit: spiritcore 2022-04-27