Shop OBEX P1 Docs P2 Docs Learn Events
measureing time of travel — Parallax Forums

measureing time of travel

Jeena99Jeena99 Posts: 14
edited 2009-11-28 18:44 in Robotics
I am working on a project and I am using Boe Bot robot and basic stamp Micrcntroller
I·want to use ·Whiskers to measure the time the robot has travelled without hitting an obsticle·.
And I am ·thinking·how to write the code·...
I want to avoid relying on a for lop counter to measure the time.
So I thought of using the methode COUNT

I appreciate any help or suggessions
Thanx

Post Edited (Jeena99) : 11/22/2009 8:13:57 AM GMT

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2009-11-25 20:28
    You could use a real-time clock, but that has·resolution only·to seconds (no fractional seconds).

    If/when the BoE-bot encounters an obstacle it could then read the time and then compare to that of the·previous obstacle/event.

    Post Edit -- You could (??) increment a variable (Word)·each time you pass through a servo refresh routine, but that would have a top-end limitation (appx 20 min.)· Still, not real exacting.

    Post Edited (PJ Allen) : 11/25/2009 10:04:49 PM GMT
  • ZootZoot Posts: 2,227
    edited 2009-11-26 17:07
    Use a 555 timer setup to output a square wave at, say, 2hz (that will give you a tick every 1/2 second, and since we'll be measuring edges, you'll get 1/4 second increments on your internal "timer").

    Hook the output of the 555 circuit up to an input pin, then:


    
    DO
    ' do some stuff
    
    ' output to motors
    PULSOUT, x,y,z
    PULSOUT, x,y,z
    
    'update time
    IF whiskerL = 1 AND whiskerR = 1 THEN ' both off
       IF timeCount.BIT0 <> clock555pin THEN
           timeCount = timeCount + 1
       ENDIF
    ELSE
       timeCount = 0
    ENDIF
    
    IF timeCount > 120 THEN ' approx 30 seconds
        DEBUG "whoa, 30 seconds without an obstacle"
    ENDIF
    
    LOOP
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • Jeena99Jeena99 Posts: 14
    edited 2009-11-28 18:44
    Thank u so much PJ and Zoot
    What you`ve said is really helpful


    Jeena smile.gif
Sign In or Register to comment.