RSLogix 5000 Clock Design

Krilun

Member
Join Date
Aug 2008
Location
Cleveland
Posts
44
I wrote a clock subroutine (Functional Block Diagram). The clock works fine, however, I cannot find a way to update the clock. If the program crashes and needs to be restarted, I need to have the current time sent in so the clock knows the current time. Does anyone know how to do this?

-Ken
 
I'm not sure if you wrote a routine to keep track of the time, or if you wrote something to time intervals. If you wrote an actual clock, you should probably look into using GSVs and SSVs on the WALLCLOCKTIME attribute. The WALLCLOCKTIME is the CPUs internal clock and will definitely be more accurate than a routine. You need a 7 DINT array to store the time. When you do the GSV with that array as the destination, your array will have the time as [0]->Year, [1]->Month, [2]->Day, [3]->Hour, [4]->Minute, [5]->Second, [6]->Microsecond.

To set the time you fill in another 7 DINT array in the same manner with the date/time you wish to set, and use the SSV instruction.
 
I'd like to actually write an actual clock. What is this GSV and SSV you speak of and where can I find it? Thanks Pandersen
 
The GSV (Get System Value) and SSV (Set System Value) are not available in the FBD language, so you would have to use them in ladder.

ControlLogix already has a clock in it which you can access with those two instructions using the method I posted just before. There is a lot of nice information available about them and the WALLCLOCKTIME class in the RSLogix help file - just search for GSV, SSV, or WALLCLOCKTIME and read everything that comes up.
 
_search.GIF


Do a search on this forum for wallclocktime. There are a ton of threads about using it.

Also there are several tech notes and sample programs in the AB knowledge base. http://www.rockwellautomation.com/knowledgebase/ Do
a search on wallclocktime.
 
Oakley said:
You could develop an AOI that reads the wallclock, then use it in FBD.

Excellent idea!

To get this:
A08302008A.JPG


import this AOI code which calls GSV using the ST language and returns Year, Month, Day, Hour, Minute, and Second to output handles on a function block - requires V16 or greater.
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
     <RSLogix5000Content SchemaRevision="1.0" SoftwareRevision="16.03" TargetType="AddOnInstructionDefinition" ContainsContext="true" Owner="TConnolly" ExportDate="Sat Aug 30 13:08:08 2008" ExportOptions="Context">
     <Controller Use="Context" Name="Time">
     <AddOnInstructionDefinitions Use="Context">
     <AddOnInstructionDefinition Use="Target" Name="GetDateTIme" Revision="1.0" ExecutePrescan="false" ExecutePostscan="false" ExecuteEnableInFalse="false" CreatedDate="2008-08-30T18:45:47.218Z" CreatedBy="TConnolly" EditedDate="2008-08-30T19:06:30.718Z" EditedBy="TConnolly" SoftwareRevision="v16.03"
     >
     <Parameters>
     <Parameter Name="Year" DataType="DINT" Usage="Output" Radix="Decimal" Required="false" Visible="true">
     <Description>
     <![CDATA[WallClockTIme Calendar Year]]>
     </Description>
     <DefaultData>00 00 00 00</DefaultData>
     </Parameter>
     <Parameter Name="Month" DataType="DINT" Usage="Output" Radix="Decimal" Required="false" Visible="true">
     <Description>
     <![CDATA[WallClockTIme Calendar Month]]>
     </Description>
     <DefaultData>00 00 00 00</DefaultData>
     </Parameter>
     <Parameter Name="Day" DataType="DINT" Usage="Output" Radix="Decimal" Required="false" Visible="true">
     <Description>
     <![CDATA[WallClockTIme Calendar Day]]>
     </Description>
     <DefaultData>00 00 00 00</DefaultData>
     </Parameter>
     <Parameter Name="Hour" DataType="DINT" Usage="Output" Radix="Decimal" Required="false" Visible="true">
     <Description>
     <![CDATA[WallClockTime
     Hour]]>
     </Description>
     <DefaultData>00 00 00 00</DefaultData>
     </Parameter>
     <Parameter Name="Minute" DataType="DINT" Usage="Output" Radix="Decimal" Required="false" Visible="true">
     <Description>
     <![CDATA[WallClockTIme Minute]]>
     </Description>
     <DefaultData>00 00 00 00</DefaultData>
     </Parameter>
     <Parameter Name="Second" DataType="DINT" Usage="Output" Radix="Decimal" Required="false" Visible="true">
     <Description>
     <![CDATA[WallClockTIme Second]]>
     </Description>
     <DefaultData>00 00 00 00</DefaultData>
     </Parameter>
     </Parameters>
     <LocalTags>
     <LocalTag Name="wct" DataType="DINT" Dimensions="7" Radix="Decimal">
     <DefaultData>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
     00 00 00 00 00 00 00 00 00 00 00 00</DefaultData>
     </LocalTag>
     </LocalTags>
     <Routines>
     <Routine Name="Logic" Type="ST">
     <STContent>
     <Line Number="0">
     <![CDATA[//AOI - returns the cuttent date and time to individualt instruction outputs for use in FB.]]>
     </Line>
     <Line Number="1">
     <![CDATA[GSV(WallClockTime,,LocalDateTime,wct[0]);]]>
     </Line>
     <Line Number="2">
     <![CDATA[Year:= wct[0];]]>
     </Line>
     <Line Number="3">
     <![CDATA[Month:=wct[1];]]>
     </Line>
     <Line Number="4">
     <![CDATA[Day:=wct[2];]]>
     </Line>
     <Line Number="5">
     <![CDATA[Hour:=wct[3];]]>
     </Line>
     <Line Number="6">
     <![CDATA[Minute:=wct[4];]]>
     </Line>
     <Line Number="7">
     <![CDATA[Second:=wct[5];]]>
     </Line>
     <Line Number="8">
     <![CDATA[]]>
     </Line>
     </STContent>
     </Routine>
     </Routines>
     </AddOnInstructionDefinition>
     </AddOnInstructionDefinitions>
     </Controller>
     </RSLogix5000Content>

(To import, paste code into notepad and save with a .L5X extension. Then right click "Add On Instructions" in the Logix5000 project tree, and select "Import Add On Instruction")
 
Hi Alaric.
Nice job.
If you do a search on the Rockwell website there is code to calc the day of week from the date variable. Would be nice to integrate that into the AOI as well. It was a project I was always going to do but never got around to it.
Regards Alan Case
 
Alan Case said:
Hi Alaric.
Nice job.
If you do a search on the Rockwell website there is code to calc the day of week from the date variable. Would be nice to integrate that into the AOI as well. It was a project I was always going to do but never got around to it.
Regards Alan Case

Come on Alaric, half a job isnt good enough !!! :) :) :)
 
