ControlLogix GSV Command (WallClockTime) 11


Intdoduction to ControlLogix GSV Command (WallClockTime)

In this post, we will discuss the ControlLogix GSV Command (WallClockTime).  Earlier processors, such as the SLC-500 and PLC-5 had a data file dedicated to system status (S2).   In the S2 file, you could find the data table addresses of system information such as the date and time, forcing status, faults, processor status, I/O status, etc.    We know that on a new ControlLogix project there are no tags whatsoever.   If you need any status from the system, you will use the GSV command.   The GSV command is a simple copy command.   The GSV gets data from the system (where we cannot see it).  Then it copies the data to a tag where we can see the data and use it in our project.

In this post, we will access the WALLCLOCKTIME object.  This object has several attributes.   Imagine a large clock on the wall with different sections.  These sections would be the attributes.  One section would display the current time in our own time zone.   Another section (attribute) would be for UTC.  Yet another section would display the total number of seconds that have passed since Jan 1, 1970.   This is good for time stamping because simple seconds are easy to compare without worrying about days, months, and years.

The attribute that we will talk about in this post will be the LocalDateTime.   For other attributes, and other classes in the GSV command, consult the help file.

Create your tag

This tag will store 7 DINT’s (Double Integers), so we will make this tag an array.   The seven elements of this tag will contain:  Year, Month, Day, Hour, Minute, Second, and MicroSeconds.

In this case, we’ll go to the controller tag database, and in “Edit Tags” Mode, create a tag called SystemTime.  You can name the tag anything you like, though, as long as you follow the guidelines for creating a tag.

System Time

Click the ellipsis (the three dots) next to the data type of DINT to get to the setup screen for the data type, then run DIM0 up to 7.   This will create the array of 7 DINTS that we need.   An array is just a group of elements with the same name, and same data type, but a different index after each one.

DINT Setup

Now, expand your SystemTime tag by clicking the “+” next to SystemTime, and you will see that we have all 7 elements.   Here, I will also add a description of what each of the 7 elements are used for.

Array Descriptions

Next, go to “Monitor Tags” Mode.   You will see that the tag has no data.   This is because we did not execute the GSV command yet.

GSV No Data

Add your logic for the ControlLogix GSV Command (WallClockTime)

I’m going to put the GSV Command into the MainRoutine.    The class will be “WallClockTime”, and the attribute will be “LocalDateTime”.   Our destination is the first element of the array that we just created, which is SystemTime[0]. Keep in mind that older versions of RSLogix / Studio 5000 only have the “DateTime” attribute. Older versions (I believe v13 and lower) do not support the time zone offset. This is why when you upgrade from an earlier version, you might get a warning about the “DateTime” attribute.

GSV Instruction

Now, I’m going to download my work.   If you are online, just finalize your edits.  Then we’ll go back to the Controller Tag Database, and “Monitor Tags”.

Values Wrong

Notice that our values are wrong.   Changing the values here seems to have no effect.   This is because if you change a value here, the value is immediately changed back to the value of the system clock as soon as the GSV Executes again. We need to change this in the system itself.

Set the Time

To set the time, we will do this at the source.   Go to “Controller Properties”.   To get to controller properties, you can right-click the controller to get to properties.   Another option is to press the controller properties icon, which is directly beneath your keyswitch in the online toolbar.

Controller Properties

Next, click the Date/Time tab to set the date.

Set Date Time

If you click “Set Date, time, and Zone from Workstation”, the time will be loaded from your PC into the processor.   If the time is still incorrect, you can adjust the fields accordingly.    Note:  The checkbox does NOT automatically adjust for daylight savings time.   It just adds an hour if we are currently on DST.  If you want to automatically adjust for DST, you have to write logic for that.  Soon, you might not have to worry about that anymore though.  There is currently legislation in congress to eliminate standard time, and this could happen in 2023.

Another option to automatically adjust the system time is to use the clock update tool.  Basically, this is just a service that runs on your PC to update your processors automatically.

Now, your tags will read the proper values:

Correct Time

Read here on how to implement a UDT with the GSV Command.   In this  post, you will end up with tags such as Time.Year, Time.Month, etc.

For more information on ControlLogix, visit the ControlLogix Post Page!

— Ricky Bryce


Leave a comment

Your email address will not be published. Required fields are marked *

11 thoughts on “ControlLogix GSV Command (WallClockTime)

  • Matt Reinker

    Thank you very much!
    Just what I needed and explained and illustrated to show me how to do it.
    Definitely bookmarking this page.
    Thanks,
    P.S. I also read the creation part during my lunch break.

    • Ricky Post author

      Yes, sir! The GSV won’t get the day of week for you by itself, but Rockwell has a good sample that should already be installed on your computer when you installed RSLogix 5000. The default location of this sample is located in C:\RSLogix5000\Projects\Samples\ENU\vxx\Rockwell Automation\DayOfWeek.ACD. I checked it on mine, and it’s already there on version 13, 16, and 20. I would think most all of the versions would have that sample. If you can’t find it, let me know, and I’ll email the sample file over to you. You can just export those rungs and import them into your own project. The sample code already has the GSV instruction, and a UDT for both the GSV and the DOW (Day Of Week). Take care! — Ricky

  • Jerry Pitt

    This is great information and very helpful although my time setting in the controller changes randomly and almost daily . Also sometimes completely goes back to not set at all . I used an SSV function to set the GSV time and date originally . Any Ideas ?

    • Ricky Post author

      There are a few things I can think of that might cause that. Which processor do you have? Just a few questions:
      1) Is your SSV still in the program? What triggers it? Is it inadvertently executing? If there is a condition before the SSV, Cross reference that bit, and see if it’s used anywhere else.
      2) Battery / Energy Storage OK? If your program loads from an SD card, or CompactFlash, then you could be loosing the time at power down, and not realizing you lost the memory if it re-loads at power up.
      3) Are you using the clock update tool on any computer with an invalid time?
      4) I don’t know if this is an issue anymore, but in the older versions, it was possible to copy data past a file boundary. For example: Let’s say I perform a file fill, and fill an array with 100 zeros. If the array was only 50 words long, Then who knows where those extra zero’s end up? They could be getting into parts of memory where you don’t want them.

      Those are just a few things I can think of to check off the top of my head.
      — Ricky