Using the System Clock in PLC Program

matt4276

Member
Join Date
Jun 2016
Location
Pennsylvania
Posts
12
I am using a Studio 5000 with an Allen Bradley CompactLogix 1769-L24ER-QB1B controller. Im wondering how I can use the system clock to be able to display the actual time on an HMI screen and be able to program lights to turn on for a certain time at a specified time. Im thinking that I might be able to use a GSV instruction but im not really sure how it works and cant find much information on it. Any help is appreciated.
 
Hit F1 in Studio 5K and search for GSV. This gives you a lot of information.

What you're looking for is the WALLCLOCKTIME object.

It's very useful to have defined a UDT containing seven DINT objects corresponding to the returned WALLCLOCKTIME Year, Month, Day, Hour, Minute, Second, Microsecond.

If you choose to develop a precision timing and pulse emission utility shared by other controller programs, you will understand its value.
 
Last edited:
I am using a Studio 5000 with an Allen Bradley CompactLogix 1769-L24ER-QB1B controller. Im wondering how I can use the system clock to be able to display the actual time on an HMI screen and be able to program lights to turn on for a certain time at a specified time. Im thinking that I might be able to use a GSV instruction but im not really sure how it works and cant find much information on it. Any help is appreciated.

All the info you need is built into Studio5000 Help system...

Just highlight the GSV instruction mnemonic, and hit F1....

Scroll to the bottom of the help page, and hit the link to "GSV/SSV" Objects, scroll down the next page to find the link to "WallClockTime"

To GSV the WallClockTime, you will see you need a DINT[7] array for the destination of the GSV.

[0] Year
[1] Month
[2] Day
[3] Hour
[4] Minute
[5] Seconds
[6] uSeconds

The destination for the GSV will then be TagName[0]

Alternatively, create a UDT containing 7 DINTs, with them named

.Year
.Month
.Day
.Hour
.Minute
.Seconds
.uSeconds

The destination for the GSV will then be TagName.Year

Ask if you need more help...

JeremyM was quicker !
 
Thanks everyone! It makes sense to me now. I couldn't get it to work at first because I didn't know that the first element of the array needed to be used for the destination instead of the array name (Clock[0] instead of just Clock). Was not aware that it would automatically populate the rest of the array.
 
Thanks everyone! It makes sense to me now. I couldn't get it to work at first because I didn't know that the first element of the array needed to be used for the destination instead of the array name (Clock[0] instead of just Clock). Was not aware that it would automatically populate the rest of the array.

The GSV just overlays the data it receives to the location specified as the destination, and subsequent locations as needed. You can GSV into any array starting point - e.g. ProductionData[120]

However it won't go "outside" of the tag specified.

Recommended the UDT route - makes the code more readable....
 
So now I face another problem. Say the time is 18:00 and I want a light to turn on in 12 hours which would be 6:00 the next day buy using the value of 12 on an HMI screen. How would I use the GSV values to make this happen?
 
So now I face another problem. Say the time is 18:00 and I want a light to turn on in 12 hours which would be 6:00 the next day buy using the value of 12 on an HMI screen. How would I use the GSV values to make this happen?

Turn your clock data into a larger DINT value...

(Day*24) + (Hour)

...will allow you to do something up to 31 days from now.
 
The most I would ever want to go in advance is a max of 24 hours. I guess my question is if I say turn on in (Current Hour + Input Hours) as in (18:00 + 12:00) will it know that it means 6:00 or will it never come on because it is going to be looking for 30:00 which never happens?
 
off the top of my head
you could always include days in calculation ie
if (Current Hour + Input Hours) > 24 Then (Current Day + 1) AND (Current Hour + Input Hours) - 24

or set up an hour pulse and use counters to trigger event when counters hits input hours.

the last time I did something similar I used an epoch clock
 
Last edited:

Similar Topics

Hello everyone, I'm working on a project that involves controlling an array of nozzles within a CNC environment, where the nozzles travel along a...
Replies
5
Views
190
I've been tasked with modifying a current hmi program for the addition being added to the cell (auto/manual ,I/O ,Status). When I try to upload...
Replies
2
Views
430
Dear All, Currently I'm working for PICO Hydro system that installed at remote rural area which there have no power supply from service...
Replies
3
Views
1,482
I work for a used industrial machinery merchant. We try to get uploads from all our machines for future customer support and security. We have a...
Replies
0
Views
850
I use a lot of different control system platforms and software packages while doing my projects, but one stands out as being the one I absolutely...
Replies
30
Views
21,346
Back
Top Bottom