Can you use two DS1302 with a Basic Stamp ----->>>> Solved
Hi Every One
If this can be done how would you
I would like to use Elapsed Timer on one DS1302
I would·like to use DS1302_Counter timer on·other ·
Can any pins be shared
(one)·· How would you·hook up the two DS1302
(two)·· How would set up the time keeping part of the routine too switch from elapsed timer to regular timer
The regular (counter timer)·timer would be the one in the back ground this would keep track of the total amount of elapsed
··
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 12/6/2008 2:16:47 PM GMT
If this can be done how would you
I would like to use Elapsed Timer on one DS1302
I would·like to use DS1302_Counter timer on·other ·
Can any pins be shared
(one)·· How would you·hook up the two DS1302
(two)·· How would set up the time keeping part of the routine too switch from elapsed timer to regular timer
The regular (counter timer)·timer would be the one in the back ground this would keep track of the total amount of elapsed
··
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
![idea.gif](http://forums.parallax.com/images/smilies/idea.gif)
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 12/6/2008 2:16:47 PM GMT
Comments
Thank You for your reply
I need to run one time chip all the time and stop and start the other time chip
For something·I working on the·Elapsed Timer routine that·I wrote a few month ago·now·I want to·also have a running timer that keep track of total Elapsed Time
Here is the link to this Project
http://forums.parallax.com/showthread.php?p=737892
What I would do is use the extra 7 bytes in the chip to store the start time, then calculate the difference between the stored time and the current time read from the chip
Could you give an example of how to do this
__________________________________________________________________________________________________
·Thanks for any·
Sam
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 10/19/2008 12:10:21 PM GMT
Looks like your application is to measure your on time for your HVAC unit over X amount of time. Also looks like your using a BS2.
Maybe we are thinking too complicated. Do you really need the DS1302? Do you have power outages? If not power outages and not needing a highly accurate time base, you can do everything in the stamps RAM. Just remember one thing, there is tons of ways to do things.
the following is not code that will work, just a thought process.
Startup:
Make all ram values = 0, also all bytes, gives you up to 255 on each
I figure only 8 bytes are being used, and can add another 4 bytes for when your water sprayer is on. +-)
Main: 'for when not on, only update total elapsed time
If Pump is On gosub onmode 'start measuring on time
PAUSE 1000 ' wait 1 second
gosub AddTotal 'add to total time
gosub UpdateDisplay 'refresh display
Goto Main
AddTotal: '
TSec=TSec + 1 'add one to total on seconds
IF TSec>=60 Then 'if seconds is equal to or over 60 add one to minute, and reset seconds
TMin=TMin+1
TSec=0
ENDIF
IF Tmin>=60 Then
THour=THour+1
Tmin=0
ENDIF
IF THour>=24 Then
TDay=TDay+1 'note if allowed to run over 255 days it will get reset to 0, or error out. Can make this a word type variable for over 60k days.
THour=0
ENDIF
RETURN
OnMode:
Do until Pump = 0 'keep looping until pump is turned off
Pause 1000 'wait one second
OSec=OSec + 1 'add one to "on" seconds
IF OSec>=60 Then 'if seconds is equal to or over 60 add one to minute, and reset seconds
OMin=OMin+1
OSec=0
ENDIF
IF OMin>=60 Then
OHour=OHour+1
OMin=0
ENDIF
IF THour>=24 Then
ODay=ODay+1 'note if allowed to run over 255 days it will get reset to 0, or error out. Can make this a word type variable for over 60k days.
OHour=0
ENDIF
gosub AddTotal 'add to total time
gosub UpdateDisplay 'refresh display
Loop
Return
UpdateDisplay:
Add code here to scroll through info needed.
Return
Thank You for your reply
A few thing
(One)·I will not be controling any thing except for·the DS1302 with the Basic Stamp
(Two) I am needing· a highly accurate Time Base
With the elapsed timer routine that·I wrote it work very well
What the problem is that I need to keep track of how long the timer has been running·from the last time it was start to next time i want to reset the timer
Here is what I want to
ONE
·Keep track of running time of AC unit when compresor is running
Two
·How many restarts there are
These two I have already done· I need to do the last one and get it to work if there is a way to to do this
Three
How many Months, Day, Hours and Minutes have Elapsed Time has gone by when the timer was start
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
The reason I am asking is I want to display both DS1302 Chips Time on an LCD Display
Also do you have to use different "VAR" "CON" and also SUB Rountine for each DS1302 Chip
RTC_Out:
· HIGH CS1302··························
· SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]reg, ioByte]
· LOW CS1302···························
· RETURN
RTC_In:
· HIGH CS1302··························
· SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]reg]
· SHIFTIN DataIO, Clock, LSBPRE, [noparse][[/noparse]ioByte]
· LOW CS1302···························
· RETURN
Set_Time:······························
· HIGH CS1302··························
· SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]WrBurst]
· SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]secs, mins, hrs, date, month, day, year, 0]
· LOW CS1302···························
· RETURN
Get_Time:······························
· HIGH CS1302···························
· SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]RdBurst]
· SHIFTIN DataIO, Clock, LSBPRE, [noparse][[/noparse]secs, mins, hrs, date, month, day, year]
· LOW CS1302····························
· RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 11/28/2008 2:23:43 PM GMT
I'm not all that familiar with the DS1302, but you would need to have a SELECT or ENABLE line in order to address each chip separately. Otherwise you will have contention on the DATA and CLOCK lines.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When all else fails, try inserting a new battery.
Thank You for your reply but
The reason I am asking is I want to display both DS1302 Chips Times on an LCD Display at the same
I know that the stamp can only one thing at a time
I have to ask a·question·and it this
As I have below in a post where I ask about·do you have to have different·VAR and CON and SUB Routine for each DS1302 Chip
RTC_Out:
RTC_Out1:·········· and so on for each routine
All of these chips use an SPI interface and all had common clock and data lines.
I understand the part about·sharing the Clock and Data Line
Bruce Bates
Thank You for your reply
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 11/29/2008 2:20:45 PM GMT
Can one tell me if I am on the right track or not
I am working on a dual DS1302 Chip board today so i can not try it now to see if it will work
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Unless I've overlooked something, you need a second set of variables for the elapsed time timer. Take a look:
Get_Time: ' DS1302 Burst Read
HIGH Timer ' Select DS1302
SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]RdBurst]
SHIFTIN DataIO, Clock, LSBPRE, [noparse][[/noparse]secs, mins, hrs, date, month, day, year] <==
LOW Timer ' Deselect DS1302
PAUSE 100
HIGH ElapsTimer ' Select DS1302
SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]RdBurst]
SHIFTIN DataIO, Clock, LSBPRE, [noparse][[/noparse]secs, mins, hrs, date, month, day, year] <==
LOW ElapsTimer
RETURN
The second fetch of information will clobber the first, presuming you wanted to keep the elapsed time data separate from the regular timer data.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When all else fails, try inserting a new battery.
Thank You for point this out to me
The second fetch of information will clobber the first, presuming you wanted to keep the elapsed time data separate from the regular timer data.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
P.S. - As a note...the project I mentioned that had two DS1302 chips was because I wanted one to have the time, and use the other as a counter. Later I consolidated the project by simply incrementing or decrementing a counter variable whenever the seconds changed. It only required two variables and got rid of the second DS1302.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
Thank You for your reply
This is just what·I want to do·what you have here
·Now, if you actually need to compare any of the information then you will need a whole new set of variable to handle this. Take care.
Can you share the code for this
I wanted one to have the time, and use the other as a counter. Later I consolidated the project by simply incrementing or decrementing a counter variable whenever the seconds changed. It only required two variables and got rid of the second DS1302.
I want one timer to run all the time and the other timer to run when the equipment is running
Here is· what·I came up with in the Attachement below
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
When I needed a separate counter from the time I just used the program loop to increment (or decrement) the counter variable each time the seconds changed. For example, say you have the DS1302 set and running with the current time. Whatever it is doing its seconds are always updating. So now you need to run a timer…maybe it needs to count up until an event happens. So here’s some pseudo-code…
Of course, you will want to reset the counter on entry and there are several other little details missing, such as the specifics of each subroutine.· But this all depends on the application.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
Thanks for the··pseudo-code…· very help full
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam