Method to keep track of dates without adding a DS1302 RTC?
I have a 6432 display board that I want to be able to display a message based on the day to set of dates. For example, if it was Valentines Day, it would display 1 or 2 Valentines Day messages. If it was the Holiday Season (e.g. a weeks worth of dates lets say), it would display Holiday type messages. I already know how to display messages but I want to find an algorythm that can keep track of a date or set of dates that I can use on an SX28 (or probably more likely an SX48). The messages will just be in DATA statements or in an array string or something.
Does anyone have any ideas on how this can be easily done vice having to add a DS1302 (Real Time Clock) to check the dates. Can the SX chips keep track of dates and how? I don't need to get down to the second or hour - just day or group of days.
Thanks.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Smykowski: Well-well look. I already told you: I deal with the customers so the engineers don't have to. I have people skills; I am good at dealing with people. Can't you understand that? What is wrong with you people?
Does anyone have any ideas on how this can be easily done vice having to add a DS1302 (Real Time Clock) to check the dates. Can the SX chips keep track of dates and how? I don't need to get down to the second or hour - just day or group of days.
Thanks.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Smykowski: Well-well look. I already told you: I deal with the customers so the engineers don't have to. I have people skills; I am good at dealing with people. Can't you understand that? What is wrong with you people?
Comments
That said, you could put the length of each month into data statements for reading (e.g. 31, 28, 31, 30, 31, 30, etc) so that as you count days upward you know when to roll the month over. You would need:
- secs count
- mins count
- hours count (to 23)
- days count
- months count
- year (even one digit would be OK, just so you could track if it's a leap year or not)
Don't forget code for changing all those values so you can reset time in the event of a power off or reset (another advantage of an RTC - easy battery backup).
Psuedo-code:
I think that covers it.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Post Edited (Zoot) : 3/25/2009 2:39:54 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Post Edited (Zoot) : 3/25/2009 2:40:36 PM GMT
http://www.cpearson.com/excel/holidays.htm
regards peter
I don't have a big SW background, but I've bumped up against the limits of the SX48 already... and had to cut out stuff in order to make it fit. I'm assuming that a big look up table would take a lot of room, especially since (depending on the year) the holidays can switch weeks, like Zoots said earlier.
Agreed, an RTC would be a much simpler solution, but if you were doing this as a learning exercise you could spend the time coding.
There is a "tricky" way to determine the number of days in each month without a lookup table by looking at the month value as a binary nibble and comparing Bit0 with Bit4.
Excluding February, if the Bits disagree, then the month has 31 days, otherwise the month has 30 days.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Remember though, that the RTC will not be a holiday Calendar -- you'll still have to figure out holidays from the date or day of week or week of the month, etc. As I wrote above, for dated holidays it's easy, but for "drifting" holidays (e.g. Thanksgiving, Labor Day, etc.) it can be much trickier.
There are some bonuses to an RTC also, like maintaining time even when shut-down or during reset, a bit of extra (battery backed-up) RAM, etc.
Old_Lady: the lookup table for days in a month would only be 12 bytes -- so it's not really big at all:
AddrLabel:
DATA 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Thanks again for all the great input and thought into this!
In regard to time keeping, I need to convert in both directions between regular (Julian?) Years, Months, Days, Hours etc. and "UNIX" time, and find it quite a bear. I use Phil Pilgrim's clever algorithms for that, but in SX/B it consumes tons of precious code space that I have compacted quite a bit. Leap years really screw things up.
Does anyone have clever shorthand tricks to share?
Cheers,
Peter (pjv)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
For any given date it calculates the day of the week.
Here's the wiki: http://en.wikipedia.org/wiki/Zeller's_congruence
Chris I.