Daylight Saving Time
cydelcamat
Posts: 53
in BASIC Stamp
Hi guys! does anyone here has an experience on making a daylight saving time using basic stamp 2?
Comments
If I may ask for a better explanation of what you're trying to do since you can't really "make" a daylight savings time. Daylight Savings Time is the practice of advancing clocks during summer months by one hour so that evening daylight lasts an hour longer, while sacrificing normal sunrise times.
You must be looking for something more specific to an application?
' {$STAMP BS2}
' {$PBASIC 2.5}
time VAR Byte (6)
n4800 CON 188
n9600 CON 84
MAIN:
SERIN 0, n4800,[WAIT("GGA,"),STR time\6]
DEBUG CR
time(2) = time(2) + 3
IF time(2) > "5" THEN
time(2) = time(2) - 6
time(1)= time(1) + 1
ENDIF
SEROUT 1, n4800, ["$GNGGA,",time(0),time(1), time(2),time(3),time(4),time(5)]
GOTO MAIN
Sorry, don't use a basic stamp so I cannot post any code for you.
When the DS1302 was replaced with the DS3231 for better temperature stability, the code was updated.
This code controls the operation of an automated truck dumper and the main program is reasonably complicated. However, if you look at the code in the Slot 1, all the clock routines are there, including automatic changeover for DST.
Good luck!
Tom
In the fall, it is more complicated because the magic second happens twice:
I would like to post some code that is Built around the (BS2e/BS2 48/40), DS1302, Tracy Allen's (Day of Week DOW) code and my own code. I was wanting Tracy to go over my logic before I posted anything, but now is as good a ever.
Note: some insight. The code always passed the bench test (100%) of the times after I got my part of the code figured out (testing within 30 min. window of the DLST). The first 4 times (Mar/Nov. twice) the code failed during normal operations. Reason: The DS1302 DOW format is (1 - 7) for Days Of the Week. Tracy's Julian Day Of the Week is (0 - 6) and I caught it at first but some how some way remove the (+1) at the end of his code. I promised my wife for 2 years the code was correct. The true "test" came when I let it run for 8 days, during normal operation. From Sunday to (DLST) Sunday. That's when the code and DS1302 became out of sync without the added (+1) at the end of the calculation. Lesson learned, normal operation is more then just a bench mock up.
Like I said, it worked year ago Mar. (spring forward) last Nov. (fall backward) and this Mar. (spring forward).
My overall code continuously monitors the DLST code (same code 3 slots) during normal operation and its during one of the delays if DLST happens, then other Alarm Times are adjusted forward/backwards to stay in sync. Bench test pass and failed when suppose to (all variables changed), have not done the real world test yet.
Also within my 'Main Menu' code there is a toggle ON/OFF selection because not everyone lives in a DLST area.
PS: don't know how ya'll get your PBASIC code within the yellow scrolling block???
can not get it to work in preview to attach code...help
Wow that is from a few years ago and I'm glad to hear you got it worked out. Happy to look at it. You can post code by using the "Attach a file" link below the comment box. Or, hit the "C" icon that resides at the top of the comment box and then paste your code snippet in between the code tags that appear in line with your text.
@Cydelcamat,
If using GPS for this project, the GGA sentence has only the time, but RMC is better for your purpose because it gives you both time and date. Convert the date to an ordinal form, then calculate the day of week so you can find the two Sundays that mark the transitions.
Use the "C" button above in you text input window. Inserting code that way keeps its formatting and is much easier to read and check! Good luck!
Like this...