Today we're kicking off a new series entitled, “Insight's Inbox,” which are articles based on the reader email questions we receive.
I would like to enable some ControlLogix code when it's between 8am and 5pm, Monday through Friday.
How do I do this?
You're in luck, this is definitely do-able with the ControlLogix.
Here are the two steps I would take to make this work:
Part 1) What time is it?
The first step is to find out the current time, which you can read from your processor using a GSV instruction.
Unlike the PLC-5, SLC-500, and MicroLogix, all of which have a status file, to access similar information in a ControlLogix or CompactLogix requires a GSV (get system variable) or SSV (set system variable) instruction.
In this case, to get the time you would use the GSV instruction to read from the WALLCLOCKTIME object and put those values into a tag array of seven DINTs.
Note: More information about the WALLCLOCKOBJECT can be found in the ControlLogix instruction set reference manual.
Learn to Program ControlLogix Programmable Controllers
Next, in the sample code which comes with RSLogix 5000 there is a program called, “DayOfWeek.ACD” which you can use to calculate what day of the week from the time.
At this point you'll have both the current time and the day of week, so you're now ready for step 2 below.
Part 2) Compare the current time and day to your operating range
Now that you have the current time and day of week in your Controller Tags, you'll do some comparisons.
The first comparison I would do is for the day of the week – if it's Saturday or Sunday then you code would not run according to your schedule and you don't need to do any additional comparisons.
The second comparison I would do would be if it's before 8am. If it is, then your code again would be not run according to your schedule and there's no need to do the next comparison.
The final comparison I would do would be to check to see if it's after 5pm. If this last compare is not true then your code should run as the current time is between 8am and 5pm, Monday through Friday.
I hope this article base on an email conversation with a Insight's reader was helpful.
If you have anything you would like to add to the above conversation, or have a question, please don't hesitate to use the “post a comment or question” for at the bottom of this page.
Update: If you have your own question you'd like to ask, please post it as a comment on a related post here at TheAutomationBlog.com
Until next time, Peace ✌️
Shawn M Tierney
Technology Enthusiast & Content Creator
Have a question? Join my community of automation professionals and take part in the discussion! You'll also find my PLC, HMI, and SCADA courses at TheAutomationSchool.com.
Sponsor and Advertise: Get your product or service in front of our 75K followers while also supporting independent automation journalism by sponsoring or advertising with us! Learn more in our Media Guide here, or contact us using this form.
- Automation Morning Show for March 20, 2023 - March 20, 2023
- Updated Picture of Insights In Automation Studio A - March 18, 2023
- Automation Morning Show for March 17, 2023 - March 17, 2023