Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Scheduling mechanism question.

Status
Not open for further replies.

alphacat

New Member
Hey.
I'm writing a scheduling mechanism and would like to ask a question about it.

Lets say that a user wants to perform a monthly operation, starting from January 31.
What will be the next 4 times that this operation will be repeated?

Option #1 that i thought of is:
February 28 (or 29 in case of a leap year)
March 31
April 30
May 31

What is the common way of doing it?
 
Last edited:
You need to define your problem/words more completely. "Monthly" can mean anytime within the month. So, Jan 31, Feb 13, March 5, April 30, etc. could, in that context, mean "monthly."

That said, the dates you give are also consistent with "monthly."

In a service environment (e.g., calibrating an instrument "monthly"), one might pick a particular day that occurs in each month (i.e., any date =<28), but that creates problems with weekends and holidays. Another alternative is to specify something like the "first Wednesday of each month," and so forth.

Edit: Common practices

It was common to do routine maintenance and calibration on particular days (as in the above example) or before a certain number of days has elapsed. The latter allows such servicing to be done before weekends or holidays, as service intervals can usually be shorter, but not longer than required by whatever requirements one must meet.

John
 
Last edited:
Using a RTC chip?

A RTC would provide the data you need.
 
Thank you jphan, i got your point.

atferrari, how would a RTC help?
RTC only gives you the time.
Its up to you when to schedule events.
 
You have to make a clock. There are some on this board that will do nicely. I put one on here myself that has month and day but does not correct for leap year.
 
I'm actually using the internal RTC of the Uc i have.
I just dont see how do you intend to make use of it.
Of course that i use it to know how many years/months/days/hours/minutes/seconds have passed.
But its got nothing to do with my question, i think.
 
It depends on the definitions. Is Jan 31:
(a) the last day of the month? Jan 31, Feb 28/29, Mar 31, Apr 30 etc
(b) the 31st day of the month? Jan 31, Feb no-op, Mar 31, Apr no-op, May 31 etc
(c) the last Sunday of the month? Jan 31, Feb 28, Mar 28, Apr 25 etc
(d) the 5th Sunday of the month? Jan 31, May 30, Aug 29, Oct 31 etc

The problem really is that you've picked an "extreme" example. If it was monthly on the 25th then there would be no question (and similarly if the user tried to specify monthly on the 47th day of the month there'd be no question either - this would be rejected as silly). 29-31 are valid dates sometimes, but not every month. So if you want monthly on the Nth day of the month then you have to limit N to 1-28, or choose Jan 31 on some other basis (the last Sunday etc), otherwise it doesn't make sense.
 
I use a look-up table. I am very busy right now so I will post this old clock I did years back with a PIC16f84. You can dig through here and find the table. It has some half ass source code descriptions:
 
Ooops! Here it is:

Change the file extension back to dot doc

So: clock.txt change to: clock.doc
 

Attachments

  • Clock.txt
    123.7 KB · Views: 176
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top