determining date of the week

Thread Starter

mCatalin

Joined May 1, 2014
5
Hello,
I have a project to make for my Digital Systems Design laboratory, which is a
programmable office agenda. I need to display, each at a time, Date(day,month and year), clock(hour and minute), temperature, and THE DAY OF THE WEEK, and i need help for the last one, how can i find the day of the week from the date? (I need to make this project in Active Hdl) I don't need the entire solution but just an idea to make me start. Thank you.
 
Last edited:

shteii01

Joined Feb 19, 2010
4,644
By day of the week do you mean a number?
Like: Monday would be 1, first day of the week. Tuesday would be 2, second day of the week. Like that?

Also. Are we doing English week where Sunday is first day of the week?
 

Thread Starter

mCatalin

Joined May 1, 2014
5
I need to display with text and Monday is first day of the week.. but it doesn't matter once i found the number of the day i know how to decode it from binary to display as i want...

Also: for date i used zecimal counters, 4162 i think.. and every number of date correspond to 1 counter so: 2 counters for day, 2 for month and 4 for year.
 
Last edited:

MrChips

Joined Oct 2, 2009
30,706
I have a programming blog which may help you with Days of the Week.

Edit: Sorry, I reviewed my code and it doesn't do what you are asking. I have this in another project that I will have to dig up.
 
Last edited:

WBahn

Joined Mar 31, 2012
29,976
Consider the following:

If you know that a certain reference date, say January 1, 2014, fell on a Wednesday and you know that the date is question, say May 1, 2014, is 120 days after the reference date, can you figure out what day of the week May 1, 2014 is?

Once you figure out how to get the DOW given the information above, the next problem is to figure out how to find how many days have elapsed between two dates.
 

Thread Starter

mCatalin

Joined May 1, 2014
5
yes but i don't know how to implement those algorithms with circuits (i need a hint about what should i use, counters, MUXs, or whatever...)
 

WBahn

Joined Mar 31, 2012
29,976
The proper way would probably be to use a microcontroller. This is a computational problem that is best dealt in software.

Short of that, you could start with a very brute force approach. Can you make a counter circuit that keeps track of the date (year, month, day)? If so, then all you need to do is initial that circuit to a known reference date and then set a simply modulo-7 counter to the value corresponding to day of the week for that reference date. Then simply advance both counters until you get to the target date. Done.

If you want to do a more elegant approach based on one of the many algorithms that are out there, then first make sure that YOU understand the algorithm and can walk through it successfully. Then implement the circuits that perform each piece of it. Your comprehension of the algorithm will tell you what components you need. We can help guide you, but it needs to be in response to YOU showing that you understand the algorithm and the discussion needs to be on issues associated with specific aspects of implementing that algorithm.
 

Thread Starter

mCatalin

Joined May 1, 2014
5
Thank you WBahn for your response... I chose to make it with a modulo-7 counter and I found a solution for the moment when i set the current date..
If is a bisect year i need to increment the counter 2 times and if it is not just once, if the month has 31 days and i increment it than i need to increment the counter 3 times, 2 times for 30 days, 1 time for bisect year February. How can i give 2 or 3 clocks on the counter from 1 signal?
 
Top