Shop OBEX P1 Docs P2 Docs Learn Events
Noob question.. — Parallax Forums

Noob question..

UnsuiUnsui Posts: 2
edited 2010-10-05 20:29 in Robotics
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!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-05 17:14
    Your program looks like it sort of would work, enough that you'd be able to fine tune it. In any event, Back_Up should be called if both whisker switches are closed at the same time. Check your wiring again. Make sure the switches are connected to I/O pins 5 and 7. The switches should connect the I/O pin to ground when they're closed. You should have a pullup resistor between each I/O pin and +5V.

    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.
  • UnsuiUnsui Posts: 2
    edited 2010-10-05 17:27
    Thanks Mike. I think I just needed to recenter the servos. Spent a day tearing it down and rebuilding it and I didn't even think about recentering the servos. Do they need recentering often?
  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-05 20:29
    They shouldn't need "re-centering" more than once. When they're initially made, their control pot could be anywhere in its range. Once adjusted, they should keep their setting for a long time.
Sign In or Register to comment.