Logix5000 DateTime

eight_bools

Lifetime Supporting Member
Join Date
Apr 2019
Location
Oklahoma
Posts
69
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

DateTime.jpg
 
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).
_
 
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
 
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
 
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'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'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
 
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 ...
 
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...
 
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.
 

Similar Topics

I am trying to determine a "projected completion date and time" for a batch process based on the process start time, and the total recipe time...
Replies
4
Views
1,444
I'm a Siemens person, and this is one of my first AB programs. The customer wants everything programmed in Ladder. I have a lot of data (3...
Replies
14
Views
159
Good day everyone. if you have a logic for 3 pumps (lead/lag/off), would you please email it to me? I really appreciate it!
Replies
7
Views
157
Maybe this is just not possible, or maybe I am doing something wrong. Background; I have a data array of over 1500 products. For sorting I...
Replies
6
Views
727
Hello everyone, I'm currently using RS Logix5000 software for machine programming with this Rockwell PLC using the Structured Text method. The...
Replies
19
Views
1,951
Back
Top Bottom