Sign in to follow this  
Followers 0
Beuwolf_1

Simple problem but driving me nuts!

5 posts in this topic

I know I must be missing some thing but what I'm looking for is a bit of sample code or insite into an IBOX that will allow me to enter a time, Hour and Minute, for an operation to start and a time in Hour and Minute to stop. I need it to automatically start and stop if the times are changed. I have no problem with the start and stop I have now but my boss would like it to sequence correctly in real time if the schedule is changed. I am using an equals on start and preset hours and minutes to start and stop. But if the start time is set earlier or later, you need to wait till the next start time for it to correct. He would like it to monitor the presets all the time and start and stop as the presets change. While the screen capture isn't clear it should give you an idea of what I'm presently doing. If equal to hour and minute start time, latch the output. If equal to hour and minute stop time, reset the bit. Once its latched, changing the times require it to complete what it has first and then go. So if anyone has an idea or example or an instruction set I have missed, I sure would appreciate it. Thanks in advance

Share this post


Link to post
Share on other sites
It seems that you have two possible start and stop times for each day. I'm guessing that there are two segments of time in each day for the operation to be on. Is it possible that they will overlap? First of all, for each hour/minute point (it doesn't matter if they are ON or OFF times, create a rung ending in a C bit. The rung has the following format: System Hour Event Hour C20 Saturday 1 ON ----+----| > |-----------------------------------------+---------( ) | | | System Hour Event Hour System Minute Event Minute | +----| = |----------| >= |-------+ (I hope you got it from that. The 'C20 is describing the contact at the end. Let's take Saturday. You have a rung for each of 'Saturday 1 ON', Saturday 1 OFF', 'Saturday 2 ON' and 'Saturday 2 OFF' So you combine them like this: System Is Saturday Saturday 1 ON Saturday 1 OFF C201 -------| |----------+----------| |----------------|/|-----------+---------( ) | | | Saturday 2 ON Saturday 2 OFF | +----------| |----------------|/|-----------+ Note that the reference to C201 IS NOT A SET, it is just an OUT This will turn C201 ON/OFF even if the times are changed. From your naming I will take it that the ON times do not cross midnight. if they can you have another can of worms to open. If you specify your CPU maybe I can come up with a more specific idea. Edited by b_carlton

Share this post


Link to post
Share on other sites
Beuwolf_1, This is my attempt (it's never as clean as Bernie's). If you need two separate events you will need to expand on this. PLC 06 // Rung 1 // Address 0 #BEGIN COMMENT "What I'm tring to do is make a value in a Dword that corresponds to the day hour and " "minute in the PLC RTC" #END STR SP1 LD V7770 MUL K100 ADD V7767 OUT V2000 LD V7771 OUT V2001 // Rung 2 // Address 7 #BEGIN COMMENT "What I'm tring to do is make a value in a Dword that corresponds to the day hour and " "minute for the desired turn on time from the HMI " #END STR SP1 LD V5000 MUL K100 ADD V5001 OUT V2002 LD V5002 OUT V2003 // Rung 3 // Address 14 #BEGIN COMMENT "What I'm tring to do is make a value in a Dword that corresponds to the day hour and " "minute from the desired turn off time in the HMI" #END STR SP1 LD V5003 MUL K100 ADD V5004 OUT V2004 LD V5005 OUT V2005 // Rung 4 // Address 21 STR SP1 LDD V2000 CMPD V2002 AND SP62 OUT C0 // Rung 5 // Address 26 STR SP1 LDD V2000 CMPD V2004 AND SP60 OUT C1 // Rung 6 // Address 31 STR SP1 LDD V2002 CMPD V2004 AND SP62 OUT C2 // Rung 7 // Address 36 STR C0 AND C1 ANDN C2 OUT C3 // Rung 8 // Address 40 STR C0 ANDN C1 AND C2 OUT C4 // Rung 9 // Address 44 STR C3 OR C4 OUT Y0 // Rung 10 // Address 47 END // Rung 11 // Address 48 NOP #BEGIN ELEMENT_DOC "Y0","","","output" "C0","","","turn on bit" "C1","","","turn off bit" "C2","","","turn off day of week is lower than turn on day of week" "C3","","","output needs to be on and values are not inverted" "C4","","","turn off day of week is lower than turn on day of week and output needs to be on" "V2000","","","hours and minutes RTC When used as a dword contains day of week hours and minutes" "V2001","","","day of week RTC" "V2002","","","hours and minutes HMI When used as a dword contains day of week hours and minutes ON" "V2003","","","day of week HMI ON" "V2004","","","hours and minutes HMI When used as a dword contains day of week hours and minutes OFF" "V2005","","","day of week HMI OFF" "V5000","","","contains the hours of the HMI turn on clock time (0-23)" "V5001","","","contains the minutes on the HMI turn on clock time (0-59)" "V5002","","","Contains the day of the week HMI turn on clock time(Mon., Tues., Wed., etc.)" "V5003","","","contains the hours of the HMI turn off clock time (0-23)" "V5004","","","contains the minutes on the HMI turn off clock time (0-59)" "V5005","","","Contains the day of the week HMI turn off clock time(Mon., Tues., Wed., etc.)" "V7767","_V7767","Sys","contains the minutes on the clock (0-59)" "V7770","_V7770","Sys","contains the hours of the clock (0-23)" "V7771","_V7771","Sys","Contains the day of the week (Mon., Tues., Wed., etc.)" "SP60","","","on when the value in the accumulator is less than the instruction value" "SP61","","","on when the value in the accumulator equals the instruction value" "SP62","","","on when the value in the accumulator is greater than the instruction value" #END Edited by milldrone

Share this post


Link to post
Share on other sites
As a side note - we had a few semi-defective DL06s lying about (1 output destroyed, our fault) and the management suggested break bell controllers. I couldn't let it go a simple compare to fixed times. (And I had a couple of free hours on my hands) I let them define (in terms of ON/OFF pulse times) what one bell would sound like and assign a name. Then I let them define a day in terms of trigger times and what type defined bell for each and assign a name. Then they define the current week in terms of the pre-defined days. I linked the DL06 units (4 buildings with possibly different time setups) via our plant Ethernet and a VB program on the manager's desk. So they defined 3 bell types (this is using the VB program - I didn't have to program these) A solid on - 3 seconds - used for start of day, end of day, start of break, end of break A two pulse - used for warnings 1 minute before start of day, end of break A three pulse - used for 'cleanup' near the end of the day. They defined the work day and defined a weekend day (no bells) They initially filled the week with 5 normal days and two weekend days. When we changed from 8 to 10 hour days (4 days a week) they just made a new day type and plugged that into the work week making Friday a 'weekend day'. I have to re-synch the internal RTCs about once a month but that's all the maintenance I do (takes about 1 minute total) If they change a timing the program re-runs the day but skips any times which have already passed and stops waiting for the next event to take place. It was fun to do.

Share this post


Link to post
Share on other sites
Thanks for the help. The multiply by 100 got me to thinking. After that it was all downhill from there. I knew I was missing something simple and that got the ball rolling. Thanks again for the assistance. Even the Boss thought it was a cool idea. LOL

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0