Shop OBEX P1 Docs P2 Docs Learn Events
Boe-Bot Ir navigation problems (again) — Parallax Forums

Boe-Bot Ir navigation problems (again)

BroodCrusherBroodCrusher Posts: 4
edited 2012-03-11 19:34 in BASIC Stamp
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

Comments

  • FranklinFranklin Posts: 4,747
    edited 2012-03-11 09:43
    Put some debug statements in your IF code to see what the sensors are returning. It also helps us if you wrap your code in the code tags to retain the indenting.
  • BroodCrusherBroodCrusher Posts: 4
    edited 2012-03-11 15:16
    Franklin wrote: »
    Put some debug statements in your IF code to see what the sensors are returning. It also helps us if you wrap your code in the code tags to retain the indenting.

    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.
  • FranklinFranklin Posts: 4,747
    edited 2012-03-11 16:48
    I tried doing that but it gave me an error :"expected a constant, variable, or unary operator).
    Could we see the code that gave you the errors (Wrapped in "[code]" tags please)
  • BroodCrusherBroodCrusher Posts: 4
    edited 2012-03-11 17:41
    [code] DEBUG IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN[code]
  • ercoerco Posts: 20,256
    edited 2012-03-11 19:34
    DEBUG acts like a print statement, nothing more. Try:

    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
    
Sign In or Register to comment.