Shop OBEX P1 Docs P2 Docs Learn Events
ssir detector, please help — Parallax Forums

ssir detector, please help

111mike111mike Posts: 2
edited 2005-04-05 14:19 in Robotics
Hello,

my son and I are building our first robot.· We are using the basic stamp 2 on a homework board with a polulu motor driver.· We are trying to use an ssir detector for object detection.· We are able to get our motors running independently, but we're getting nothing from the SSIR detector itself.· We've tried running the program that came with it with no results.· There's not a lot of information about the SSIR on the net.· Is this thing a lemon, or maybe just defective.· We're about ready to give up on this whole deal.· What we need is a simple program to enable us to use this detector to sense objects and then have the motors take the appropriate evasive action.· Can anyone help us?· Any suggestions would be greatly appreciated.· Here's a sample of the code we used for the SSIR.

Thank you,

111mike



'{$stamp BS2}
'{$PBASIC 2.5}

·DIR0 = 1··· 'sets pin 0 - to imput

·Holdbit VAR Bit······ 'sets up a variabe for the echo

·start:



FREQOUT 0,1,38500······· 'sends out signa to IR LED
· Holdbit = IN0········· 'store reply

· DEBUG 1,"sensor =", DEC Holdbit,CR ' dispays resutlts



GOTO start

Comments

  • JonbJonb Posts: 146
    edited 2005-04-02 23:16
    What components are you using. Are they the standard ones that come with the boe bot? They output high when nothing is detected and low when they detect IR light at the proper frequency. The program you posted seems ok. Only problem I see straight off the bat is that IN0 should be output when sending out the 38.5khz signal then set to input to check for result.

    I recently set up a pair of IR emitters and detectors following directions in the boe bot documentation page 245.

    http://www.parallax.com/dl/docs/books/edu/Roboticsv2_2.pdf

    Also I tested the sensors by placing a LED on the output pin which greatly helped in troubleshooting. If your IR emitter/detector is a 1 pin component, then changing input/output direction will work.

    Post Edited (Jonb) : 4/2/2005 11:46:52 PM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-03 01:44
    Mike,

    ·· I see one more problem in your code...Don't know which part is wrong, but DIR0 = 1 sets it to an OUTPUT not an INPUT as the comment describes.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-04-03 20:07
    I think I would do:

    '{$stamp BS2}
    '{$PBASIC 2.5}

    ' Pin 0 FREQOUT sends an IR signal.
    ' Pin 0 input reads the IR-Detector.

    INPUT 0 'sets pin 0 - to imput

    Holdbit VAR Bit 'sets up a variabe for the echo

    start:
    FREQOUT 0,1,38500 'sends out 1 mSec signal to IR LED -- and leaves pin an output
    INPUT 0
    Holdbit = IN0 'store reply

    DEBUG 1,"sensor =", DEC Holdbit,CR ' dispays resutlts
    GOTO start

    ' Note HoldBit == 1 on no-reflection, 0 on reflection
  • 111mike111mike Posts: 2
    edited 2005-04-04 23:39
    Thanks Allan,

    Your suggestions worked. I was even able to write a quick program to get our motors to respond once an object is detected. This has helped out immensely. Here is the whole thing program if you're interested. Pretty small potatoes. If you have a moment, I was wondering why it is 0 on reflection and not a 1. I think I'm missing something here.

    Thanks again for your help,

    111mike


    '{$stamp BS2}
    '{$PBASIC 2.5}


    speed VAR Byte
    Holdbit VAR Bit 'sets up a variabe for the echo
    x VAR Byte





    DO

    GOSUB pathchecker
    GOSUB forward


    LOOP

    ' -- -- subroutines -- --


    Pathchecker:


    ' Pin 0 FREQOUT sends an IR signal.
    ' Pin 0 input reads the IR-Detector.

    INPUT 1 'sets PIn 1 - To input




    start:

    FOR x=1TO 100

    PAUSE 50
    FREQOUT 1,1,38500 'sends out 1 mSec signal to IR LED -- and leaves pin an output
    INPUT 1
    Holdbit = IN1 'store reply

    DEBUG 1,"sensor =", DEC Holdbit,CR ' dispays resutlts
    IF holdbit = 0 THEN forward
    NEXT


    END

    ' Note HoldBit == 1 on no-reflection, 0 on reflection




    Forward:


    HIGH 6 'take serial line high

    LOW 8 ' reset motor controller

    HIGH 8

    PAUSE 100 ' motor controller start up time


    FOR speed = 0 TO 50

    SEROUT 6, 84, [noparse][[/noparse]$80, 0, 1, speed] 'third number in brackets is motor control,
    SEROUT 6, 84, [noparse][[/noparse]$80, 0, 3, speed] 'L.motor=0, R.motor=1, FWD=1,RVS=0, motor control value(3rd #)is
    'motor#(0 or 1)times 2, + value for FWD. or Rvs.(0 or 1).
    'see note, page 8, motor control handbook


    PAUSE 20

    NEXT
    PAUSE 5000

    FOR speed = 50 TO 0

    SEROUT 6, 84, [noparse][[/noparse]$80, 0, 1, speed] 'stops
    SEROUT 6, 84, [noparse][[/noparse]$80, 0, 3, speed]



    PAUSE 20
    NEXT
    PAUSE 1000

    GOTO pathchecker
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-04-05 14:19
    Why 1 on no-detect? Well, the reason is because the IR-Detector is an 'active' device. There's really quite a lot going on inside that little square of plastic. It's looking for a particular blink-rate frequency of blinking IR light. When it doesn't see one, it lets its output 'float' up to 5 volts. When it does see one, it provides a 'low' signal on its output.

    That's how the device works. I know it seems counter-intuitive, but that's what the designers did. I'm sure they had a good reason for doing it that way (less power required? Better signal detect? Wired-Or configuration?) but that's the short answer.
Sign In or Register to comment.