Noob question..
Hello All!
So I just got my Boe-Bot a few weeks ago and it's my first bot. I'm familiar with programming to an extent and I feel like I understand what's going on in my code but I'm vexed by a problem.
I've installed the whiskers and tested them, I've also written several successful programs for basic locomotion. But when I go to combine the two it refuses to work(at least correctly). I've disassemble and reassemble the circuits, rewritten the code. Followed the book to the letter. So here is the code:
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
pulseCount VAR Byte
FREQOUT 4, 2000, 3000
'main
DO
IF (IN5 = 0) AND (IN7 = 0) THEN
GOSUB Back_Up
GOSUB Turn_Left
GOSUB Turn_Left
ELSEIF (IN5 = 0) THEN
GOSUB Back_Up
GOSUB Turn_Right
ELSEIF (IN7 = 0) THEN
GOSUB Back_Up
GOSUB Turn_Left
ELSE
GOSUB Forward_Pulse
ENDIF
LOOP
'subroutines
Forward_Pulse:
PULSOUT 13, 850
PULSOUT 12, 650
PAUSE 20
RETURN
Turn_Left:
FOR pulseCount = 0 TO 20
PULSOUT 13, 650
PULSOUT 12, 650
PAUSE 20
NEXT
RETURN
Turn_Right:
FOR pulseCount = 0 TO 20
PULSOUT 13, 850
PULSOUT 12, 850
PAUSE 20
NEXT
RETURN
Back_Up:
FOR pulseCount = 0 TO 40
PULSOUT 13, 650
PULSOUT 12, 850
PAUSE 20
NEXT
RETURN
Basically no matter what input registers the Back_Up subroutine doesn't run, and the IN7 causes a 180 degree left rotation and the IN5 a 90 degree rotation. I'm really excited to progress but I'm stumped right now and I don't know what I'm missing. Please HELP!
Thanks!
So I just got my Boe-Bot a few weeks ago and it's my first bot. I'm familiar with programming to an extent and I feel like I understand what's going on in my code but I'm vexed by a problem.
I've installed the whiskers and tested them, I've also written several successful programs for basic locomotion. But when I go to combine the two it refuses to work(at least correctly). I've disassemble and reassemble the circuits, rewritten the code. Followed the book to the letter. So here is the code:
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
pulseCount VAR Byte
FREQOUT 4, 2000, 3000
'main
DO
IF (IN5 = 0) AND (IN7 = 0) THEN
GOSUB Back_Up
GOSUB Turn_Left
GOSUB Turn_Left
ELSEIF (IN5 = 0) THEN
GOSUB Back_Up
GOSUB Turn_Right
ELSEIF (IN7 = 0) THEN
GOSUB Back_Up
GOSUB Turn_Left
ELSE
GOSUB Forward_Pulse
ENDIF
LOOP
'subroutines
Forward_Pulse:
PULSOUT 13, 850
PULSOUT 12, 650
PAUSE 20
RETURN
Turn_Left:
FOR pulseCount = 0 TO 20
PULSOUT 13, 650
PULSOUT 12, 650
PAUSE 20
NEXT
RETURN
Turn_Right:
FOR pulseCount = 0 TO 20
PULSOUT 13, 850
PULSOUT 12, 850
PAUSE 20
NEXT
RETURN
Back_Up:
FOR pulseCount = 0 TO 40
PULSOUT 13, 650
PULSOUT 12, 850
PAUSE 20
NEXT
RETURN
Basically no matter what input registers the Back_Up subroutine doesn't run, and the IN7 causes a 180 degree left rotation and the IN5 a 90 degree rotation. I'm really excited to progress but I'm stumped right now and I don't know what I'm missing. Please HELP!
Thanks!
Comments
If the BoeBot isn't turning properly, re-center the servos. There's an adjustment you must make so that the wheels don't move if they're sent a pulse 1.5ms wide (PULSOUT <pin>,750). This is described in the "Robotics with the BoeBot" tutorial.