Contact and Coil | Nearly In Control



Reading the ControlLogix System Time in Ladder Logic

Since I’m in the tutorial mind-set right now, I thought I’d mention this little gem. Here’s how you can read the ControlLogix (or CompactLogix) PLC system time into a UDT so you can use the current time value in your ladder logic program.

First I created a UDT called “TIME”:

RSLogix 5000 - Read System Time - UDT

Then you just need to use the GSV (Get System Value) instruction with the WallClockTime class, and LocalSystemTime attribute to read the controller’s time into an instance of your UDT (here I created a new tag called LocalDateTime of type TIME). Note that I used the Year element of the LocalDateTime tag as the parameter, because that’s the first address of the tag. It starts writing there but fills in the entire UDT with the time values:

RSLogix 5000 - Read System Time in Ladder Logic

Now you can program your sprinklers to turn on and off in the middle of the night! :)



  • Steve · August 18, 2010 at 10:43 pm

    Needed something like this to transfer system time to an rsview register for an event time stamp.
    still struggling with defining the tag values, and getting the proper response.
    can you send me the exact step by step, I intend to use a one shot to fire it

  • Author comment by Scott Whitlock · August 19, 2010 at 12:17 am

    @Steve, unfortunately I don’t have a running ControlLogix around here right now, so I can’t go online and verify it. But the steps are straightforward: create the UDT as shown above, create one (controller scrope) tag called LocalDateTime of type TIME, and then enter the GSV instruction shown above. However, you’ll need some logic to fire it. I believe it’s an asynchronous instruction, so a one-shot may not work. Check the F1 help docs to be sure.

  • Jack · March 21, 2012 at 9:01 am

    Thanks. Worked great for me. I then used a one shot to capture the time of a reset, then Wonderware to display on my HMI.

  • Dennis Gulliver · January 24, 2013 at 12:47 pm

    Exactly what I couldn’t figure out thanks

  • Chris White · November 7, 2013 at 4:04 pm

    Its also worthwhile noting, that if you create a new Periodic Task under Tasks, with a periodic time of around 10msec, Add a Program and subsequent LAD file, you can pull back an awful lot of wasted scan time compared to running the GSV in a Continuous Task.

    GSV’s are very scan time hungry, so throwing non critical instructions into a periodic task really lightens the burden on the processor.

  • Doug · February 17, 2015 at 2:08 pm

    Works great. Thanks for the information!

Leave a Reply



Theme Design by