If the need arises to use specific time in your ladder logic program, this guide will give you a reference to go by.
Possibly you have a cleaning device that only needs to operate once an hour or once a day or maybe you want to operate a whistle at noon every day, the easiest way to accomplish this task would be to use the Controller’s time (which lives in the memory of the controller).
The value of the controller’s clock is not readily available in the controller tag database, but rather you must make a request in the ladder program to access it.
Along with many other attributes available from the controller, you can use a GSV (Get System Value) Instruction to access this attribute.
This short guide will take you through setting up this request and then using it to accomplish a task.
Create a line of ladder and in the instruction palette under “Input/Output”, choose a “GSV” Instruction and set up the following:
Class Name: WallClockTime
Attribute Name: DateTime
Dest: CurrentTime (This is a tag you will create, DINT type with an array of 7)
Write your logic changes.
Right-Click on “CurrentTime” and Select Monitor to view the tag in the controller tag database
DINT = Year
DINT = Month (1-12)
DINT = Day (1 – 31)
DINT = Hour (0-23) This value is GMT, no matter the controller time zone setting
DINT = Minute (0-59)
DINT = Second (0-59)
DINT = Microseconds (0-999,999) Never had to use it, but I guess it is a possibility
To Activate an Output for a Solenoid on the Hour, Every Hour for five seconds
Create a new ladder rung with an EQU instruction and use the CurrentTime to see if the “Minute” of the controller time is equal to “0”.
If the controller’s time (in Minutes) is equal to “0”, then start a timer for 5 seconds. During that time, you can use the Timer.TT bit to turn on the output for the solenoid in the same rung or you can add an additional rung as shown below to accomplish this.
Keep in mind there are many attributes to obtain by request to a controller via the GSV (Get System Value) instruction and there is an entire library of information on how to get almost any needed value that you would like to obtain.
Using the controller’s time is just one of them, but a very useful one. I have used it many times for reporting, shift changes, whistles and a myriad of reasons. It is a standard logic that I place in every controller that I set up.
My best to you in making the needed logic changes that need to happen on time, every time!
Written by Brandon Cooper
Senior Controls Engineer and Freelance Writer
- PanelView 800 – Datalogging and Trending - August 10, 2021
- PanelView 800 – Using the Recipe Feature - August 3, 2021
- SIMATIC HMI Basic Panel – Using the Recipe Feature - July 27, 2021