<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to UPS with Codesys</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/4b2cd65c12/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Runtime/thread/4b2cd65c12/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Runtime/thread/4b2cd65c12/</id><updated>2020-02-27T15:37:31.945000Z</updated><subtitle>Recent posts to UPS with Codesys</subtitle><entry><title>UPS with Codesys</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/4b2cd65c12/?limit=25#bccb" rel="alternate"/><published>2020-02-27T15:37:31.945000Z</published><updated>2020-02-27T15:37:31.945000Z</updated><author><name>hence.persson</name><uri>https://forge.codesys.com/u/hence-persson/</uri></author><id>https://forge.codesys.com561219718babaf72e9684b136e634a391b95a7fd</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;There always are a problem using UPS and raspberry as raspberry doesnt have a BIOS with auto start option.. &lt;br/&gt;
The Raspberry needs to shutdown and have 0V input a short time before power applied.. &lt;br/&gt;
There are UPSes that work this way see attached picture for Andino-UPS different states.. If you had a "real" industrial computer the normal working UPSes would work.&lt;/p&gt;
&lt;p&gt;Pictures taken from here: &lt;a class="" href="https://github.com/andino-systems/Andino-UPS/tree/master/src" rel="nofollow"&gt;https://github.com/andino-systems/Andin ... master/src&lt;/a&gt; m &lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: fsm" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=5008"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: states1.png" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=5007"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>UPS with Codesys</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/4b2cd65c12/?limit=25#be47" rel="alternate"/><published>2020-02-27T15:37:31.154000Z</published><updated>2020-02-27T15:37:31.154000Z</updated><author><name>i-campbell</name><uri>https://forge.codesys.com/u/i-campbell/</uri></author><id>https://forge.codesys.com53ecc3152c17fbfeb821a758d475906299f354f6</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I couldn't find a nice tutorial for Persistence Manager, just the online help which details the components of Persistence Manager.  They go through this in the training courses.&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="https://store.codesys.com/application-composer-bundle.html" rel="nofollow"&gt;Application Composer&lt;/a&gt; for free from the store, showing the Modules View, and pressing the generate button.&lt;/p&gt;
&lt;p&gt;It is kind of designed for exactly what you want.&lt;/p&gt;
&lt;p&gt;I see you have already found the application manager store example which has the functions to store the var persistent retain data to &lt;span style="color: underline;"&gt;a&lt;/span&gt; file and restore it... I haven't needed to try to get these to work though as Persistence Manager does it all for me. (Perhaps turn off the default "OnPowerfail" storage recovery with these two lines in your .cfg)&lt;br/&gt;
&lt;span&gt;[CmpApp]&lt;/span&gt; &lt;br/&gt;
RetainType.Applications=None&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>UPS with Codesys</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/4b2cd65c12/?limit=25#d09f" rel="alternate"/><published>2020-02-27T15:37:29.021000Z</published><updated>2020-02-27T15:37:29.021000Z</updated><author><name>arj3090</name><uri>https://forge.codesys.com/u/arj3090/</uri></author><id>https://forge.codesys.comd84b16abcb825f80b3f286a1d49a72cf02e80f8a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;I-Campbell hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
Archie, are you going about this the wrong way?&lt;br/&gt;
Have you tried the persistence manager which specifically implements what you are after?&lt;br/&gt;
&lt;a class="" href="https://help.codesys.com/webapp/f_application_composer_persistence_manager;product=core_Application_Composer;version=3.5.14.0" rel="nofollow"&gt;https://help.codesys.com/webapp/f_appli ... n=3.5.14.0&lt;/a&gt;&lt;br/&gt;
Recipes is also an option, but Persistence Manager just has everything you could want. Redundant files.. write on change or write on demand.&lt;br/&gt;
Ian&lt;br/&gt;
I briefly checked the Persistent Manager, but haven't got it to work yet. I am missing a step or two somewhere. I do like the Save On Change feature. It would be really nice if the normal Persistent Variables had the feature.&lt;/p&gt;
&lt;/blockquote&gt;&lt;/div&gt;</summary></entry><entry><title>UPS with Codesys</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/4b2cd65c12/?limit=25#432a" rel="alternate"/><published>2020-02-27T15:37:28.280000Z</published><updated>2020-02-27T15:37:28.280000Z</updated><author><name>arj3090</name><uri>https://forge.codesys.com/u/arj3090/</uri></author><id>https://forge.codesys.combe618ebc6840963439b9c00de4f5b582f0dee179</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Edwin Schwellinger hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
Hi,&lt;br/&gt;
I would try:&lt;br/&gt;
 if GPIO.input(0):&lt;br/&gt;
        subprocess.run("sudo shutdown -h now", shell=True, check=True)&lt;br/&gt;
