Shop OBEX P1 Docs P2 Docs Learn Events
clocking R/C car time — Parallax Forums

clocking R/C car time

Macgman2000Macgman2000 Posts: 59
edited 2005-04-17 16:05 in General Discussion
Hello all,

I have an application for clocking the time it takes to go between 2 points 10' apart. I am using IR LEDS and IR-modules. I want the timer to start when pointA IR is interrupted and stop when pointB IR is interrupted and display the time interval (most likely in milliseconds).

I would appreciate any help!!!!

The IR receive modules are pulled high via 5k resistors and when illuminated by IR goes low.

Best Regards,
Nick

Comments

  • BeanBean Posts: 8,129
    edited 2005-04-17 01:47
    What is the minimum and maximum time ?
    Do your IR-modules go high or low when the beam is broken ?
    How do you want the time interval displayed (LCD, LED ect) ?

    That should be fairly easy if you use SX/B.
    Basically the code would look like this (assuming the IR-modules go high when beam is broken, and the maximum time is·< 65·seconds)

    · CountL=0
    · CountH=0
    WaitStart:
    · IF IR1 = 0 THEN WaitStart
    TimeIt:
    · PAUSE 1
    · INC CountL
    · CountH=CountH + C
    · IF IR2 = 0 THEN Timeit
    ' Total time is (CountL + CountH*256) milliseconds


    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video Display Module" Available Now.

    www.sxvm.com

    "A problem well defined, is a problem·half solved."


    Post Edited (Bean) : 4/17/2005 1:50:43 AM GMT
  • Macgman2000Macgman2000 Posts: 59
    edited 2005-04-17 03:19
    yes, I am using an LCD to display the elapsed time. The IR-led's need to be modulated at 38Khz, I suspect that makes it more difficult? The IR RX modules have a 5k pull up, when the IR beam is broken they will go from Low to high (low is when the RX module is receiving an IR signal).·Time range I would say 2ms to 60sec.

    Thanks!!!

    Best Regards,
    Nick
    ·
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-17 14:34
    If you want to modulate the IR LEDs with the SX you'll need to setup an interrupt. If you setup your ISR to flip the IR LEDs every 13 uS then you can also use that in your timing -- 13 uS * 76.92 = 1 ms ... that might be close enough for what you're doing.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • BeanBean Posts: 8,129
    edited 2005-04-17 16:05
    Jon is right, because the interrupt will skew the PAUSE timing (making it longer that what you specify). So doing the timing in the interrupt routine would be the most accurate.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video Display Module" Available Now.

    www.sxvm.com

    "A problem well defined, is a problem·half solved."
    ·
Sign In or Register to comment.