ssir detector, please help
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
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
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
·· 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
'{$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
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
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.