CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Tue Oct 22, 2019 12:39 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Oct 09, 2019 6:06 pm 
Offline

Joined: Sat Feb 17, 2007 5:06 pm
Posts: 34
I have an input signal going into GPIO 26 from a UPS that indicates it is time to shutdown the OS and save data. How can I use that GPIO in Codesys to force my persistent values to save?

The reason I need to do this is because the shutdown sequence of the device causes Codesys to abruptly exit before Linux is properly shut down and Codesys will not save data. I need to make Codesys immediately save the data when the signal changes.

I found a function block to save persistent values to a specified file, but I want to save it to the normal location so on startup Codesys reads the values without the need for my program to do anything.


Top
   
PostPosted: Wed Oct 09, 2019 9:30 pm 
Offline

Joined: Tue Mar 26, 2019 4:28 pm
Posts: 26
Hi Archie,

Sounds like this link below won't help you if your shutdown kills Codesys too early. Does it work if you modify it to:
Code:
sudo /etc/init.d/codesyscontrol stop

viewtopic.php?t=8063#p18745


Top
   
PostPosted: Wed Oct 09, 2019 10:02 pm 
Offline

Joined: Sat Feb 17, 2007 5:06 pm
Posts: 34
My hardware causes a difficult situation. It has a built in UPS that relies on a Python script to fire an event when the power changes, which in turn performs the system shutdown. Prior to the system shutdown command, the UPS removes power from the Ethernet ports, which causes Codesys to dump out in a license fault.

In the Python power change event, I added the code mentioned to stop Codesys prior to power being removed from the Ethernet ports and all works good. However after I installed the PREEMPT RT patch, the CPU usage goes up to about 30% causing high jitter and poor performance. In order to fix this problem, I enable the FIQ by changing dwc_otg.fiq_enable=N in the /boot/cmdline.txt file. Enabling the FIQ in turn stops the Python event from doing its job and no longer stops Codesys.

My best compromise I can come up with is to have the Codesys program watch the signal from the UPS and explicitly have it store the persistent values the same way it does when Codesys shuts down normally. But I have not found a function block to perform this task.


Top
   
PostPosted: Thu Oct 10, 2019 6:02 pm 
Offline

Joined: Tue Mar 26, 2019 4:28 pm
Posts: 26
This store example seems to have functions for reading and writing persistent/retain memory area with the CmpApp library.
https://store.codesys.com/application-m ... re=default

I think you can alternate file retain files in the event one gets corrupt, and load the backup if the last write failed..

Interested in your projectarchive or how-to once you get something working.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited