Shop OBEX P1 Docs P2 Docs Learn Events
servo with Sharp IR distance as tracking — Parallax Forums

servo with Sharp IR distance as tracking

robban35robban35 Posts: 32
edited 2010-10-02 13:43 in BASIC Stamp
Hi!

i am trying to make a sharp IR distance sensor attached on a servo to track an object...

step 1:

move the servo as a scan from left to right. (this i have managed)

but the following .....

if an object is detected then start track

when an object is detected move the servo to the position were the object is..

Comments

  • ercoerco Posts: 20,256
    edited 2010-10-01 07:38
    Your code...?
  • robban35robban35 Posts: 32
    edited 2010-10-01 07:50
    here´s my code....

    ' {$STAMP BS2}
    i VAR Word
    b VAR word
    time VAR Word
    go:
    FOR i=1 TO 5
    PULSOUT 6, 1 ' move the servo
    GOSUB dis
    IF time<100 THEN en
    PAUSE 150
    NEXT

    st:

    FOR i=1 TO 5
    PULSOUT 6,1300
    IF time<100 THEN en
    GOSUB dis
    PAUSE 150
    NEXT
    GOTO go


    dis:
    HIGH 10
    PAUSE 1
    RCTIME 10,1,time
    DEBUG DEC time,CR
    IF time<100 THEN en
    RETURN

    en:
    DEBUG "Target",CR
    GOSUB track
    RETURN

    track:
    FOR i=1 TO 1
    IF time>500 THEN forward
    IF time<500 THEN revers
    PULSOUT 6, (b) ' move the servo
    GOSUB dis
    PAUSE 300
    NEXT
    RETURN

    FORward:
    b=B+1
    RETURN
    revers:
    b=B-1
    RETURN
  • NWCCTVNWCCTV Posts: 3,629
    edited 2010-10-01 23:13
    You would not by chance be working on this for a camera setup, would you? I believe I have a post or two somewhere on this or possibly another forum on that very issue. I will see if I can dig it up and will post when I find it.
  • ercoerco Posts: 20,256
    edited 2010-10-02 09:21
    Tracking using one distance-measuring sensor on the tracking servo will be problematic. You can know if an object is detected, but when it moves, you don't know which way it moved, so you will end up hunting randomly for it.

    If you had one or more stationary sensors in the cam's field of view, you could use that dats to aim your cam.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2010-10-02 13:40
    If this is in fact for a ccamera, another way would be to somehow tap in to the camera or software motion detection.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2010-10-02 13:43
    Another issue to consider is how far away will objects be when tracking. If you placed multiple senors in a circle you could program possibly for nearby, but if you go too far out what happens when the servo is moving and suddenly detects another object????
Sign In or Register to comment.