.&lt;br/&gt;
.&lt;br/&gt;
This is a graceful shudown of Linux which will lead to a graceful shutdown of the plc runtime -&lt;br/&gt;
I assume this will then lead to a valid retain file too.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The reason I cannot do this is because the power may return before the UPS is fully drained. In this case the Pi would not boot back up. It would require someone to manually disconnect the power from the Pi or remove power into the UPS for about 60 seconds to let it fully drain.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>UPS with Codesys</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/4b2cd65c12/?limit=25#8b4c" rel="alternate"/><published>2020-02-27T15:37:27.552000Z</published><updated>2020-02-27T15:37:27.552000Z</updated><author><name>i-campbell</name><uri>https://forge.codesys.com/u/i-campbell/</uri></author><id>https://forge.codesys.comfd74ca1d7b65093bbdb075f74523b9a8a884a704</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Archie, are you going about this the wrong way?&lt;br/&gt;
Have you tried the persistence manager which specifically implements what you are after?&lt;br/&gt;
&lt;a class="" href="https://help.codesys.com/webapp/f_application_composer_persistence_manager;product=core_Application_Composer;version=3.5.14.0" rel="nofollow"&gt;https://help.codesys.com/webapp/f_appli ... n=3.5.14.0&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Recipes is also an option, but Persistence Manager just has everything you could want. Redundant files.. write on change or write on demand.&lt;br/&gt;
Ian&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>UPS with Codesys</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/4b2cd65c12/?limit=25#0159" rel="alternate"/><published>2020-02-27T15:37:25.355000Z</published><updated>2020-02-27T15:37:25.355000Z</updated><author><name>eschwellinger</name><uri>https://forge.codesys.com/u/eschwellinger/</uri></author><id>https://forge.codesys.com842c93d2f35121f998a8b204bf0a30234d2fbafe</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;br/&gt;
I would try:&lt;/p&gt;
&lt;p&gt;if GPIO.input(0):&lt;br/&gt;
        subprocess.run("sudo shutdown -h now", shell=True, check=True)&lt;br/&gt;
.&lt;br/&gt;
.&lt;br/&gt;
This is a graceful shudown of Linux which will lead to a graceful shutdown of the plc runtime -&lt;br/&gt;
I assume this will then lead to a valid retain file too.&lt;/p&gt;
&lt;p&gt;BR&lt;br/&gt;
Edwin&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>UPS with Codesys</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/4b2cd65c12/?limit=25#9220" rel="alternate"/><published>2020-02-27T15:37:24.555000Z</published><updated>2020-02-27T15:37:24.555000Z</updated><author><name>arj3090</name><uri>https://forge.codesys.com/u/arj3090/</uri></author><id>https://forge.codesys.comd98829fa778edde5a83de8564dd9b6302e7a4f34</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;To be more specific, this is the UPS I am using:&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="https://www.bicker.de/index.php/eng/Products/UPS-systems/DC-UPS/UPSIC-2403D" rel="nofollow"&gt;https://www.bicker.de/index.php/eng/Pro ... PSIC-2403D&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I have the relay output wired to GPIO0 of the Pi device.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>UPS with Codesys</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/4b2cd65c12/?limit=25#2c35" rel="alternate"/><published>2020-02-27T15:37:22.479000Z</published><updated>2020-02-27T15:37:22.479000Z</updated><author><name>arj3090</name><uri>https://forge.codesys.com/u/arj3090/</uri></author><id>https://forge.codesys.com73427cb0be1c9bff83d1d96e6416d9f7dc2400b1</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;This is a different device with an external UPS. I was never able to get the first device with the built-in UPS to work because of the power being removed from the Ethernet ports&lt;/p&gt;
&lt;p&gt;On the new device I cannot shut down Linux because the power may return before the UPS is completely drained. If Linux were shut down and the input power returned to the UPS, then Linux would not restart. So I need some way to force Codesys to save the data.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>UPS with Codesys</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/4b2cd65c12/?limit=25#e618" rel="alternate"/><published>2020-02-27T15:37:21.756000Z</published><updated>2020-02-27T15:37:21.756000Z</updated><author><name>eschwellinger</name><uri>https://forge.codesys.com/u/eschwellinger/</uri></author><id>https://forge.codesys.com5cd3874c3c317d93f07f450987e5434235042258</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;br/&gt;
if you do this manually do you agree that this works?&lt;br/&gt;
I think if you trigger this by a GPIO and your UPS triggers a Linux shutdown - and as you told switch off Ethernet nic&lt;br/&gt;
at the same time.. this will not work properly. ( As I remember from an older post)&lt;br/&gt;
Is using a different UPS an option PI for you? For example:  l &lt;a class="" href="https://forum.codesys.com/viewtopic.php?f=23&amp;amp;t=5872&amp;amp;x=10867&amp;amp;p=13721&amp;amp;lan=en" rel="nofollow"&gt;viewtopic.php?f=23&amp;amp;t=5872&amp;amp;p=10867#p13721&lt;/a&gt; l &lt;/p&gt;
&lt;p&gt;BR&lt;br/&gt;
Edwin&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>UPS with Codesys</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/4b2cd65c12/?limit=25#69cb" rel="alternate"/><published>2020-02-27T15:37:21.039000Z</published><updated>2020-02-27T15:37:21.039000Z</updated><author><name>arj3090</name><uri>https://forge.codesys.com/u/arj3090/</uri></author><id>https://forge.codesys.com9dc098d0e5197c3b8754bf35f2abfbcd415ee648</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I have a Pi based device with a UPS. The relay output from the UPS is wired to GPIO0. I created a Python script to save persistent data when the UPS loses power and the GPIO0 signal changes. This is the code I am using:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;GPIO&lt;/span&gt;.&lt;span class="nv"&gt;input&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;:
        &lt;span class="nv"&gt;subprocess&lt;/span&gt;.&lt;span class="nv"&gt;run&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sudo bash /etc/init.d/codesyscontrol stop&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;, &lt;span class="nv"&gt;shell&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;True&lt;/span&gt;, &lt;span class="nv"&gt;check&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;True&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
      &lt;span class="k"&gt;else&lt;/span&gt;:
        &lt;span class="nv"&gt;subprocess&lt;/span&gt;.&lt;span class="nv"&gt;run&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sudo bash /etc/init.d/codesyscontrol start&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;, &lt;span class="nv"&gt;shell&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;True&lt;/span&gt;, &lt;span class="nv"&gt;check&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;True&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;It does not seem very graceful to fully stop the Codesys service and restart when power is restored. Is there a better method to tell Codesys to save the persistent values?&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>