time stamping recorded data
Is it possible to time stamp data that is written to eeprom?
I have an speed sensor that is activated by a magnet on a gear driven by an electric motor. I read the time between pulses and write that value to eeprom. Then i have a pause in my code to control the rate at which I log data. However, if I pause for 100ms it is clear from the data that I have logged, that I'm logging not at 10 Hz, but much slower. Is there a way to calculate the time in ms between execution of commands in a loop?
Here is the code with the loop that I want to time stamp.
FOR eeaddr= log TO endlog
· PULSIN 11, 0, cyclet············ 'read sensor on pin 4
· DEBUG DEC cyclet, CR
· result = cyclet/100············ 'fit data to byte
· WRITE eeaddr, result············ 'write data to eeprom
· PAUSE 10························· 'sample rate
· NEXT
Thanks for the help...
Jeremy
I have an speed sensor that is activated by a magnet on a gear driven by an electric motor. I read the time between pulses and write that value to eeprom. Then i have a pause in my code to control the rate at which I log data. However, if I pause for 100ms it is clear from the data that I have logged, that I'm logging not at 10 Hz, but much slower. Is there a way to calculate the time in ms between execution of commands in a loop?
Here is the code with the loop that I want to time stamp.
FOR eeaddr= log TO endlog
· PULSIN 11, 0, cyclet············ 'read sensor on pin 4
· DEBUG DEC cyclet, CR
· result = cyclet/100············ 'fit data to byte
· WRITE eeaddr, result············ 'write data to eeprom
· PAUSE 10························· 'sample rate
· NEXT
Thanks for the help...
Jeremy
Comments
http://www.emesystems.com/BS2speed.htm
If your entire program cycled a "pause 100" statement ONLY, then it would cycle pretty close to 10Hz. But the other commands take time to execute. For instance, the "pulsin 11, 0, cyclet" takes ATLEAST "cyclet" milliseconds to execute (plus the time to fetch the command from the eeprom and process it prior to executing). The "debug" statement is basically a "serout" command that takes time to send commands to your computer. The "write" command probably takes a couple milliseconds also.... so your program is basically cycling at more than 100ms due to the time to execute other commands. If you want to make it cycle closer to 10Hz, you'll need to shave off some from the "pause 100" statement. You could just do this by trial and error, if you have a way to measure it.
As for timestamping: you can do that... but it depends on how accurate you want to get. If you want the timestamp to be accurate to the millisecond, you'll need to get a timekeeping chip that operates down to the milliseconds. You could also just use a 555 and a counter, if you want to go the cheap and adjustable route. If you're only interested in the second (to get a feel for how many samples/sec you're getting), see the timekeeping chip parallax offers:
http://www.parallax.com/detail.asp?product_id=604-00005
Hope that helps,
Dave
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Knight Designs
324 West Main Street
P.O. Box 97
Montour Falls, NY 14865
(607) 535-6777
Business Page:·· http://www.knightdesigns.com
Personal Page:··· http://www.lightlink.com/dream/chris
Designs Page:··· http://www.lightlink.com/dream/designs
·
Dave
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Knight Designs
324 West Main Street
P.O. Box 97
Montour Falls, NY 14865
(607) 535-6777
Business Page:·· http://www.knightdesigns.com
Personal Page:··· http://www.lightlink.com/dream/chris
Designs Page:··· http://www.lightlink.com/dream/designs
·