<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to variables not retained through power cycle?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/bd03572382/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Runtime/thread/bd03572382/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Runtime/thread/bd03572382/</id><updated>2020-02-27T16:09:58.120000Z</updated><subtitle>Recent posts to variables not retained through power cycle?</subtitle><entry><title>variables not retained through power cycle?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/bd03572382/?limit=25#5e9b" rel="alternate"/><published>2020-02-27T16:09:58.120000Z</published><updated>2020-02-27T16:09:58.120000Z</updated><author><name>adrian.nicola</name><uri>https://forge.codesys.com/u/adrian-nicola/</uri></author><id>https://forge.codesys.com8e25c35304fe5576e13beec62432ea369d23d620</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;YES It not retain variable if its a power down.&lt;br/&gt;
 Whatever to retain some settings variable,  in my projects i discover that if i give a restart command to raspberry it save and keep the variable used like persistent.&lt;/p&gt;
&lt;p&gt;i put a switch on web interface for save and reset.This switch  it activate a GPIO pin. On raspbery OS i run cyclical a PYTHON script to read other GPIO pin and reset the raspbery when pin its active. This  2 GPIO pins are connected with a wire. when i push the switch from web interface  i reset the raspbery &lt;/p&gt;
&lt;p&gt;I dont know why i dont manage to send a reset command from codesys to raspbery directly from software  and i make this improvisation. if anybody succeed to send a software reset command from codesys to raspbery pls share here and i will not need this wire and python shit.&lt;/p&gt;
&lt;p&gt;whatever it works. i can save and retain my settings if its a power down if before was save with reset method&lt;/p&gt;
&lt;p&gt;I dont search the posts maybe somebody find some other methods. with this you dont need UPS&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>variables not retained through power cycle?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/bd03572382/?limit=25#d24f" rel="alternate"/><published>2020-02-27T16:09:57.289000Z</published><updated>2020-02-27T16:09:57.289000Z</updated><author><name>johan76swart</name><uri>https://forge.codesys.com/u/johan76swart/</uri></author><id>https://forge.codesys.comead1a13b15e5cebce3c5dd8464d824281f46b76b</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi Con2827,&lt;/p&gt;
&lt;p&gt;It is important to keep in mind that the Raspberry Pi is not an Industrial PLC, however there is a workaround if you want to save variables.&lt;br/&gt;
I do this by writing and reading variables to its own file. There is a library dedicated to achieve this, SysFile Library.&lt;/p&gt;
&lt;p&gt;Usually I have some User configurable variable which I would like to save, and then on startup load those variables back into program.&lt;br/&gt;
First I have created a function block to make this operation more stream like.&lt;/p&gt;
&lt;p&gt;See this attachment for creating such a function block. &lt;/p&gt;
&lt;p&gt;You will see that I have use two separate triggers for the read and write functions.&lt;/p&gt;
&lt;p&gt;You could have a manual write or an action defined write on the write trigger, which essentially writes the variable to a file name of your choice.&lt;br/&gt;
Usually I load my variables on startup with a timed pulse and inhibit any write actions for a few seconds.&lt;/p&gt;
&lt;p&gt;Hope you will find this info useful.&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Johan.&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Read_WriteVariables.png" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=2000"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="https://forum.codesys.com//download/file.php?id=1999" rel="nofollow"&gt;Read_WriteFile.pdf &lt;span&gt;&lt;span&gt;[39.3 KiB]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>variables not retained through power cycle?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/bd03572382/?limit=25#0a83" rel="alternate"/><published>2020-02-27T16:09:56.461000Z</published><updated>2020-02-27T16:09:56.461000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com5546408d0f4874b707566337486dfaa1dfbd8003</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; scott_cunningham&lt;/p&gt;
&lt;p&gt;To answer your questions:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;I am no help on this point - I work with industrial controls.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Persistent retain are standard keywords of the PLCopen group, which was designed for industrial automation. They are not removed from the IDE based on what the hardware platform can or cannot support. CoDeSys's original target market was industrial automation and has been expanded to the Pi probably as a teaching tool support. &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For an industri PC, the program goes to the file system but persistent retains go to an NVRAM. Clearly, the Pi doesn't have NVRAM. &lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You will have to make a workaround with storing values in your file system, or switch to a hardware platform that supports persistent retain (it won't be $30, however).&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>variables not retained through power cycle?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/bd03572382/?limit=25#1c59" rel="alternate"/><published>2020-02-27T16:09:54.024000Z</published><updated>2020-02-27T16:09:54.024000Z</updated><author><name>con2827</name><uri>https://forge.codesys.com/u/con2827/</uri></author><id>https://forge.codesys.com79265dc97c0230067bf24a4bc5ff46f987e1f76d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thanks, I had seen other posts on this, but still have questions:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;It seems the recommendation is to have a ups, to allow a proper shutdown of the pi.  But that doesn't necessarily help since it's not always possible to properly shut down the pi, ups or not.  &lt;/li&gt;
&lt;li&gt;What is the purpose of having RETAIN PERSISTENT variables anyway, in this case?&lt;/li&gt;
&lt;li&gt;If the pi retains the logic/program/etc - which it does, I don't have to do a download after a power cycle - why not the variable data too?&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;</summary></entry><entry><title>variables not retained through power cycle?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/bd03572382/?limit=25#536b" rel="alternate"/><published>2020-02-27T16:09:53.204000Z</published><updated>2020-02-27T16:09:53.204000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com925828804abb3759571d379e78715e3670723447</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; scott_cunningham&lt;/p&gt;
&lt;p&gt;I believe from another post that the RPii does not support persistent retain. You will need a UPS and store you variables in a file.   l &lt;a class="" href="http://forum.codesys.com/viewtopic.php?f=21&amp;amp;t=6937&amp;amp;x=14993&amp;amp;hilit=Persistent&amp;amp;p=14993&amp;amp;lan=en" rel="nofollow"&gt;viewtopic.php?f=21&amp;amp;t=6937&amp;amp;p=14993&amp;amp;hilit=Persistent#p14993&lt;/a&gt; l &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>variables not retained through power cycle?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/bd03572382/?limit=25#1dec" rel="alternate"/><published>2020-02-27T16:09:50.928000Z</published><updated>2020-02-27T16:09:50.928000Z</updated><author><name>con2827</name><uri>https://forge.codesys.com/u/con2827/</uri></author><id>https://forge.codesys.com93fa6841060183051820df2bbe763448b02456d3</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I have variables defined as RETAIN PERSISTENT, in a persistent variable list, but their values are not retained when power is cycled.&lt;/p&gt;
&lt;p&gt;Did I miss something in configuring these variables?  What is the correct configuration so that they retain their values?&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>