Shop OBEX P1 Docs P2 Docs Learn Events
time stamping recorded data — Parallax Forums

time stamping recorded data

jlosawjlosaw Posts: 3
edited 2005-01-25 16:57 in BASIC Stamp
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

Comments

  • BorisBoris Posts: 81
    edited 2005-01-25 13:34
    This page has information on "Basic Stamp timing" basically tells you how long it takes to execute each command.
    http://www.emesystems.com/BS2speed.htm
  • achilles03achilles03 Posts: 247
    edited 2005-01-25 13:37
    Jeremy,
    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 SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-01-25 16:26
    Not sure what data is in the variable cyclet, but if that's your speed data, then you're not logging the time with it anyway.· You would need to add into the routine code to store at least 2 more bytes of data, which would also take more time, as well as EEPROM space.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    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
    ·
  • achilles03achilles03 Posts: 247
    edited 2005-01-25 16:40
    Chris is right about the PULSIN command. For some reason I mixed up COUNT with PULSIN. So ignore the 3rd sentence in my post. smile.gif

    Dave
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-01-25 16:57
    Dave, I suppose if he can calculate the interval for each successive loop, he could just calculate the time of each event based on the start time.· That would also take less time through the loop trying to log more data, AND you'd have more EEPROM space.

    idea.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    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
    ·
Sign In or Register to comment.