Controlling the Speed of your Boe-Bot

Let’s take a moment and look at the program that we used before to center the servos:

  speedLeft = 0
  speedRight = 0
  time = 30000
  GOSUB Wheel_Speeds

First we have the command “DO”…

…and then five lines below that we see another command …”LOOP”.

This tells us that the program is going to “DO” something (whatever that is), and then it’s going to “LOOP” back up and DO “it” again.  In short, it looks that this program will continue to loop forever unless something interrupts it.

In between the DO and LOOP commands we have:

  speedLeft = 0
  speedRight = 0

This appears as though the speed of the Left and Right servos are set to a speed of “0” …fully stopped?  So what happened when we first ran this program and the servos were perhaps moving?  That’s why we adjusted the screw — we calibrated the mechanical device (the servo) to the program that is going to be controlling it.   Now when any program wants to turn the servos off, all it needs to do give the servo motor a control value of “0” and it’s stopped.

So what do you suppose happens if you change “speedleft = 0” to “speedleft = 100”?

  • Try it and see if you’re right.
  • How about changing the value from “100” to “27”?  Try it.
  • Try different values between 0 and 100 for both the speedLeft and speedRight parameters. Do you see a pattern?
  • Write your observations in your Engineering Notebook.

So what did you discover?  Can you control the speed of both motors independently and simultaneously? 


Challenge #1

  • Change the speed values so that the Boe-Bot rolls in a circle (causing both servos to turn) to the right. 
  • Next, fine tune your program, so that the Boe-Bot’s circle is approximately three feet in diameter. 
  • Now, alter your programs such that your robot is going in the opposite direction. 
  • Document these program changes and their results in your Engineering Notebook.


Challenge #2

There’s a critical safety issue when baby chickens escape from the protection of the hen house.  But, as luck would have it, you are part of the Chicken Protection Engineering Team (C-PET). Other team members are addressing such challenges as how to detect when a baby chick has “escaped”, and how to get Little Chicken safely back home. Your mission, should you decide to accept it, is to give your Boe-Bot the ability to temporarily “corral” the baby chick within an 18” diameter “safety zone”.  Once your Boe-Bot has established this zone, a suction hose (developed by another engineering team) will deploy, and whisk the baby chick away to safety.  For some inexplicable reason, your Project Manager informs you that part of your design specification requires your Boe-Bot to run in reverse.  Please be advised that no baby chicks shall be injured during this Design Challenge.

  • Change the values such that the Boe-Bot rolls backwards in a circle to the left that’s about eighteen inches in diameter, as quickly as it can go.
  • Write your Code for this Challenge in your Engineering Notebook.  Be sure to use comments throughout your programs.

(Hint: Chapter 4 in Robotics with the Boe-Bot)


Collaborative Design Challenge A

Discuss (with your Counselor) and define a Challenge that you’ll need to accomplish.  At a minimum, it should include making the Boe-Bot navigate some pre-determined path.

  • Document what the Challenge is that you’ve agreed upon.  Then, as you try different programs to accomplish the task(s), keep good notes on what works, what doesn’t, and what other observations and ideas that you encountered or came up with.  
  • Once you have a working version of the Code (that accomplishes the Challenge) be sure to give your program “comments” as well.  This will help you in the future when you’re trying to figure out what the program is doing (or supposed to be doing!) as each command is executed.

Servo motors are controlled devices.  They are “told” (electronically) what to do.  We call that type of connection “Output”.  That is to say that the servo is controlled by an output coming from the microcontroller.

In almost every microcontroller system however, it’s a two-way street.  There’s both Output (making something happen), and Input (being notified that something happened).

In the same way that we connected I/O lines (like P12 and P13) to the servos, we can also connect sensing circuitry to an I/O line as well.  That’s why they’re called “I/O lines” – each one (of the 16 available on the BASIC Stamp2), can be used either as an Input or an Output.