How to calculate the day of the week?

sparky64

Member
Join Date
May 2003
Location
Newcastle upon Tyne
Posts
127
I need to prompt an operator to do a certain task at 7am every other day, Monday, Wednesday & Friday.
I,ve written some code in an SLC 5/04 that increments a counter at midnight starting from Sunday, so Monday is 1, Tuesday is 2 etc......and then on the following Sunday at midnight, the counter increments to 8, when the accumulator value is equal to 8, I move a value of 1 to the accumulator, so it's back to Monday.
I then condition the 7am so it only comes on, on the 1st day 3rd day and 5th day (Counter ACC value = 1, 3 or 5).
This works fine, but I am interested to know how other people would do this, is there a more scientific way of doing this?

Cheers

Sparky :cool:
 
Last edited:
Sparky64

The simple answer to this is I use the PLC real time clock, most of my project's are done using S7 300's and 400's and they have the facility to do this, I cannot comment on other PLC's as I lead a sheltered life that is dominated by Siemens.

Paul
 
For SLC5/03 and 5/04
S:37 Calender Year
S:38 Month
S:39 Day of month
S:40 Hours
S:41 Minutes
S:42 Seconds

I have not found the say of the week yet but it somewhere.
 
I'll take that back,

93lt1 said:
I think the "day of week" is only available with SLC 5/05

It only seems to be displayed in the 5/05 in the structured form for the status file. In the decimal view of the status file it is there for SLC 5/03 and 5/04, If you change the radix from "structured" to "decimal" S:53 is the word. 0=Sunday, 1=Monday, etc.
 
S:53 for SLC5/4 1747-L542B appears as "Discrete Input Interrupt -Timer" in decimal form.
However in Structured form, S:53 is not there under any tab.
 
I still have the "Discrete Input Interrupt -Timer" for S53, and 54 on my screen.
How do you copy the SLC screen? it is very helpfull in discussion
 
After looking in 6 SLC 5/04, I found only one (OS401 Series C) having the S:53 as "Reserved/Clock Calender Day of the Week"
There is something fishy with this status.
 
shahn4 said:
How do you copy the SLC screen?

Just a regular Windows screen shot, cut and converted to a ".gif".



What version of RSLogix500 do you have? I have version 6.


For each of the processor's available 5/03, 5/04, and 5/05, I created a new project and went directly to the status file to look for S:53. Each showed the "day of week" description text. What happens if you try that? It sounds like you are looking at programs that you already have.
 
Had to dig out the book!

I had to look into the "instruction set reference".

S:53 is divided into 2 parts; the low byte is day of week, and the high byte is labeled "reserved".

isr.gif
 
Thanks for your detailed reply.
I do have a new version 6.00, however, I was looking at the existing programs. It seems like this upgrade is related with version 6.00.
The older-developed programs have description given at the time of previous RSlogix.
Thus it appears as something else.
:p
 
I found the following formula on the Math Forum to calulate the day of the week.

Here is a formula for finding the day of the week for ANY date.

N = d + 2m + [3(m+1)/5] + y + [y/4] - [y/100] + [y/400] + 2

where d is the number or the day of the month, m is the number of the
month, and y is the year. The brackets around the divisions mean to
drop the remainder and just use the integer part that you get.

Also, a VERY IMPORTANT RULE is the number to use for the months for
January and February. The numbers of these months are 13 and 14 of the
PREVIOUS YEAR. This means that to find the day of the week of New
Year's Day this year, 1/1/98, you must use the date 13/1/97. (It
sounds complicated, but I will do a couple of examples for you.)

After you find the number N, divide it by 7, and the REMAINDER of that
division tells you the day of the week; 1 = Sunday, 2 = Monday, 3 =
Tuesday, etc; BUT, if the remainder is 0, then the day is Saturday,
that is: 0 = Saturday.

The Math Forum link for Day of the Week

I was playing around and here is some code the the SLC 5/03 or SLC 5/04 to calulate the day of the week. It should be fairly easy to convert this to Control Logix.


Kim
 

Similar Topics

Hi everyone, This is my first time posting, so please forgive any omissions or mistakes. I am attempting to control the velocity of a stepper...
Replies
18
Views
685
Good morning, I have a question. I don't know much about ST yet I would like to calculate the average number of products per hour. how do I do...
Replies
22
Views
2,865
Can someone help me with this? I'm no good at SCL - virtually everything I've done so far has been ladder logic. The return value from the...
Replies
13
Views
1,008
I want to calculate the energy consumed from instantaneous power. Can this be done using the TOT block with timebase set to Hour?
Replies
2
Views
653
Hi everyone, I have to calculate the length in millimeters of a glass that enters a transport (I don't know the speed yet) through a barrier...
Replies
15
Views
3,432
Back
Top Bottom