Raspberry retain variables

switcher
2014-04-22
2022-10-22
<< < 1 2 3 > >> (Page 2 of 3)
  • kruglovay - 2016-04-13

    Edwin Schwellinger hat geschrieben:
    Execute a 'sync' by after saving the retains manually.
    This lead to a file flush.. retains are saved immediately.

    Hello. I tried ```

    SysProcessExecuteCommand('sudo sync', ADR(cmdResult));

    but it doesn't save retains.
    

    SysProcessExecuteCommand('sudo reboot -h now', ADR(cmdResult));

    ```
    Reboot do the job.
    Is there a command to save retains without rebooting?

     
  • artemka - 2016-06-18

    Edwin Schwellinger hat geschrieben:
    Hi,
    usually nothing is needed except an UPS... no additional code to execute.
    BR
    Edwin

    Hello! You can learn how to turn off the raspberries to remain variable retain? Linux any team for this need. Thank you!

     
  • Kampfwurst - 2017-01-07

    kruglovay hat geschrieben:
    Is there a command to save retains without rebooting?

    Im also looking I tried "sudo sync" with no sucess

     
  • chris.beard - 2017-01-07

    Is there persistent variables on codesys 3?

    Sent from my SM-N9005 using Tapatalk

     
  • eschwellinger

    eschwellinger - 2017-01-08

    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

     
  • SebastianRaPi - 2017-02-07

    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

     
  • eschwellinger

    eschwellinger - 2017-02-08

    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:

    1. Save these Retains in the application via CmpApp (with this solution you do not have the latest retain state)
    2. Save the values ​​via Sysfile - or Inifile writers from the CODESYS Store product
    3. 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

     
  • francoinf - 2017-10-05

    Hi all,
    I have the same problem.
    Has a solution been found?
    Thanks, best regards

     
  • jbarrio - 2017-10-23

    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.

     
  • eschwellinger

    eschwellinger - 2017-11-18

    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

     
  • Bereggergo - 2017-11-20

    Hello Edwin,

    I see now. Thanks for your reply!

    BR,
    Gergö

     
  • eschwellinger

    eschwellinger - 2018-01-04

    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

     
  • nabilla - 2018-01-06

    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

     
  • eschwellinger

    eschwellinger - 2018-01-06

    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

     
  • JAPIB

    JAPIB - 2018-01-12

    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

     
  • jascur - 2018-03-20

    If I have an UPS and reboot my raspberry does variables declared as retain will keep values??

     
  • jbarrio - 2018-03-21

    If you gracefull shutdown raspberry yes, have or not have UPS.

    BR

     
  • donavira - 2018-12-04

    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]

     
  • eschwellinger

    eschwellinger - 2018-12-05

    Hi,
    could you please send the project to the CODESYS store -> my question -> bugreport
    I'll try to reproduce.

    BR
    Edwin

     
  • donavira - 2018-12-05

    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.

     
  • donavira - 2018-12-11

    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.

     
  • Anonymous - 2019-04-01

    Originally created by: phenixrb

    Hello,
    does anyone have a solution that works for a raspberry pi 3 B +?
    thank you

     
  • richard-wang - 2022-10-19

    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.

     
<< < 1 2 3 > >> (Page 2 of 3)

Log in to post a comment.