![]() ![]() ![]() ![]() ![]() ![]() |
||
![]() |
||
![]() ![]() ![]() ![]() This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc. |
||
![]() |
![]() |
#1 |
Lifetime Supporting Member
![]() ![]() Join Date: Apr 2019
Location: Oklahoma
Posts: 28
|
Logix5000 DateTime
Good Afternoon,
I am playing with the GSV WallClockTime and an AOI i downloaded off the Rockwell website to try and return a day of week for a schedule. I have not worked with Time or an AOI before and was wondering if anyone could give me some pointers. I attached a screenshot of how I did it, is there a better way or some sort of best practice for this? The AOI from the Rockwell website is ID 78066 "Day of the Week given date (AOI in ST, AOI in LD) Thanks |
![]() |
![]() |
#2 |
Lifetime Supporting Member
|
I am not sure I understand the query.
The image shown ensures uses GSV and WallClockTime/LocalDateTime (cf. this link) to ensure the current Year, Month and Day-of-Month are in attributes .Inp_Year, .Inp_Month, and .Inp_Day, respctively, of object DayOfWeek. If the DayOfWeek.Inp_Day has changed since the last time this AOI was called with this DayOfWeek, the second AOI, DayOfWeek_LD, is called with object DayOfWeek, with converts that year, month, and day of month to day of week, probably using an algorithm like the one at this link; I suspect it puts a day of week (e.g. 0-6 where 0=Sunday, 1=Monday, etc., 6=Saturday) in attribute DayOfWeek.WeekDay (or similar). _
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() |
![]() |
![]() |
#3 |
Lifetime Supporting Member + Moderator
![]() ![]() Join Date: Jul 2004
Location: uk
Posts: 5,387
|
I think it is bizarre that they don't use a more modern RTC chip in their controllers that provides the day-of-the-week as an output.
The AOI code is lengthy, and to have to perform that somewhat complicated set of maths to arrive at the day of the week is pretty poor. Even cheap digital watches have it built-in. Perhaps RA need to update their hardware from something built in the 1980's
__________________
___________________________ Everything works with smoke. Let it out, and it stops working. Nil Carborundem Illegitimi |
![]() |
![]() |
#4 |
Lifetime Supporting Member + Moderator
|
Version 34 (I think) has date and time tag datatypes . One could be led to believe these datatypes would have a more direct route to the Wallclock and sort all that out...
I haven't tested this assumption yet
__________________
. . . and then I pronounced myself an idiot, to which there was general agreement and merriment . . . |
![]() |
![]() |
#5 |
Lifetime Supporting Member
|
For simplicity sake, I did my own logic for day of the week and it's very simple. The only issue with it is that you need to manually set the day of the week on PLC download/powerup.
|
![]() |
![]() |
#6 |
Lifetime Supporting Member
|
It's using a sledgehammer to crack a nut, and I don't know if it would be worth the effort or if the network infrastructure exists, but a RaspberryPI or other SBC running a mini-server and almost any protocol (e.g. Modbus) could provide the day of week, and then the code in the PLC is a single instruction (MSG?) that need only know the IP address, port, and protocol of the mini-server (or it could even use a serial line), and executes in the 0.1-1Hz range. The SBC would only need power and connectivity to an NTP server, and the server configuration and configuration is an all but trivial exercise.
S:~$ python -c 'import datetime;print(datetime.datetime.weekday.__doc__)'Return the day of the week represented by the date.
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() |
![]() |
![]() |
#7 | |
Lifetime Supporting Member + Moderator
![]() ![]() Join Date: Jul 2004
Location: uk
Posts: 5,387
|
Quote:
High time the controllers got a decent RTC
__________________
___________________________ Everything works with smoke. Let it out, and it stops working. Nil Carborundem Illegitimi |
|
![]() |
![]() |
#8 |
Lifetime Supporting Member + Moderator
![]() ![]() Join Date: Jul 2004
Location: uk
Posts: 5,387
|
It won't work for everyone - should be automatic ...
__________________
___________________________ Everything works with smoke. Let it out, and it stops working. Nil Carborundem Illegitimi |
![]() |
![]() |
#9 |
Lifetime Supporting Member + Moderator
![]() ![]() Join Date: Jul 2004
Location: uk
Posts: 5,387
|
The LINT data-type has been around for many versions prior to V34. The only format for it's display was date/time. There were no instructions that could use that data. Perhaps V34 allowed it to be used, but I have no knowledge of that...
__________________
___________________________ Everything works with smoke. Let it out, and it stops working. Nil Carborundem Illegitimi |
![]() |
![]() |
#10 | |
Member
![]() ![]() Join Date: Sep 2009
Location: Melbourne
Posts: 28
|
Quote:
They would also have to deal with the backwards compatibility (so couldn't change existing WallClock etc GSV functions). Plus that would only solve for current date/time day of week, not future / past... The custom AOI doesn't seem like it would be so difficult. There are cut down formulaes for it if you only care about recent times.. to do the calculations for historical times it can get pretty crazy pretty quickly.. like back in early Roman times when the calendar only had 10 months. |
|
![]() |
![]() |
Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Modicon M580 PLC - Comparing DateTime | joeburmeister | LIVE PLC Questions And Answers | 3 | March 4th, 2021 05:27 PM |
Time Array Comparison Logix5000 | whussain6 | LIVE PLC Questions And Answers | 3 | May 17th, 2016 10:52 AM |
Logix5000, ControlNet fault with code 16#0022 and 16#0203 | wendaiyu | LIVE PLC Questions And Answers | 1 | February 22nd, 2016 11:23 AM |
Mapping Inputs in Logix5000 | Bering C Sparky | LIVE PLC Questions And Answers | 11 | November 12th, 2014 10:03 AM |
+ or - for Logix5000? | Rob D. | LIVE PLC Questions And Answers | 26 | May 19th, 2006 06:06 PM |