You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

Reply
 
Thread Tools Display Modes
Old May 20th, 2022, 02:35 PM   #1
eight_bools
Lifetime Supporting Member
United States

eight_bools is offline
 
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
Attached Images
File Type: jpg DateTime.jpg (105.3 KB, 121 views)
  Reply With Quote
Old May 20th, 2022, 03:44 PM   #2
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 5,152
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
  Reply With Quote
Old May 23rd, 2022, 01:24 AM   #3
daba
Lifetime Supporting Member + Moderator
United Kingdom

daba is offline
 
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



  Reply With Quote
Old May 23rd, 2022, 03:32 PM   #4
TheWaterboy
Lifetime Supporting Member + Moderator
United States

TheWaterboy is offline
 
TheWaterboy's Avatar
 
Join Date: May 2006
Location: State of Denial
Posts: 1,419
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 . . .
  Reply With Quote
Old May 24th, 2022, 11:23 AM   #5
harryting
Lifetime Supporting Member
United States

harryting is offline
 
harryting's Avatar
 
Join Date: May 2002
Location: Puget Sound
Posts: 2,478
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.
  Reply With Quote
Old May 24th, 2022, 12:03 PM   #6
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 5,152
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.
Monday == 0 ... Sunday == 6
$ python -c 'import datetime;print(datetime.datetime.now().weekday())'
1
$ date
Tue May 24 11:56:54 EDT 2022
__________________
_
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
  Reply With Quote
Old May 24th, 2022, 07:27 PM   #7
daba
Lifetime Supporting Member + Moderator
United Kingdom

daba is offline
 
Join Date: Jul 2004
Location: uk
Posts: 5,387
Quote:
Originally Posted by drbitboy View Post
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.
Monday == 0 ... Sunday == 6
$ python -c 'import datetime;print(datetime.datetime.now().weekday())'
1
$ date
Tue May 24 11:56:54 EDT 2022
It sure isn't rocket science, and if a Raspberry Pi can do it ....

High time the controllers got a decent RTC
__________________
___________________________

Everything works with smoke. Let it out, and it stops working.

Nil Carborundem Illegitimi



  Reply With Quote
Old May 24th, 2022, 07:32 PM   #8
daba
Lifetime Supporting Member + Moderator
United Kingdom

daba is offline
 
Join Date: Jul 2004
Location: uk
Posts: 5,387
Quote:
Originally Posted by harryting View Post
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.
It won't work for everyone - should be automatic ...
__________________
___________________________

Everything works with smoke. Let it out, and it stops working.

Nil Carborundem Illegitimi



  Reply With Quote
Old May 24th, 2022, 07:40 PM   #9
daba
Lifetime Supporting Member + Moderator
United Kingdom

daba is offline
 
Join Date: Jul 2004
Location: uk
Posts: 5,387
Quote:
Originally Posted by TheWaterboy View Post
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
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



  Reply With Quote
Old May 24th, 2022, 08:51 PM   #10
bevanweiss
Member
Australia

bevanweiss is offline
 
Join Date: Sep 2009
Location: Melbourne
Posts: 28
Quote:
Originally Posted by daba View Post
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
You'll probably find it's no longer a dedicated RTC, and will be integrated into the main CPU they use (some kind of ARM core MPU I expect..).

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.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
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


All times are GMT -4. The time now is 11:08 PM.


.