You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old March 15th, 2019, 05:41 PM   #1
Skidood
Member
Canada

Skidood is offline
 
Join Date: Oct 2016
Location: Ontario
Posts: 135
recover operation after power failure based on elapsed time

Hi group,

I am trying to figure out how to calculate time elapsed during a power failure. If the PLC is off for more than 30 minutes, when the power is restored I want to enable a bit. If the power is off for less than 30 minutes, the bit is left alone.

I believe I previously saw a logic example where the amount of time that has passed since the beginning of the year is constantly stored, and then upon power restoration, the current time/day is compared to that somehow but that strategy seems a bit wonky.
I know that I will be working with the First Pass bit.
I can also tell you that my program already writes the current day, hour, minute and second to their own integer files 4 times per second.

Any takers?
  Reply With Quote
Old March 15th, 2019, 06:20 PM   #2
Ken Roach
Lifetime Supporting Member + Moderator
United States

Ken Roach is offline
 
Ken Roach's Avatar
 
Join Date: Apr 2002
Location: Seattle, WA
Posts: 14,796
What make and model of PLC ?

Some have a Real-Time Clock and a power-down routine that will allow them to store the time of the power failure.
  Reply With Quote
Old March 15th, 2019, 06:23 PM   #3
Skidood
Member
Canada

Skidood is offline
 
Join Date: Oct 2016
Location: Ontario
Posts: 135
Sorry, its a MicroLogix 1400. I am already writing RTC values to integers as mentioned. Thank you.
  Reply With Quote
Old March 15th, 2019, 06:46 PM   #4
Aabeck
Member
United States

Aabeck is offline
 
Aabeck's Avatar
 
Join Date: Feb 2013
Location: Detroit
Posts: 1,339
I did this on a laminating hot press to continue the cycle if the power was off less than 20 minutes and the hydraulic pressure was not lost. The customer specified it to abort the cycle if the power was off more than 20 minutes.



What I did was power the PLC by the UPS for the HMI computer. The PLC watched for the main power to drop and recorded that time. When the power came back on if the PLC was still running, or just restarted at the power coming back on was calculate the lost time.


Calculating the hours and minutes was fairly easy, but if the power dropped during a cycle that continued into the next day, maybe month and year, got complex.


If the power restores after midnight the next day see what day of the month it is, the number of days that month (leap year Feb's have 29) and the year to calculate how many days/hours/minutes the power was off.


Along with these calculations I just added a 20 minute timer to time out - as the UPS keeps the PLC running for almost an hour.
__________________
Never underestimate the quality of idiots that will be running your machines
http://aabeck.com
  Reply With Quote
Old March 15th, 2019, 07:08 PM   #5
Aabeck
Member
United States

Aabeck is offline
 
Aabeck's Avatar
 
Join Date: Feb 2013
Location: Detroit
Posts: 1,339
Yes, if midnight is not going to ever be an issue that would work.


However keep in mind that when a timer gets /DN it skips a scan before starting back timing. For this I would run your timer for 120 seconds, then do a compare GEQ T4:x.ACC 60 then add 1 to n7:0 and SUB T4:x.ACC 60 T4:x.ACC and you will get more consistent timing.
__________________
Never underestimate the quality of idiots that will be running your machines
http://aabeck.com
  Reply With Quote
Old March 15th, 2019, 07:27 PM   #6
Skidood
Member
Canada

Skidood is offline
 
Join Date: Oct 2016
Location: Ontario
Posts: 135
In case you were replying to me, I'm sorry, I deleted the post you were referring to.
I thought I had a solution and posted it but then realized it wasn't good.
Thank you for the answer.


Quote:
Originally Posted by Aabeck View Post
Yes, if midnight is not going to ever be an issue that would work.


However keep in mind that when a timer gets /DN it skips a scan before starting back timing. For this I would run your timer for 120 seconds, then do a compare GEQ T4:x.ACC 60 then add 1 to n7:0 and SUB T4:x.ACC 60 T4:x.ACC and you will get more consistent timing.
  Reply With Quote
Old March 15th, 2019, 07:37 PM   #7
Ken Roach
Lifetime Supporting Member + Moderator
United States

Ken Roach is offline
 
Ken Roach's Avatar
 
Join Date: Apr 2002
Location: Seattle, WA
Posts: 14,796
You could explicitly calculate a Julian Date (the Day of the Year), then calculate the number of seconds equivalent to it. Then you could compare the last-copied value to the powerup value.

The Free-Running Clock zeroes out at power-up, so it's not going to be useful.
  Reply With Quote
Old March 15th, 2019, 07:40 PM   #8
Skidood
Member
Canada

Skidood is offline
 
Join Date: Oct 2016
Location: Ontario
Posts: 135
OK here is what I will try.
PLC writes a zero to N7:0 every night at 00:00 and adds 1 to N7:0 once per minute.
It already continually stores current RTC year, month, hour, minute and seconds to integers.

ON power up:
-if current day, month, or year is greater than the last stored day, month, or year respectively, set the 'abort" bit.
- if hour difference is >1, set abort bit
- if hour difference is LEQ 1, THEN:

Multiply current hour of day by 60 and send to N7:1
Add current minutes to N7:1
If N7:1 exceeds N7:0 by more than 30, set the abort bit.
  Reply With Quote
Old March 15th, 2019, 07:50 PM   #9
Skidood
Member
Canada

Skidood is offline
 
Join Date: Oct 2016
Location: Ontario
Posts: 135
Also, for the logic scanned on the first pass, I was wondering if its better to place the first pass rung(s) at the beginning of the main ladder or at the end of it. Seems to me that putting it at the end makes more sense since all the other ladder logic in the program will be over-ridden by whatever is in the first pass rung. If the fist pass is at the top of the main ladder, the ensuing logic instructions in the rest of the program could over-ride it what i want to accomplish in the first pass. Am I out to lunch here?
  Reply With Quote
Old March 16th, 2019, 07:29 AM   #10
Aabeck
Member
United States

Aabeck is offline
 
Aabeck's Avatar
 
Join Date: Feb 2013
Location: Detroit
Posts: 1,339
Quote:
Originally Posted by Skidood View Post
Also, for the logic scanned on the first pass, I was wondering if its better to place the first pass rung(s) at the beginning of the main ladder or at the end of it. Seems to me that putting it at the end makes more sense since all the other ladder logic in the program will be over-ridden by whatever is in the first pass rung. If the fist pass is at the top of the main ladder, the ensuing logic instructions in the rest of the program could over-ride it what i want to accomplish in the first pass. Am I out to lunch here?
If there is a chance what is written from a First-Pass could be overwritten later in the scan I would put a XIO First-Pass on the other rungs so they were not processed on the first scan.
Also, Since the First-Scan writes 0 to your N7:0 it could do that first, then the rest of your calculations could be completed the same scan without causing any problem.
__________________
Never underestimate the quality of idiots that will be running your machines
http://aabeck.com
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Confusion regarding power supply rating for CompactLogix Salman S. LIVE PLC Questions And Answers 8 March 7th, 2017 05:07 PM
To Latch Or Not To Latch BOWRIDER LIVE PLC Questions And Answers 43 October 21st, 2015 04:19 AM
IEC Timer Elapsed time mapping in WinCC ry_fern LIVE PLC Questions And Answers 0 December 1st, 2010 03:30 AM
Redlion Triggers based on time wutnots LIVE PLC Questions And Answers 5 August 4th, 2010 08:44 PM
S7-416-2 DP Fault - SFB20 sparky64 LIVE PLC Questions And Answers 8 July 30th, 2004 02:48 AM


All times are GMT -5. The time now is 08:39 PM.


.