Troubles Keeping Time
francoja
Posts: 10
Hey everyone,
I'm working on building a time sensitive switch; a switch that would turn on and off at specific times specified by user inputs. I'm using the DS1302 timekeeping chip and I ran into a couple problems. I used the first program listed in the AppKit.pdf that was on the online catalog. Using this program I don't have much variable space left for the rest of the program that I have to write.
After I setup the time and date using one program, can I reprogram the Stamp without erasing the DS1302 or is the DS1302 dependent on the Stamp? Can I run the program to initially set the time and date and then run another program that will just take time readings from the DS1302? If so, how?
I'm relatively new to Basic Stamps and the programming language so any help would be appreciated.
Thanks
I'm working on building a time sensitive switch; a switch that would turn on and off at specific times specified by user inputs. I'm using the DS1302 timekeeping chip and I ran into a couple problems. I used the first program listed in the AppKit.pdf that was on the online catalog. Using this program I don't have much variable space left for the rest of the program that I have to write.
After I setup the time and date using one program, can I reprogram the Stamp without erasing the DS1302 or is the DS1302 dependent on the Stamp? Can I run the program to initially set the time and date and then run another program that will just take time readings from the DS1302? If so, how?
I'm relatively new to Basic Stamps and the programming language so any help would be appreciated.
Thanks
Comments
"A temporary connection to a controller establishes the DS1302’s time. Thereafter, the chip can operate as a stand-alone "
http://www.google.com/url?sa=t&ct=res&cd=7&url=http://www.parallax.com/dl/docs/prod/appkit/ds1302Rtc.pdf&ei=y4ERRuDuHIz-gwPX6-mAAg&usg=__j3w8kdXdpwFoYbWaPR0_hBkojpc=&sig2=42rVjdVDy9-EfVIyKyxdig
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
When you define a variable it simply gives the variable name an address to one of the locations.
Of course you can overwrite variables.
Better have a look at the basic stamp help file. Look for "Memory and Variables" in the index. The variable space exists whether you define variables or not.
You can use the extra space on the time chip for storage
You can use the program space in the stamp (eeprom) to store variables, see READ, and WRITE commands.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
http://forums.parallax.com/showthread.php?p=531080
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
You are looking for the most efficient method to store data but you have not told us how much data you intend to store and what time frame you want to store it.
How much resolution do you need, to the second, will take 17 bits to store , if you log data for more then 24 hours you need more bits to specify the DAY as well.
If you were to use a resolution of 2 seconds instead of one you could store 24 hours of data in 2 bytes.
Taking a fixed amount of readings per day you could store them in an array in eeprom. Each block of x bytes would be a days worth of data so you dont have to store the day.
If you have variable data you could store one word say $FFFF as a marker between days of data
So really, one needs to define the data one wants to store before looking for the "best" solution.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
ReadRTCBurst:
'Read all time-keeping registers in one burst
HIGH RTCCS
SHIFTOUT DTA, Clk, LSBFIRST, [noparse][[/noparse]%1\1,BrstReg\5,%10\2]
SHIFTIN DTA, Clk, LSBPRE, [noparse][[/noparse]Seconds,Minutes,Hours,Date,Month,Day,Year]
LOW RTCCS
RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
I have a start time and a stop time for each day of the week. So I have 14 hours and minutes I have to store.
I will try again. How many data points do you need to store during the 840 minutes each day.
What is it you are storing the time stamp for and how many times does that event happen during the 14 hours each day.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
How many on / off times do you want the user to be able to inout then?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
http://forums.parallax.com/showthread.php?p=601101
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Since the on off times are in the eeprom they will not disapear when power goes off to stamp.
14 on off times times 7 days is only 98 times 3 bytes is under 300. You have 2047 bytes of eeprom to work with so you can store year,month,day,minute,seconds for that many datapoints.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
I think I'm all set.