Shop OBEX P1 Docs P2 Docs Learn Events
Event timing — Parallax Forums

Event timing

dbergdberg Posts: 5
edited 2009-06-09 21:31 in BASIC Stamp
How do i measure an event (high/low on i/o pin) that takes approximately 3 seconds with millisecond accuracy? Thanks in advance for any help!

Comments

  • SRLMSRLM Posts: 5,045
    edited 2009-06-09 21:07
    What is the minimum time? What is the maximum time?
  • Mike GreenMike Green Posts: 23,101
    edited 2009-06-09 21:31
    www.emesystems.com has some good information (see the "app-notes" link) on the execution time of various statements. The only way to get millisecond accuracy would be to use external hardware. This scheme may be good enough for your circumstances and would give you a resolution on the order of 1ms.
    timePulse:
       if in0 = 0 then timePulse ' wait for the leading edge of the pulse
    waitForEnd:
       time = time + 1 + 0 ' the extra addition adds about 140us
       if in0 = 1 then waitForEnd ' continue until the trailing edge of the pulse
       return
    



    You'd take the resulting value and apply a correction factor that you'd have to determine empirically since Tracy's website doesn't give timings for all the operations used.
Sign In or Register to comment.