Shop OBEX P1 Docs P2 Docs Learn Events
Boe-Bot Navigating With Whiskers — Parallax Forums

Boe-Bot Navigating With Whiskers

RobbieRobot_1RobbieRobot_1 Posts: 3
edited 2009-08-23 18:38 in Robotics
Hello,

I am 12 years old and·new to PBASIC and just built my Boe-Bot, but ran into an issue when programming "RoamingWithWhiskers" on page 179 in the "Robotics With the Boe Bot" manual.· Most of my programming experience is limited to LEGO and C++.·

After uploading the program to the boe-bot, the whiskers work, the led's light when depressed, however, the servos do not respond to the inputs and one of the servos turn in the opposite direction.· Essentially, once powered up after loading the program, the boe-bot's servos turn, with one turning opposite the other, but do not respond to the inputs (no backing up and no turning, just running static and constant).· Here's my code, I hope someone can get me on track.· Thank You!

' {$STAMP BS2}
' {$PBASIC 2.5}··················· ' stamp directive
' Robotics with the Boe-Bot - RoamingWithWhiskers.bs2
' Boe-Bot uses whiskers to detect objects, and navigates around them.

DEBUG "whisker states", CR,
····· "Left···· Right", CR,
····· "
···
"
DO
· DEBUG CRSRXY, 0, 3,
······· "P5 = ", BIN1 IN5,
······· "·· P7 = ", BIN1 IN7
· PAUSE 50
IF (IN7 = 0) THEN
· HIGH 1
ELSE
· LOW 1
ENDIF
IF (IN5 = 0) THEN
· HIGH 10
ELSE
· LOW 10
ENDIF
LOOP
DEBUG "Program Running!"
'
[noparse][[/noparse] Variables ]
pulseCount···· VAR···· Byte··················· ' For...NEXT loop counter.
'
[noparse][[/noparse] Initialization ]
FREQOUT 4, 2000, 3000························· ' Signal program start/reset.
'
[noparse][[/noparse] Main Routine ]
DO
· IF (IN5· = 0) AND (IN7 = 0) THEN············ ' Both whiskers detect obstacle
··· GOSUB Back_Up····························· ' Back up & U-Turn (Left twice)
··· GOSUB Turn_Left
··· GOSUB Turn_Left
· ELSEIF (IN5 = 0) THEN······················· ' Left Whisker Contacts
··· GOSUB Back_Up····························· ' Back up & turn right
··· GOSUB Turn_Right
· ELSEIF (IN7 = 0) THEN······················· ' Right Whisker Contacts
··· GOSUB Back_Up····························· ' Back up & turn left
··· GOSUB Turn_Left
· ELSE········································ ' Both Whiskers 1, no contacts
··· GOSUB Forward_Pulse······················· ' Apply a forward pulse
· ENDIF······································· ' and check again
LOOP
'
[noparse][[/noparse] Subroutines ]
Forward_Pulse:································ ' Send a single forward pulse
· PULSOUT 13,850
· PULSOUT 12,650
· PAUSE 20
· RETURN
Turn_Left:··································· ' Left turn, about 90-degrees
· FOR pulseCount = 0 TO 20
··· PULSOUT 13, 650
··· PULSOUT 12, 650
··· PAUSE 20
· NEXT
· RETURN
· Turn_Right:······························· ' Right turn, about 90-degrees
··· FOR pulseCount = 0 TO 20
····· PULSOUT 13, 850
····· PULSOUT 12, 850
····· PAUSE 20
··· NEXT
··· RETURN
Back_Up:···································· ' Back up.
· FOR pulseCount = 0 TO 40
··· PULSOUT 13, 650
··· PULSOUT 12, 850
··· PAUSE 20
· NEXT
· RETURN

Comments

  • WhitWhit Posts: 4,191
    edited 2009-08-23 12:27
    Have your servos functioned correctly in the previous excercises? (Especially the excercises in Chapter 2 - where you centered the servos and also in Chapter 3, where you tested the Boe-Bot's operation)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Whit+


    "We keep moving forward, opening new doors, and doing new things, because we're curious and curiosity keeps leading us down new paths." - Walt Disney

    Post Edited (Whit) : 8/23/2009 12:35:55 PM GMT
  • RobbieRobot_1RobbieRobot_1 Posts: 3
    edited 2009-08-23 17:36
    Changing the pulsout duration arguments from 650 to 850 on either pin does not reverse the direction of either servo?
  • RobbieRobot_1RobbieRobot_1 Posts: 3
    edited 2009-08-23 18:06
    You were right, I did not properly center the servos, thank you!
  • WhitWhit Posts: 4,191
    edited 2009-08-23 18:38
    RobbieRobot_1 said...
    You were right, I did not properly center the servos, thank you!
    No problem! That is what it sounded like to me. Glad you're up and running. Have fun! turn.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Whit+


    "We keep moving forward, opening new doors, and doing new things, because we're curious and curiosity keeps leading us down new paths." - Walt Disney
Sign In or Register to comment.