Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: EDurako on April 30, 2019, 02:11:44 PM
-
I have searched to the best of my ability and not found the correct keywords to remedy my issue. I seem to be having a mental block.
I would like to have a pump (Y23) only energized if the current time is between 0545 and 1630 Monday through Thursday. I have tried several things and can't seem to find the secret recipe.
I tried a "greater than or equal to" between SDT0.Time and 01054500 and "less than or equal to" SDT0.Time and 01163000. Both of these numbers were changed by the program (see screen shot). I thought if that would work I could repeat it for the days of the week I want to run.
I then tried looking into the DTCMP command, I couldn't figure out how to get Monday morning in the "second time" slot.
I have a makeshift long logic (see screen shot) that is currently working, but I know that there is a more sophisticated way to execute this.
Please help
-
The .Time is a DWORD representation of the Day of Week, Hour, Minute, Second as BYTEs. Don't use that.
-]SDT0.Hour == 5[-----]SDT0.Minute >= 45[---+----]SDT0..DayOfWeek >= 1[----]SDT0.DayOfWeek <= 4[------------------(OUT)
|
-]SDT0.Hour >= 6[-----]SDT0.Hour <= 15[-----+
|
-]SDT0.Hour == 16[----]SDT0.Minute <= 30[---+
-
Thank you very much, I think I properly deciphered your reply (screen shot).
BY FAR way cleaner than the way I was looking at it. :)
-
What I like to do is create symbolic constants for the days of the week.
On the Doc Editor, click Symb button to create a Symbolic Constant (one for each day of the week)
So,
Sun equals the decimal constant 0
Mon equals the decimal constant 1
Tue equals the decimal constant 2
?
Sat equals the decimal constant 6
THEN I your Ladder Logic, replace the .DayOfWeek comparison (right side) from the decimal constants to these symbolic constants (Mon and Thu):
]SDT0..DayOfWeek >= Mon[----]SDT0.DayOfWeek <= Thu[
and the code reads much better. Attached is a screen shot. Note how the "Extra Info" field reveals the constant value above the symbolic name (nickname), so you get both the symbolic name AND its value!
-
I also like to create a four digit variable for hours/minutes, so then you can do the time gates in one shot, instead of separate hour and minutes comparisons.
-
I will try to execute the doc editor tomorrow when I get back into work. I?m so thankful for this forum. I wish I could figure out how to do an advanced search to narrow my results
-
Geez, what the hell did he ever do to you?
-
I wish I could figure out how to do an advanced search to narrow my results
Use Google. e.g.
"day of week" site:forum.hosteng.com