Yeah, I'll get right on that... and while I'm at it I'll add a Julian date output as well. Anyone need sunrise/sunset? I think I also did one of those, so may as well roll it in. o_O
 
Hi Alaric. I wasnt trying to be pushy and suggest that you code it but more of an open invite to someone who had the time or the inclination to expand the AOI out a bit.
But while you are at it a sunrise/sunset time would be nice.
We should be able to calc our latitude approx from the difference between the GSV time and localtime.
Regards Alan Case
 
Alaric, awesome job! Thank you a lot, that will surely help me in my future work.

However, sigh... I need to stick with version 15 on the project I'm working on currently. So I use a GSV in ladder logic to get the date, however the date receieved is incorrect. It claims the year is 1998... basically everything is not right.

Is there a way to display the current correct date? Is there something I'm not doing?
 
The BIOs is indicating the correct time on the processor. The GSV should be syncing the two clocks but it doesn't seem to be working
 
Alan Case said:
Hi Alaric. I wasnt trying to be pushy and suggest that you code it but more of an open invite to someone who had the time or the inclination to expand the AOI out a bit.
But while you are at it a sunrise/sunset time would be nice.
We should be able to calc our latitude approx from the difference between the GSV time and localtime.
Regards Alan Case

Hey Alan, (and 504bloke) I knew that - I was kidding around and being sarcastic :ROFLMAO:- I guess the tone didn't come through. Cheers. 🍺
 

Similar Topics

I need a clock for a 1756-l72 ver 20. I can not use the wall clock because it is used for reporting. i need a clock that the time can be changed...
Replies
3
Views
2,105
Hello I need to make a pulse every second of RSlogix the 5000th I have read this thread through and tested it as rdrast writes in Post # 14...
Replies
4
Views
6,000
I would like to reset a counter at the end of the and say at Sunday at 6pm this there a system clock bit I can use for this? Do I use a equals...
Replies
1
Views
3,331
Hello all, I have a question in regards to RSlogix 5000. I am having issues with the program force closing when I try to make online edits. We...
Replies
0
Views
95
Greetings ... someone sent me a request for some student handsouts that I developed ... turns out that I had this hosted on my business website...
Replies
0
Views
109
Back
Top Bottom