1 minute timer clock
stampguy
Posts: 3
I am trying to use an IC, perhaps the DS1302 or DS1307 to create a simple 1 minute clock; basically every 60 seconds the circuit will give a brief
pulse. Any ideas or Basic Stamp code examples to do this would be much appreciated. I am new to the Stamp. Thanks.
pulse. Any ideas or Basic Stamp code examples to do this would be much appreciated. I am new to the Stamp. Thanks.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
This is if you are going to use a DS1302 Time Chip
Take a look at this post three ed one down from the top
Please Take a look at the Counter Demo in that post
·http://forums.parallax.com/showthread.php?p=568430
To create a simple 1 minute clock; basically every 60 seconds the circuit will give a brief pulse.
All you have to do is change the······ IF mins = $03······ ·to this··· ·IF mins = $01· or· secs = $59
Where it has EXIT just after that·put what you want next thing to do and·go back to this routine and so on
I put an example ·here for you I have not tested it to see if it works or not but it should your just· have to play with it until you get it working
·
·
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 3/27/2008 6:45:47 PM GMT
That code looks right, but it would be 59 instead of $59. That is hexadecimal 59, which is 89 in decimal.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I am 1010, so be surprised!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
I have done this method as well and could post some example code for a time using this method if you like.
Would you post this so I could see how this is done
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
First let’s deal with just a seconds timer for simplicity. If you want to see one that handles minutes and seconds I will post that from home since I have a copy there. For seconds you would simply set the number of seconds into a variable. A byte variable can hold a value up to 255, so let’s say we want to pause for 75 seconds…
timer = 75
GOSUB Get_Time
oldSecs = secs
DO
GOSUB Get_Time
IF oldSecs <> secs THEN
timer = timer – 1
oldSecs = secs
ENDIF
IF timer = 0 THEN EXIT
LOOP
‘ end of time routine
This routine will count down from 75 seconds down to 0 without affecting the normal real time on the module. It assumes you have declared all variables and are using subroutines from my own DS1302 Demo Code. The code will remain inside the DO…LOOP section until the count reaches zero (75 seconds) at which point it will execute whatever is after the LOOP command. If you want to display the counter during the count on the DEBUG screen you could add the following line just after the ENDIF statement…
DEBUG HOME, DEC timer, “ REMAINING… “
I hope this helps. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
I am new to stamps...could you please provide the full code including variable declarations etc, so that I can cut and paste it into my code using a 1307 (I have the PDB).
So would your code integrate into my code, i.e. does your subroutine need to be constantly called from my main program?
Basically, I need a circuit outside of the BS2 that is constantly running (or perhaps I may need to enable/disbable it), but for now, let's assume that it runs all the time. Every 1 minute the circuit outputs a short pulse - somewhere in the 1 to 100 ms area...not sure yet. 1 minute later it does the same thing ad infinitum. This 1307 circuit then connects to the BS2.
Within the BS2 and my program code, I run a subroutine that constantly checks the input pin for the existance of that 1 minute pulse. When I see the pulse then I increment a counter.
A circuit showing how to configure the 1307 (external parts, crystal, caps, output to stamp etc) would be much appreciated. Thanks Chris.
Thank you for posting this code
·If you want to see one that handles minutes and seconds I will post that from home since I have a copy there.
Would you post this code as well
·Thanks for all of your help
·
·stampguy
Basically, I need a circuit outside of the BS2 that is constantly running (or perhaps I may need to enable/disbable it), but for now, let's assume that it runs all the time. Every 1 minute the circuit outputs a short pulse - somewhere in the 1 to 100 ms area...not sure yet. 1 minute later it does the same thing ad infinitum.
First of all you can ONLY do one thing at TIME with a Basic Stamp
Now if you want to have a timer COUNT for a minutes then do something else then go back to Counting agian· then yes you can do this
·But NOT both at the SAME TIME
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 3/27/2008 6:57:01 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
I can post the countdown timer code which handles minutes and seconds as decimal values and is non-destructive to the RTC values
Would You please post countdown timer code
Thank You for your Help
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Instead of the STAMP counting up for 60 seconds or checkin gfrequently to see if the real time is sec=00, you can just tell the stamp to sleep until the timeleeper chip changes its alarm pin to high. I forget the numbers of chips that hold hte time, but you can find on maxim / Dallas site.
This approach is useful when you need the real time anyhow (like to put a time stamp on data) which will require you to buy one of the timepkeeping chips - might as well get one with the alarm feature.
Have you used the DS1306 before and do you have a working Demo Code that
you can share
I look at it a little and it seem to have the same type of format
I am right about this here is the link to it
http://datasheets.maxim-ic.com/en/ds/DS1306.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
The second idea (which I more frequently use) is not to check for a 0 value from the RTC, but to use your own counter, using the RTC only as a reference for seconds. The RTC time/date remain intact.
Sam_sam_sam,
I will post the code tonight or tomorrow…It is at my home office. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Sam_sam_sam,
.....>>>>> I will post the code tonight or tomorrow…It is at my home office.
Take care...........>>>>>>>>>>>>>>>
....>>>> I can post the countdown timer code which handles minutes and seconds as decimal values and is non-destructive to the RTC values,
Did you for get about me·I would still like to see this code
Thanks for all of your time and help
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
I would not and could not forget about you! I simply forgot to get the code off my home PC. It’s good I have you to keep my on my toes and so I will get it tonight. I am even sending myself an e-mail right now to remind me. Should be here about 3 hours from now. Thanks again for keeping me on my toes!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
In this case the time was set by pressing buttons for the minutes and seconds.· There was also a clear button.· When the start button was pressed the time was saved into the DS1302 RAM so basically the following subroutines were executed...
Set RAM stored relevant data for the timing cycle...(maybe it was hours and minutes...fuzzy, I think the comments are wrong· · anyway...)
The next routine starts the timing cycle...Even though it is resetting the clock, in most cases you will not need to do that since this routine simply checks for a change in seconds.· Show_Run_Time is simply the subroutine that updates this particular display.· This way if the display changes, only that subroutine is affected.
Finally, when time is up...Flash display and beep...
I hope this provides some useful information...I would be happy to answer specific questions on the code if need be.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Okay, found the code and realized this project was done for a client so I cannot post the code in its entirety...What I can do is provide the timer relevant data...
Thank You for posting this code this will help ALOT····
·I need a mins and secs count down timer for something I am working on
I have it woking good
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
I was thinking about why I reset the clock in this code during the Timer_Run section and I remembered…If you arbitrarily use the RTC seconds for timing your accuracy could be off by up to one second because the seconds may be changing at any point upon entry into the routine…In most cases this won’t be a problem, but in all fairness I thought I would mention it. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
I··was thinking about why I reset the clock in this code during the Timer_Run section and I remembered…If you arbitrarily use the RTC seconds for timing your accuracy could be off by up to one second because the seconds may be changing at any point upon entry into the routine…In most cases this won’t be a problem, but in all fairness I thought I would mention it. Take care.
I was trying to understand why the reset the clock in Timer_Run section my
self but thought it had to with some part of another routine and that you could
not share because you........>>>>>>·realized this project was done for a client so I cannot post the code in its entirety...What I can do is provide the timer relevant data...
Which I comptlely understand that I am glad that you shared this part of the code
Thanks for sharing it
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam