Boe-Bot Ir navigation problems (again)
Hello all,
I recently finished programming the 'fastirroaming.bs2" for my Boe-Bot. I tested the Ir sensors, and they worked fine. The problem is, When execute the roaming program, my robot just keeps going straight. I stuck me hand infront, it just stopped in my hands, I tried it in a room, and just went straight into the wall. I double checked my programming, but I'm attaching it just in case. I checked my circuit works fine, because the IR sensors work perfect. I think it's a communication problem between my IR sensor and my wheels. Any help would be appreciated.
Code:
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
irDetectLeft VAR Bit
irDetectRight VAR Bit
pulseLeft VAR Word
pulseRight VAR Word
FREQOUT 4, 2000, 3000
DO
FREQOUT 8, 1, 38500
irDetectLeft = IN9
FREQOUT 2, 1, 38500
irDetectRight = IN0
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
PULSOUT 12,pulseRight
PAUSE 15
LOOP
I recently finished programming the 'fastirroaming.bs2" for my Boe-Bot. I tested the Ir sensors, and they worked fine. The problem is, When execute the roaming program, my robot just keeps going straight. I stuck me hand infront, it just stopped in my hands, I tried it in a room, and just went straight into the wall. I double checked my programming, but I'm attaching it just in case. I checked my circuit works fine, because the IR sensors work perfect. I think it's a communication problem between my IR sensor and my wheels. Any help would be appreciated.
Code:
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
irDetectLeft VAR Bit
irDetectRight VAR Bit
pulseLeft VAR Word
pulseRight VAR Word
FREQOUT 4, 2000, 3000
DO
FREQOUT 8, 1, 38500
irDetectLeft = IN9
FREQOUT 2, 1, 38500
irDetectRight = IN0
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
PULSOUT 12,pulseRight
PAUSE 15
LOOP

Comments
How would i put a debug statement in my IF code? I tried doing that but it gave me an error :"expected a constant, variable, or unary operator). I tested the sensors before hand, they work perfect.
DEBUG "Program Running!"
DEBUG "Made it to label abc"
DEBUG "Made it to label def"
DEBUG "leftirdetector=",irdetectleft,CR
and
' DEBUG_DEBUGIN.BS2 ' This program demonstrates the ability to accept user input from the ' Debug terminal, and to accept numeric entry in any valid format. ' {$STAMP BS2} ' {$PBASIC 2.5} myNum VAR Word Main: DO DEBUG CLS, "Enter a any number: " ' prompt user DEBUGIN SNUM myNum ' retrieve number in any format DEBUG CRSRXY, 0, 2, ' display number in all formats SDEC ? myNum, SHEX ? myNum, SBIN ? myNum PAUSE 3000 LOOP ' do it again END