This material is archive-only, and will no longer be updated. Please update your bookmarks to the PDF text download page: Robotics with the Propeller Boe-Bot.

Test Forward Backward and Stay Still

Back in Center and Test the Servos, you ran a test program named 2 Test Full Speeds.spin, and it made the servos turn full speeds in opposite directions.  With the way the servos are mounted facing in opposite directions, that translates into forward motion for the PropBOE-Bot.  For example, here is a picture of the PropBOE-Bot's left and right sides.  See how the left wheel has to turn counterclockwise and the right wheel has to turn clockwise for forward motion?

  • With the power switch off, gently and slowly move the PropBOE-Bot forward and verify the directions the left and right wheels have to turn.
  • Repeat for backwards, left turn, and right turn.

    Wheel rotations for making the Propeller Boe-Bot robot roll forward.

Test Code

This program is a slightly modified version of 2 Test Full Speeds from the Test Direction and Speed Control page in Center and Test the Servos lesson.  The PropBOE Square Wave object has been added to the OBJ block with the nickname freq, and a call to freq.Out announces the start of the program.  After that, it's the same, starting with the left P14 servo turning full speed counterclockwise, and the right P15 servo turning full speed clockwise.  After that, there's a 3 second pause, and during that time, the PropBOE-Bot should move forward.  Next, the servos will reverse directions for backward motion for another three seconds, followed by the stop signal.  Let's try it.

  • Open 2 Test Full Speeds from your PropBOE-BotAssembleAndTest folder (the folder, not the zip file!).
  • Load the Program with into the Propeller chip's EEPROM with F11.
  • Verify that the PropBOE-Bot moves forward for three seconds, then backward for three seconds, then stops.
''2 Test Full Speeds.spin                
  system : "Propeller Board of Education"
  servo  : "PropBOE Servos"              
  time   : "Timing"                      
  freq   : "PropBoe Square Wave"         
PUB Go | i                               
  freq.Out(4, 1000, 3000)                
  servo.Set(14, 200)                     
  servo.Set(15, -200)                    
  servo.Set(14, -200)                    
  servo.Set(15, 200)                     
  servo.Set(14, 0)                       
  servo.Set(15, 0)                      

Try This

Here are some variations on the program that make the PropBOE-Bot pivot right, then pivot left, then rotate right, then rotate left, then stop.  Try it out, and pay close attention to the rotation speed and direction of each wheel.

  • Save 2 Test Full Speeds.spin under another name in the same folder.
  • Add the code below to the end of the program.
  • Watch carefully after the forward and backward to see the two pivots followed by the two rotations.

  servo.Set(14, 200)                    ' Pivot right
  servo.Set(15, 0)
  servo.Set(14, 0)                       ' Pivot left
  servo.Set(15, -200)
  servo.Set(14, 200)                    ' Rotate right
  servo.Set(15, 200)
  servo.Set(14, -200)                   ' Rotate left
  servo.Set(15, -200)
  servo.Set(14, 0)                       ' Stop
  servo.Set(15, 0)

Your Turn

Each time.Pause call after the two servo.Set calls determines how long each maneuver lasts.  The time the maneuver lasts in turn determines the distance it travels or how far it turns.  Knowing this, you can fine tune the distances and turns.  

  • Try chaning the two time.Pause(3000) calls to time.Pause(2000).  Did the PropBOE-Bot travel 2/3 of the distance?
  • Try adjusting the time.Pause(750) calls to make a 45-degree pivot and a 90-degree turn in place.