Professional Documents
Culture Documents
Servo2007 12
Servo2007 12
o
l
.
5
N
o
.
1
2
S
E
R
V
O
M
A
G
A
Z
I
N
E
H
E
R
O
S
E
R
V
O
S
S
P
A
R
E
T
H
E
R
O
D
,
S
P
O
I
L
T
H
E
B
O
T
T
A
S
K
P
R
I
M
I
T
I
V
E
S
D
e
c
e
m
b
e
r
2
0
0
7
Cover.qxd 11/6/2007 3:46 PM Page 84
Order 24 hours a day, 7 days a week
www.Jameco.com
Or call 800-831-4242 anytime
Jameco Electronics. *According to the line cards on their web sites on August 28, 2007. Trademarks are the property of their respective owners.
OTHER JAMECO ADVANTAGES:
More major brands of semis than any other catalog.
99% of catalog products ship the same day.
Lowest prices guaranteed, or we pay 10%.
Major brand names and generic equivalents
for even greater cost savings.
5
10
15
20
Were passive aggressive
When it comes to passive products, we dont pull
any punches: we stock more major brands of
passive components than any other major cata-
log distributor.* So whatever brands you need
from AMP or AVX to Vishay or Wakefield
youre more likely to find them all at Jameco.
Check our stats below and see for yourself.
Its another Jameco advantage.
Jameco
Digi-Key
Mouser
Newark
func Dispit()
dim tstr as string
dim newtime as string
dim oldgpstime as string
FormMenu(0,0,0,)
FormButton(Disp_Start,-1,-1,-1,-1,Abort)
First Open the File
if FileOpen(1,gfname,Open) = 0 then
msgbox(Unable to open file: +gfname,0,Open File)
FormMenu(0,0,1,)
FormButton(Disp_Start,-1,-1,-1,-1,Start)
exit()
endif
============================================================
- Main Data Display Loop -
loop:
if FormButton(Disp_Start,0) > 0 then
FileClose(1)
FormMenu(0,0,1,)
FormButton(Disp_Start,-1,-1,-1,-1,Start)
exit()
endif
if FileEOF(1) = 1 then
FileClose(1)
Print End of Data
FormMenu(0,0,1,)
FormButton(Disp_Start,-1,-1,-1,-1,Start)
exit()
endif
- Read a Line of data from Log File
procNEMA(FileReadLine(1))
- If we get a GGA message lets update the display
strif NEMAmsg = GGA then
newtime=converttime(GGA_UTCTime,-5))
FormLabel(Disp_time,-1,-1,-1,-1,newtime)
Formlabel(Disp_Fix,-1,-1,-1,-1,GGA_FIXtxt)
Formlabel(Disp_mode,-1,-1,-1,-1,GSA_SATMODE)
Formlabel(Disp_sats,-1,-1,-1,-1,GSA_SATCOUNT)
GSV_NOM=0
GSV_MSG=0
if GGA_Fix <> 0 then
Formlabel(Disp_Longitude,-1,-1,-1,-1,GGA_Longitude+GGA_EW)
Formlabel(Disp_Latitude,-1,-1,-1,-1,GGA_Latitude+GGA_NS)
Formlabel(Disp_Alt,-1,-1,-1,-1,GGA_AltValue+GGA_AltUnit)
Formlabel(Disp_Course,-1,-1,-1,-1,RMC_COG)
Formlabel(Disp_Speed,-1,-1,-1,-1,Format(float(RMC_SOG *
1.1508),.0)+ mph)
else
Formlabel(Disp_Longitude,-1,-1,-1,-1,)
Program Snippet
FIGURE 12
FIGURE 13
SERVO 12.2007 39
continued ...
Simpson3.qxd 11/5/2007 3:51 PM Page 39
40 SERVO 12.2007
abort button is hit, the file is closed
and the function exits. Each line
retrieved from the log file is passed to
the procNEMA function and only
when a GGA message is received does
the display get updated.
The plotit function in the
GPSLogPlot program is very similar to
the dispit function, with the exception
of how the GPS information is pre-
sented. The plotit function uses a spe-
cial command built into the Zeus lan-
guages called GPSCVTLongitudedec
and GPSCVTLatitudedec to convert
the GPS positional string data to an
integer value in degrees * 100000.
This is a whole number that can be
used for plotting.
One final variation of the dispit
function is the StartCapture function
used in the GPSDataLogger program. In
this function, a com port is opened and
its parameters are
set based on
the actual device
selected. The function also calls various
setup functions to place the device into
the correct mode when needed. Instead
of calling the procNEMA function
directly, data from the device is added
to a global variable called rxdat when
it is received. A call is then made to a
function called procdata. This function
pulls a single line (one at a time) from
the rxdat variable and passes them to
the procNEMA command as before.
Sending Log Data
Plotting and displaying data is
cool to play with, but the main reason
we want to capture the data is so that
we can simulate an actual GPS mod-
ule or receiver. I have included a pro-
gram called GPSLogOutput shown in
Figure 13. GPSLogOutput allows you
to play back the captured log data to
a serial port. The program looks and
operates much like the GPSLogDisplay
program, but also sends a copy of the
captured data to a serial com port.
You select the com port via the
Settings menu shown in Figure 14.
You can also set the baud rate and
flag the data to be sent in real time.
Using the Log
Data with a
Microcontroller
Next month, when we start
to interface the GPS modules
to a microcontroller, the
GPSLogOutput program will be
indispensable. In addition to
your PC, you will
need a DiosPro
DiosProg1.txt
func main()
dim val
hsersetup baud,HBAUD4800,start,txon
nodata:
hserin nodata,val
debug val
goto nodata
endfunc
Program 1
FIGURE 14
FIGURE 15
FIGURE 16
Program Snippet continued ...
Formlabel(Disp_Latitude,-1,-1,-1,-1,)
Formlabel(Disp_Alt,-1,-1,-1,-1,)
Formlabel(Disp_Course,-1,-1,-1,-1,)
Formlabel(Disp_Speed,-1,-1,-1,-1,)
endif
- Used for realtime display option
strif oldgpstime <> newtime then
oldgpstime = newtime
if realtime = 1 then pause(1000)
endif
endif
goto loop
endfunc
Simpson3.qxd 11/5/2007 3:51 PM Page 40
microcontroller and a carrier
board. I will be using the
Dios Workboard Deluxe
shown in Figure 15. The
DiosPro has a UART built
into the chip that has a TTL
interface. This is perfect for
the modules, but in order to
use our PC as a simulator, you
will need an EZRS232 interface shown
in Figure 16.
In order to use the GPSLogOutput
program, you will need two serial
ports on your PC. One port will con-
nect to the program port on the
Workboard and the other will connect
to the EZRS232 module. Connect the
following pins on the EZRS232
module to the Dios Workboard as
shown in Figure 17.
EZRS232 Pin 1 Workboard VSS
EZRS232 Pin 2 Workboard VDD
EZRS232 Pin 3 Workboard Port 8
EZRS232 Pin 4 Workboard Port 9
Load code shown in Program 1
into the DiosPro compiler and
program the chip. Once loaded, start
the GPSLogOutput program and load
up one of the LogData files I have
included. Set the GPSLogOutput com
port to the one that is connected to
the EZRS232 module. Set the baud
rate to 4800 as shown in Figure 18.
Once this is done, hit the start
program. You should see NEMA data
in the debug terminal of the Dios
compiler as shown in Figure 19.
It just so happens that the
DiosPro already has a library called
DiosNEMA. It is automatically loaded
when you place a call to the
procNEMA function in your Dios
program as shown in
Program 2.
This library will
break down the
GGA and RMC com-
mands and load up a
FIGURE 19
FIGURE 20
Dios NEMA Proccessor
func main()
clear
hsersetup baud,HBAUD4800,start,txon,clear
print Mode Lat Long Alt Speed Dir
print - - - -
loop:
procNEMA()
if NEMAcmd = 3 then GGA
if NEMAfix > 0 then
print NEMAfix,:,NEMAsats, ,{-6.0} NEMAlatmin, ,NEMAlongmin;
print ,{6.1} NEMAaltitude, ,{4.1} NEMAspeed, ,NEMAdir
else
print No Fix ,NEMAfix,:,NEMAsats
endif
endif
goto loop
endfunc
include \lib\DiosNEMA.lib
Program 2
SERVO 12.2007 41
FIGURE 17
FIGURE 18
Simpson3.qxd 11/5/2007 3:52 PM Page 41
set of global variables that you can
use in your own program. In Program
2, I used the print command to send
various pieces of NEMA data to the
debug terminal shown in Figure 20.
Whats Next
Next month, Im going to show
you how to connect the various GPS
modules to the microcontroller and
how to parse the data.
Be sure to check for updates
and downloads for this article at
www.kronosrobotics.com/Projects
/GPS.shtml SV
The following is a breakdown of sources
for all the components needed for
Parts 1 through 4 of this project.
SPARK FUN ELECTRONICS
EM-406A GPS Module
www.sparkfun.com/commerce/
product_info.php?products_id=465
EM-406 Evaluation Board
www.sparkfun.com/commerce/
product_info.php?products_id=653
EM-408 GPS Module
www.sparkfun.com/commerce/
product_info.php?products_id=8234
Copernicus Evaluation Board
www.sparkfun.com/commerce/
product_info.php?products_id=8145
Nine-Pin Serial Cable
www.sparkfun.com/commerce/
product_info.php?products_id=65
6V AC Adapter
www.sparkfun.com/commerce/
product_info.php?products_id=737
External Antenna with SMA connector
www.sparkfun.com/commerce/
product_info.php?products_id=464
SMA to MMCX Adapter Cable
www.sparkfun.com/commerce/
product_info.php?products_id=285
KRMICROS
ZeusPro
www.krmicros.com/Development/
ZeusPro/ZeusPro.htm
KRONOS ROBOTICS
EZRS232
www.kronosrobotics.com/xcart/
product.php?productid=16167
DiosPro Chip
www.kronosrobotics.com/xcart/
product.php?productid=16428
Dios WorkBoard Deluxe
www.kronosrobotics.com/xcart/
product.php?productid=16452
Parts List
42 SERVO 12.2007
Simpson3.qxd 11/5/2007 3:53 PM Page 42
R
ewards and punishments
can serve as fundamental
motivations for learning. Think
of how you train your dog through
tasty treats or the occasional knock
on the nose. Your robot isnt much
different. You can reward a robot for
staying on target or punish it for getting
out of line in much the same way.
Dogs already know how good a
treat is and can associate the reward
with their behavior. Robots, however,
need to be taught what a reward
is and how to relate it to their
actions. Reinforcement learning (RL) is
a technique for educating your robot
about actions that are beneficial or
detrimental.
Lets work with a barebones
example. Say you want to teach your
robot to stop at a goal one foot in front
of it. You could program that behavior
directly, but that approach could get
tedious or tricky with more complex
scenarios. What if you want the robot
to find its way through a maze? What
if you want the robot to find the
quickest path through a range of
terrains? Or the most opti-
mal grip for an assortment
of drinking cups? Or the
optimal tilt angle to shoot a
projectile? RL can help.
First, you have to define
a goal, actions, states,
rewards, a policy for choos-
ing actions, and a value
function for the states. In
general, for each time step t, an action
a is taken, the state s is updated, and
reward r is given (Figure 1).
Lets go back to the example of
stopping at a goal one foot in front
of a starting point. We will need a
sensor (e.g., odometry) that can return
how far the robot has moved. Next,
by Karla Conn
SERVO 12.2007 43
FIGURE 1. Basic relation
between a robot and
an RL environment.
Conn.qxd 11/1/2007 11:10 AM Page 43
44 SERVO 12.2007
we need to define the scenario (see
Table 1).
A program flowchart and the cen-
tral loop of the corresponding example
code are shown in Figure 2. Go to
www.servomagazine.com to down-
load RL_stand_alone_example.cpp for
the full C++ code. To begin the RL
algorithm, we initialize the odometry,
starting state, starting action, reward,
and the values of the states. The robot
will begin stopped (a2) at a location
away from the goal (s2) and then use
the policy to select actions. With each
action taken, the state is updated and
a reward is given based on the new
state. The objective is to take actions
that lead to the current state matching
the goal (s1).
While the current state is not the
goal, the robot takes actions based
on the policy (e.g., randomly). Then,
sensors are used to determine the
new state and a reward is given. Values
of the states (value_s1, value_s2)
are updated based on the reward
until the search for the goal is
satisfied. Once the goal is found, the
robot can stop.
In the above example, say the first
action randomly chosen is stop. The
odometry would be updated (i.e., less
than one foot), and the state would be
updated based on the definitions (since
odometry < one foot, new state = not
goal, represented by s2). Therefore,
the reward given for the state would
be zero, and the value function would
update the state value by adding
the current state value to the reward
(s2 = 0 + 0).
Say the next action
randomly chosen is move
forward and the robot
moved at least a foot,
then the odometry would
read at least one foot or
more. The updated state
would be set to s1 (i.e.,
since odometry one
foot, new state = goal).
Therefore, the reward
given would be one, and
the value function would
update the state value (s1
= 0 + 1). The while loop
would be satisfied and
since the robot has found
the goal, it can stop. The
result is an educated set
of state values that can be used in
later runs of the program to improve
performance.
Intrigued with how the algorithm
works? Impressed? Unimpressed?
Perhaps. The above example outlines a
mere foundation for a valuable way to
teach a robot. RL is valuable because it
can adapt to so many different
situations and remains flexible enough
to accommodate a variety of goals
and/or state definitions.
In the remainder of this introducto-
ry article, I will touch on some ways
you can compound on the basics set
up so far and give examples of where
to try your own RL ideas. First, a bit of
fair warning. Your robot may need lots
and lots of iterations (maybe hundreds
or thousands of runs, depending on
the application) before the RL
algorithm settles on an optimal
solution. So schedule adequate time
for your robot to learn, but dont let
that word of caution stop you from
giving your robot the means to learn
on its own. Dont be confined to the
definitions in the above basic example,
either. There are plenty of ways to
expand on the RL parameters.
For example, instead of random
selection, the policy can choose to
Start
Initialize
Parameters
Goal
Found?
Stop
Use Policy to
Choose Action
Take
Action
Update
State Value
Update
State
Give
Reward
//Goal Found?
while (current_state != s1){
//Use Policy to Choose Action
if (random_number < 5){
current_action = a1;
}
else current_action = a2;
//Take Action
if (current_action == a1){
//execute move forward action
}
else //execute stop action
//Get new Odometry value in units of feet
//Update State
if (odometry >=1){
new_state = s1;
}
else new_state = s2;
//Give Reward
if (new_state == s1){
reward = 1;
}
else reward = 0;
//Update State Value
if (new_state == s1){
value_s1 = value_s1 + reward;
}
else value_s2 = value_s2 + reward;
//Replace Current State with New State
current_state = new_state;
}
//Once current_state is the goal, stop
current_action = a2; //execute stop action
Y
N
FIGURE 2. Program
flowchart (left) and
central while loop of
RL_stand_alone_example.
cpp (right).
Goal: When odometry one foot
Actions (a
1
, a
2
): a
1
= move forward
a
2
= stop
States (s
1
, s
2
): s
1
= goal
s
2
= not goal
Reward: If current state = not goal, reward = 0
If current state = goal, reward = 1
Policy: Random selection
Value: New state value = current state value + reward
Table 1
Conn.qxd 11/1/2007 11:11 AM Page 44
move into states with the highest
value. Preference could also be set
to choose moving forward, turning
left, etc. Modifications can certainly
be made to the definitions for states
and actions. Also, initializing the
state values to zero is common, but
assigning specifically-chosen values or
randomly populating state values is
permitted.
Rewards can also be negative
(punishments) to penalize states that
move away from the goal, and any
piece of data which you wish to
maximize or minimize can be used as
part of the reward function. For
instance, what if you want your robot
to learn to choose actions which find
the goal quickly? Incorporate a variable
to represent time or the number of
steps taken to find the goal in a
negative reward function (reward =
-full_reward*time_step). A slightly
negative step-based reward is like
giving your robot a little kick at each
step toward the goal, training it to
hurry up and find the goal faster.
A constructive addition to an RL
algorithm is the combination of states
and actions into state-action pairs. This
concept is called Q-learning, where
Q(s,a) represents the value of taking
action a in state s. This way, the reward
function rewards the state-action pair
that caused the action to move from a
non-goal state into the goal state.
Multiple runs can develop the
Q(s,a) values for all state-action pairs in
a task until the optimal solution is
found. Even if the optimal solution is
not found (due to equivalent solu-
tions), each run can refine the Q(s,a)
values towards closer representations
of the true value of taking action a in
state s.
Table 2 shows a set-up for an RL
algorithm with (i) a policy with a pref-
erence for moving forward, (ii) multiple
states besides the goal, and (iii) a
slightly negative step-based reward
function. A full example of this C++
code (RL_expanded_example.cpp),
including a random population of the
state values and state-action pairs, can
also be downloaded from www.ser
vomagazine.com.
Once mastered, you can use this
algorithm in loads of applications. You
simply need a task with a goal. Then
you define your states, actions,
rewards, policy, and value function. Say
you want your robot to learn how to
coordinate its leg movements to
crabwalk. Define plausible states and
actions, and set a reward function
based on forward movement. Then let
your robot loose to learn. Give your
robot plenty of chances to find the
goal, and youll have a self-sufficient
robot in no time.
Once your robot can learn to
associate rewards with its actions,
challenge it to a duel of who can find
the quickest path through a maze or
over rough terrain. Reward yourself
and your robot accordingly. SV
SERVO 12.2007 45
Goal: When odometry two feet
Actions (a
1
, a
2
, a
3
): a
1
= move forward
a
2
= stop
a
3
= move backward
States (s
1
, s
2
, s
3
, s
4
): s
1
= goal (odometry two feet)
s
2
= not goal (two feet > odometry one foot)
s
3
= not goal (one foot > odometry zero feet)
s
4
= not goal (zero feet > odometry)
Reward: If current state = s
4
, reward = -8*time_step
If current state = s
3
, reward = -4*time_step
If current state = s
2
, reward = -1*time_step
If current state = s
1
, reward = 100
Policy: 60% move forward, 30% highest state-action pair
value, 10% random
Value: New state-action pair value = current state-action
pair value + reward
Table 2
Conn.qxd 11/1/2007 11:11 AM Page 45
46 SERVO 12.2007
I
t is an appealing thought to have a
robot that can be instructed how to
perform a task by simply showing it
what to do. It would save a lot of time
otherwise spent on programming the
robot. The concept to simplify robot pro-
gramming by giving the robot abilities to
mimic tasks shown by the user is called
Programming by Demonstration, or PbD.
In future applications where
robots are assumed to be found
everywhere in our life it would also be
advantageous to give them instructions
on exactly how we want a task
performed simply by showing the task.
Another reason to try simplifying robot
programming is that smaller enterpris-
es with shorter production series might
then become interested in automating
their production.
Motion Capturing
The first step in the PbD process is to
capture the data. That is, record and store
the motions performed by the human
demonstrator and their impact on the
environment. Several options using
different measurement principles are
available for this purpose. If a vision-
based system is used, the human can
move without too many constraints These
systems require rather heavy image
processing, though. In most cases, the
system tracks different markers attached
to certain body parts and the limb motion
is reconstructed with the help of a
kinematic model of the human body. It is
also possible to extract human body
motions directly from raw image data.
Another option is to use a dedicated
wearable motion capturing system
(popular for movie making and analyzing
motion in sports). The measurement
system is firmly attached to the areas of
the body that need to be captured. This
type of system requires less data
processing, however, the user cannot
move as freely. Another catch is the price;
for example, a reliable six degree of
freedom tracker starts at about $10,000!
Another issue with a wearable data
capturing system is that the information
the sensors can pick up is limited to a
Programming By Demonstrating Robots
TASK PRIMITIVES
It is relatively easy for humans to imitate a task shown to us. This ability to
imitate is well developed both in us and in other primates, but rarely found in
other animals. Think of a pet; it is not straightforward to just show your dog how
to fetch the newspaper. So, it should be no surprise that it has been very hard
to design a robot with the same imitating capabilities as humans.
by Alexander Skoglung
and Boyko Iliev
Skoglund.qxd 11/5/2007 4:01 PM Page 46
specific area. For example, a glove will
only provide data on the fingers
configuration; no data will be available
on hand position and orientation, or
objects in the sensors vicinity. Basically,
the sensor is blind to the environment.
Data fusion to combine several
inputs into a single source is often
necessary in order to gather information
surrounding the motion capturing
device. In structured environments
(such as factory lines), CAD models can
be used to aid the data capturing
instead of using more sensors.
Task Primitives
Another important aspect to
consider is what your robot is capable of.
The mechanical structure of the robot
will determine what tasks and motions it
can perform. For example, Figure 1
shows a six degree of freedom robot
arm with the elbow in an up position.
It is important to distinguish
between tasks and motions. Returning
to the example of a dog fetching your
newspaper, the dog can perform the
required task, but in a different way (or
motion) than you would since dogs
dont have hands. (Of course, you
could do it the same way as your dog).
The difference between human and
robot body configurations means that
the robot may be able to perform a
task, but not with the same motion as
a human. Therefore, the human needs
to know how the robot behaves.
To approach the problem of
different body configurations, there are
two assumptions to be made that will
simplify the process. First, the humans
and robots end effectors (the humans
hand and the robots gripper) can be
associated with each other. Second, the
task can be seen as a set of subtasks.
In the the case of subtasks,
consider a fairly general task such as
Pick-and-Place commonly performed by
industrial robots. Break the task down
into smaller building blocks: Move-To-
Point, Move-Linearly-To-Point, Move-
Along-Path, Approach-Object, Grasp-
Object, Release-Object, and so on.
Given a clever design of these building
blocks, a great number of tasks can be
described by a small set of task
primitives. Each of these building
blocks can be seen as small robot
programs that when put in sequence
will produce a full task.
One of the big challenges in PbD is
how to map the demonstrated task to
these primitives. Researchers are
currently trying to solve the daunting
challenge of how a robot should learn
completely new and novel tasks from a
set of predetermined primitives. For an
industrial robot that only performs Pick-
and-Place operations, learning novel
tasks is clearly requesting too much.
A number of basic facts about the
task are usually known in advance. In
a Pick-and-Place operation, the robot
starts from a certain position, moves to
an object, grasps the object, moves the
object to a new location, releases the
object, and moves away from it. It is
our belief that future manipulators
should be simple to program and have
these basic behaviors built in.
To simplify mapping from the
demonstration of primitives, we make the
assumption that the robots end-effector
is corresponding to the demonstrators
hand; by doing so, we indirectly tell the
robot that only the humans end
effectors trajectory is of importance.
Besides recording the end
effectors motion path, the velocity
profile (Figure 2) provides important
information about where the motion
segments start and end.
In a Pick-and-Place task, we know
the order of sub-tasks (illustrated in
Figure 2). The first detected point is
associated with the location to pick up
FIGURE 1. The manipulator in our experimental
setup, an ABB IRB140 equipped with a vacuum
gripper. A video of the task being performed
is available at AASS Learning Systems Labs
webpage: www.aass.oru.se/Research/ Learning/.
SERVO 12.2007 47
Skoglund.qxd 11/5/2007 4:02 PM Page 47
48 SERVO 12.2007
an object; the second location is where
to place the object. The trajectory
between these two locations should be
imitated, but the start and end points
are not important since they are not
actually parts of the task. However, the
segment on the trajectory just before
the grasp and after the release should
be imitated to preserve the way the
grasp is performed.
When the different variables (such
as locations, velocities, and orientations)
of the task are determined, the
sequence of instructions is transferred to
the robot controller. The sequence could
look like this:
1) <Move-To-Point 640,30,80>
2) <Grasp-Object 640,30,20>
3) <Move-Along-Path 648,25,87>
4) <Move-Along-Path 647,28,90>
By doing so, we assume the lower
control levels of the manipulator, such
as inverse kinematics, constraints of
the workspace, generation of the
trajectory with a higher granularity,
etc., to execute the requested
commands in the proper way.
It is important to note that other
primitives than these can be used.
For example, some tasks require the
robot to reorient an object, turn an
object several times (assembly tasks),
and so on. Consider the capabilities
of the robot; what motions can the
robot do and what motions are
impossible?
The primitives are small pieces of
program code that should reflect what
the robot can do and how it would do
it, and the human demonstrations put
these pieces together in a sequence.
A comparison can be made to a
programming language, made up by a
small set of instructions, from which
large programs can be written. In this
comparision, these task primitives are
an attempt to add some high-level
features to robot programming.
An Example Scenario
Lets look at how to teach an
industrial robot equipped with a
vacuum gripper to execute a Pick-and-
Place task. Inside the gripper, a spring
with a switch is mounted to detect
resistance when picking or placing an
object (illustrated in Figure 3). The
steps from the demonstration to a
robot program would be:
1) A human demonstration is captured
and transformed into the robots
reference frame.
2) Trajectories are segmented to
extract the points where the motions
start and end.
3) Extracted motions are decomposed
into task primitives.
4) Each task primitive is automatically
translated into robot-specific code.
5) The complete task is executed by
the robot.
It is important to note for Step 4
that the task is known in advance
which makes it possible to describe the
task as a predetermined sequence of
task primitives. These task primitives
are designed specifically for the robot,
but can be executed on most six
degree of freedom serial manipulators.
The primitives controlling the
grasp and release are specific to the
0 1 2 3 4 5 6 7 8 9 10
0
100
200
300
400
500
600
700
M
e
a
n
S
q
u
a
r
e
d
V
e
l
o
c
i
s
t
y
(
m
m
)
Time (sec)
GraspObject
MoveToPoint MoveToPoint
MoveAlongPath
MoveAlongPath
MoveAlongPath
ReleaseObject
First motion Second motion Third motion
d
u
Set point
Starting point
l
Gripper
Spring
FIGURE 2. The blue line is the mean
squared velocity from a human
demonstrator, recorded from the
fingertip at 12 Hz. The green vertical
lines are the detected start of a motion,
where the velocity profile is over a
certain threshold and the increase is over
a certain level. In a similar way, the red
vertical lines are the end of a motion.
FIGURE 3. The vacuum
gripper with the spring
switch; d is the distance
between the target point
and the starting point,
and is dependent of the
sensor inaccuracy, u. When
the spring is compressed
and the switch turned on,
the downward motion
immediately stops and the
suction is turned on.
Skoglund.qxd 11/5/2007 4:02 PM Page 48
type of gripper used. Furthermore,
we assume that the demonstrator is
aware of the manipulators structure,
such as workspace boundaries and
possible motions.
The demonstration is done under
the assumption that the teachers index
finger is associated with the suction cup
of the gripper. During demonstration,
the fingertip is tracked by a motion
capturing device, shown in Figure 4.
Initially, the demonstrator moves
from a starting point, P
0
, to the desired
pick-point, P
pick
(Figure 5). Then, he/she
moves along a certain path towards the
desired place-point, P
0
, and finally, back
to the end position P
w
(t).
The collected data consists of
position coordinates used for two
purposes: to detect the Pick-and-Place
positions, P
pick
and P
place
, and to
reconstruct the desired trajectory that
the robot should travel from P
pick
to P
place
.
The decomposition of a Pick-and-
Place task into task primitives is
illustrated in Figure 2. By using primitives
reflecting the commands available in the
robot language of the manipulator, we
achieve a simple implementation. In this
particular scenario, the following
primitives are used:
Move-Linearly-To-Point moves the
manipulators end effector linearly
(Cartesian space) to the desired point
in the workspace.
Move-To-Point moves the
manipulators end effector to the point
where it can hook on to the
demonstrated trajectory.
Move-Along-Path follows a
demonstrated trajectory by taking a
sequence of points with relatively
high granularity as the input, and
then executing an interpolated motion
between these points.
Grasp-Object moves towards an
object using a search motion (due to
the uncertainty of the objects location)
and grasps the object. A search motion
moves the gripper slowly towards
the object until contact is detected
by the touch sensor and the motion
is stopped.
Release-Object is similar to Grasp-
Object, but releases the object
instead.
The two first primitives are
typically implemented on standard
industrial manipulators as instructions,
since most manipulators would be of
limited use without such basic
instructions. The last three primitives
are not normally part of the
programming language for industrial
robots, so its a benefit to add them to
the repertoire.
A Primitive Example
Now lets take a closer look at the
task primitive Grasp-Object. Before
performing a grasp operation, the
For those interested, check out the
coverage listed below on the subject of
robot learning from demonstration:
Robotics and Autonomous Systems,
vol. 47, no. 2&3 (2004).
Robotics and Autonomous Systems,
vol. 54, no. 5 (2006).
Neural Networks, vol. 19, no. 3 (2006).
IEEE Transactions on Systems, Man, and
Cybernetics, vol. 37, no. 2 (2007).
Visit the AASS Learning Systems Labs
webpage at www.aass.oru.se/Research
/Learning/. More details on the subject
in this article can be found in the paper:
A. Skoglund, B. Iliev, B. Kadmiry, and R.
Palm. Programming by Demonstration of
Pick & Place Tasks for Industrial
Manipulators using Task Primitives in the
Proceedings of the IEEE International
Symposium on Computational
Intelligence in Robotics and Automation
(CIRA), Jacksonville, FL, 2007.
Further Reading
0
w
(t)
P
place
P
pick
L (t)
w
L
0
P
P
FIGURE 4. The 6D-tracker mounted
on a data glove that was used to
capture the human demonstration.
FIGURE 5. The dotted
line is the demonstrated
path, starting at P
0
going
to P
0w
(t)$, via P
pick
and
P
place
. The solid line is
the robot path with the
different starting location,
L
0
, executing the grasp
and release primitives
just above the Pick-and-
Place points, respectively.
SERVO 12.2007 49
Skoglund.qxd 11/5/2007 4:02 PM Page 49
approach phase of the gripper towards
the object must be performed. The
position and orientation of the table
are known since the manipulator is
mounted on a table, like the robot in
Figure 1. However, the height of the
object to be grasped is unknown due
to the uncertainty of the sensor, thus
the approach primitive has to deal
with uncertainty.
When performing a grasp
operation, the manipulator is given a
goal position to move towards the
object and search for contact with it.
When a certain resistance is detected
(that is, a compliant spring is
compressed to a certain length) the
motion stops. The starting point is
determined by the distance, d, derived
from the inaccuracy of the sensor that
performs the motion capturing. The
retracting motion is the same as the
approach but in reverse.
Since the grasp and release
primitives are actually the same but
with one binary input variable to
decide whether to grasp or release
this pays off in the design process.
Conclusion
Task primitives link high-level
human instructions to particular
robot/gripper functionalities. By using
task primitives, the programming of a
robot becomes faster and simpler,
which is one goal of the PbD concept.
One drawback to PbD is that
motion capture systems with high
accuracy are expensive. Either PbD
needs to become less sensitive to
inaccuracies (for example, by use of
information from additional sensors and
intelligent environments) or the price
for accurate sensors needs to drop.
Another problem is that many
motion trackers use magnetic fields for
positioning and therefore suffer from
degrading accuracy when theyre close
to large metal objects or electric
motors generating magnetic fields.
Alternative trackers are vision based
or use optics instead of magnetic fields.
Intelligent environments containing RFID
tags, passive location sensors, and other
sensory units can be a complement
to motion capturing sensors when
interpreting the environment.
One can also think of solutions
where more than one primitive can be
active at the same time.
For example, a gripper can have
two primitives for approaching an
object from two orthogonal directions.
By blending them, one can achieve
reaching motions that approach the
object from an arbitrary direction.
Some of the current research on
the topic addresses the problem of
action classification where the motions
performed by the demonstrator are
recognized automatically. However, the
design of various task primitives is still
needed. The challenge of designing fully
autonomous robots is finding a way to
enable the robot to generate new task
primitives through learning, development,
and interaction with humans and the
surrounding world on its own. SV
50 SERVO 12.2007
Skoglund.qxd 11/6/2007 1:53 PM Page 50
W
hether they be fact or fiction,
you dont see many things
robotic moving about with
trailing AC line cords. As a matter of
fact, if you classify todays smart
weapons as bots, the only serious
mobile mechatronic devices that I can
think of that may still trail a wire are
the early wire-guided anti-tank missiles.
Will Robinsons buddy didnt drag
a cable around. Come to think of it, old
Robby didnt have a tail, either.
Thats because Will and Robby lived in
a time when battery technology was
very good. You are fortunate as our
battery technology today isnt too
shabby, either. However, even with the
best of batteries, there is a possibility
that you can lose important pieces of
data that your mechatronic creation
has learned or sensed when its lights
go out.
On the other hand, if your roving
pile of mechanical parts and transistors
is not a hunter-gatherer, you will
come to find it a royal pain to
reload those special parameters and
configuration data that are kept in the
robots volatile SRAM every time the
battery goes south.
In many instances, EEPROM is the
answer. However, if you have to
change your precious data too often,
youll eventually wear out the EEPROM
cells. And, even though EEPROM is a
good way to store nonvolatile data,
sometimes there just isnt enough
EEPROM available to do the job.
If EEPROM densities are too small
for your application and you dont
want to design in a hard drive or
battery-backed SRAM, the real (and
simple) answer to reliable nonvolatile
storage is Ferroelectric Nonvolatile RAM.
The RAMTRON FM21L16
We are about to embark upon a
project that will tie a RAMTRON
FM21L16 Ferroelectric Nonvolatile
RAM (FRAM) device to a 16-bit
PIC24FJ128GA010. The FM21L16 is
organized as 128K x 16. This 16-bit
FRAM configuration melds well with
the 16-bit PIC24FJ128GA010. If your
application does not require or cannot
handle a 16-bit data bus, the FM21L16
can be configured to run in eight-bit
mode, which doubles the available
FRAM to 256K x 8.
SERVO 12.2007 51
Put a new memory technology
to work in your robot!
Using FRAM
FRAM
for
Non-Volatile
Storage
Using for
Non-Volatile
Storage
by Fred Eady
Eady.qxd 11/6/2007 9:34 AM Page 51
R
S
-
2
3
2
C
O
N
N
E
C
T
O
R
N
O
T
E
S
:
1
.
1
0
M
H
z
o
s
c
i
l
l
a
t
o
r
=
D
I
G
I
K
E
Y
4
9
0
-
1
1
9
6
-
1
-
N
D
2
.
V
C
A
P
=
D
I
G
I
K
E
Y
5
1
1
-
1
4
4
7
-
1
-
N
D
3
.
Y
1
I
S
O
P
T
I
O
N
A
L
A
N
D
I
S
N
O
T
I
N
S
T
A
L
L
E
D
A
0
A
1
A
2
A
3
A
4
A
5
A
6
A
7
A
8
A
9
A
1
0
A
1
1
A
1
2
A
1
3
A
1
4
A
1
5
A
1
6
D
Q
0
D
Q
1
D
Q
2
D
Q
3
D
Q
4
D
Q
5
D
Q
6
D
Q
7
D
Q
8
D
Q
9
D
Q
1
0
D
Q
1
1
D
Q
1
2
D
Q
1
3
D
Q
1
4
D
Q
1
5
A
0
A
1
A
2
A
3
A
4
A
5
A
6
A
7
A
8
A
9
A
1
0
A
1
1
A
1
2
A
1
3
A
1
4
A
1
5
A
1
6
D
Q
0
D
Q
1
D
Q
2
D
Q
3
D
Q
4
D
Q
5
D
Q
6
D
Q
7
D
Q
8
D
Q
9
D
Q
1
0
D
Q
1
1
D
Q
1
2
D
Q
1
3
D
Q
1
4
D
Q
1
5
W
E
O
E
C
E
U
B
L
B
W
E
O
E
C
E
L
B
U
B
P
G
C
P
G
D
M
C
L
R
R
X
I
N
T
X
T
X
O
U
T
T
X
R
X
T
X
O
U
T
R
X
I
N
R
X
3
.
3
V
D
C
3
.
3
V
D
C
3
.
3
V
D
C
3
.
3
V
D
C
C
1
1
.
1
u
F
+
C
1
0
2
2
0
u
F
C
1
2
.
1
u
F
U
2
F
M
2
1
L
1
6
1
9
2
0
2
1
2
2
2
4
2
5
2
6
2
7
1
7
4
0
4
2
4
3
4
4
1 2 3 4 5
6
4
1
7 2
9
8 3
0
9 3
1
1
0
3
2
1
3
3
5
1
4
3
6
1
5
3
7
1
6
3
8
3
9
1
8
1
1
3
3
1
2
3
4
2
8
2
3
A
1
5
A
1
4
A
1
3
A
1
2
A
1
1
A
1
0
A
9
A
8
W
E
U
B
A
7
A
6
A
5
A
4
A
3
A
2
A
1
A
0
C
E
O
E
D
Q
0
D
Q
8
D
Q
1
D
Q
9
D
Q
2
D
Q
1
0
D
Q
3
D
Q
1
1
D
Q
4
D
Q
1
2
D
Q
5
D
Q
1
3
D
Q
6
D
Q
1
4
D
Q
7
D
Q
1
5
L
B
A
1
6
V
D
D
V
D
D
V
S
S
V
S
S
Z
Z
N
C
C
2
.
1
u
F
C
3
.
1
u
F
C
4
.
1
u
F
C
9
.
1
u
F
C
5
.
1
u
F
C
8
.
1
u
F
C
6
.
1
u
F
C
7
.
1
u
F
U
3
S
P
3
2
3
2
1
3 8
1
0
1
1 1 3
4 5
2
6 1
2
9 1
4
7 1
5
1
6
R
1
I
N
R
2
I
N
T
2
I
N
T
1
I
N
C
1
+
C
1
-
C
2
+
C
2
-
V
+
V
-
R
1
O
U
T
R
2
O
U
T
T
1
O
U
T
T
2
O
U
T
V
S
S
V
D
D
R
1
1
0
K
Y
1
O
P
T
I
O
N
A
L
C
1
7
.
1
u
F
U
1
P
I
C
2
4
F
J
1
2
8
G
A
0
1
0
1
2
3 4 5 6 7 8 9
1
0
1
1
1
2
1
5
1
6
1
7
1
8
3
0
3
1
3
2
3
3
3
4
3
5
3
6
3
7
4
8
4
9
5
0
5
1
5
2
5
3
5
4
5
5
9
1
7
5
9
2
9
7
9
8
9
9
1
0
0
7
1
6
4
5
7
2
7
2
9
2
8
7
0
6
9
8
1
8
0
1
4
6
5
8
2
4
0
4
1
4
2
4
3
4
4
4
5
4
6
4
7
7
9
7
8
7
7
7
6
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
7
2
7
3
7
4
9
5
9
4
6
7
6
6
6
3
6
2
6
1
6
0
5
9
5
8
6
8
9
0
8
9
8
8
8
7
8
6
8
5
8
4
3
8
8
3
3
9
5
6
9
6
9
3
1
3
5
2
5
1
R
G
1
5
V
D
D
R
E
5
R
E
6
R
E
7
R
C
1
R
C
2
R
C
3
R
C
4
R
G
6
R
G
7
R
G
8
V
S
S
V
D
D
R
A
0
R
E
8
A
V
D
D
A
V
S
S
R
B
8
R
B
9
R
B
1
0
R
B
1
1
V
S
S
V
D
D
R
D
1
5
R
F
4
R
F
5
U
1
T
X
U
1
R
X
R
F
8
R
F
7
R
F
6
R
A
6
V
S
S
R
A
7
R
G
1
3
R
E
2
R
E
3
R
E
4
R
D
1
1
O
S
C
2
R
G
2
R
B
7
/
P
G
D
R
A
1
0
R
A
9
R
D
1
0
R
D
9
R
D
4
R
D
1
3
R
G
9
V
S
S
R
D
5
R
F
1
2
R
B
1
2
R
B
1
3
R
B
1
4
R
B
1
5
V
S
S
V
D
D
R
D
1
4
R
D
1
2
R
D
3
R
D
2
R
D
1
R
E
9
R
B
5
R
B
4
R
B
3
R
B
2
R
B
1
R
B
0
R
B
6
/
P
G
C
R
D
0
R
C
1
3
R
C
1
4
R
G
1
4
R
E
1
R
A
1
5
R
A
1
4
O
S
C
1
V
D
D
R
A
5
R
A
4
R
A
3
R
A
2
R
D
8
R
G
0
R
G
1
R
F
1
R
F
0
E
N
V
R
E
G
V
C
A
P
R
D
7
R
A
1
R
D
6
R
F
1
3
R
G
3
R
G
1
2
R
E
0
M
C
L
R
R
F
2
R
F
3
I
C
S
P
C
O
N
N
E
C
T
O
R
1 2 3
4 5 6
1 2 3
4 5 6
R
2
1
0
0
+
C
1
1
0
u
F
C
1
3
.
1
u
F
C
1
6
.
1
u
F
C
1
4
.
1
u
F
R
3
1
K
C
1
5
.
1
u
F
D
B
9
F
E
M
A
L
E
1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
52 SERVO 12.2007
SCHEMATIC 1. As you can see,
there are plenty of open pins
just waiting for you to connect
them to something in your
FRAM project.
Eady.qxd 11/6/2007 9:34 AM Page 52
As youve probably already ascer-
tained, the FM21L16 does not require
a battery to retain the data contained
within its memory cells. Otherwise, the
FM21L16 reads and writes just like a
piece of standard volatile SRAM. Once
the power is removed from the
FM21L16, it can hold on to the data in
its possession for a minimum of 10
years. Before you decided to put your
FM21L16 into a deep sleep, you can
issue up to 100,000,000,000,000
read/write cycles to the device with
no concern for loss of data due to
memory cell damage.
I still have fond memories of hang-
ing 2KB chunks of SRAM from the pins
of 8748 and 8751 microcontrollers.
The very first of Microchips PIC17CXX
series of microcontrollers I was
exposed to were supported with
standard UV-erasable EPROM devices,
whose pin layouts resembled their
SRAM counterparts. So, Im glad to see
that the FM21L16 has followed in the
traditional footprint path that was
initiated back in the day by Intels line
of industry standard EPROM devices.
The FM21L16s industry standard pad
layout allows the FM21L16 to be
dropped into the space that a standard
128K x 16 volatile SRAM device would
take up.
In addition to being durable, the
FM21L16 is fast; 60 ns reads can be
initiated using the FM21L16s active-
low CE pin or by simply changing the
address. To prevent accidental data
corruption, the FM21L16 utilizes a low
voltage monitor that blocks access to
the FM21L16s memory array when
the power rail drops below a specified
voltage.
If you dont want your
FRAM-equipped mechanical devices
computing device to overwrite critical
data within the FM21L16, you have the
ability to write protect any of the
FM21L16s eight uniform 16K x 16
memory blocks. The FM21L16 is tough
enough to ride in the electronic
compartment of an automobile. That
means it would prove to be a very
macho part inside of your mechanical
animal, as well.
Designing the FRAM
Controller
I dont know about you, but I love
to put electronic stuff together from
scratch. So, lets design and build a
PIC24FJ128GA010-based controller
that is equipped with a serial port and
a FM21L16 FRAM device. Before we
begin, it might be a good idea to
examine the FM21L16s pinout and
understand what we need to design in
to read and write to the FM21L16s
memory cells. Ive provided a
schematic for you to reference as we
discuss the FM21L16s control pins
and I/O lines.
Naturally, we will have to deal with
assigning the FM21L16s 17 address
lines to PIC24FJ128GA010 microcon-
troller I/O pins. The PIC24FJ128GA010
does not support 17-bit I/O port
configurations. However, there are a
couple of 16-bit ports and a few other
I/O ports with a minimum of 10
available I/O positions. The trick is to
select the port that is easiest to access
in relation to the FM21L16s address
SERVO 12.2007 53
SCREENSHOT 1. Using a four-layer printed
circuit board eliminates the need to
route power and ground connections to
each hardware device. The latest version
of ExpressPCB allows the inner layers to
be cut into areas. Being able to separate
the inner power and ground layers is
great if you have to run multiple
voltages or separate ground planes.
SCREENSHOT 2. Every power and
ground connection has been assigned to
a power or ground plane in this shot.
Eady.qxd 11/6/2007 9:35 AM Page 53
pin layout. Also, well need to get
as many address lines from a
single PIC24FJ128GA010 I/O port as
possible. Following some brain bash-
ing, I selected the PIC24FJ128GA010s
PORTE for the first 10 bits of the
FM21L16s 17-bit address require-
ment. The remaining seven bits
of PORTB will be used to complete
the PIC24FJ128GA010s 17-bit
address bus.
The PIC24FJ128GA010s PORTB is
a 16-bit I/O port. However, Ive used
seven of its bits as address lines.
Fortunately, I still have a complete
16-bit I/O port that I can apply to the
FM21L16s 16-bit data bus. As you can
see in the schematic, Ive assigned the
PIC24FJ128GA010s 16-bit PORTD I/O
port to handle the FM21L16 data
bus duties.
The FM21L16s CE (Chip Enable)
pin is used to select the device and
begin a new memory access. Taking
the FM21L16s CE pin low while
holding the FM21L16s ZZ input high
will kick off a memory access event.
The ZZ (Sleep) pin is an important one
if your project needs to conserve
power. I decided not to dedicate a
PIC24FJ128GA010 I/O pin to the ZZ
input, which also eliminates us from
having to write some ZZ code to
support it. If you decide to use the ZZ
pin, be sure you understand how it
relates to the FM21L16s CE pin.
The FM21L16 datasheet recom-
mends that the ZZ input be tied to Vdd
when it is not utilized. As you can see
in the schematic, I follow directions
very well. The address data on the
FM21L16s address bus is latched
internally on the falling edge of the
FM21L16s CE. The FM21L16 has a
special feature that allows page mode
reads while the CE pin is low by
manipulating the two least significant
bits of the address bus. I simply
chose the most convenient
PIC24FJ128GA010 I/O pin for the
FM21L16s CE line. Since we can
choose to manipulate the CE pin or tie
it to a logic low level, I designed in a
jumper that connects the FM21L16s
CE pin to the PIC24FJ128GA010 or
directly to ground.
As with the CE pin selection, there
is absolutely no science behind my
selection of the FM21L16s WE (Write
Enable) line connection. A FM21L16
write cycle is initiated when the active-
low WE pin is driven to a low logic
level. Data on the FM21L16s data bus
is written into the FM21L16s memory
cells on the rising edge of the WE
pulse. The initial high-to-low logic level
transition of the WE pin is used to latch
in the new column address for page
mode write cycles.
I decided to control the FM21L16s
OE (Output Enable) line simply because
I can. The FM21L16s active-low OE line
allows the contents of the FM21L16s
data bus to be exposed to the
PIC24FJ128GA010s PORTD I/O pins
during read operations. Driving the
FM21L16s OE line to a high logic level
will tri-state the FM21L16s data bus.
In this project, I could have simply
tied the OE line low. I figure well write
that one instruction to drive RG3 low
and never touch the I/O pin again. If
you have other things competing for
the PIC24FJ128GA010s data bus,
you must utilize the FM21L16s OE
control pin.
The UB (Upper Byte) and LB
SCREENSHOT 3. The FRAM is located
on the far right of this shot. Note that I
attempted to route all of the top traces
(red) horizontally and all of the bottom
layer traces (green) vertically.
SCREENSHOT 4. The hard work is done.
All of the 17 address lines and 16 data
lines are in place in this shot.
54 SERVO 12.2007
Eady.qxd 11/6/2007 9:35 AM Page 54
(Lower Byte) FM21L16 control pins are
very interesting. Depending on how
you drive UB and LB, you can read and
write the most significant byte only or
read and write the least significant byte
only or read and write all 16 bits of the
FM21L16s data bus. Taking the
FM21L16s UB pin high will tri-state the
most significant byte (DQ15:8) of the
FM21L16s 16-bit data bus. Conversely,
a high logic level applied to the LB
control pin will tri-state the least
significant byte (DQ7:0) of the
FM21L16s 16-bit data bus. There was
no way I was not going to put some
PIC24FJ128GA010 control behind
these two FM21L16 control bits.
The FM21L16 wants to see a volt-
age rail that resides between 2.7V and
3.6V. The absence of a voltage regula-
tor circuit in the schematic leads one
to the conclusion that Im supplying
the FRAMs and PIC24FJ128GA010s
power via a 3.3V wall wart.
Well have no way of knowing
whats inside the FRAM without having
some way of communicating the state
of the data at a certain address to a
human. Im still on the fence about
throwing away my RS-232 interface for
a USB interface. So, what you see in
this design is a standard 3.3V RS-232
interface driven by a tried and true
SP3232 circuit.
All thats left to do is assign a 0.1
F power supply bypass capacitor to
each Vdd pin in the design and con-
nect the PIC24FJ128GA010s internal
voltage regulator capacitor between
Vcap and ground. Note that the
PIC24FJ128GA010s ENVREG (Enable
Voltage Regulator) pin is tied logically
high to enable the PIC24FJ128GA010s
internal voltage regulator circuitry.
It all looks good on paper. So, lets
translate the schematics contents to a
physical device.
Building up the
Controller
I used the services of ExpressPCB
to design and fabricate our FRAM
controller printed circuit board (PCB).
To make things easy, I opted to put
the FRAM hardware down on a four-
layer PCB.
The very first thing I do after
determining a preliminary layout
is assign and make the power connec-
tions to the PCBs inner planes.
Connecting pins to the power and
ground planes of a four-layer PCB is a
simple ExpressPCB procedure. Take a
look at Screenshot 1. Ive laid in a
0.026 via, connected it to the
appropriate PIC24FJ128GA010 power
pin, selected the via, right-clicked on
the via, and assigned the via connec-
tion to the power plane of the PCB. I
performed the power and ground
assignment task against all of the
PIC24FJ128GA010, FRAM, SP3232,
and ICSP power pins. The entire set of
FRAM controller power plane connec-
tions can be seen in Screenshot 2.
The schematic really organizes
things nicely. However, youre reading
a technical magazine and I know you
want the skinny on the actual PCB
design. So, Ive chronicled the FRAM
PCB layout process in a series of screen
captures for your enjoyment.
After I laid in the power and
ground connections, I took on the task
of routing the 17-bit address bus. Note
SERVO 12.2007 55
SCREENSHOT 6. This is a shot of the MPLAB
Watch window following a run of the
MAIN ROUTINE. If you take a pencil to
the PORTB and PORTE bits, youll see that
together they form an address of 0x1FFFF.
SCREENSHOT 5. Sometimes even a blind
hog finds an acorn. Everything fits and
everything is connected. The next step
involves getting the board manufactured
and getting it populated.
Eady.qxd 11/6/2007 9:36 AM Page 55
that in Screenshot 3 I attempted wherever possible to route
the top layer traces horizontally in relation to the bottom
layer traces, which are routed vertically. You can see that
attempting to route in power and ground traces would have
made this PCB design task take on a certain odor of
ugly. Another advantage to using a four-layer PCB is that the
internal ground plane reduces electronic noise in the FRAM
controllers circuitry.
Screenshot 4 folds in the 16-bit data bus connections
between the PIC24FJ128GA010 on the left and the
FM21L16 on the right of the shot. You never know until you
get deep into it if your preliminary device layout will actually
work out. From the looks of Screenshot 4, we may have
lucked out.
The rest of the connections to the FRAM control pins,
the RS-232 port, and the ICSP programming/debugging port
can be seen in the full-board capture represented in
Screenshot 5. Four days later, everything that you now see as
paper and electronic images becomes reality in Photo 1.
I check my PCB designs over at least 10 times before
submitting them for manufacture. As it turned out, I found
three minor mistakes that I corrected after photographing
the FRAM controller board. The ExpressPCB PCB layout file
I have provided for you via the SERVO website (www.servo
magazine.com) incorporates all of the corrections. Be
aware that the FRAM controller PCB you see in Photo 1 is a
prototype version. If you want the pretty silkscreen and
solder mask, order a production version of the FRAM
PCB. Also, before submitting your FRAM controller PCB for
manufacture, remove or move the silkscreen legends I placed
on the pads of the resistors and capacitors to allow for
reliable soldering.
Now that weve taken our FRAM controller from paper
to printed circuit board, lets give it some smarts.
FRAM Cram
Although you see a ceramic oscillator module in Photo 1,
we wont be using it. Instead, we will use the
PIC24FJ128GA010s internal Fast RC Oscillator (FRC).
Well boost the PIC24FJ128GA010s native FRC from its
default 4 MHz to 16 MHz using the PIC24FJ128GA010s
internal 4X PLL.
The Microchip C30 C compiler will be our firmware
vehicle and well use the Microchip REAL ICE as our
programming/debugging platform. Both the C30 C compiler
and the REAL ICE will fall under the command of Microchips
MPLAB IDE. Lets begin the firmware creation process
by assigning firmware variables to the actual hardware
connections. Heres the code:
//******************************************************
//* FRAM CONTROL PINS
//******************************************************#
define WE LATGbits.LATG2
#define OE LATGbits.LATG3
#define CE LATCbits.LATC14
#define LB LATFbits.LATF4
#define UB LATFbits.LATF5
//******************************************************
//* DATA BUS DEFINITIONS
//******************************************************
#define data_in PORTD
#define data_out LATD
#define data_lo 0
#define data_hi 1
#define rd_data TRISD = 0xFFFF
#define wr_data TRISD = 0x0000
//******************************************************
//* ADDRESS BUS DEFINITIONS
//******************************************************
#define addrlo LATE
#define addrhi LATB
This is pretty simple stuff that will save you lots of time
when you start coding. Rather than trying to remember what
pin does what, I have given each pin a logical name
that relates to its function. Well use the data_lo and data_hi
definitions when we write the code to read the FRAM in
eight-bit mode. The rd_data and wr_data definitions will
allow us to easily put the PIC24FJ128GA010s data bus port
into input or output mode.
We already know that well have to test this puppy. So,
why not go ahead and put aside some variables that will
store what we read from the FM21L16. Here they are:
unsigned int framdata16;
char framdatalo, framdatahi;
Well use framdata16 to read the 16-bit data value and
framdatalo/framdatahi to store the results of eight-bit reads.
We now have enough stuff tied down to begin seriously
56 SERVO 12.2007
PHOTO 1. If you look closely, you can see my boo-boos. I missed
placing a via to the CE jumpers and I rotated a trace all the way
through the ICSP resistors and capacitors. What you cant see
is a switched address line on the bottom layer of the board. I
fixed all of these errors after I took this shot. Note the 0603 0.1 F
capacitors surrounding the PIC24FJ128GA010 and the FM21L16.
The rest of the passive components are 0805 SMT devices.
Eady.qxd 11/6/2007 9:37 AM Page 56
writing our FRAM I/O routines. Since the very first thing one
would do to access the FM21L16 is write the desired address
to the FRAM address pins, lets put together a routine to
write the memory cell address to the FRAMs address bus.
Recall that we split the PIC24FJ128GA010s address bus
between the E and B I/O ports. Therefore, we must do some
minor bit manipulation to get the correct address out onto
the PIC24FJ128GA010s address bus. No problem:
//******************************************************
//* WRITE FRAM ADDRESS
//******************************************************
void wr_fram_addr(unsigned long addr)
{
addrlo = addr & 0x000003FF;
addrhi = (addr & 0x0001FC00) >> 1;
}
The addrlo alias is actually PORTE of the
PIC24FJ128GA010. Since PORTE only consists of 10 bits, we
provide a mask value of 0x3FF to capture all of the PORTE
address information. If you count the 1 bits in the addrhi
mask, youll come up with seven. Thats how many more bits
we need to assemble to complete the 17-bit FRAM address.
The most significant seven bits of PORTB are represented by
the alias addrhi and we need to put the most significant bit
of the FRAM address into the most significant bit of addrhi.
That explains the one-bit shift to the right.
We have the option of performing three types of read
operations. Heres the code for a 16-bit FRAM read:
//******************************************************
//* 16-BIT FRAM READ
//******************************************************
unsigned int rd_fram16(void)
{
unsigned int data;
rd_data; //PIC24FJ128GA010 data bus = input mode
UB = 0; //enable upper byte of FRAM data bus
LB = 0; //enable lower byte of FRAM data bus
WE = 1; //make sure write is disabled
CE = 0; //begin the read access
Nop(); //access time wait
data = data_in; //read the data into the PIC
CE = 1; //terminate the read cycle
return data;
}
Before we do anything else, we must put the
PIC24FJ128GA010s data bus (PORTD) into input mode.
Thats what the rd_data macro does for us. Putting both the
UB and LB FRAM control lines at a logic low level enables
the full 16-bit FM21L16 to the PIC24FJ128GA010s PORTD.
We are clocking the PIC24FJ128GA010 at 16 MHz, which
means we have a 125 nS cycle time. Thus, one NOP (No
Operation) instruction is plenty of time for the FM21L16
to respond to a read operation. We also have enough time
for a full FRAM write cycle, which has a maximum duration
of 110 nS.
Performing eight-bit FRAM reads is just as easy as pulling
off a 16-bit read operation. Using the UB and LB FRAM
control pins allows us to read either the high byte or low byte
of the FRAM data bus. I wrapped both read types into a
single function:
//******************************************************
//* 8-BIT FRAM READ
//******************************************************
unsigned int rd_fram8(char mode)
{
unsigned int data;
rd_data;
switch(mode)
{
case data_lo: //read the low data byte only
UB = 1; //kill the FRAM upper byte
LB = 0; //enable the FRAM lower byte
WE = 1; //make sure write is disabled
CE = 0; //begin read process
Nop(); //read access time
data = data_in & 0x00FF; //get data
CE = 1; //terminate read operation
break;
case data_hi: //read the high data byte only
UB = 0; //enable the FRAM upper byte
LB = 1; //kill the FRAM lower byte
WE = 1; //make sure write is disabled
CE = 0; //begin read process
Nop(); //read access time
//read and adjust FRAM data
data = (data_in & 0xFF00) >> 8;
CE = 1; //terminate read operation
break;
}
return data;
}
To use the eight-bit read, you must enter the mode
(data_lo or data_hi) as an argument to the rd_fram8
function. Nothing to it, right? Thats it for the FM21L16
read functions. Lets move on and do the FRAM write
function coding.
Im sure you have a good grasp of what to do here. See
how close you came in your mind to writing the same 16-bit
FRAM write code Ive presented here:
//******************************************************
//* 16-BIT FRAM WRITE
//*******************************************************
void wr_fram16(unsigned int data)
{
wr_data; //PORTD = output mode
UB = 0; //enable upper FRAM byte
LB = 0; //enable lower FRAM byte
data_out = data; //put the data on PORTD
CE = 0; //access the FRAM
WE = 0; //begin the write cycle
Nop(); //write cycle wait
WE = 1; //terminate write cycle
CE = 1; //terminate FRAM access
rd_data; //return PORTD to input mode
}
Again, the eight-bit writes are no more difficult than the
16-bit write. And, again, Ive combined the upper and lower
eight-bit write functions into a single routine:
SERVO 12.2007 57
Eady.qxd 11/6/2007 9:37 AM Page 57
//******************************************************
//* 8-BIT FRAM WRITE
//******************************************************
void wr_fram8(char data, char mode)
{
wr_data;
switch(mode)
{
case data_lo:
UB = 1; //kill the FRAM upper byte
LB = 0; //enable the FRAM lower byte
data_out = data & 0x00FF; //data on PORTD
CE = 0; //access the FRAM
WE = 0; //begin the write operation
Nop(); //write cycle time
WE = 1; //terminate the write cycle
CE = 1; //terminate FRAM access
break;
case data_hi:
UB = o; //enable the FRAM upper byte
LB = 1; //kill the FRAM lower byte
//put data out onto PORTD
data_out = (data & 0xFF00) >> 8;
CE = 0; //access the FRAM
WE = 0; //begin the write operation
Nop(); //write cycle time
WE = 1; //terminate the write cycle
CE = 1; //terminate FRAM access
break;
}
rd_data;
}
Note that the FRAMs OE pin is never accessed in the
read routines. Thats because I set OE to a logical low at the
beginning of the FRAM read/write program:
int main(void)
{
CLKDIV = 0; //no clock division
OE = 0; //set OE active
Since were already there, lets continue with the FRAM
read/write main program flow:
//******************************************************
//* INITIALIZE I/O PORTS
//******************************************************
//make PORTB data bus pins digital
AD1PCFG = 0xFE00;
LATB = 0x01FF;
TRISB = 0x01FF;
LATC = 0xFFFF;
TRISC = 0x4FFF;
LATE = 0x0000;
TRISE = 0x0000;
LATF = 0xFFFF;
TRISF = 0xFFCF;
LATG = 0xFFFF;
TRISG = 0xFFF3;
This is standard PIC stuff. All you really need to pay
attention to here is the disabling of the PORTB analog
functionality on the PORTB pins we are using to support the
address bus.
Its always a good idea to control your own destiny
when it comes to initial logic levels. In the code snippet that
follows, I made sure that all of the FRAM control pins
were in a state that disabled any read or write access to
the FRAM:
//******************************************************
//* INITIALIZE FRAM
//******************************************************
CE = 1;
WE = 1;
OE = 1;
If were going to use the FRAM controllers RS-232 port,
well need to support it with some code. I used the C30 C
compilers mathematician to compute the RS-232 port baud
rate divisor:
#define YFREQ 4000000 //internal FRC frequency
#define PLLMULT 4 // PLL multiplier
#define FCY YFREQ*PLLMULT //PLL clock frequency
#define BAUDRATE 57600 //desired baud rate
//compute the baud rate divisor value
#define BRGVAL ((FCY/BAUDRATE)/16)-1
Recall that the PIC24FJ128GA010s internal FRC defaults
to 4 MHz at reset. I simply used the PIC24FJ128GA010s
configuration bits to set up the FRC and turn on the PLL:
_CONFIG1(JTAGEN_OFF & GCP_OFF & BKBUG_ON &
COE_OFF & ICS_PGx2 & FWDTEN_OFF)
_CONFIG2(IESO_OFF & FNOSC_FRCPLL & FCKSM_CSD-
CMD & OSCIOFNC_OFF & POSCMOD_NONE)
If youre not familiar with the _CONFIGx language, just
view the PIC24FJ128GA010.h include file, which is part of
the Microchip C30 C compiler package. Once the compiler
has ciphered BRGVAL, all I have to do is plug it in. The rest
of the UART registers default to the standard RS-232
parameters and only require bits to be set to enable the
UART circuitry:
//******************************************************
//* INITIALIZE UART1
//******************************************************
U1BRG = BRGVAL;
U1MODE = 0x8000; // Reset UART to 8N1 and enable
U1STA = 0x0400; // Rst status reg, enable TX,RX
_U1RXIF=0; // Clear UART RX Interrupt Flag
I decided to show you the UART interrupt flag even
though were not going to use UART interrupts in this
project. If you decide to expand upon the FRAM controller
project, youll most likely need to use the UART in interrupt
mode.
Were at the top of the hill now. All of the FRAM
read/write functions are in place and the UART is ready for
action. Lets run a 16-bit FRAM write cycle and utilize all of
the read modes as a test case:
58 SERVO 12.2007
Eady.qxd 11/6/2007 9:37 AM Page 58
//******************************************************
//* MAIN ROUTINE
//******************************************************
framdata16 = 0; //clear the variable
//put 0x1FFFF on the FRAM address bus
wr_fram_addr(0x001FFFF);
//write 0x1234 to address 0x1FFFF
wr_fram16(0x1234);
//read the address we just wrote to
framdata16 = rd_fram16();
//read the lower byte of address 0x1FFFF
framdatalo = rd_fram8(data_lo);
//read the upper byte of address 0x1FFFF
framdatahi = rd_fram8(data_hi);
// Print values to terminal emulator
printf(\r\n0x%04X,framdata16);
printf(\r\n0x%02X,framdatahi);
printf(\r\n0x%02X,framdatalo);
while(1); //loop here
forever
The terminal emulator I refer to in the MAIN ROUTINE
code snippet is called Tera Term Pro. Tera Term Pro is a free
download from the web.
The results of running the MAIN ROUTINE code are
shown in the MPLAB Watch window capture you see in
Screenshot 6. The printf statements also wrote the contents
of the Watch window variables out to the Tera Term Pro
terminal emulator window.
Its Your Data
So, put a RAMTRON FM21L16 to work for you. To make
implementing a RAMTRON FM21L16 a bit easier for all of you,
I have provided a copy of the code and the ExpressPCB layout
files for you on the SERVO website. The PIC24FJ128GA010 has
plenty of analog-to-digital converters, PWM, and digital I/O
that I didnt touch. Use my ExpressPCB layout to expand upon
the design to meet your robotic needs. See you next time. SV
P
erform proportional speed, direction, and steering with
only two Radio/Control channels for vehicles using two
separate brush-type electric motors mounted right and left
with our mixing RDFR dual speed control. Used in many
successful competitive robots. Single joystick operation: up
goes straight ahead, down is reverse. Pure right or left twirls
vehicle as motors turn opposite directions. In between stick
positions completely proportional. Plugs in like a servo to
your Futaba, JR, Hitec, or similar radio. Compatible with gyro
steering stabilization. Various volt and amp sizes available.
The RDFR47E 55V 75A per motor unit pictured above.
www.vantec.com
STEER WINNING ROBOTS
WITHOUT SERVOS!
Order at
(888) 929-5055
SERVO 12.2007 59
Microchip (www.microchip.com)
PIC24FJ128GA010; MPLAB; C30 C Compiler; REAL ICE
RAMTRON (www.ramtron.com) FM21L16
ST Micro (www.stmicro.com) SP3232
Sources
Fred Eady can be reached via email at fred@edtp.com.
Contact the Author
Eady.qxd 11/6/2007 9:38 AM Page 59
60 SERVO 12.2007
// castling bonuses
B8 castleRates[]={-40,-35,-30,0,5};
//center weighting array to make pieces prefer
//the center of the board during the rating routine
B8 center[]={0,0,1,2,3,3,2,1,0,0};
//directions: orthogonal, diagonal, and left/right
from orthogonal for knight moves
B8 directions[]={-1,1,-10,10,-11,-9,11,9,10,-10,1,-
1};
//direction pointers for each piece (only really for
bishop rook and queen
B8 dirFrom[]={0,0,0,4,0,0};
B8 dirTo[]={0,0,0,8,4,8};
//Good moves from the current search are stored in
this array
//so we can recognize them while searching and make
sure they are tested first
by James Isom
A
bi-m
onthly
colum
n for
kids!
LESSONS
FROM THE
LABORATORY
LESSONS
FROM THE
LABORATORY
NXT Packbot:
Part 2
STEP 1:
STEP 4:
STEP 7:
Parts:
Parts:
Parts:
Parts:
STEP 2:
Parts:
STEP 5:
Parts:
Parts:
STEP 3:
STEP 6:
L
ets pick up where we left
off in October and add the
shoulders and a few other
pieces to the NXT Packbot.
Left Shoulder:
The shoulders are mirror images
of one another. I included both
sets of steps just in case you
don't like puzzles.
LessonsFromTheLab.qxd 11/5/2007 4:19 PM Page 60
SERVO 12.2007 61
STEP 8:
STEP 10:
Parts:
STEP 11:
Parts:
STEP 9:
Parts:
Parts:
STEP 13:
STEP 16:
Parts: Parts:
STEP 12:
STEP 15:
STEP 14:
Parts: Right Shoulder: Parts: Parts:
LessonsFromTheLab.qxd 11/5/2007 4:19 PM Page 61
62 SERVO 12.2007
STEP 17:
STEP 20:
STEP 23:
STEP 26:
Parts:
Parts:
Parts:
Parts:
STEP 18:
Parts:
Parts:
Parts:
STEP 19:
Parts:
STEP 22:
STEP 25:
Parts:
Parts:
STEP 21:
STEP 24:
LessonsFromTheLab.qxd 11/5/2007 4:20 PM Page 62
STEP 29:
STEP 32:
STEP 35:
Parts: Parts:
Parts:
STEP 28:
STEP 31:
STEP 34:
STEP 27:
STEP 30:
STEP 33:
SERVO 12.2007 63
Add Treads:
Place two treads around the front wheels. The back
portion of the treads will eventually be attached to a
rear assembly that will be covered in a future article.
Attach the Shoulders:
The shoulder placement is
a bit tricky, so have a look
at the following images
to make sure you get the
placement right.
Building and
Connecting the
Front Strut:
LessonsFromTheLab.qxd 11/5/2007 4:21 PM Page 63
64 SERVO 12.2007
STEP 36:
STEP 39:
Adding the Arm Brackets:
Build an arm bracket using the following steps
for each shoulder. I have colored the model white
for these steps so the new parts are easier to see.
Parts:
STEP 37:
Parts:
STEP 38:
Parts:
Thats it for this installment. Theres
more to come in February. Your NXT
Packbot should now look like this. SV
LessonsFromTheLab.qxd 11/5/2007 4:22 PM Page 64
SERVO 12.2007 65
Page65.qxd 11/5/2007 2:44 PM Page 65
66 SERVO 12.2007
Electronic Parts & Supplies
Since 1967
C Stamp Controller
LOW COST - High Pin Count
48-Pin Module with Analog
High Speed, Large Memory
Professional SW Dev. Tools
Easy to Connect Accessories
Free Expert Technical Support
www.c-stamp.com
Toll-Free: 1 (800) 985-AWIT
HobbyEngineering
www.HobbyEngineering.com
Robot Kits, Parts, Tools and Books
IMService
P. O. Box 1 42, New Hudson, MI 481 65
Phone: 888-451-1670
or: 248-486-3600
imsrv. com
Desktop CNC
Solutions
For the finest in robots,
parts, and services, go to
www.servo
magazine.com
and click on
Robo-Links.
Robolinks.qxd 11/5/2007 4:29 PM Page 66
Subscribe online at: www.servomagazine.com
or call: 877-525-2539 (toll free) / 818-487-4545 (outside US)
Go to
www.servomagazine.com
to enter your gift order!
Be sure to use promotion code Y7WXMS when ordering.
U.S. Prices
1 Yr $24.95
2 Yr $45.95
3 Yr $65.95
Give the
gift that
lasts all
year!
Give the
gift that
lasts all
year!
SV-GiftSubAd2007.qxd 11/1/2007 3:38 PM Page 67
68 SERVO 12.2007
W
hen I was growing up, two tech-
nologies captivated both science
and science fiction: robots and lasers.
Both started out expensive and compli-
cated, but today, these technologies
are within reach on any budget. This is
especially true of lasers, which just a
generation ago were laboratory
curiosities and the stuff of adventure
novels. Now they are such an integral
part of our lives we have all but
forgotten about them. Weve lost the
appreciation of how useful they can be.
Thanks to advances in semiconduc-
tor technologies, you can purchase a
fully functioning laser for just a few
dollars. Given their low cost, and the
unique properties and capabilities of
laser light, you may want to consider
combining these two stalwarts of
sci-fidom into your next project. What
follows are some ideas to pique your
interest and, of course, a listing of
online sources you can check out to
further your education and experimen-
tation into the world of lasers.
Lasers 101
Though there are many types of
lasers, they all do pretty much the same
thing: Lasers amplify a source of photons
into an intense beam of light. The
wavelength of the light varies across
the visible, infrared, and ultraviolet
spectrum. Most people are familiar with
the ruby-red light of the common laser
pointer. These operate at about 650-670
nanometers (nm), depending on their
design. A newer class of laser pointers
put out a green beam (about 530 nm),
which is useful because the human eye
is most sensitive to light of this wave-
length. The green lasers are more expen-
sive to manufacture, so they cost more.
Many devices such as CD and DVD
players use infrared lasers that put out an
invisible beam in the 750-780 nm range.
While you cant see the beam, an
infrared laser is nevertheless quite useful,
especially when combined with sensors
that are most receptive to light in the
infrared region. These include most types
of phototransistors and photodiodes, and
both CMOS and CCD image arrays.
And, of course, there are lasers
that emit light in the deep blue and
even ultraviolet region. These are fairly
expensive, finding typical uses in
such things as high definition DVD
players, and validating the authenticity
of paper currency.
The vast majority of lasers today
are the semiconductor variety. They are
typically constructed of a sandwich of
semiconducting material that has been
cleaved at exactly the right angle to
allow a pinpoint of amplified laser light
to be emitted. At low currents, the
laser operates like a light emitting
diode (LED); with the proper operating
current, the device emits true laser
light, described below.
Semiconductor lasers can be further
classified by their operating mode. Most
of the devices we are most familiar with
are designed for continuous light
output. These are operated within a con-
trolled region of current; if the current is
too low, the light that is emitted lacks
the laser characteristics. If the current is
too high, the device will overheat and
burn up. To maintain the proper operat-
ing output, a sensor inside the laser
collects a portion of the emitted light
and a control circuit varies the current to
keep it within the prescribed range.
Other semiconductor lasers
capable of much higher light outputs
operate in a pulsed mode. They are
operated by applying a series of pulses,
each one of a short enough duration
that the device will not overheat. The
intensity of the laser is controlled by
varying the duty cycle the ratio of on
time versus off time of the pulses.
Diode lasers may be self con-
tained, or they may require separate
driver electronics. Self-contained diode
lasers include the laser itself, as well as
its control circuitry. You need only
apply power. This is the case with laser
pointers. Diode lasers without circuitry
require a separate driver board. The
board provides the correct voltage and
current to the laser diode at all times.
One advantage to getting a laser
diode and separate driver board is the
extra flexibility in operating the laser.
With a separate driver board, you often
have more control over the intensity of
the laser output. The better driver
boards have a separate modulation
input that allows you to use an external
signal to turn the laser on and off very
quickly. Modulation speeds of 5-10 kHz
are common.
The older style of laser (still found
on the surplus market) uses a tube
filled with various gasses. A familiar
version is the helium-neon laser, which
emits a red beam of 632 nm. The laser
itself is constructed of a glass tube
Using Lasers With
Your Robots
Tune in each month for a heads-up on
where to get all of your robotics
resources for the best prices!
RoboResources.qxd 11/4/2007 6:36 PM Page 68
filled with a mixture of helium and
neon gasses. A high voltage is applied
to terminals on either end of the tube.
Carefully positioned mirrors on either
end serve to amplify the light that
bounces back and forth. One of the
mirrors is fully reflective; the other is
partially reflective. Once suitably ampli-
fied, the light escapes the partially
reflective mirror and exits the tube.
There are yet more methods of
producing lasers, including various crys-
tals such as ruby and YAG, plasma, and
even Jello. Ill leave it to you to research
these if the subject is of interest to you.
The Properties of
Laser Light
Laser light is special for a number
of reasons. First is that unlike most light
sources, the beam from a typical laser is
composed of a single wavelength, or
color. The single wavelength makes it
possible to isolate the color, and ignore
all others. For example, if youre
designing a sensor that is only sensitive
to the light of your laser source, you can
filter out all but that light. You know
whatever remaining light your sensor is
picking up is probably from your laser.
(In actuality, many lasers emit sev-
eral specific wavelengths, called main-
lines. These may be selectively filtered
or split to obtain the desired color. For
example, an argon gas laser emits both
a green and a weaker blue light. A
simple prism may be used to separate
the mainlines of a laser, while not
reducing the light output of the beam.)
Recall from high school physics
that while light is made up of photons,
the photons travel as a wave. Because
a laser beam is made up of the same
wavelength of light, the photons exit
the laser and travel in synchronism.
This is called coherence. One striking
benefit of coherence is the effect of
reflections of the laser light. These
reflections cause the waves of light to
interfere with one another. What was
once practically a solid beam of
light is now a mish-mash of light rays
that commingle in measurable ways.
Such so-called local interference
forms the basis for a number of sens-
ing techniques. Ill cover a few in a bit.
Another useful property of laser
light is the limited degree to which it
spreads as it travels through space. This
is due to the nature of coherence,
described above. All light eventually
spreads out, but with the right laser and
the right optics, its possible to focus
laser light into an extremely thin beam
that stays thin for a longer distance
than regular light. Without this proper-
ty, we would not have CDs or DVDs.
For robots, we can use this property
to ensure a small pinpoint of light
regardless of the distance between the
light source and its target. The spot
caused by the laser beam will remain
relatively small and compact whether the
laser is a foot away from the target or 20
feet away. Simple collimating optics can
further control the spread of the beam.
Last, and certainly not least, is the
sheer intensity of a laser beam. A small
pocket laser, operating on a couple of
watch batteries, can emit a light as
brilliant as noon day sun. Of course,
the area of the light is limited to a small
spot, but that works to our advantage.
Even in average lighting conditions, its
relatively easy for people and sensors
to spot the light of a laser beam.
Uses for Lasers in
Robotics
Some applications for lasers in
robotics are obvious, and some are not.
First to mind are decorative uses dress-
ing up the bot with colored lasers that
flash on and off as the machine drives
down a darkened hallway. Combine a
laser beam with a reflective diffraction
grating, and the beam is split into
multiple sub-beams that dance around
the room as the robot travels. You
can get metalized diffraction grating
material at any party store. Just look for
the stuff that makes a rainbow when
you look at it under ordinary light.
More practical applications for using
lasers with robots involve some type of
sensor. Light-based sensors are already
popular solutions in all types of robots,
but the majority of these use standard
non-laser (i.e., non-coherent) infrared or
visible light. Such sensors work by
detecting the amount or direction of
light. The coherent nature of laser light
permits additional sensory techniques.
One notable approach is to rely on
the local interference of a laser beam
reflected off a surface. To the naked
eye, the local interference appears as
speckle, a grain-like pattern that
moves as the light or the surface
moves. You could use this idea as a
way to measure movement and even
distance. Point a laser toward the
ground, and pick up the reflections
using a suitable sensor. As the robot
moves, the pattern of the speckle also
moves in direct proportion to the direc-
tion and distance of that movement.
Systems of these types that rely on
local interference typically warrant a
multi-cell sensor array. A single light
sensor is insufficient to detect the
motion of the speckle pattern.
However, sensor arrays, such as linear
CCDs or even low-resolution CMOS
camera chips, can be used to measure
finite differences in the speckle pattern.
Lasers also find use in various
beacon and landmark systems used for
robotics. One or more lasers pointed
upward from a stationary lighthouse
are used to project a pattern of beams
or lines onto a white ceiling. A tradi-
tional CMOS or CCD camera is pointed
toward the ceiling, and with the right
filtering, sees only the dots/lines of the
laser. The unique orientation of the
dots or lines reveals the location of the
robot within the room. This is basically
the same concept as the celestial
navigation techniques used for
centuries by mariners. Its already used
in some commercial and experimental
robotic navigation systems.
Recall above that because of the
property of coherence, a laser beam
will keep its pencil-thin shape for a
longer distance than ordinary light.
With appropriate optics, a single sensor
can focus onto the same area that the
laser beam is being projected onto.
Using a variety of timing techniques, its
possible to construct a laser-based
distance measurement device that can
scan a room and build a 3D map of
objects in front of the sensor. This is the
basic idea behind the expensive laser-
based rangefinder systems build by
German electronics manufacturer SICK.
Determining the distance between
SERVO 12.2007 69
RoboResources.qxd 11/4/2007 6:36 PM Page 69
70 SERVO 12.2007
laser sensor and target can be accom-
plished in a variety of ways. With fast
enough electronics, its possible to
measure distances using time of flight
of the light itself, which travels about
186,000 miles per hour. Perhaps a
more common method that does not
require fast switching electronics is
to modulate the laser beam with a
fairly low frequency sine wave. The
difference between the phase of the
source laser beam modulation and its
returned reflection indicates distance.
Laser Safety
The light from a laser is highly
intense, and when aimed directly into
someones eyes can cause severe pain
and optic damage. In the United
States, lasers are regulated by the Food
and Drug Administration, or more
specifically, an FDA unit known as the
Center for Devices and Radiological
Health, or CDRH.
Lasers are roughly classified by the
potential damage they can cause; this
damage is defined by relying on simple
metrics, such as whether the beam is
visible or invisible to the human eye, if
the light of the laser is ever exposed
outside of the device its used in, the
power output of the beam (usually
expressed in milliwatts or watts), and
whether the beam is stationary or
constantly in motion.
As noted on the FDA website, laser
devices are separated by class. The
lower class numbers are the least dan-
gerous. Each of these classes has its
own warnings and restrictions for use.
Class I products include laser printers
and CD players where the laser radiation
is usually contained within the product.
Class II and IIa products include bar
code scanners.
Class IIIa products include laser pointers.
Class IIIb and IV products include
laser light shows, industrial lasers, and
research lasers.
The vast bulk of lasers available to
consumers is Class IIIa. Note that the
laser in a CD player is ordinarily a Class
I device (but thats when its used inside
the player where its light is never
exposed). Used outside youve
hacked a CD player and raided its optics
the laser is most likely a Class IIIa.
Also note that the FDA limits Class
IIIa devices to five milliwatts, as indicat-
ed by a light meter specifically designed
to measure laser output levels. Its tech-
nically possible to operate some laser
pointers with a higher-than-normal
voltage, or even to pulse them with
significantly higher voltages. The result
is an increase in power output that
makes these devices non-compliant.
Class IIIa and lower lasers are gen-
erally considered safe, but only in their
intended application. Whether or not
the laser light may be harmful to people
or animals depends on the output
power of the laser, whether the laser is
visible, and if the beam is held station-
ary for a long enough period of time. Id
recommend never using anything above
a Class IIIa laser in a robotics project,
and then only use a visible light laser.
The beam of an infrared laser can
be damaging to the eyes, and when
strapped to a robot, an unsuspecting
person or animal may be inadvertently
exposed to the effects of the beam.
When an infrared laser must be used,
consider only employing it in a fashion
where its beam is pointed down to the
ground, and not out or up.
If you must use a higher power
laser, do so only with appropriate
research and safety training, and be
sure to follow all laws and regulations.
If your goal is to design a mobile light
show robot, employing high power 10
watt diode lasers, do so only after you
have fully immersed yourself into the
study of laser safety.
Be aware that operating certain
Class IIIb and above lasers in
public without the appropriate safety
measures may be against the law, and
could expose you to severe fines.
Finally, should you opt for older
fashioned tube lasers on your robot,
know that these require high voltages
to operate. These voltages typically
in the 1-2 kilovolt range can cause
nasty shocks. Be sure all wiring is
covered. Lasers with glass tubes (like
helium neon) should be suitably
protected in plastic or metal enclo-
sures, to avoid the risks of broken glass.
Sources
In addition to the sources listed
American Science and Surplus often carries optics and sometimes laser components.
RoboResources.qxd 11/4/2007 6:36 PM Page 70
here, be sure to check out the regular
advertisers in both SERVO and Nuts &
Volts, as many of them carry surplus
lasers and optics.
Almaz Optics
www.almazoptics.com
Even lasers need the occasional
lens. This outfit sells optics for conven-
tional and laser light applications.
American Science and Surplus
www.sciplus.com
Variable surplus merchandise, so
check their catalog. Often carries
optics and sometimes laser compo-
nents. Low prices.
Anchor Optics
www.anchoroptics.com
Low-cost optics and laser (diode
and gas) products.
Coherent, Inc.
www.cohr.com
Leading manufacturer of industri-
al, educational, and laboratory lasers.
The site contains numerous application
notes and other useful information.
Industrial Fiber Optics
www.i-fiberoptics.com
Manufacturer of educational
grade lasers. Check out their informa-
tional pages.
Information Unlimited
www.amazing1.com
Lasers, laser products, and optics
for all sizes and types of interesting
projects.
Instapark
www.instapark.com
Online retailer of laser pointers
and diode laser modules. Fairly low
prices, even for the green lasers.
Jameco
www.jameco.com
Small but impressive selection
of diode lasers and laser pointers.
Laser Glow
www.laserglow.com
Red, green, yellow, and even blue
laser pointers and diode laser modules.
Laser Surplus Sales
www.lasersurplus.com
Laser Surplus Sales carries lasers
and optics, at surplus prices.
This includes variety of gas, solid-state,
and crystal (e.g., ruby) lasers, and
upporting optics.
Melles Griot
www.mellesgriot.com
Maker of laser components,
optics, and complete laser systems,
Jameco has a small but impressive selection of diodes and laser pointers.
SERVO 12.2007 71
Another established company, Midwest offers a number of higher powered
diode lasers, including Class IIIb units of 40 mW and more.
RoboResources.qxd 11/4/2007 6:37 PM Page 71
from educational to industrial. Check
out their online tutorials, such as the
section on fundamental optics.
Meredith Instruments
www.mi-lasers.com
Meredith Instruments is one of the
oldest names in hobby and educational
lasers. Good selection of low-cost red
diode lasers, collimating lenses, and
line-producing optics.
Midwest Laser Products
www.midwest-laser.com
Midwest Laser Products is another
established company, offering a
number of higher powered diode
lasers, including Class IIIb units of
40 mW and more.
US Food and Drug
Administration CDRH website
www.fda.gov/cdrh
Main portal to the CDRH pages at
the United States Food and Drug
Administration. Plenty of useful
information and factoids about lasers,
laser use, and laser safety. SV
72 SERVO 12.2007
Gordon McComb can be reached
via email at robots@robotoid.com
CONTACT THE AUTHOR
RoboResources.qxd 11/4/2007 6:38 PM Page 72
Robot Builders Sourcebook
by Gordon McComb
Fascinated by the
world of robotics but
dont know how to
tap into the incredible
amount of informa-
tion available on the
subject? Clueless as
to locating specific
information on robot-
ics? Want the names,
addresses, phone
numbers, and websites of companies that
can supply the exact part, plan, kit, building
material, programming language, operating
system, computer system, or publication
youve been searching for? Turn to Robot
Builders Sourcebook a unique clearing-
house of information that will open 2,500+
new doors and spark almost as many new
ideas. $24.95
123 Robotics Experiments
for the Evil Genius
by Myke Predko
If you enjoy tinkering
in your workshop and
have a fascination for
robotics, youll have
hours of fun working
through the 123
experiments found in
this innovative project
book. More than just
an enjoyable way to
spend time, these
exciting experiments also provide a solid
grounding in robotics, electronics, and
programming. Each experiment builds on
the skills acquired in those before it so
you develop a hands-on, nuts-and-bolts
understanding of robotics from the
ground up. $25.00
FIRST Robots: Aim High
by Vince Wilczynski / Stephanie
Slezycki
This book looks at
30 different robot
designs all based on
the same chassis,
and provides in-
depth information
on the inspiration
and the technology
that went into build-
ing each of them.
Each robot is fea-
tured in 6-8 pages providing readers with a
solid understanding of how the robot was
conceived and built. There are sketches,
interim drawings, and process shots for each
robot. $39.95
2007 CD Rom
Pre-order before December 20th and get
free shipping (U.S. Only) $24.95
Order other CDs with your 2007 copy of
SERVO or NV (of any combination) and pay
only $21.95 each.
Plus get the free shipping!
All orders will ship mid December.
Mechanisms and Mechanical
Devices Sourcebook
by Neil Sclater / Nicholas Chironis
The fourth edition
of this invention-
inspiring engineering
resource covers the
past, present, and
future of mechanisms
and mechanical
devices. Youll find
drawings and
descriptions of more
than 2,000 compo-
nents that have
proven themselves over time and can
be incorporated into the very latest
mechanical, electromechanical, and mecha-
tronic products and systems. Overviews of
robotics, rapid prototyping, MEMS, and
nanotechnology, along with tutorial chapters
on the basics of mechanisms and motion
control, will bring you up-to-speed quickly
on these cutting-edge topics. $89.95
We accept VISA, MC, AMEX, and DISCOVER
Prices do not include shipping and
may be subject to change.
CNC Robotics
by Geoff Williams
CNC Robotics gives you
step-by-step, illustrated
directions for designing,
constructing, and testing
a fully functional CNC
robot that saves you 80
percent of the price of an
off-the-shelf bot and
that can be customized
to suit your purposes
exactly, because you designed it. Written
by an accomplished workshop bot
designer/builder, this book gives you
everything you need. $34.95
The SERVO Webstore
Insectronics
by Karl Williams
This complete project
book delivers all the step-
by-step plans you need
to construct your own
six-legged insect-like
robot that walks and
actually responds to its
environment. Using
inexpensive off-the-shelf
parts hobbyists can build a better bug
and at the same time have loads of fun
honing their knowledge of mechanical
construction, programming, microcontroller
use, and artificial intelligence. $19.95
Attention Subscribers ask about your discount on prices marked with an *
N N
E E
W
!
W
!
SERVO 12.2007 73
WebstoreDec07.qxd 11/5/2007 3:25 PM Page 73
Get your very own limited-edition SERVO Magazine T-shirt. Shirts come
in sizes S, M, L, and are available in either black or white.
All shirts are 100% preshrunk cotton.
SERVO
Magazine
T-Shirts
For men and women
G
re
a
t
G
re
a
t
G
if
G
if t Id
e
a
!
t Id
e
a
!
$
1
9
.9
5
!
$
1
9
.9
5
!
From HomoSapien to RoboSapien Before R2D2 there was R1D1
Take This Stuff and Hack It!
by Dave Prochnow
Transform common
household items into real-
ly cool stuff. You don't
need to be an electronics
genius to get started turn-
ing everyday items into
high-performing wonders.
With how-to guru Dave
Prochnow's step-by-step
directions and fully illustrated plans, even
beginners can hack their way to a high-tech
home, cooler toys, and less yard work.
Certain to fire your imagination and start you
plotting new, original, and even more creative
wonders you can make from ordinary house-
hold items, Take This Stuff and Hack It! is the
perfect gift for your inner inventor. $27.95
Building Robots with LEGO
Mindstorms NXT
by Mario Ferrari, Guilio Ferrari
The Ultimate Tool for
MINDSTORMS
Maniacs, the new
MINDSTORMS kit has
been updated to
include a program-
ming brick, USB cable, RJ11-like cables,
motors, and sensors. This book updates the
robotics information to be compatible with
the new set and to show how sound, sight,
touch, and distance issues are now dealt
with. $39.95
N N
E E
W
!
W
!
J
U
N
-0
7
J
U
N
-0
7
Forbidden LEGO
by Ulrik Pilegaard / Mike Dooley
Build the Models
Your Parents
Warned You
Against.
Forbidden LEGO
introduces you to
the type of free-
style building that
LEGOs master
builders do for fun
in the back room. Using LEGO bricks in com-
bination with common household materials
(from rubber bands and glue to plastic
spoons and ping-pong balls) along with
some very unorthodox building techniques,
youll learn to create working models that
LEGO would never endorse. $24.95
Robot Builders Bonanza
Third Edition
by Gordon McComb / Myke Predko
Everybodys favorite
amateur robotics book
is bolder and better
than ever and now
features the fields
grand master Myke
Predko as the new
author! Author duo
McComb and Predko
bring their expertise
to this fully-illustrated
robotics bible to enhance the already
incomparable content on how to build
and have a universe of fun with robots.
$27.95
NEED MORE
INFO?
Go where
SERVE
goes!
The online stor The online store @ e @
www www.ser .ser v vomagazine omagazine.com .com
To order call 1-800-783-4624
N N
E E
W
!
W
!
74 SERVO 12.2007
WebstoreDec07.qxd 11/5/2007 3:26 PM Page 74
To order call 1-800-783-4624
Or order online www.servomagazine.com
BACK ROOM SPECIALS
The Official Robosapien
Hacker's Guide
by Dave Prochnow
The Robosapien robot
was one of the most
popular hobbyist gifts
of the 2004 holiday
season, selling approxi-
mately 1.5 million units
at major retail outlets.
The brief manual
accompanying the
robot covered only
basic movements and maneuvers the
robot's real power and potential remain
undiscovered by most owners until now!
This timely book covers all the possible
design additions, programming possibilities,
and "hacks" not found any place else.
$24.95 Sale Price $14.95
Pub date: August 17, 2005
Concise Encyclopedia
of Robotics
by Stan Gibilisco
Written by anaward-win-
ning electronics author,
the Concise Encyclopedia
of Robotics delivers 400
up-to-date, easy-to-read
definitions that make even
complex concepts
understandable. Over
150 illustrations make the
information accessible at a
glance and extensive cross-referencing
and a comprehensive bibliography facilitate
further research.
$19.95 Sale Price $9.95 Only 2 Left
Pub date: November 12, 2002
SERVO'S CUSTOM
EMBROIDERED HAT
This is one good looking hat, with its stone
washed blue cap and bright yellow/gold
stitching. There's no better way to show
everyone that you're well endowed with a
bigger - than - average brain then by proudly
displaying your affiliation with SERVO
Magazine. $ 14.95*
Hydrogen Powered Racer and Hydrogen Station
Recently named as one of the Best Inventions of 2006 by Time Magazine, the H-racer is now the
best selling fuel cell product in the world. The H-racer is a micro-version of what engineers and
scientists have been dreaming about for real cars: combining hydrogen with oxygen to generate
a DC current to power an electric motor. Unlike a gas-powered car engine, the only byproducts
of this electrochemical process are electricity, heat, and pure water. With the H-racer, you can
witness the power of new energy technology in the palm of your hand. Horizon has created
this unique, patented miniature fuel-cell car and hydrogen refueling station. All you need to do
is add water. Only $115.00 plus S/H
Robotics Demystified
by Edwin Wise
YOU DON'T NEED ARTIFICIAL INTELLIGENCE
TO LEARN ROBOTICS!
Now anyone with an
interest in robotics can
gain a deeper under-
standing without for-
mal training, unlimited
time, or a genius IQ. In
Robotics Demystified,
expert robot builder
and author Edwin Wise
provides an effective and totally painless
way to learn about the technologies used
to build robots!
$19.95 Sale Price $13.95
Pub Date October 20, 2004
The Day the Earth
Stood Still
An alien (Klaatu) with his
mighty robot (Gort) land
their spacecraft on Cold
War-era Earth just after
the end of World War II.
They bring an important
message to the planet
that Klaatu wishes to tell
to representatives of all
nations. Directed by: Robert Wise
Actors: Michael Rennie, Patricia Neal
Run Time: 92 minutes $14.95
Forbidden Planet:
50th Anniversary Edition
A starship crew goes to
investigate the silence of a
planets colony only to
find two survivors and a
deadly secret that one of
them has. Dr. Morbius and
his daughter Altaira have
somehow survived a
hideous monster which
roams the planet.
Directed by: Fred M. Wilcox
Run Time: 98 minutes $26.95
Blade Runner
(The Directors Cut) (1982)
In a cyberpunk vision of
the future, man has devel-
oped the technology to
create replicants, human
clones used to serve in the
colonies outside Earth but
with fixed lifespans. In Los
Angeles, 2019, Deckard is a
Blade Runner, a cop who
specializes in terminating replicants.
Directed by: Ridley Scott
Rated: R Violence $19.95
NEW! THE SERVO STORE NOW OFFERS DVDS!
With this kit, you now can see and
feel the future of energy generation
in your own hands!
SERVO 12.2007 75
Order now and get
your Hydrogen Racer
before Christmas
WebstoreDec07.qxd 11/5/2007 3:27 PM Page 75
M
y first impression of a Robo-1 style biped was one of
amazement. It walked, performed tricks, and could
battle in competition.
WOW! So, I bought a Kondo KHR-1, spent many hours
building it. And there it was. Now what to do with it!?
I programmed in moves I downloaded from the Internet
and impressed my friends. I created new moves and
sequences and taught it to climb a small staircase. (Not very
easy for movements based on static positions!) Out of the
box, the robot needed to be tethered. There was a kludgy
remote available from Kondo, but I opted not to buy that.
Ive been a programmer since the late 70s, so, of
course, I had to try to improve the interface. I spent the next
few months hacking the communications protocol and wrote
a PDA remote controlled WiFi interface. Thats when
the disappointment hit. The robot could only run
pre-programmed sequences of static frames. If the surface
was tilted, the robot fell over. If the surface was rough, the
robot fell over. Drat!
As with most technical things, there are always
innovations. The Hitec RoboNova soon came along. It was
programmable via an onboard RoboBasic interpreter.
Optional gyros even helped stabilize its movements.
COOL! So I bought a RoboNova, spent many hours
building it. And there it was. Now what to do with it!?
I programmed in moves I downloaded from the Internet
and impressed my friends. There was also a decent PC
program for creating new static positions. So, like most
other RoboNova hobbyists, I built RoboBasic programs. It
even had an out of the box I/R TV style remote. But the
general limiting algorithm was the same:
Receive a command from the remote control.
Run a sequence.
Loop.
I wanted to make the robot walk more like a human.
Rather than just run one sequence after another, what I
really needed were dynamic movements. However, most of
the math involved is beyond the people reading this article,
including myself. Not to mention that the RoboNova only has
an Atmel ATmega128 MCU running at 7 MHz.
I decided to develop a better static model frame
sequencer. One that can transition sequences when common
frames exist in both. First, I tried to do this in RoboBasic. I hit
so many limitations with the compiler that I gave up and
wrote MOOSE (My Own Operating System Executive) to
replace the RoboBasic operating system (kids, dont try this
at home). Yet, I want to point out that a clever Basic
programmer can still make this design work.
And now a pearl of wisdom:
Define your task and build the database prior to writing
any code.
A wisely designed database set ultimately reduces the
amount of code needed to perform a given task. Below is a
list of the features and record type definitions included in the
MOOSE sequencer database.
1) Use the vendors existing static position builder program.
2) Communicate with existing programs.
3) Have variable length sequences.
4) Allow adjustable velocity between frames.
5) Point-to-point servo movement between frames
6) Independence of footedness, play left footed or right
footed.
7) Symmetry flag, indicating a frame is identical left footed
or right.
8) Play a sequence forwards or backwards.
9) Hold at critical places in the sequence momentarily (for
stability).
10) Transition sequences at closest similar frame.
11) Auto-repeat sequences, if desired.
12) Change footedness of sequence on auto-repeat, if
desired.
13) Change direction of sequence on repeat, if desired.
14) Work with my wireless serial based PS2 style controller.
Transitioning Sequencer
Using Static Frames for
Biped Control
by Daniel Albert
76 SERVO 12.2007
Appetizer.qxd 11/4/2007 6:30 PM Page 76
// Record Types
// P: single static Position (Long name, servo
// positions[24])
// S: sequence (Long Name, ID, Flags)
// Sequence Flags:
// (R)epeat sequence over, change footedness.
// (r)epeat sequence over verbatim.
// directional changes only go forward!
// (D)irectional change at end of seq, change
// footedness & continue
// (d)irectional change at end of seq. and
// continue
// F: looping frames within seq. (Position Long Name,
// bit flags)
// Frame Flags:
// (V)elocity V0 - V3 (V0 = slowest)
// (A)mbidextrous - can change footedness from
// left to right if need
// (J)ump - play this move during a sequence
// change, else skipped
// (H)old - Hold when moving forward into this
// position
// (h)old - Hold when moving backward into this
// position
// (S)ymmetrical - This move can be played either
// way
FreeLoader a PC based program I wrote to
accompany MOOSE parses the following example text
file and loads the EEPROM of the RoboNova. Record types
precede the colon. Flags trail.
P:Zero,100,76,144,96,101,100,101,30,81,100,100,100,101,
30,81,100,100,100,100,76,144,96,101,100
P:Lean,69,79,133,101,113,100,105,45,71,100,100,100,101,
37,71,100,100,100,117,96,118,100,94,100
P:ON1Foot,59,73,136,107,117,100,105,45,71,100,100,100,1
00,37,71,100,100,100,116,77,143,98,90,100
P:LeanWide,67,102,114,92,116,100,106,51,83,100,100,100,
98,40,65,100,100,100,106,139,80,89,107,100
P:KneeUpInCenter,87,113,74,130,93,100,105,30,84,100,100
,100,101,33,90,100,100,100,108,109,83,128,112,100
P:KneeUpInFront,86,124,76,152,94,100,67,35,67,100,100,1
00,125,37,82,100,100,100,114,110,88,111,107,100
P:ShortPlantWeightBk,84,10,182,121,95,100,67,40,73,100,
100,100,112,36,72,100,100,100,109,134,67,120,105,100
P:ShortPlantWeightCt,100,63,121,130,102,100,67,43,64,10
0,100,100,120,43,64,100,100,100,100,117,138,71,102,100
P:ShortPlantWeightFw,105,113,78,128,108,100,72,43,68,10
0,100,100,135,48,68,100,100,100,80,107,172,43,93,100
P:LongPlantWeightCtr,100,44,121,151,100,100,67,43,64,10
0,100,100,120,43,64,100,100,100,100,130,138,47,100,100
P:KneeUpInBack,114,110,88,134,107,100,60,47,70,100,100,
100,144,34,81,100,100,100,86,124,76,53,94,100
P:LongPlantFw,117,134,58,142,102,100,66,43,68,100,100,1
00,139,46,65,100,100,100,83,114,181,43,97,100
P:LongPlantBk,90,09,161,132,99,100,81,42,78,100,100,100
,116,42,59,100,100,100,106,152,54,101,103,100
P:WidePlantBk,85,15,167,121,113,100,73,42,78,100,100,10
0,129,42,59,100,100,100,109,136,53,121,106,100
P:WidePlantFw,117,154,35,132,111,100,78,42,78,100,100,1
00,134,29,77,100,100,100,77,115,183,25,103,100
P:bigKneeUpFw,95,18,143,137,115,100,64,34,81,100,100,10
0,131,47,70,100,100,100,113,133,87,67,87,100
P:bigKneeUpBk,100,98,96,45,105,100,144,34,81,100,100,10
0,60,47,70,100,100,100,109,96,127,108,97,100
P:BU1,100,130,120,80,110,100,150,160,10,100,100,100,150
,160,10,100,100,100,100,130,120,80,110,100
P:BU2,80,155,85,150,150,100,185,40,60,100,100,100,185,4
0,60,100,100,100,80,155,85,150,150,100
P:BU3,75,165,55,165,155,100,185,10,100,100,100,100,185,
10,100,100,100,100,75,165,55,165,155,100
P:BU4,60,165,30,165,155,100,170,10,100,100,100,100,170,
10,100,100,100,100,60,165,30,165,155,100
P:BU5,60,165,25,160,145,100,150,60,90,100,100,100,150,6
0,90,100,100,100,60,165,25,160,145,100
P:BU6,100,155,25,140,100,100,130,50,85,100,100,100,130,
50,85,100,100,100,100,155,25,140,100,100
//
S:Stand,01,r
F:Zero,S,V3,A
F:Lean,V5,J,A
//
S:ShortStepFwdBck,11,R //(R)epeat sequence
// with changed footedness
F:Lean,V6,J,A
F:KneeUpInFront,V6
F:ShortPlantWeightBk,V6,H
F:ShortPlantWeightCt,V6
F:ShortPlantWeightFw,V6,h
F:KneeUpInBack,V6
//
S:ShortStepTurn1way,15,R //(R)epeat sequence with
//changed footedness
F:Lean,V6,J,A
F:KneeUpInFront,V6
F:ShortPlantWeightBk,V6,H
F:ShortPlantWeightCt,V6
F:LongPlantWeightFw,V6,h
F:KneeUpInBack,V6
S:ShortStepTurnOtherway,17,R //(R)epeat sequence with
// changed footedness
F:Lean,V6,J,A
F:KneeUpInFront,V6
F:LongPlantWeightBk,V6,H
F:ShortPlantWeightCt,V6
F:ShortPlantWeightFw,V6,h
F:KneeUpInBack,V6
//
S:ShortStepLftRgt,E3,D //(D)irection and footedness
// changed at end. Repeatable
// at start
F:Lean,A,V5
F:KneeUpInCenter,V5
F:ON1Foot,V5
//
S:RotateInPlace,69,r //(r)epeat sequence verbatim
F:Lean,V3,A
F:LongPlantWeightCtr,V3
F:Stand,V3,S,A
//
S:UpFromBack,B6 //runs once and stops at Stand
F:Lean,V3,J,A
F:BU1,V6
F:BU2,V6
F:BU3,V6
F:BU4,V6
F:BU5,V6
F:BU6,V6
F:Zero,S,A,V6
END
MOOSE starts out on boot-up by playing the first sequence;
in this case, S:Stand. The serial port waits for a data packet
indicating the status of the wireless PS2 controller. MOOSE
converts the joystick and button data to a requested sequence
ID, direction, and footedness. If it finds an S that matches the
requested ID, it will then search both the current sequence and
the requested sequence for the best transition point.
You may notice several things about the S:Stand
sequence. It has two static frames: F:Zero and F:Lean. In addi-
tion, it is has the r flag indicating it will repeat at the end.
Why would you want to lean in a stand sequence?
Normally, you wouldnt. The F:Lean frame has a J flag
indication that it is merely a jump point and will only be
played if necessary during a transition to another
sequence. So, until you jump away from the S:Stand
sequence, the F:Lean is ignored.
Now the Fun Begins!
Lets say that we want to transition to the
SERVO 12.2007 77
Appetizer.qxd 11/4/2007 6:30 PM Page 77
S:ShortStepFwdBck sequence with a forward direction, starting
with the left foot. MOOSE sees that there is a common frame
F:Lean in both sequences. It plays the F:Lean in the S:Stand
sequence, followed by the next desired frame F:KneeUpInFront.
Had the direction requested been backwards, MOOSE
would see that S:ShortStepFwdBck can be repeated and
would run the sequence in reverse starting with
F:KneeUpInBack. Upon reaching either end of a repeating
sequence that requires a change of footedness, MOOSE will
change from left to right foot and continue the sequence. A
full backwards/forwards or left footed/right footed walk can
be achieved from six static frames.
Now, Lets Turn While Walking!
We dont need to know where we are in a sequence and
we dont need to finish the sequence in order to transition.
Going from S:ShortStepFwdBck to S:ShortStepTurn1way
can transition on any of the four common frames. MOOSE
will immediately switch sequences on the next frame if it can.
If not, it will find the next best jump point. I know there are
some really sharp readers out there are saying, What if the
left knee is up and we want to transition to the right knee up
... they are the same frame ... can it hop?
No problemo! Even though the RoboNova cant hop, MOOSE
continues the sequence until it finds either a symmetrical
frame where it can just switch current footedness to requested
footedness with no delay (i.e., S:Stand) or an ambidextrous frame
where it can play it twice (i.e., Lean left then Lean right).
Sequences with the direction flag set like S:ShortStepLftRgt
play forward only from their first frame up to the last, can
switch footedness if needed, and play backwards down to the
first. They can then repeat from the first frame if the repeat
flag is set. One time sequences like S:UpFromBack get played
forward once and stop at the last frame.
Frames with the (H)old and (h)old flag pause momentar-
ily to allow the robot to settle. These flags are directional
since it may be critical to hold during the bounce that occurs
when placing a foot to the ground but not hold in the reverse
direction of picking the foot off the ground.
Well, thats all there is to giving your biped some dynam-
ic like sequences without using dynamic model programming.
If you have a RoboNova and would like to test drive
MOOSE and FreeLoader, please contact me.
MOOSE emulates much of your original Basic programs
serial command protocol. It can communicate with RoboBasics
servo motor real time control in order to create the static frames
and even adjust and store the zero settings. MOOSE and
RoboBasic cannot exist concurrently. If you try to upload a Basic
program, you will wipe out MOOSE and reload RoboBasic. I
would be happy to assist any brave, savvy RoboBasic program-
mer that wants to try to emulate this sequencer in RoboBasic.
Support for a five degree of freedom IMU (Inertial
Measurement Unit) is currently under development. SV
78 SERVO 12.2007
Dan Albert can be reached via email at dan@alberts-equation.net.
CONTACT THE AUTHOR
Appetizer.qxd 11/4/2007 6:31 PM Page 78
S
ervos? Just what is a servo (or a servo
motor or servo mechanism, as they
are sometimes called)? Is that a years
collection of this magazine? Most of us
who have built robots have used one or
more of these in our creations, but not all
robots use servos. Most of the larger vari-
eties of robots dont use servos though
they might employ shaft encoders to
provide some sort of positional feedback
to a controlling microcontroller or
computer. Most combat robots (like the
ones that seem out of control) dont use
any form of them, so why do so many
experimenters utilize them?
Who would have ever thought that
these small plastic boxes would have had
such an impact on experimental
robotics? I remember playing with a four
channel R/C system years ago, trying to
figure out how I could use it in a robot.
Most of my robots were usually rather
large and the tiny servos could do little
more than move small special effects
appendages. Cute decorations really
served no useful function, so I decided to
hack one to see what I could do with it.
I believe that first thing I made was
a linear actuator. Pulling the 4.7K pot
out, cutting off the stops from the
output gear, I attached a 25 turn lead
screw and a 25 turn 5K trim pot (in the
place of the other one) to the output
shaft and had an amazingly powerful
push-pull actuator. Other experi-
menters in our robotics group were
attaching them to arm and leg joints,
and driving the servos with 555/556
timer circuits or 6502 microprocessors,
and a few started to use them as drive
motors for small robots wheels.
Typical Servos Used
in Robotics
The three servos shown in Figures
1a, 1b, and 1c are just a tiny fraction of
the many types, torque capacities, sizes,
and weights available from the many
manufacturers today. Servos are quite
often the only motive force of many
experimenters robots. Most of the
beginners kits from Parallax and others
use similar servos in small robots.
Tabletop robots can make use of
the little motor/gearbox to drive a
set of wheels and the associated
electronics to receive the pulse trains
from a microcontroller and convert
them to drive signals. This is a cheap
and effective way to get a robot design
from a few sketches to a working
machine in a few hours.
As robot experimenters, we think
of those little black boxes that
were originally developed for model
airplanes as the only servo that were
familiar with. Many of us have boxes of
them; some hacked, some in pieces,
and some actually in one piece.
Servo Feedback
With the advent of specialized ICs
and electronics, modern servos have
emerged as marvels of mechanics and
electronics. Servos have been used in
industrial applications for years, long
a
n
d
SERVOS
b y T o m C a r r o l l
FIGURE 1a. JR servo. FIGURE 1b. HiTec robot servo. FIGURE 1c. Futaba coreless servo.
SERVO 12.2007 79
Then&Now.qxd 11/5/2007 4:29 PM Page 79
80 SERVO 12.2007
before model aircraft found them useful
to move various surfaces to change the
direction of flight. Newer applications
are popular for CNC machine tool use.
Figure 2 shows three servos used
to move the three axes of a milling
machine by Servo Products. Way back
in 1787, James Watt used a servo-like
device the flyball governor to reg-
ulate the speed of his steam engines.
Figure 3 from the cover of a 1952
Scientific American Magazine shows a
classic drawing of the flyball governor.
It certainly was not what we think of
today as an electrical/electronic servo,
but it could be set in different positions
to control the speed of a steam engine.
The revolving set of balls was
directly connected to the engines output
shaft and as the speed increased,
centrifugal force caused the balls to move
outward, pulling down the upper ring
and connected lever. As this ring moved
downward, it would slowly shut down
the flow of steam by moving a valve, thus
slowing the engine and revolving balls.
At one point, a stable speed was
developed. By manually changing the
distance between the ring and where
the valve cut down the steam flow, one
could set the engines speed wherever
desired. A relief valve was set to open
at a specific pressure, thus preventing
an exploding boiler.
No, this certainly is not a typical
servo that were familiar with, but it did
utilize feedback to control a machine.
No 1.0 to 2.0 millisecond pulses were
sent remotely to Watts engine to
control speed, just a simple mechanical
adjustment by a human operator.
What is a Servo?
Just like the definition of a robot is
so different to so many people, a servo
has many definitions. Allow me to pres-
ent four definitions of the term servo
that I found at random through Google:
A servo is: An electromechanical
device that uses feedback to provide
precise starts and stops for such
functions as the motors on a tape drive
or the moving of an access arm on a
disk (PC Magazine).
A servo is: An automatic device
used to correct errors in the operation
of machinery, used in satellite-tracking
systems, power-steering systems on
some cars, and to control robots and
keep ships on course (encyclopedia).
A servo is: A small mechanism
inside the RC vehicle, the servo is a device
with a motor, gears, and circuits that con-
trols things like steering and speed. A
typical RC car has a steering servo to
make the wheels turn and a speed con-
trol or throttle servo to make it go faster
or slower. Other types of servos may be
present to control other functions (radio-
control car enthusiasts definition).
A servo is: An electro-mechanical
device that is used to convert the
received signal into mechanical move-
ment. Servos are used to move control
surfaces, throttles, retractable landing
gear, or auxiliary functions (model
airplane enthusiasts definition).
Servo is: The name of a great
robot experimenters magazine. (Sorry,
I just had to put that in.) If you Google
servo, youll find most definitions and
hits are about the model airplane types.
How Does a Servo
Work?
Are you really any closer to
knowing just what a servo is? So many
articles in this magazine (including
some of mine) have gone over how a
typical model aircraft servo works. The
more popular and certainly cheaper
models utilize a pulse width modula-
tion pulse train from the R/C receiver.
The pulse train consists of 50 to 60
pulses per second with each pulse
being one to two milliseconds long,
though experimenters have used 0.8 to
2.2 ms pulses to drive the servo further
than the typical 90 to 120 degrees of
travel. A shorter series of pulses will
drive the servos output shaft one
direction, and the longer pulses will
drive the other way with positions in
between for pulses closer to 1.5 ms.
In these older servos that have
been used for years, there are three
wires to the servo: a signal wire (for the
pulse train) that can be a number of
colors; a 4.8 to 6 volt power wire that
is usually red; and a ground wire that is
usually black or brown. Note that there
is no output wire to inform an operator
or microcontroller just where the
servos shaft is positioned.
Early Model Aircraft
Servos
One of the first R/C systems that I
used was by Kraft. Figure 4 shows an ear-
lier analog Kraft system with three servos
mounted in the airplane, lying behind
the transmitter and receiver in the
foreground. Back in the 80s, several of
us from the Robotics Society of Southern
California were invited down to the Kraft
FIGURE 3. Flyball governor on the
cover of Scientific American.
FIGURE 2. Three axis milling machine
set up by Servo Products.
Then&Now.qxd 11/5/2007 4:30 PM Page 80
plant in Vista, CA and were given a tour
of the facility. The guy leading us around
the Kraft facility gave us a lot of servos,
receivers, and battery packs just for good
will; maybe he saw that the end was
near. Futaba from Japan was starting to
really hurt the US manufacturers and
Krafts days seemed numbered.
Experimenting with them at home,
I found the Kraft servos to be quite well
made. I also had an old Heathkit R/C
system that I built that used two PS-4
servos made by Orbit (remember kits?).
Kraft later came out with the smaller
KPS-12 servos that some people I knew
built into robot joints for walkers. I later
began to frequent the Hobby Shack
(now Hobby People) in Fountain Valley,
CA and found that Futaba and HS
Cirrus line of R/C equipment to be a lot
cheaper for my R/C projects.
One of my first R/C robots for a
movie used a Hobby Shack AeroSport
four channel system with two Vantec
speed controllers for the two wheels
and two very large Cirrus servos for the
two arms. I used coil springs to compen-
sate for the arms weight and the little
robot could easily pick up over a pound.
Futaba took the lead several
decades ago and is still one of the more
popular R/C systems with a full line of
servos for all applications, including
servos designed specifically for robots.
HiTec of Korea also has a line of servos
specifically designed for robots, as does
the Robotis Bioloid line of Dynamixel
servos (actuators), also from Korea.
Servo Selection
You may be wondering just what
type of servo that youll need for your
project. For economys sake, you can
start with the cheaper analog servos
with a three pole cored motor, plastic
gears, and bushings for the shaft. These
will work great for almost all applica-
tions where you need to study the basics
before advancing to your final design.
The next step for tougher applica-
tions is to buy a metal geared servo
with ball bearings on the main shaft.
Coreless motors have quicker changes
in speed over the three and five pole
cored motors. The most advanced are
the digital servos with an embedded
microcontroller to deliver a greater
number of PWM pulses to the motor
for quicker response, greater accuracy,
and torque with less deadband. They
do draw a bit more power to operate,
but that is usually not too much of a
concern for robot builders.
Of course, servos vary widely in
their torque, weight, and size. The Cirrus
CS-3 Micro Joule SX servo weighs only
three grams (its four channel receiver
weighs a bit less), yet it only has seven
oz. in. of torque (see Figure 5). Monster
servos can weigh over a pound and put
out 10 foot pounds of torque or more.
It all depends on what you need.
This single paragraph certainly
cannot narrow down the right servo
for your application; you need to go
to the Internet or to manufacturers
websites and do some research.
Servo Feedback vs.
Feedback to a
Microcontroller
This magazine takes its name from
these devices that so many of us have
used in our robots for years, yet servos
offer no built-in intelligence. They only
take commands from a microcontroller
or R/C receiver and move to a certain
point and stop. But hack the little
suckers and you have an intelligent
drive motor of sorts.
After reading my August column
on Robot Arms, Alex Dirks of
CrustCrawler wrote SERVO concerning
what he felt were incorrect statements
that I made concerning servos used in
many experimenters robots the
types used with radio controlled model
airplanes to move various wing and
rudder surfaces. He referred to the
following statements that I made
concerning their use with robot arms:
The advantage of using R/C
servos is the positional feedback.
Potentiometric feedback, as in R/C ser-
vos, allows the controlling computer to
know where each joint is positioned.
Alex countered with the following:
FIGURE 4. Early Kraft radio.
FIGURE 5. Cirrus CS-3 Micro
Joule SX servo.
FIGURE 6. Robotis Dynamixel AX-12. FIGURE 7. Robotis Dynamixel RX-28.
SERVO 12.2007 81
Then&Now.qxd 11/5/2007 4:30 PM Page 81
There are no feedback mechanisms
built into any standard servo today with
the exception of the AX-12+ (the servo
from Robotis and several others in that
line) and a few specialized servos used
in biped type robots. Alex knows
servos as President of CrustCrawler, a
business he started six years ago with
the HexCrawler and QuadCrawler.
The products he feels have the
most promise today are probably the
AX12 Smart arms designed around the
Robotis smart servos that Ill discuss
later. However, it is CrustCrawlers and
the other well-known suppliers of
ready-to-roll robots and kits that have
steered the servo manufacturers into
designs that are made specifically for
robot experimenters.
I felt that the best way to under-
stand where he was coming from was
to talk with him personally. When I
talk about servo feedback, he told
me, I mean feedback to an external
controller. Feedback that is limited to
the servo itself without feedback to an
external controlling/monitoring device
such as a microcontroller or host
computer limits the usefulness of the
servo motor substantially. I convinced
him that I was speaking of the
feedback of the internal potentiometer
to the internal circuitry, not to the
outside world. Its internal feedback pot
serves only to tell the internal circuitry
just where the servo horn is positioned.
I feel that this is an advantage over
the use of a stepper motor as a stepper
can become stuck and the microcon-
troller will assume that it still has
moved the required number of turns. A
microcontroller connected to a typical
servo will send the appropriate series
of specific width pulses and the servo
will continue to try to move to the right
spot until it is there.
Intelligent Servos
Alex feels that the standard servo
of today whether analog or digital
will soon be phased out for walking
robots, especially the higher end kits
and ready-builts. The Robot Exclusive
Actuator Dynamixel from Robotis is
one of the most innovative servos to
come out in years. The Robotis line of
rotary actuators (as they call them)
have some very good features for
robot experimenters. They certainly
command a premium price but
humanoid builders will find one feature
very useful in their designs the ability
to be daisy-chained rather that have
three leads from each of, say, 18 ser-
vos leading back to a controller board.
Dynamixel actuators, such as the
AX-12+ (Figure 6), speak to each other
through a TTL line, and units such as
the RX-28 (Figure 7) communicate
through the popular RS-485 protocol.
CrustCrawler has developed the AX12
Smart arm that uses the Robotis
Dynamixel actuators for the arms joints.
Each servo in the daisy chain is assigned
an address for control and feedback pur-
poses. Yes, these devices have true feed-
back to the controlling microcontroller,
such as an Atmel or BASIC Stamp.
Most of the larger manufacturers
and dealers of robots and robot kits in
SERVO Magazine have numerous styles,
costs, and capabilities of servos in their
lineups. Figure 8 shows a line of servos
from Pololu. The Seattle Robotics Society
(SeattleRobotics@yahoogroups.com) has
excellent sources for hacking and
modifying servos as do many other
groups sites. R/C and model aircraft
sites offer much useful information.
In the two months that I have
been working on this article off and
on, I have come across so much
information on the subject of servos
and many of the articles are complete-
ly contradictory with others. So, dont
take everything that you read as fact.
Talk with fellow robot experimenters
and just take one apart and determine
how it works and what youre going to
do with it next. Modern servos are a
true bargain. SV
FIGURE 8. Line of servos from Pololu.
Tom Carroll can be reached via email
at TWCarroll@aol.com.
CONTACT THE AUTHOR
All Electronics Corp. ..........................19, 66
AP Circuits/e-pcb.com ............................13
AWIT ..........................................................66
Budget Robotics ......................................16
CrustCrawler ...............................................3
Electronics123 ..........................................19
Floatation Center Art Gallery ..............65
Futurlec .....................................................66
Gears Educational Systems, LLC ............50
Hitec ..........................................................13
Hobby Engineering .................................66
IMService ............................................19, 66
Jameco .................................................2, 66
Lorax Works ........................................19, 66
Lynxmotion, Inc. .......................................17
Maxbotix ...................................................66
Maximum Robotics ............................30, 66
Net Media .................................................83
Parallax, Inc. ...............................Back Cover
PCB Pool .............................................66, 72
Pololu Robotics & Electronics ..........42, 66
Robotis Co. Ltd. .......................................78
RobotShop, Inc. .................................66, 72
Schmartboard.....................................19, 65
SCON .........................................................19
Solarbotics/HVW .......................................7
SORC ..........................................................59
SPSU...........................................................21
Technological Arts ...................................66
TORMACH ................................................35
Vantec .......................................................59
Yost Engineering ......................................45
Advertiser Index
82 SERVO 12.2007
Then&Now.qxd 11/5/2007 4:31 PM Page 82
Order 24 hours a day, 7 days a week
www.Jameco.com
Or call 800-831-4242 anytime
Jameco Electronics. *According to the line cards on their web sites on August 28, 2007. Trademarks are the property of their respective owners.
OTHER JAMECO ADVANTAGES:
More major brands of semis than any other catalog.
99% of catalog products ship the same day.
Lowest prices guaranteed, or we pay 10%.
Major brand names and generic equivalents
for even greater cost savings.
5
10
15
20
Were passive aggressive
When it comes to passive products, we dont pull
any punches: we stock more major brands of
passive components than any other major cata-
log distributor.* So whatever brands you need
from AMP or AVX to Vishay or Wakefield
youre more likely to find them all at Jameco.
Check our stats below and see for yourself.
Its another Jameco advantage.
Jameco
Digi-Key
Mouser
Newark
S
E
R
V
O
S
S
P
A
R
E
T
H
E
R
O
D
,
S
P
O
I
L
T
H
E
B
O
T
T
A
S
K
P
R
I
M
I
T
I
V
E
S
D
e
c
e
m
b
e
r
2
0
0
7
0 4 74470 58285
12>
U.S. $5.50 CANADA $7.00
Cover.qxd 11/6/2007 3:46 PM Page 84