Making a BS2 Controlled Alarm Clock? Or even Clock?
I thought this would be an intresting experiment, so im curious to know just what I might need to emulate a real clock. I could probably be able to code for half of it but im totally stumped on part of the circutry. Any ideas?

Comments
http://www.parallax.com/detail.asp?product_id=604-00005
8 - * * * *
4 - * * . * *
2 - * * . * *
1 - * * * *
Each * is a led, and they are lit up in order to show the time in 00:00 format (after binary conversion, as show by the numbers).
Heres the 60-Second portion of code I worked on:
' {$STAMP BS2} 'Terminally Controlled Clock '-60 Second Scrolling Sequence countseq: GOSUB seq1 HIGH 8 GOSUB seq1 HIGH 9 GOSUB seq1 HIGH 10 GOSUB seq1 HIGH 11 GOSUB seq1 HIGH 12 GOSUB seq1 HIGH 13 GOTO finished finished: DEBUG "Finished!" HIGH 14 END seq1: HIGH 4 PAUSE 1000 LOW 4 HIGH 5 PAUSE 1000 LOW 5 HIGH 6 PAUSE 1000 LOW 6 HIGH 5 PAUSE 1000 LOW 5 HIGH 4 PAUSE 1000 LOW 4 HIGH 5 PAUSE 1000 LOW 5 HIGH 6 PAUSE 1000 LOW 6 HIGH 5 PAUSE 1000 LOW 5 HIGH 4 PAUSE 1000 LOW 4 HIGH 5 PAUSE 1000 LOW 5 RETURNWhat im intrested in knowing, is if theres a way to use some kind of For..Next coding to replace the bulky gosub's and high sequences. I'll probably check the Nuts and Volts pages, but if anyone knows a specific page on that, do tell
Post Edited (Emission) : 6/30/2006 3:07:29 AM GMT
Thats intresting, im gonna look into that. Thanks.
http://www.mindsensors.com/index.php?module=pagemaster&PAGE_user_op=view_page&PAGE_id=53
I like Nitin's RTC because of its small size and it has mounting holes I can easily mount it to my BOE bot. It also doesn't take up any breadboard space (except the 4.7k pullup resistors for the I2C communication).
Matt
high i
pause 1000
low i
next
for i = 5 to 4
high i
pause 1000
low i
next
Off the top of my head (warning, the top of my head is bald)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
I'll post something in a few minutes that should work.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
links:
My band's website
Our album on the iTunes Music Store
' {$STAMP BS2} ' {$PBASIC 2.5} CountPin VAR NIB seqPin VAR NIB idx VAR NIB countseq: FOR CountPin = 8 TO 14 IF CountPin < 14 THEN GOSUB seq1 ELSE DEBUG "Finished!" ENDIF HIGH CountPin NEXT END seq1: FOR idx = 0 TO 9 LOOKUP idx, [noparse][[/noparse]4, 5, 6, 5, 4, 5, 6, 5, 4, 5], seqPin HIGH seqPin PAUSE 1000 LOW seqPin NEXT RETURN▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
links:
My band's website
Our album on the iTunes Music Store
This code itself only takes up 7% of the EEPROM so theres plenty of room for the rest of the sequences, and the actual clock coding.
' {$STAMP BS2} ' Variable Test Environment clockseq: HIGH 4 PAUSE 995 GOSUB clrnums HIGH 5 PAUSE 995 GOSUB clrnums GOSUB numseq3 PAUSE 994 GOSUB clrnums HIGH 6 PAUSE 995 GOSUB clrnums GOSUB numseq5 PAUSE 994 GOSUB clrnums GOSUB numseq6 PAUSE 994 GOSUB clrnums GOSUB numseq7 PAUSE 994 GOSUB clrnums HIGH 7 PAUSE 995 GOSUB clrnums GOSUB numseq9 PAUSE 994 GOSUB clrnums PAUSE 995 GOTO clockseq clrnums: LOW 4 LOW 5 LOW 6 LOW 7 RETURN numseq3: HIGH 4 HIGH 5 RETURN numseq5: HIGH 4 HIGH 6 RETURN numseq6: HIGH 5 HIGH 6 RETURN numseq7: HIGH 4 HIGH 5 HIGH 6 RETURN numseq9: HIGH 4 HIGH 7 RETURNNo need to go through all the gymnastics you're performing.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
links:
My band's website
Our album on the iTunes Music Store
·······················································································
I am with you on this one
I·would like to know this my self··
Can you give me an example of how I would use outb?
And, is outb applicable for all pins 0 - 15?
I reading this POST·to see what comes out of this
This might be a cool project
SSteve·said this
outb·=·whateverValue
Please explane whateverValue are you meaning binary #
If I want to display time in a 1 2 4 8 binary format (where its read by reading the sum of the digits, as binary is read is this what you are taking about whateverValue
Thanks to anyone that can help me understand how to do this and Thank You for your Time
Sam···
Rafael
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You've got to play the game.
You can't win.
You can't break even, except on a very cold day.
It doesn't get that cold.
~Laws of Thermodynamics~
inb/outb = pins 4-7
inc/outc = pins 8-11
ind/outd = pins 12-15
inl/outl = pins 0-7
inh/ouh = pins 8-15
ins/outs = pins 0-15
will set pins 4, 5, & 6 to high and pin 7 to low.
This is described in the BASIC Stamp reference manual under "Memory Organization"
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
links:
My band's website
Our album on the iTunes Music Store
http://forums.parallax.com/showthread.php?p=552892
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
The LED's just wont light up, I don't understand. Am I doing something wrong?
And no, I haven't seen that project, but it looks cool. Think I can reduce the size of that whole setup to the size of a watch?
' {$STAMP BS2} ' {$PBASIC 2.5} DIRB = %1111 here: OUTB = %1111 PAUSE 1000 GOTO here▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
links:
My band's website
Our album on the iTunes Music Store
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
' {$STAMP BS2} ' Single Digit Binary Clock idx VAR Nib binval VAR Nib DIRB = %1111 CLK_SEQ FOR idx = 0 TO 9 LOOKUP idx, [noparse][[/noparse]%0000, %0001, %0010, %0011, %0100, %0101, %0110, %0111, %1000, %1001], binval OUTB = binval PAUSE 998 NEXT GOTO CLK_SEQMan, without your help id be so lost, but look, I reduced those gymnastics to 8 lines of efficient code. The Pause phase will be replaced by a counter that keeps track of the time and convert the decimal values to binary coding for the display. Its looking a lot easier now that I have this down-pat. I'll get back to you guys when I have the final coding written out.
has exactly the same effect as
so your code can be reduced to this:
' {$STAMP BS2} ' Single Digit Binary Clock idx VAR Nib binval VAR Nib DIRB = %1111 CLK_SEQ FOR idx = 0 TO 9 OUTB = idx PAUSE 998 NEXT GOTO CLK_SEQ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
links:
My band's website
Our album on the iTunes Music Store
' {$STAMP BS2} ' HH:MM Binary Format LED Clock mincyc0 VAR Byte mincyc1 VAR Byte hrcyc0 VAR Byte hrcyc1 VAR Byte hrcyccheck VAR Byte DIRS = %1111111111111111 INIT_VAL hrcyc1 = 1 hrcyc0 = 2 OUTH = %00010010 hrcyccheck = 12 START PAUSE 59984 MIN_CYC0 mincyc0 = mincyc0 + 1 OUTA = mincyc0 IF mincyc0 = 10 THEN MIN_CYC1 GOTO START MIN_CYC1 mincyc0 = 0 mincyc1 = mincyc1 + 1 OUTB = mincyc1 IF mincyc1 = 6 THEN MIN_CLR GOTO START MIN_CLR mincyc1 = 0 GOTO HR_CYC0 RETURN HR_CYC0 hrcyc0 = hrcyc0 + 1 hrcyccheck = hrcyccheck + 1 OUTC = hrcyc0 IF hrcyc0 = 10 THEN HR_CYC1 IF hrcyccheck = 13 THEN HR_CLR GOTO START HR_CYC1 hrcyc0 = 0 hrcyc1 = hrcyc1 + 1 OUTD = hrcyc1 GOTO START HR_CLR hrcyccheck = 1 hrcyc0 = 1 hrcyc1 = 0 GOTO STARTThe INIT_VAL line tells the clock to start at 12:00 (hrcyc1 = 1 & hrcyc0 = 2, hrcyccheck is the checking system). The hrcyccheck variable is used to check to make sure the clock rolls over to 01:00 when the clock reaches 12:59:59. This code takes up a mere 6% of EEPROM but if you can shorten this code, feel free. The clock works %100 to my knowledge (the right LED's light up at the right time), but there might be one or two bugs that I haven't noticed. I went through and wrote the program fairly quickly so im not %100 sure. I'll get back to you guys with the final pictures of the working clock
By the way, that project that chris is doing, he's cheating a little by using a time keeper IC and other IC's. I did the entire functions of my clock within the BS2, the only external circutry consists of the LED's.
Now that this project is consdered DONE, I'm gonna go revise Chris's project a little
Post Edited (Emission) : 7/2/2006 5:48:07 AM GMT
MIN_CLR
mincyc1 = 0
GOTO HR_CYC0
RETURN
HR_CYC0
hrcyc0 = hrcyc0 + 1
You can leave out the lines in red.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
links:
My band's website
Our album on the iTunes Music Store
Please don't be to quick to judge one persons project over another. Let me assure you, Chris isn't cheating by using an external IC for his clock. Since none of the PBASIC Stamps have an accurate timebase built-in, the only proper way to keep time, and have alarms is with an external IC.
You will find that the longer your program operates the more INACCURATE it will become. Additionally, the solution Chris has chosen will be much more accurate over varied temperatures, as well as over longer periods of time.
Add to that the ability to set and reset the exact time which Chris has, and you do not. Moreover, Chris has the date handy as well, and you do not. Last is the issue of daylight savings time (if that is applicable to you) and year 2000 compatibility (Y2K).
If you were to change the resonator on the Stamp to a crystal, you might end up with a more accurate timebase, but you'd still have the other "features" to contend with.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
Post Edited (Bruce Bates) : 7/2/2006 6:29:15 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com