PDA

View Full Version : RSLogix 5000 Clock Design


Krilun
August 29th, 2008, 08:37 AM
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

pandersen
August 29th, 2008, 09:09 AM
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.

Krilun
August 29th, 2008, 09:12 AM
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

pandersen
August 29th, 2008, 09:18 AM
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.

TConnolly
August 29th, 2008, 07:26 PM
http://www.plctalk.net/qanda/uploads/_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
August 30th, 2008, 07:46 AM
You could develop an AOI that reads the wallclock, then use it in FBD.

TConnolly
August 30th, 2008, 02:21 PM
You could develop an AOI that reads the wallclock, then use it in FBD.

Excellent idea!

To get this:
http://www.plctalk.net/qanda/uploads/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.
<?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")

Alan Case
August 30th, 2008, 07:34 PM
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

504bloke
September 1st, 2008, 04:09 PM
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 !!! :) :) :)

TConnolly
September 1st, 2008, 11:32 PM
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. :banghead:

Alan Case
September 2nd, 2008, 04:47 AM
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

Krilun
September 2nd, 2008, 07:47 AM
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?

Oakley
September 2nd, 2008, 08:41 AM
Adjust the clock settings of the processor.

Krilun
September 2nd, 2008, 09:02 AM
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

TConnolly
September 2nd, 2008, 11:17 AM
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 :lolis:- I guess the tone didn't come through. Cheers. :beer:

Krilun
September 2nd, 2008, 12:20 PM
I found a way to sync the clock on PC and my PLC. There is a tool you can download that syncs them and it worked great.

Contr_Conn
September 5th, 2008, 04:38 PM
take a look at tn 54858

TConnolly
September 5th, 2008, 05:12 PM
take a look at tn 54858

Posted to the KB yesterday, with attribution to this forum. :D

Contr_Conn
September 5th, 2008, 05:19 PM
Just keep in mind very high execution time for LocalDateTime, looks like firmware does some complicated math calculating local time

http://www.rakb-images.com/images/54909-1.jpg

This is from 1756-RM087

FrancisTan
January 13th, 2010, 04:54 PM
Rockwell changed the WallClockTime for the newer version of Logix 5000. In order to get the local hours, you must use LocalDateTime in the Attribute Name in the GSV instruction. Otherwise element 3 of the result will be displayed in GMT.