NASA‐Th
Lesson
Today w we can p understa motion.
First, let servo is compone
Three m
1. Smal
2. Gear
. Spec
3 i
moto
hreads
n
5:
Boe
B
we are going program the
and some of
t’s look at th shown belo ent of the se
main compon ll DC motor
Box with sm ial electron or
Bot
Moti
g to make ou e Boe‐Bot to f the mecha
he servos. A ow. It illustr
ervo.
nents that m
mall plastic ics inside th
Electricit
on
ur Boe‐Bots o move, we m anics behind
basic diagr ates the ext
make up the
gears to re he servo int
ty and Magne
move. Befo must first d the Boe‐Bo
am of the ternal
servo:
duce the RP erpret a pul
etism
Ne
• •
•
ore
ot
PM and incr lse signal an
Lesson 5
eeded Boe‐Bot Computer Stamp Edi USB cable
rease output nd deliver p
5: Boe‐Bot M
r with BASIC itor program e
t torque power to the
Motion
C m
For this later less As m n and el e t d iv 1. St
2. C sp The stan motion. The puls the grap between counterc 20 ms tim In order Stamp E It indicat An impo that sect ms, the v A similar It indicat times 2 μ Generall lesson, we w sons, we wi ioned earlie ver power t tandard ser ontinuous s peed at whi ndard servo Thus, we w se signal tha h plots volt n 1.3 ms and clockwise, r me elapse. to control t ditor progra tes that 12 i ortant note i tion is repre value for a f r command tes that the μs or 1.7 ms ly the comm will focus m ll go into m er, the servo to the motor rvo: the puls servo: inter ich to spin. is useful fo will be using at controls t tage versus d 1.7 ms dep respectively the motion o am. The foll is the pin nu is that when esenting the full speed cl is: servo is att s. mand is: PUL more on the ore detail a o contains s r. There are se signal tel prets the pu r positionin a continuou the servo is time. In a fu pending if th y. It is also im of the Boe‐B lowing com PULS umber the s n specifying e number of ockwise. PULS tached to pi LSOUT pin, d third compo about the DC pecial elect e two types lls the servo ulse signal t ng an object us servo. represente ull speed rot he shaft is s mportant to Bot, you hav mmand is use SOUT 12, 65 servo is atta g the duratio f 2 μs interv
SOUT 12, 85 n 12, and th duration. onent in the C motor and tronics that of servos: o what posit to spin a cer t, but has ve d by the gra tation, the p pinning clo o note that b ve to set the ed: 50 ached to and on in our pr vals. 650 tim 50 he duration e servos: the d the gear bo interpret a tion to hold rtain directi ry limited r aph below. A pulse width ckwise or between pul e pulse using d 650 is the rogram, the mes 2 μs = 1
is specified e electronic ox. ulse sign p a . ion and the rotational As you can s will vary lses there is g the Basic pulse durat value place 300 μs, or 1
NASA‐Threads Electricity and Magnetism Lesson 5: Boe‐Bot Motion
What if we wanted to change the speed of the motion? We would have to manipulate the pulse duration.
Duration Pulse idth
(ms) W Servo Action
650 1.3 Full Speed CW
700 1.4 ½ Speed CW
750 1.5 Stopped
800 1. 6 ½ Speed CCW
850 1. 7 Full Speed CCW
Hands On
Let’s look at this program that makes a Boe‐Bot move forward at full speed and then sharply turn left:
ut this program into your BASIC Stamp Editor and experiment with the duration and P
counter components of the program.
ow that you have a program that can move forward full speed and make a sharp left turn, ry to add to this program so that you make your Boe‐Bot reverse and turn sharply right. N
Solution:
NASA‐Threads Electricity and Magnetism Lesson 5: Boe‐Bot Motion
ow that you have the code written for full spe
urn, and sharp reuse
ha d to
of these a name and call on them accordingly as the flow N
t w
ed forward, full speed reverse, sharp right that code in other programs. For instance,
follow this flow chart:
This program requires multiple instances of full speed forward as well as full speed reverse. You could write the program to have the code for each motion of the Boe‐ Bot to be written each time it appears or
ou can use what is called a subroutine. written already
you do not have left turn, you may want to
t if you had a program that was suppose
Initialize Variables
(Defining the size of the variables used in the program)
y
Go Forward Full speed for a duration
Basically, if there is a code or a function in a program
f
to retype it every time it appears. You can simply call on it using a GOSUB command.
How do you use a GOSUB?
Well you give your prewritten code a name (i.e. for full speed forward, maybe its name should be fullForward). Once you have the name for the code, instead of writing that code into your program, you would type
GOSUB then the name of the code that you want to run (for forward it would be
GOSUB fullForward). Then you would type the rest of your code as you would like. You
can put as many GOSUB commands as you
want. Now whenever you need the code you can simply call on it. This is especially
Go in Reverse Full speed for a duration
Go Forward Full speed for a duration
Turn Sharply to the Right for a duration
Go in Reverse Full speed for a duration
helpful when something appears multiple times in a program. After you type out your full program with all the needed GOSUB commands below your program, you can paste the
Turn Sharply to the Left for a duration
code that the GOSUB is calling for (for full speed forward you would type fullForward: then all the code associated with full speed forward). Note that you put a colon after the name of
the code. Two things you should always remember when using the GOSUB command are:
. Put a RETURN statement on the last line of the subroutine. This tells the Boe‐Bot to go 1
back to the next line in the main program.
2. Put an END statement after your main program and before the first subroutine, so that the Boe‐Bot doesn’t plow on into the first subroutine after it finishes executing the main program.
de for full speed forward, full speed reverse, sharp right
Try it out! You already have the co urn, and sharp left turn. Give each
hart describes.
olution: t
c S