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.
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
Sponsor and Advertise: Get your product or service in front of our 70K 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 or by calling our office at 413-749-4300.
- New SIEMENS Products From This Week's Virtual Tour - May 20, 2022
- Sharing Data Between A-B Programmable Controllers - May 19, 2022
- Stepless Multi-Variable Closed Loop PID Tuning from PiControl (P102) - May 18, 2022