Timestamp info
pcrobot
Posts: 103
Hello,
I'm going to work on a project with my Stamp, where if a door is opened, it saves a timestamp. I'm just looking for any suggested reading on the subject of timestamps and the Stamp.
Thanks!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robotics
ro-bot-ics (noun)
the science or technology of robots, their design, manufacture, application, use, etc.
I'm going to work on a project with my Stamp, where if a door is opened, it saves a timestamp. I'm just looking for any suggested reading on the subject of timestamps and the Stamp.
Thanks!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robotics
ro-bot-ics (noun)
the science or technology of robots, their design, manufacture, application, use, etc.
Comments
(1) Using an accurate timebase: For example, the DS1302 Real Time Clock can be easily interfaced to the Basic Stamp. The DS1302 will keep track of hours, minutes, seconds, month, day, date, and year in which you need to ask yourself which of these functions you want to be part of your timestamp. Here is a link to Parallax's webpage for the DS1302 ( www.parallax.com/detail.asp?product_id=604-00005). On the webpage, there is a link that will download a PDF file that shows you how to interface the DS1302 with the Basic Stamp 2.
(2) Timestamp and Data Storage: A good question to ask yourself is how much data and for how long will I be recording (Example: a timestamp of hours, minutes, month, day, and year will require at least 6 bytes of the E2PROM)? Then, you will need to think about how much space the logging of the event will require and whether or not the Basic Stamp's E2PROM will be enough for the data log.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I learn when I succeed, but I learn more when I fail."
Post Edited (alinious) : 3/20/2006 1:51:56 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robotics
ro-bot-ics (noun)
the science or technology of robots, their design, manufacture, application, use, etc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I learn when I succeed, but I learn more when I fail."
I just need to find commands for sending a timestamp...
And I have another question... if I send the timestamp to the EEPROM, what will happen when I pull the power? Will the info still be there?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robotics
ro-bot-ics (noun)
the science or technology of robots, their design, manufacture, application, use, etc.
The Stamp has no internal "clock" other than the internal "instruction clock". While you could synthesise a "timestamp-type" clock, it would probbly not be as accurate as you'd like without some VERY careful coding...down to making sure that each path through conditional blocks take exactly the same amount of time to execute. This is not a trivial task and would require that you use no "low-power" commands as these would also wreak havoc with any time-dependent code. The 1302 that has been suggested is probably the least "hair-pulling" solution to your stated requirement.
As far as data written to the EEPROM, it is still there after power is removed. Just keep in mind that you must make some provision in your code to read the data back out. Also, each "cell" in the Stamp's EEPROM has a limited life cycle. How often you plan to write to it will determine whether the internal EEPROM, an external I2C or SPI EEPROM, FRAM, or some other solution would best fit the bill.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Truly Understand the Fundamentals and the Path will be so much easier...
And an EEPROM (specifically the one in your BS2, which you access with DATA statements, and READ and WRITE (Start at address zero and work your way up, the code starts at the highest address and works its way down)) can only be written about a million times. This is a loong time if done once every 5 minutes. This is a short time if done once a second.
So external eeproms (which have 8-pins, use SPI, and are easily interfaced with three wires) are recommended. Then if you wear it out, you replace a $1.50 eeprom, instead of a $50 BS2.
This is what I have so far... it's kind of an outline. I still need to fill in the correct commands.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robotics
ro-bot-ics (noun)
the science or technology of robots, their design, manufacture, application, use, etc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robotics
ro-bot-ics (noun)
the science or technology of robots, their design, manufacture, application, use, etc.
Not to belabor the point, but your code won't do anything useful. I understand that you don't have the code to read the door sensor, but, as I mentioned before, the Stamp does not have a clock, per se, that will do what you are looking for. You will need to use an external one to get the time or use a "counting" routine to synthesize your own...accepting the fact that it will not be very accurate (in microcontroller terms), and will impose certain restrictions on your program (i.e. can't do anything else while counting and looking for the door to open...if you time it right). Also, I'm not quite sure that your initial "logic" (the "Minute=", "Hour=" - type code) is going to give you any useful information. Beside the fact that everything is defined as a BYTE and would probably lead to confusion...even in your "Seconds=1000" line, I think what you "mean" to do is use division instead of multiplication.
In short, I would recommend putting this project on hold and go through the various free texts made available by Parallax. You obviously have the drive and "just enough knowledge to be dangerous" [noparse]:)[/noparse]. I would hate to see your education get droped just because you tried something just a little too ambitious without having a little more foundation in "Stamp BASICs".
Good Luck!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Truly Understand the Fundamentals and the Path will be so much easier...
Post Edited (Tom Walker) : 3/30/2006 2:06:22 PM GMT