making the robot work with 4 ir object/detection avoidance setup
lobo
Posts: 100
i build a robot with 4 infrared object detection components instead of the two that the roboticsv2 manual shows. For a program i used the one below which is page 252-253 on the roboticv2 manual. I thought by adding two more freqout and irDetects it would work but it does not. What am i doing wrong guys?
thanks in advance!
' Robotics with the Boe-Bot - FastIrRoaming.bs2
' Higher performance IR object detection assisted navigation
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
irDetectLeft VAR Bit ' Variable Declarations
Chapter 7: Navigating with Infrared Headlights · Page 253
irDetectRight VAR Bit
pulseLeft VAR Word
pulseRight VAR Word
FREQOUT 4, 2000, 3000 ' Signal program start/reset.
DO ' Main Routine
FREQOUT 8, 1, 38500 ' Check IR Detectors
irDetectLeft = IN9
FREQOUT 5,1,38500······ 'I added this
irDetectleft=IN6
FREQOUT 2, 1, 38500
irDetectRight = IN0
FFREQOUT 14,1,38500··· 'I added this
irDetectleft=IN15
' Decide how to navigate.
IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
pulseLeft = 650
pulseRight = 850
ELSEIF (irDetectLeft = 0) THEN
pulseLeft = 850
pulseRight = 850
ELSEIF (irDetectRight = 0) THEN
pulseLeft = 650
pulseRight = 650
ELSE
pulseLeft = 850
pulseRight = 650
ENDIF
PULSOUT 13,pulseLeft ' Apply the pulse.
PULSOUT 12,pulseRight
PAUSE 15
LOOP[noparse][[/noparse]code][noparse][[/noparse]/code]
thanks in advance!
' Robotics with the Boe-Bot - FastIrRoaming.bs2
' Higher performance IR object detection assisted navigation
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
irDetectLeft VAR Bit ' Variable Declarations
Chapter 7: Navigating with Infrared Headlights · Page 253
irDetectRight VAR Bit
pulseLeft VAR Word
pulseRight VAR Word
FREQOUT 4, 2000, 3000 ' Signal program start/reset.
DO ' Main Routine
FREQOUT 8, 1, 38500 ' Check IR Detectors
irDetectLeft = IN9
FREQOUT 5,1,38500······ 'I added this
irDetectleft=IN6
FREQOUT 2, 1, 38500
irDetectRight = IN0
FFREQOUT 14,1,38500··· 'I added this
irDetectleft=IN15
' Decide how to navigate.
IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
pulseLeft = 650
pulseRight = 850
ELSEIF (irDetectLeft = 0) THEN
pulseLeft = 850
pulseRight = 850
ELSEIF (irDetectRight = 0) THEN
pulseLeft = 650
pulseRight = 650
ELSE
pulseLeft = 850
pulseRight = 650
ENDIF
PULSOUT 13,pulseLeft ' Apply the pulse.
PULSOUT 12,pulseRight
PAUSE 15
LOOP[noparse][[/noparse]code][noparse][[/noparse]/code]
Comments
You should use the template Jon always mention, and it is really usefull to avoid easy bugs.
A quick look at :
well, sounds like the same irDetectleft variable is used for two differents sensors readings on pin 6 and 15...
You should create as many variables as IR sensors to hold the values and change the truth table of the decision process (' Decide how to navigate.') to take into accont the new variables.
++
Post Edited (Tibot) : 11/20/2005 1:34:57 PM GMT