in general there are retains, but you need a graceful shutdown under Linux Debian.
(no Switch off the power supply withour shutdown)
-> so UPS (uninterrupted power supply ) is mandatory to have retain variables.
BR
Edwin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
if you want to use the "VAR PERSISTENT RETAIN" with the Pi and a have reliable solution
then a UPS is a must have!
This makes the Pi more robust for the Problem 'SD card corruption caused by switch the power off' too.
Sure there are always semi-reliable solutions:
Save these Retains in the application via CmpApp (with this solution you do not have the latest retain state)
Save the values ​​via Sysfile - or Inifile writers from the CODESYS Store product
PersistenceManager of the Application Composer - this can store cyclic or on change variables (here you have to make a very precise decision for each individual variable, whether cyclic or to save changes and if cyclic which time makes sense! ))
Attention:
With all the three possibilities/solutions on the PI the one problem remain:
What happens on 'file writing' during switchoff - graceful shutdown on Linux is needed.
1. The file is not written correctly
2. SD card corrupt and Pi maybe does not come up again on bootup
That's the whole story
BR
Edwin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello:
I have the system to retain variables that I keep in a file the variables and then at the beginning I retrieve them, it works correctly when I remove tension to the equipment but when I make a modification to the plc the variables no longer start correctly and they all start at 0, this has a solution
edit:
after several tests I see that I only lose the retain variables in some cases like when I create a manager trend, does anyone know which cases are lost?
thanks for help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
However not completely clear how to use it... shouldn't be any GPIO which changes state when there is no external power supply? Do you get it how to use it exactly?
Thank you,
Gergö
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
not sure,
the requirements are simple and are basically not handled in CODESYS -> Linux OS and by the UPS
detect the the switch off of the power supply
trigger a graceful shudown of Linux
this means then . the runtime saves the retain file on shudown of the plc runtime
on next startup of the plc runtime the retains will be restored from the retain file.
That is it. You see basically this has nothing to do with CODESYS more or less you need and an UPS which does a graceful shutdown of the Linux System.
Could not really see if this is done by this UPS.
BR
Edwin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Edwin Schwellinger hat geschrieben:
Hi Zdenko,
attached an example to realize a manual save of the retain variables.
Take care cyclic writing on the SD Card could damage the filesystem especially if you switch off the system while writing to files. (graceful shutdown is needed on Linux side...)
BR
Edwin
Hi Edwin, where I can find the retain file ? (*.ret)
both in windows and the raspberry
regards,
Lala
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is it not possible to store data in a file into a USB Key instead of the SD card ?
J do this in an Eaton PLC and its work well.
But I don't know how to name the USB Key with a Raspberry.
BR.
Japib
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I cant use with retain variables with RPI3B+. Earlier RPI an Debain versions worked well. Raspberry shutdown is correct. I attached a PLC log file, wich consist a two error lines: Retain restore from file failed: [Application], area=1, size=4096,type=0x0020
Retain restore from file failed: [Application], area=2, size=4096,type=0x0120
HW: Rasperry PI3B+, Raspbian Strech 4.14., Runtime 3.5.13.20 licensed, Codesys V3.5SP13Patch2
Help me please
Thx
Edwin Schwellinger hat geschrieben:
Hi,
could you please send the project to the CODESYS store -> my question -> bugreport
I'll try to reproduce.
BR
Edwin
Hi,
I uploaded the complete projectarchive.
Thanks in advance, Donát.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Edwin,
Did you test the bug?
I tried the project with a 32 bit PC (Win XP), V3.5 SP7 Patch 3. Raspberry PI same. The retain variables stores their values after a power down.
Regards, Donát.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2019-04-01
Originally created by: phenixrb
Hello,
does anyone have a solution that works for a raspberry pi 3 B +?
thank you
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Edwin
Even this is old thread, but it actually saved my day.
The code you wrote actually works very well , I saved all my retained tags even if PI4 is powered off without using UPS.
For whoever wants to make retain variables works, please look carefully on the first page. Edwin's sample code works perfectly.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello. I tried ```
SysProcessExecuteCommand('sudo sync', ADR(cmdResult));
SysProcessExecuteCommand('sudo reboot -h now', ADR(cmdResult));
```
Reboot do the job.
Is there a command to save retains without rebooting?
Hello! You can learn how to turn off the raspberries to remain variable retain? Linux any team for this need. Thank you!
Im also looking I tried "sudo sync" with no sucess
Is there persistent variables on codesys 3?
Sent from my SM-N9005 using Tapatalk
Hi,
in general there are retains, but you need a graceful shutdown under Linux Debian.
(no Switch off the power supply withour shutdown)
-> so UPS (uninterrupted power supply ) is mandatory to have retain variables.
BR
Edwin
Hello,
is there no other chance (expect UPS) to save some variables in case of power failure for a RaspberryPi system??
It works with a normal shutdown, but with a failure not.
Thanks for more informations
Hi,
if you want to use the "VAR PERSISTENT RETAIN" with the Pi and a have reliable solution
then a UPS is a must have!
This makes the Pi more robust for the Problem 'SD card corruption caused by switch the power off' too.
Sure there are always semi-reliable solutions:
Attention:
With all the three possibilities/solutions on the PI the one problem remain:
What happens on 'file writing' during switchoff - graceful shutdown on Linux is needed.
1. The file is not written correctly
2. SD card corrupt and Pi maybe does not come up again on bootup
That's the whole story
BR
Edwin
Hi all,
I have the same problem.
Has a solution been found?
Thanks, best regards
Hello:
I have the system to retain variables that I keep in a file the variables and then at the beginning I retrieve them, it works correctly when I remove tension to the equipment but when I make a modification to the plc the variables no longer start correctly and they all start at 0, this has a solution
edit:
after several tests I see that I only lose the retain variables in some cases like when I create a manager trend, does anyone know which cases are lost?
thanks for help.
Hello Edwin,
I have a DS1307 RTC Module for my Raspberry:
https://www.amazon.de/gp/product/B01FR7 ... UTF8&psc=1
There is a description how configure rpi not to lose the clock time:
https://cdn-learn.adafruit.com/download ... rry-pi.pdf
Is there any safe way or possibility with this RTC module to keep the retain variables of codesys after power loss?
Thanks,
Gergö
Hi Gergö,
no this does only retain the clock, no additional Memory/space for storing variables.
Why not using an UPS?
http://www.pimodulescart.com/shop/item.aspx?itemid=30
guess for this there you'll find a driver in the libraray section to Access even via CODESYS the state of the UPS.
BR
Edwin
Hello Edwin,
I see now. Thanks for your reply!
BR,
Gergö
Hello Edwin,
finally I got this:
http://www.raspberrypiwiki.com/index.php/Power_Pack_Pro
Amazon says it's an UPS HAT:
https://www.amazon.de/ILS-Geekworm-Expa ... B0769HHT95
However not completely clear how to use it... shouldn't be any GPIO which changes state when there is no external power supply? Do you get it how to use it exactly?
Thank you,
Gergö
Hi,
not sure,
the requirements are simple and are basically not handled in CODESYS -> Linux OS and by the UPS
this means then . the runtime saves the retain file on shudown of the plc runtime
on next startup of the plc runtime the retains will be restored from the retain file.
That is it. You see basically this has nothing to do with CODESYS more or less you need and an UPS which does a graceful shutdown of the Linux System.
Could not really see if this is done by this UPS.
BR
Edwin
Hi Edwin, where I can find the retain file ? (*.ret)
both in windows and the raspberry
regards,
Lala
Hi,
beside the bootproject
runtime Directory
/PlcLogic/Application/
for the the Pi this:
/var/opt/codesys/PlcLogic/Application
Application.app
Application.crc
Application.ret
For Control Win:
c:\ProgramData\CODESYS\CODESYSControlWinV3x64\PlcLogic\Application
BR
Edwin
Hello,
Is it not possible to store data in a file into a USB Key instead of the SD card ?
J do this in an Eaton PLC and its work well.
But I don't know how to name the USB Key with a Raspberry.
BR.
Japib
If I have an UPS and reboot my raspberry does variables declared as retain will keep values??
If you gracefull shutdown raspberry yes, have or not have UPS.
BR
Dear Edwin,
I cant use with retain variables with RPI3B+. Earlier RPI an Debain versions worked well. Raspberry shutdown is correct. I attached a PLC log file, wich consist a two error lines: Retain restore from file failed: [Application], area=1, size=4096,type=0x0020
Retain restore from file failed: [Application], area=2, size=4096,type=0x0120
HW: Rasperry PI3B+, Raspbian Strech 4.14., Runtime 3.5.13.20 licensed, Codesys V3.5SP13Patch2
Help me please
Thx
RPI3B+_retain_load_fail.xml [33.82 KiB]
Hi,
could you please send the project to the CODESYS store -> my question -> bugreport
I'll try to reproduce.
BR
Edwin
Hi,
I uploaded the complete projectarchive.
Thanks in advance, Donát.
Hi Edwin,
Did you test the bug?
I tried the project with a 32 bit PC (Win XP), V3.5 SP7 Patch 3. Raspberry PI same. The retain variables stores their values after a power down.
Regards, Donát.
Originally created by: phenixrb
Hello,
does anyone have a solution that works for a raspberry pi 3 B +?
thank you
Hi Edwin
Even this is old thread, but it actually saved my day.
The code you wrote actually works very well , I saved all my retained tags even if PI4 is powered off without using UPS.
For whoever wants to make retain variables works, please look carefully on the first page. Edwin's sample code works perfectly.