Shop OBEX P1 Docs P2 Docs Learn Events
PING software or hardware read method without waiting — Parallax Forums

PING software or hardware read method without waiting

JanJan Posts: 2
edited 2008-01-29 18:13 in General Discussion
Besides using a CPU.pulseIn() command, is there a way to read the return pulse length without having to wait for the longest pulse (e.g. 2131, which is about 19 milliseconds)?

This way the CPU can do other processing and come later to check the result.

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-01-29 18:01
    The pulseIn returns as soon as a valid pulse has been measured so if your pulses
    are 1 msec, then pulseIn returns after 1 msec + waittime for pulsestart.
    pulseIn uses 8.68 usec resolution.
    If that resolution is not that important, you can do (pseudo code)

    mark a timer
    loop {
    ···check the pin for the right edge (rising or falling),
    ·· do something else
    }
    get the time passed.

    regards peter
    ·
  • JanJan Posts: 2
    edited 2008-01-29 18:13
    The Ping sensor returns a pulse width of 73.7 usec per inch (from Ping.java). Trying to keep a resolution of inches would require freq / 2 sampling for a 73.7 usec measurement. Not alot of time to do other work (in the order of milliseconds would interesting based upon Javelin exe speed).· Am I missing something or any other ideas?

    thanks,
Sign In or Register to comment.