Tạp chí Servo
Trang 4SERVO Magazine (ISSN 1546-0592/CDN Pub Agree
#40702530) is published monthly for $24.95 per year by
T & L Publications, Inc., 430 Princeland Court, Corona, CA
92879 PERIODICALS POSTAGE PAID AT CORONA, CA AND
AT ADDITIONAL ENTRY MAILING OFFICES POSTMASTER:
Send address changes to SERVO Magazine, P.O Box
15277, North Hollywood, CA 91615 or Station A, P.O.
Box 54,Windsor ON N9A 6J5; cpcreturns@servomagazine.com
08 Robytes by Jeff Eckert
Stimulating Robot Tidbits
10 GeerHeadby David Geer
Zeno — The First Complete Character Robot
14 Ask Mr Roboto by Pete Miles
Your Problems Solved Here
61 Twin Tweaks
by Bryce and Evan Woolley
More Than Meets the Eye —
the Mighty Morphing V-Bot
67 Different Bits
by Heather Dewey-Hagborg
Neural Networks for the PIC Microcontroller
Part 4: Self-Organizing Maps
71 Robotics Resources
by Gordon McComb
Small Brains for Your Bot
75 Appetizer by Gerard Fonte
Terms of Endearment
79 Then and Now by Tom Carroll
Robots Take to the Air
PAGE 24
Trang 5VOL 6 NO 1
ENTER WITH CAUTION!
MEET THE MIGHTY MORPHING V-BOT/pg 61
by Michael Simpson
Part 4: A closer look at the interface needed for each of the GPS modules covered in this series.
by Fulvio Mastrogiovanni
This article focuses on the entire control loop that’s used to allow a rover to safely navigate on Mars using information from Earth.
Microcontrollers Made Easy
Give ARTI ONE a new lease on life.
Features & Projects
Trang 6Published Monthly By
T & L Publications, Inc.
430 Princeland Court Corona, CA 92879-1300
(951) 371-8497 FAX (951) 371-3052 Product Order Line 1-800-783-4624 www.servomagazine.com
Subscriptions
Inside US 1-877-525-2539 Outside US 1-818-487-4545
P.O Box 15277 North Hollywood, CA 91615
PUBLISHER
Larry Lemieux
publisher@servomagazine.com ASSOCIATE PUBLISHER/
Heather Dewey-Hagborg Fulvio Mastrogiovanni
CIRCULATION DIRECTOR
Tracy Kerley
subscribe@servomagazine.com MARKETING COORDINATOR
WEBSTORE
Brian Kirkpatrick
sales@servomagazine.com WEB CONTENT
Michael Kaudze
website@servomagazine.com PRODUCTION/GRAPHICS
Shannon Lemieux Joe Keungmanivong
ADMINISTRATIVE ASSISTANT
Debbie Stauffacher
Copyright 2008 by
T & L Publications, Inc.
All Rights Reserved
All advertising is subject to publisher’s approval.
We are not responsible for mistakes, misprints,
or typographical errors SERVO Magazine
assumes no responsibility for the availability or condition of advertised items or for the honesty
of the advertiser.The publisher makes no claims
for the legality of any item advertised in SERVO.
This is the sole responsibility of the advertiser Advertisers and their agencies agree to indemnify and protect the publisher from any and all claims, action, or expense arising from
advertising placed in SERVO Please send all
editorial correspondence, UPS, overnight mail,
and artwork to: 430 Princeland Court,
INFRASTRUCTURE
A fundamental aspect of robotics is
that the application domain can range
from ocean beds and table tops to the
nooks and crannies of extraterrestrial
dunes It’s no coincidence that the
techniques and technologies described in
the article featured in this issue of SERVO
can be applied to virtually any application
areas However, if you have a particular
interest in space exploration, then you’ll
find Fulvio Mastrogiovanni’s article,
“Space Robotics,” of particular note.
Fulvio, a PhD candidate from the Mobile
Robotics and Artificial Intelligence at the
University of Genova, Italy, offers a
focused consideration of control theory
applied to the practical challenges
presented by the NASA Mars Explorer
Rover mission The article also hints at an
often ignored and poorly understood
aspect of robotics — that of infrastructure
Space exploration and transport,
together with development of more
traditional military gear, are responsible for
many of the innovations in sensors,
software, and platform designs that trickle
down to civilian robot developers.
However, even if you have access to
the components and algorithms used by
NASA engineers, you’d probably find it
impossible to develop a robot that even
approximates the abilities of the impressive
Martian rovers The missing ingredient is
infrastructure — the robots, conventional
tools, and processes used to develop the
vehicles and robots destined for space.
Consider the array of advanced
robotics used in the construction and
testing of the shuttle’s external tank The
shuttle’s external tank, which has a length
of 55 feet and diameter of 28 feet, is
fabricated at the Michoud Assembly
Facility, near New Orleans When I toured
the facility, I was amazed at the robots
and other automated equipment required
to achieve the tolerances necessary for
space flight In particular, I witnessed a
fully assembled fuel tank mounted
horizontally on a motorized spindle in a
way that enabled robots to apply
insulating foam to the aluminum-lithium tank I tried to imagine the control systems and motors necessary to rotate the 58,000 lb tank and maintain a precise coating depth Although I haven’t seen it first hand, I assume that the robotic equipment used to create the multi-stage Boeing Delta II that transported the Martian rovers is just as impressive.
Sam Christy’s article on programming for FIRST controllers and Tim Paterson’s article on square roots illustrate a key
‘invisible’ component of the infrastructure required to develop robots If you’re like many roboticists, you probably have a drill press, soldering iron, a few boxes of spare parts, perhaps a library of reference texts, and a PC To the uninitiated, the PC may
be simply another artifact in your workshop However, if you’re involved with developing control loops, machine vision, wireless communications, or other computational tasks, then your PC may be your primary development tool In this regard, traditional tools and components often fail to capture the enormity of effort, planning, and time that goes into developing a robot.
If you’re new to robotics, then you’re just beginning to appreciate the depth and breadth of your development infrastructure (or lack of it) Whether you’re primarily involved in developing pneumatic weapons for battle bots or vision recognition algorithms for a commercial robotic platform, you’ll soon discover that a development infrastructure is a prerequisite for efficient, unencumbered robot development.
At the start of my robotics career, I invested almost a year of effort developing
a flexible infrastructure The major components include:
• Drill Press and Bit Assortment
• Vise
• Work Bench
• Dremel and Accessories
• Dual-Trace Digital Oscilloscope
Trang 7• Air Compressor
• Hand Tools
• Glues and Adhesives
• Nut and Bolt Library
• Clamps
• Cables, Wire, and Shrink Tubing
• Connectors and Pins
• Soldering/Desoldering Station
• R/C Unit
• Nibbler Tool
• PC
• Software (Schematic generation, simulation, compilers)
• Sensors (US, IR, motion, etc.)
• Microcontrollers (STAMP, PICs, ATMEL)
• Storage Bins
• Breadboard System
• Multi-drawer Tool Chest
I’m still working on the infrastructure, but at a much lower
level So, how do you go about building an infrastructure? If
you’re fortunate enough to be financially well positioned, then
the anticipatory approach is a viable option Assuming that you
can accurately anticipate your upcoming needs, then you can
assemble an infrastructure within a few weeks Even with
equipment in hand, you’ll need several weeks to learn how to
operate and apply your new hardware and software.
At the other extreme is the as-needed approach, which
entails purchasing tools and test equipment on an as-needed
basis While easy on the pocket, this approach often results in a
loss of momentum Stopping a project midway to await delivery
of a drill or torque wrench and then learning how to use the
device can derail an otherwise focused project There is also the
defocusing associated with taking time to identify the best
oscilloscope, drill press, or other item.
The two approaches aren’t mutually exclusive For example,
I use a hybrid approach in which a few major purchases — drill
press, multimeter, hand tools, and oscilloscope — are added to as
needed I’ve learned the hard way that when you build an
infrastructure, buy the best that you can afford Don’t be lured by
an inexpensive hand tool or soldering iron that will satisfy your
current project Instead, try to anticipate what you’ll need over
the next five years It costs more to buy a cheap tool and then a
more expensive tool a few months later, than to buy the right tool
to begin with I’m a big fan of eBay where — if you’re patient
enough — you can find good deals on equipment that might
otherwise be out of your reach.
Another option is to outsource your infrastructure by joining
a well-stocked robotics club For modest dues, you can have
access to a supportive infrastructure that may prove invaluable
to your success in robotics A related approach is
to extend your infrastructure with external services, such as
laser cutting I use Pololu Robotics and Electronics
(www.Pololu.com) for laser cutting on large projects.
Outsourcing can be expensive, but it allows you to focus on what
you do best.
As a word of warning, as you construct your infrastructure,
remember that it’s tempting to use robotics as an excuse to
amass a huge collection of fantastic tools and equipment This is
fine if your intent is to collect tools However, if your goal is to
produce functional robots, then do your best to avoid the
seduction of gear SV
Advanced Course3 Days$1995
Program and Control:
GPS Receivers RS232, 485 Serial Communications Wireless Communications IEEE Zig Bee, Bluetooth Distance Sensors RFID Readers and Tags Motor Control W/Feedback
Minneapolis, MN, Jul 21-23 Los Angeles, CA, Aug 18-20 Newark, NJ, Sep 22-24 San Diego, CA, Oct 6-8
Check the web for more dates
Intro Course3 Days$1995
Program and Control:
LED and LCD Displays
DC, Servo, and Stepper Motors Temperature and Light sensors RS232 Serial Communications ADCs and EEPROMs Timers, Interrupts, & Clocks Visual Basic Interfaces
Columbus, OH, Jan 21-23 Los Angeles, CA, Feb 4-6 Huntsville, AL, Feb 18-20 Newark, NJ, Mar 3-5
Check the web for more dates
WoW! Finally, Hands-on Training for
RCG Research
Innovative Ideas in Electronics Design
Monster power!
14-50V 3.15 x4.5”x1.5”
fwd-only channel 5V - 18V
1.6“ x 1.6” x 0.5”
2.5A 12A
6 6 6
5V - 24V 2.7“ x 1.6” x 0.5”
13A 45A Peak!
6 6 6 6 6 6 6
14V - 50V - Dual H-bridges - 150 Adjustable current limiting Temperature limiting Three R/C inputs - serial option Many mixing options - Flipped Bot Input Rugged extruded Aluminum case 4.25" x 3.23" x 1.1”
Closed-loop control of two motors Full PID position/velocity loop Trapezoidal path generator PIC18F6722 CPU
C source for routines provided See
Giant Servo Mode!
www.embeddedelectronics.net
$250
MAD E IN THE USA
H-bridges: Use with Dalf or with your Micro/Stamp
Simple-H
6 6 6 6
6-28V 25
2.25 x2.5 x0.5”
3 wire interface current & temp protection
A!
$79
In re-reading my December 2007 Robotics Resources column, I spotted
a small error regarding the light wavelength of the laser diodes used in
DVD players Most commercial DVD players use 650 nanometer (deep
red) laser diodes, rather than the 780 nanometer (infrared) laser diodes
common in CD players.
Gordon McComb Robotics Resources
Trang 8Goodbye E-Harmony, Hello
Bot-Harmony
You may have noticed (or tried not
to notice) that some robots are
becom-ing a lot more lifelike and even allurbecom-ing
One example is Dion, a Chinese babe
who is said to mimic all sorts of human
features, including facial expressions,
skin temperature and elasticity, breath,
and heartbeat According to the
manu-facturer, she can even be built to
resem-ble the specific person of your choice
Another deliberately seductive
mechanism is Actroid DER2, developed
at the University of Osaka and
manufac-tured by Kokoro Co This one is
designed “to play an active part for
many occasions as a chairperson with
fluent narrations and booth bunny.” You
can even rent her for a five-day outing
for $400,000 yen (about $3,500 US)
I didn’t locate any specific
infor-mation about how intimate these
yum-bots are designed to be, but if you are
presently settling for a partner who
has to be inflated for each romantic
encounter, you might be interested in
a recent book by AI expert David Levy
The good news is that it someday will
be common for people to marry and
have sex with robots The bad news is
that Levy doesn’t expect it to be legal
and acceptable until about 2050 He
also predicted that Massachusetts will
be the first to legalize it
If you want to follow that line oflogic, pick up a copy of Love and Sex with Robots: The Evolution of Human-Robot Relationships, published
late last year by HarperCollins (www.
harpercollins.com) The hardcover
edition will cost you $24.95, or youcan get the e-book for $19.95
Arm Inspired by the
Real Thing
Ever since the Barrett Hand —
a three-fingered manipulator used extensively by NASA — was introduced in
1997, mechanical arms have grown moredexterous and complex, but still haven’tlooked or operated that much like thehuman counterpart But an eerily lifelikeone, even without any skin covering, hasbeen brought to us by Germany’s Festo
Corp (www.festo.com).
The company is known primarily forits pneumatic and electromechanical systems, components, and industrial controls But perhaps its most interestingaccomplishment is the creation of Airic’sArm Based on the real thing, it even hasmetal versions of the radius and ulna, themetacarpals, and the shoulder and shoulder blade One big difference, how-ever, is that it is powered by 30 of Festo’s
“Fluidic Muscles,” which are tubes ofelastomer reinforced with aramide fibers
When you fill one with compressed air, its diameter increasesand its length shortens, thus creatingmovement This actually gives Airic
an advantage over the rest of us: When the arm contracts, it doesn’trequire any additional power to staycontracted; that is, it can lift some-thing and hold it in place indefinitely.Festo intends to further developthe system by adding vision and tacticsensors and maybe even giving it aneck, a back, and a hip A short video
of the thing in action is presently at
www.youtube.com/watch?v=tVg6 xKHJKY4.
Feeding Robot for the Disabled
On a more specialized level is the
My Spoon feeding robot manufactured
in Tokyo by SECOM Co., Ltd Designed
to allow victims of spinal cord injuries,muscular dystrophy, and other disabili-ties to feed themselves without a care-giver’s assistance, it offers interchange-able controllers and utensils, and aselection of operating modes to accom-modate different disability levels It’s notquite up to the flexibility of a humanoidhand in that foods must be served fromspecific divisions of a meal tray, and theymust be in bite-sized pieces
Both users and therapists seem to
be praising its effectiveness, and it waseven nominated as a finisher in the Top
10 Robots listed by Japan’s Ministry of
Dion, from Beijing Yuanda Super
Robot Technology Co., Ltd., and
Actroid, from Kokoro Co., Ltd.
Airic’s Arm, perhaps the most realistic robotic arm yet.
Photo courtesy of Festo Corp.
The My Spoon™ feeding apparatus Photo courtesy of SECOM Co.
by Jeff Eckert
Trang 9Economy, Trade, and Industry No price
is given on the company’s website
(www.secom.co.jp/english/index.ht
ml), which probably indicates that it will
run you a pretty nice chunk of change
But the main idea is to give the user
a greater sense of independence, which
is not a bad thing And it could probably
be fitted with a nice demitasse spoon,
making it useful for a fair number of
Hollywood actors and pop stars
Creeper Checks Structural
Integrity
Quite often, even creepy little
robots on tracks can cost an amazing
amount of money For example, it was
reported that the US Army recently
ordered 40 PackBots from iRobot
(www.irobot.com) at a cost of $8.8
million, or $220,000 each It is therefore
interesting that Sanyo appears ready to
introduce a model that is rumored to be
priced at a paltry one million yen (about
$8,900) Sure, the military machines are
more heavily equipped and hardened
for rough duty and, sure, we’re
comparing horses to ponies But still, at
about 1/25th of the cost
In any event, details are spotty, but
Sanyo's new machine — so far, rather
generically named the Underfloor
Robot — is designed to scamper around
underneath potentially crumbling office
buildings, apartments, and other places
that may be suffering from structural
damage It runs about two hours on a
charge, performing visual inspections
and beaming back video of whatever it
finds It is equipped with a zoom lens
for getting down to details and will
automatically create reports and
measure the distance between objects
Other specs include dimensions
(L, W, H) of 420 x 260 x 200 mm (16.5
x 10.2 x 7.9 in), base weight of 9.6 kg
(21 lb), and the ability to traverse
bumps up to 85 mm (3.4 in) in height
Power comes from a lithium-ion
battery pack, as usual More detailed
data should be appearing at www.
sanyo.com by the time you read this.
Watch for Floating Objects
Okay, they’re not the most complexself-operating devices you’ve ever seen,and all they basically do is bob up anddown; measure tempera-
ture, salinity, and velocity;
and relay the informationback home But theamazing thing is that theInternational Argo Project
(www.argo.net), with
support from more than
40 countries, haslaunched more than3,000 of the things since
2000, and they are tered all over the globe
scat-In the operationalcycle, each float spends
10 hours at the surface,descends to its driftingdepth of 1,000 m (3,281ft), and stays there foreight to 10 days, drops
to the profiling depth of2,000 m (6,562 ft), thenmakes its measurementsduring a 10 hour ascent
The objective is toallow the world, for thefirst time, to take thepulse of the oceans on a
continuous basis and relay the information to whoever needs it within hours of its collection And
“whoever” includes you
For the beginner’s guide to
accessing Argo data, log onto www argo.ucsd.edu/Frbeginnersguide html You’ll be giving speeches on
climatology in no time SV
R o b y t e s
Diagram of an Argo Active Float.
Photo courtesy of the Argo Information Centre iRobot’s PackBot Explorer and Sanyo’s upcoming underfloor robot.
Photos courtesy of iRobot and Sanyo Electric Co Ltd.
Trang 10Zeno — due on the market as a toy
in 2009 — is the closest thing to
human that a robot has become
Its facial expressions are a story all
to themselves, enabling the most
complete robot personality and
human-to-robot emotive interactivity to
date Want some proof? Read on!
Zeno is a 16-inch, six-pound,
interactive robot boy developed by
Hanson Robotics with help from a
number of vendors including
RoboGarage and roboticist Tomotaka
Takahashi, of Japan, who is responsible
for creating Zeno’s body
The body prototype uses 18
servos, enabling the robot to walk, run,
balance on one foot, lie down and
get up, and gesture, as in non-verbal
communication, according to Dr David
Hanson, PhD, who worked with
Takahashi to produce the combined
robot, Zeno
Zeno is Born
Only recently completed (September2007), Zeno, the boy robot, offers everyhuman facial response Zeno (animationsoftware from Massive Software andMaya software) is the world’s first
“complete character robot,” according to
Dr Hanson
Complete character means Zenohas facial expressions, walking and ges-turing expressions, and conversationalcapabilities like a complete humanbeing would have
Zeno smiles, frowns, and getsangry He looks sad, surprised, andafraid He can present confusion or concentration as well, according to Dr
Hanson The mouth moves when Zeno isspeaking, the eyelids each work inde-pendent of the other, and the eyeballsturn side-to-side, and look up and down
“In the toy, we intend for the ears
to wriggle,” says Dr Hanson Zeno cannod, turn, and tilt its head “Thesemotions can be used expressively, aswell as to affect eye contact with people and otherwise look around therobot’s environment,” Dr Hanson says.Zeno — like other Hanson characterrobots — interacts with people with a fullrange of robotically orchestrated facialexpressions and conversation enabled byHanson’s Artificial Intelligence softwareand carried out by Hanson’s patentedrobot mechanics and materials
Thanks to a company calledSensory, Zeno recognizes and understands human speech, according
to Dr Hanson Zeno can respond withsubstantial verbal exchanges
Not short on words, Zeno’s lary is what scientists like Dr Hanson call
vocabu-“arbitrarily large” in size, meaning it ismore than big enough for the job athand “As people talk with the robot, therobot listens especially for words andphrases most pertinent to the recentconversation,” says Dr Hanson
Zeno analyzes human speech toget the intent of the conversation.While the robot makes errors inspeech recognition 10-20 percent ofthe time, it can still respond tohuman commentary, staying ontopic, according to Dr Hanson Thismirrors human exchanges, in whichpeople generally stay on topic butallow conversation to flow and take
Contact the author at geercom@alltel.net
by David Geer
Zeno — The First Complete
Character Robot
Human interaction is its main attraction
Photos are courtesy of Thomas Riccio unless otherwise noted.
Even from the start, Zeno’s head was more
than a hat rack Here is a shell of Zeno’s
head with notes and numbers; a part of
the design process.
A clay mock-up of Zeno from the design phase.
Trang 11on new directions, Dr Hanson explains
Frubber — It’s All
in the Skin!
Hanson’s patented Frubber
syn-thetic materials technology makes it
possible to give Zeno and other robots
a wide range of life-like, emotive facial
responses Frubber enables Hanson
robots to form near-real human
expres-sions with what is the closest to real
skin that robotics materials have come
so far, while requiring a fraction of the
power needed by other solutions
Hanson’s “structured porosity
elas-tomer” (SPEM) uses a hierarchy of pores
that can pack into other pores down to
smaller and smaller scales — even to the
molecular level — resulting in very
skin-like foam The robot skin stretches skin-like
human skin and packs like skin to enable
more realistic human expressions
Frubber stretches to greater than
eight times its original size or
compress-es to fractions of its original form while
using less than 045 percent of the
power required for other robot face
expression solutions The power
reduc-tion makes it possible to use replaceable
batteries for the facial operations which,
in turn, helps make it possible to create
human-like bipedal robots that run
with-out being tethered to power supplies
Electronics
Hanson’s electrical and computing
technologies include the
patent-pending Character Engine AI
frame-work, which works in conjunction with
animation software
The AI framework and software
enable robotic movement including
human-like qualities that were not
previously transferable from computer
animation to robotic actuation The AI
and machine intelligence can run on a
single, standard PC, which can control
the robot wirelessly, explains Dr Hanson
“In our first prototype, we are
using Bluetooth wireless for the motion
control and the sensor data, and
ana-log composite RF for video
transmis-sion In the final product, we intend to
use Wi-Fi (802.11g),” says Dr Hanson
According to Dr Hanson, theCharacter Engine framework is a modu-lar and extensible software architecturefor developing extremely intelligentcharacters This generally means thesoftware is well designed so it’s easy toexpand on the programming that exists,
to code other things to go with it
The modular approach to codingthe software makes it easy to interfacethe Character Engine with other AI androbotics software like MS RoboticsStudio, Intel Open CV, and a variety ofcognitive architectures
The Character Engine provides agood framework (programming structure) for writing personalities intothe individual robot’s characters TheCharacter Engine enables code/
personality authors to quickly createnew personalities with software toolsjust for that purpose
The Character Engine uses Mayasoftware, as well as Massive software,which will be familiar to games and animations programmers, to
control the animated ior of the robot, so it canexpress its personality So,what games and feature filmanimation language writersand program developers havebeen doing is not simplybringing characters to life onscreen, but paving the way tobring them to life in 4D!
behav-The Massive Softwareprogramming serves as themotor cortex — the interac-tive animation brain forHanson’s robots “Massive is
the right tool for the job, deliveringextremely lifelike character behavior inresponse to sensory stimuli, a capacitywell demonstrated in numerous films,including the Academy Award winningcrowd effects in the “Lord of theRings” movies,” comments Dr Hanson.The Character Engine softwarealso combines state-of-the-art comput-
er vision, face tracking, and motiontracking with other sensory input, soZeno’s personality knows who andwhat it is interacting with and respond-ing to Zeno uses motion detection andcomputer vision to recognize facial
Zeno at WIRED’s Nextfest.
Photo courtesy of Kevin Carpenter.
Full-length Zeno His body is mobile, too Zeno complete with depth of character.
Just look into those eyes!
Trang 12expressions, human gestures, and
common objects, explains Dr Hanson
Modular
Programming Proves
its Worth Again
The flexibility that modular
pro-gramming offers is imperative to
enable researchers and developers to
combine the complex elements of AI
that make it possible to simulate the
equally complex brains in human
beings, according to Dr Hanson
“We hope this focus on intelligent
characters will foster rapid progress in
sociable AI, helping to give rise to
friendly AI — the sort of AI that feels
compassion towards us, and can help
to prevent the nightmarish future ofunfriendly AI so common in sci-fi.”
“We have authors who constructthe personalities for our robots both asworks of literary art and state-of-the-artAI,” says Hanson These authors definethe robot’s motives in doing things,their intentions, and their will
Hanson’s Character Engine pursues theobjectives of the robot’s will while itinteracts with the world
Zeno is a social robot So, it willrespond positively to socially positivepeople and back away from rude people “If a person is kind to therobot, for example, Zeno will seek tospend more time with them If a person is rude, on the other hand,Zeno will be cold and distant, and seekother people to interact with or will
play alone, ignoring that person.”
In order to tell the kind peoplefrom those who are rude, Zeno uses aunique data structure to rememberpeople; a data structure Hanson callsPeople Objects The People Objectscontain photos of people, their names,memories of interactions with thosepeople, facts about them, topics of discussion and how the robot “felt”when interacting with each person
“This way, the robot builds emotionalmemories which guide his interactionsand motives,” says Hanson
Zeno’s Unveiling
Hanson Robotics unveiled Zeno tothe public in September As a result, an
Associated Press article covering the
fantastic new robot appeared in morethan 200 newspapers with circulations
in the millions
Zeno has since appeared on GoodMorning America, which has five million viewers Zeno has also been onCNN and NBC and in the pages of PC Magazine and any number of other
publications Tens of thousands sawZeno at WIRED’s Nextfest — the WIRED
magazine technology fair Zeno’s estimated exposure as of this writing ismore than 45 million Americans,according to Hanson
Zeno has his own storyboard withother characters of Hanson’s design sohe’s ready to star in his own sci-fi filmproduction Plans for Zeno includemass production at a retail price under
$300 per unit SV
GEERHEAD
Zeno is a 100 percent artificial
telligence robot running from a PC “The
PC sends motor control signals wirelessly
to Zeno, and Zeno sends sensor data
including streaming video wirelessly to
the PC,” says Dr David Hanson The PC
processes the video data comprising
he faces of people around Zeno and
the audio data from people talking
around him.
Zeno can do everything that past
Hanson robots can do and more.
Previous efforts include the Philip K Dick
android — a technological portrait of the
famous author — which won the
American Association for Artificial
Intelligence first place award in 2005.
“Our current Character Engine is
much more powerful than the Philip K.
Dick android software or the software running our Jules, Joey, and Einstein robots,” says Dr Hanson.
Hanson’s robots are fully autonomous, interactive robots that relate in a human-like manner They make eye contact, recognize people, and hold conversations.
“When the $250 Zeno is available in
2009, it will perform most of these functions even without a PC, using an embedded version of our Character Engine With the wireless connection to the PC, though, it will be even smarter, and with the extended AI on our server bank, across the network, little Zeno will
be one of the smartest robots in the world, almost frighteningly smart,” Dr.
Trang 14Q. It is my understanding that
the HSR-8498HB servos that
are used in the RoboNova
humanoid robot have position
feed-back capabilities, so I bought a couple
of them from Tower Hobbies I have
been trying for several days now to
figure out how to get position data
from these servos From what I have
seen on the Internet, all I have to do is
send the servo a 50 μs pulse, and it will
return a position signal that is similar to
the regular pulse width to move the
servo I am missing something here,
can you help me?
— Pete Senganni
how position feedback for the
HSR-8498HB servo (see Figure 1)
can be measured by sending a 50
μs pulse and then measuring thepulse width of the signal that isreturned from the servo on the samesignal line Since this was on the samedata line, a pullup resistor was needed
on the signal line
At that time, I was planning
on talking about the HMI SerialCommunication Protocol and how
to interface it with a microcontroller
I had all sorts of problems trying toget this to work, which is probablywhy there is almost no information
to be found on the Internet on how
to do this So this month, I will talkabout the problems I had trying toget this to work, and to get all of the
HSR servos from Hitec (www.hitec rcd.com) to work with a computer and
be daisy-changed together; up to 128different servos can be controlled with
a single data line
Programming features includevelocity, start/stop, min/max positionlimits, center position, dead band, proportional and derivative gains, andforward/reverse direction control All
of these features are available throughthe Hitec Multi-protocol Interface(HMI) The HMI protocol allows the servos to be controlled with traditionalposition control using the 1 to 2 mspulse width, position feedback usingthe pulse width method, and via serialdata communications which will be
Tap into the sum of all human knowledge and get your questions answered here!
From software algorithms to material selection, Mr Roboto strives to meet you where you are — and what more would you expect from a complex service droid?
by Pete Miles
Our resident expert on all things robotic is merely an Email away
roboto@servomagazine.com
Figure 1 HSR-8498HB demonstrating
two reconfigurable housings.
Figure 2 HMI Servo Programmer user interface.
Trang 15discussed here.
These four servos
currently cannot be
pro-grammed with the HFP-10
digital servo programmer
that is used to program the
other digital servos from
Hitec These four servos
can only be programmed
via a PC computer or
a microcontroller The
software for programming
these servos is available for
downloading at the Hitec
Robotics website (www.
robonova.com).
Go to the downloads
section, and the software
subsection Download and
install the program
“HMI_Servo_Programer-V1.0.2.zip.” The current
version of the software at
the time of this writing was
V1.0.2 The version
num-ber may be different by the
time you download the
software, so the program title might be
a little different Figure 2 shows an
image of the software user interface
To connect the PC to the servo, a
special cable is needed Hitec is
planning on selling this cable within the
next few months, but you can build
your own Pressing the “Help” menu
item on the HMI Servo Programmer
window will show you a schematic
drawing for the interface cable I have
redrawn this schematic in Figure 3 and
added some details Note pins 7 and 8
are wired together
Here is where my problems began
Before writing code to get a
microcon-troller to control the servo, I needed to
know if I could control the servo with
the programmer The reason for this is
so that I could monitor the serial data
back and forth between the servo and
the computer to help me understand
how to control the servo
With this cable, I was never able to
get the software to control the servo I
then tried using a RS-232 to TTL
converter that was on the Parallax
Professional Development Board
(www.parallax.com), and I still
couldn’t get it to work For a long time,
I thought it was the servo firmware
version on my HSR-8498 servos Theones I had were version 1.08, and theprogrammer manual stated that itrequired firmware version 1.10
After a while, it occurred to methat these servos were designed to
receive true RS-232 logic levels (i.e., alogic level 1 occurs with a zero or negative input voltage, and a logic level
0 occurs with a high input positive voltage) The RS-232 to TTL voltageconverter that is used on the Parallax
+4.8 - 7.4 V (SERVO POWER)
1
SIGNAL POWER GROUND SERVO CONNECTOR
DATA CARRIER DETECT (DCD)
2 RECEIVE DATA (RD)
3 TRANSMIT DATA (TD) 5
4 SIGNAL GROUND (SG) DATA TERMINAL READY (DTR)
RING INDICATOR (RI) 9
8 7
6 REQUEST TO SEND (RTS) CLEAR TO SEND (CTS) DATA SET READY (DSR) PIN RS-232 FUNCTIONS
Figure 3 Serial interface cable for the HMI Servo Programmer.
HSR-8498HB HSR-5498SG HSR-5980SG HSR-5990TG Operating Voltage 4.8-7.4V 6.0-7.4V 6.0-7.4V 6.0-7.4V
Idle Current Draw (6.0 & 7.4V) 8 & 8 mA 8 & 10 mA 8 & 10 mA 8 & 10 mANo-load Current
Draw, running (6.0 & 7.4V) 200 & 240 mA 200 & 240 mA 300 & 380 mA 300 & 380 mAStall Current Draw
(6.0 & 7.4V) 1.20 & 1.48 A 1.20 & 1.48 A 4.20 & 5.20 A 4.20 & 5.20 APulse Range
(~180°) 600-2350 μs 600-2400 μs 1100-1900 μs 1100-1900 μsCentering Pulse 1500 μs 1500 μs 1500 μs 1500 μs
Dimensions 1.57” x 78” x 1.45”(40 x 20 x 37 mm) 1.57” x 78” x 1.45”(40 x 20 x 37 mm) 1.57” x 78” x 1.45”(40 x 20 x 37 mm) 1.57” x 78” x 1.45”(40 x 20 x 37 mm)Weight 1.92 oz (54.7 g) 2.10 oz (59.8 g) 2.46 oz (70.0 g) 2.39 oz (68.0 g)
Table 1 Hitec robotic servo specifications.
Trang 16Professional Development board uses
the MAX232E chip The MAX232E
actually inverts the signal, so that a
logic level 1 on the output will have a
+5V signal and logic level 0 will be
at 0V In essence, the servos were
receiving an inverted signal
When I inverted the signal with a
4011 NAND gate, the Servo
Programmer was now able to controland program the servo Figure 4 showsthe circuit that I was able to use tocommunicate with the servos using theHMI Servo Programmer
It took a long time to eventuallyfigure out why the original circuitshown in Figure 3 would not workwith my computer It turns out that it
was my USB to RS-232 adapter Thetechnical gurus at Hitec couldn’tunderstand why this wasn’t working
on my computer since they weresuccessfully using USB to RS-232adapters with their setups For somereason, my adapter would not work.With my adapter, the 3.3K resistorcaused the signal line to always be
DATA CARRIER DETECT (DCD)
5 4 SIGNAL GROUND (SG) DATA TERMINAL READY (DTR)
RING INDICATOR (RI) 9
8 7 6 REQUEST TO SEND (RTS) CLEAR TO SEND (CTS) DATA SET READY (DSR) PIN RS-232 FUNCTIONS
1 2 3 4 5 6 7
11
8 9 10 12 13 14
4011
+5 V
T1OUT R2OUT
R2IN T2OUT R1IN
T1IN
R1OUT T2IN
C2 V GND
SIGNAL GND 4.8-7.4V +4.8 - 7.4V SERVO POWER
HSR CLASS SERVO AND CABLE
SERVO
Figure 5 Wiring an HSR class servo to a microcontroller.
Trang 17at zero volts But if I replaced the
3.3K resistor with a simple wire (i.e.,
pins 2 and 3 on the DB-9 connector
are connected/shorted together), I
would get the proper signal and the
servo responded to the HMI Servo
Programmer
This little trick happens to work
with my computer and my old
generation USB adapter I would not
recommend that anyone do this
with a regular RS-232 signal since the
purpose of the resistor is to cut the
regular ±15V signals from a proper
RS-232 line down to a safe level
that will not damage the servo (i.e.,
current limiting) If the circuit in Figure
3 does not work with your computer,
then I would recommend you use
a circuit similar to the one shown
in Figure 4
At this point, you can use the HMI
Servo Programmer to test and program
the servo The first thing you do is
select the COM port your serial cable is
connected to, and press the Connect
button If the program connects to the
servo, you will get a message at the
bottom of the user interface “Connect
OK! - HMI Servo Motor Ver- 110.” The
110 means the servo has the 1.10
firmware version
It turns out that the programmer
will connect to servos that have the
older versions of the firmware, just not
all of the features will work with the
older servos
Once connected, select the servo
from the menu list, then press the
“Read Servo” button This will read all
of the parameters that are currently
stored in the servo Now you can
change the various parameters on
the servo based on what is available
on the HMI Servo Programmer
software, such as setting a servo ID
Now, this program does not read
in the current position, voltage, or
current draw from the servo, and
cannot set specific user selected
proportional/derivative gains, or set
the speed of the software
In the ZIP file that the HMI Servo
Programmer came from is a Visual
Basic example program that will show
you how to change velocity and read
position, voltage, and current The rest
of this discussion will be based on
using a microcontroller to control theservos via serial communications
Figure 5 shows a simple schematicfor connecting one of the HSR class ofservos as identified in Table 1, to a highspeed microcontroller The serial I/Oline is bi-directional, and the 4.7K resistor is required for this to work
The serial communication protocol isshown below Note that the communi-cation protocol uses two stop bits
19200 BaudTwo stop bits
No ParityThe serial communication proto-col transmits seven bytes of data Fivebytes are transmitted to the servo,and the servo transmits two bytes ofdata back to the microcontroller
Figure 6 illustrates the data stream
The header is one byte and always0x80 (128 decimal) The checksum isthe 256 minus the sum of the first four bytes of data transmitted tothe servo
The key to getting a troller to work with these servos isthe timing between the CHECKSUMbyte transmitted to the servo and thefirst RETURN1 byte received from theservo The servo will start transmittingthe data almost immediately afterthe last stop bit from the CHECKSUMbyte Thus, the microcontrollerneeds to be able to change the datasignal line state from an output to
microcon-an input microcon-and start looking for thestart bit of the RETURN1 byte Ifthe microcontroller takes too long tomake this change, the servo will eithernot return the two bytes of data ortiming will be off and the data will
be corrupted
When it is time for the servo totransmit the data to the microcon-troller, it may not transmit any data ifthe microcontroller hasn’t changed thesignal line to an input This is why ahigh speed microcontroller is needed
My testing has indicated that thefive bytes of data sent to the servocan be successfully transmitted usingonly one stop bit instead of the specified two stop bits with no timingproblem And receiving the two databytes from the servo using one stopbit also works since the microcon-troller will wait until it gets the firststart bit for each byte of data Theadvantage of sending and receivingthe data to and from the servo usingone stop bit instead of two stop bitswill give the microcontroller a smallamount of time to change the state ofthe signal line from an output to aninput And it gives the microcontrollersome time to start the serial inputprocess to receive the data At 19200baud, each data bit takes 52 ms totransmit Thus, the microcontrollerhas only 52 ms to transition fromtransmitting data to receiving data.Also, since the data line is connected
to a pullup resistor, the troller must pull the data line lowbefore the first byte of data is trans-mitted to the servo, and immediatelyafter the CHECKSUM byte of data istransmitted to the servo This needs
microcon-to be done so the start bits can
be properly distinguished from the normally pulled high signal line
I was not able to get any of the
BASIC Stamps (www.parallax.com)
or the Basic Atom28 (www.basic micro.com) to bi-directionally commu-
nicate with the servos I was able toget the SX28 microcontroller to workwith the servos when I used a 20 MHzresonator The 52 ms time limit toswitch from serial output to serial inputmay be the limiting factor for thechoice of microcontroller used withthese servos
Table 2 shows a list of the differentcommands that works with the HSRservos with firmware version 1.10 Forthe most part, the commands 0x(#ID),0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA,0xEB, 0xEF, and 0xF6 are the ones used
COMMAND PARAM1 PARAM2 CHECKSUM RETURN1 RETURN2 HEADER
CHECKSUM = (256 - (0x80 + COMMAND + PARAM1 + PARAM2) MOD 256)
Figure 6 Serial communication data package.
Trang 18to control the servos and obtain
feedback information
One of the first things that you
should do to test to see if you have
bi-directional serial communications
established with the servo is to read
the servo firmware and ID number
using command 0xE7 To do this, send
the following five bytes of data to the
servo: 0x80, 0xE7, 0x00, 0x00, 0x99
You should receive the following two
bytes of data back: 0x6E and 0x00 The
decimal equivalent of 0x6E is 110
which is firmware version 1.10 0x00 is
the default servo ID number Unless it
has been previously changed, it should
be zero
To command a servo to move to a
specific target position, the servo ID
number serves as the move command
The target position is in milliseconds,
much like the regular pulse width
commands Since the position range is
typically between 600 and 2,400 ms, it
is always greater than 256 ms, thus the
target position becomes a 16 bit word
This needs to be broken down into
two separate bytes of data to be
transmitted to the servo The following
two equations show how to break thetarget position down into the twobytes of data:
High_Byte = INT(Target_Position/256)Low_Byte = (Target_Position) MOD 256For example, to tell the servo tomove to the 1,500 ms neutral position,the following set of data is sent to theservo: 0x80, 0x00, 0x05, 0xDC, 0x9F
The 0x80 is the header, 0x00 is theservo ID number, 0x05 and 0xDC arethe high and low bytes of the 1,500 mstarget position, and the 0x9F is theChecksum Once this command is sent,the servo will immediately begin tomove to that position
To change the speed of the servo,the 0xE9 command is used The firstparameter sent to the servo is the servo
ID number, and the second parameter
is the speed The speed commandappears to be more like a percentagebetween 0 and 100% The servo’sspeed doesn’t get any faster for num-bers greater than 100 This commandwill also return the current position of
the servo Again, the position is brokendown into two bytes of data that can
be recombined into a single value withthe following formula:
Position = (High_Byte * 256) +
Low_ByteThe HSR servos can be daisy-chained together so that one serialdata communication line can be used
to control all of the servos connected
to that line If the servos are wired thisway, then the above two commands(setting the position, velocity, and position feedback) are the only commands that will address a specificservo, by its ID number The rest of thecommands address all of the servos atthe same time
Thus, if you want to address all ofthe features of the servos, they willneed to be individually wired to themicrocontroller This is true for servofirmware version 1.10 New firmwareversions may change this
Another command for setting theservo’s target position is 0xE6 If theservo’s motion has been stopped using
Command Param1 Param2 Return1 Return2 Description
ID (Servo ID number) Valid Range: 0x00 to 0x7F, Default: 0x00
Table 2 Servo command set.
Trang 19the 0xEB command, the target position
can be changed, and when the servo
has been re-enabled it will move to the
new target position Command 0xF6
will also do this
Command 0xE5 will read the
current position of the servo in a
similar manner as command 0xE9 The
difference here is that any servo’s
position can be read with the 0xE5
command and the 0xE9 command
reads the position of a specific servo
ID number
Command 0xE8 will read the
current draw and the voltage draw of a
servo The value ranges from 0 to 255
When the servo is unloaded and not
moving, the current draw value is
typically 0 and the voltage value is 127
When I try to force the servo horn to
move by hand, the current draw value
increases and the voltage value
decreases I don’t have any information
about correlating these values to
actual current draw and voltage draw
At the very least, this information can
be used to help determine optimal
reaction load performance and to
determine if the servos are being
overloaded
Command 0xEA can be used to
change the proportional and derivative
gains for the servo to make their
motion “softer” or “stiffer.” I have not
personally experimented with these
numbers, but I have heard that
changing them could make the servos
respond faster to sudden direction
changes, and it could help reduce
servo jitter under certain loaded
conditions
An interesting command is 0xEB,
the servo Stop/Start command When
the servo is commanded to stop
(Param2 = 0), the servo will stop
moving where it is The rotor will be
locked like it was commanded to move
to this position, and will not let you
forcibly change it What is interesting is
that once the servo is stopped, its
current position can be read, the
velocity can be changed, the current
draw can be read, and other
parameters can be changed
When the servo is restarted
(Param2 = 1), the servo will move
from where it is currently located to
its new commanded position This
command can be easily
demonstrat-ed when the servo velocity is set tonear zero, and commanding theservo to move from one extreme toanother Shortly after the servo hasstarted to move, you command theservo to stop, then change the endposition or servo speed, then restartthe servo, and you will notice that itwill move to the new position at thenew velocity
The last motion command is 0xEF
This command will stop all motion control of the servo Unlike the 0xEBcommand which locks the servo position, the 0xEF command will allowthe servo to be moved by hand Servopositions can still be read after the execution of this command This feature enables the ability to manuallymove servos to specific positions, andthen records these locations so thatthey can be played back later This is
a feature that will simplify the programming efforts for animatronicand walking robot routines
In addition to the basic motioncommands described previously, theservos can be reprogrammed with amicrocontroller The key is to knowwhich memory locations contain whichparameter This is where the 0xE1,0xE2, 0xE3, and 0xE4 commands come
in handy These commands can beused to read and write to differentmemory and EEPROM locations
Unfortunately, the memory locations/addresses and their functions are not published But hasthis ever stopped anyone from gettingthe information they wanted? With
the help of a serial port monitor (I like
to use the Free Serial Port Monitor
program from monitor.com) and the HMI Servo
www.serial-port-Programmer, I was able to determineseveral of the EEPROM addresses forseveral different parameters Withthese two software packages, I canmonitor the data transmitted to andfrom the servo, determine whichmemory locations/addresses arechanged, and how they are changedwhen I change a parameter in the HMIServo Programmer software package.For example, I was able to determine that the servo ID is stored atthe EEPROM address 0x29 This can beread using the 0xE1 command, and anew value can be used to change the
ID number using the 0xE2 command
By making a set of systematic changes
in the HMI Servo Programmer, I wasable to determine that every singlechange to the EEPROM also changedthe EEPROM address of 0x2C
The value at 0x2C always seems tochange by the same numerical value as
I changed the other values This gives
an indication that this memory location
is some sort of a Checksum The best Ican tell from monitoring the data usingthe servo reset function (covered next)
is that the checksum is computed usingthe same method for individual com-mand packets Thus, the checksum isequal to 256 minus the mod 256 of thesum of all of the bytes written to EEPROM addresses from 0x00 to 0x2B (Param2 using the 0xE2 command or read by Return1 using the0xE1 command)
Header Command Param1 Param2 Checksum Return1 Return2
tmp = 0x0A - 0x00 = 0x0A (tmp = 10 - 0 = 10) checksum = 0xB3 - tmp = 0xB3 - 0x0A = 0xA3 (checksum = 179 - 10 = 169)
Trang 20To make a change to an individual
parameter, read both of the values
stored at the checksum and the
parameter EEPROM locations
Calculate the difference between the
new parameter value minus the old
parameter value, then subtract this
value from the checksum value Write
these two new values to the EEPROM
Remember, if the checksum value
becomes negative, it needs to roll over
to 255 again
For example, if I wanted to change
the Servo ID from its default value of
0x00 to 0x0A (10 decimal), then I can
write a program to read the two
EEPROM locations as shown here using
the 0xE1 command (Note the values
shown are from the HSR-5980SG
servo) Then I make the overall
checksum change calculation, also
shown in Table 3
These two new values are then
programmed back to the same
EEPROM addresses using the 0xE2
command as shown Remember,
the checksum value calculated above
is the overall EEPROM checksumvalue, which is sent as Param2, and isnot the same checksum value that iscomputed for each command packetsent to the servo as described earlier(see Table 4)
In order for these parameterchanges to take effect, the servo must
be powered down and restarted Ifthere was an error in calculating thechecksum, the servo will still work butthe motor will be disabled until theproblem is corrected
If for some reason the servo stopsfunctioning properly due to program-ming problems, the HMI ServoProgrammer software has a servo resetfeature that will reset the servo back tothe factory defaults All you need to do
is start the program, select the servotype, and select “Servo Reset” underthe File menu item Then press the Yesbutton, and the servo will be reset back
to its original condition
At this point, you should have allthe information needed to controlthese servos using serial communica-
tions By monitoring the data beingtransmitted between the servo and thecomputer (using a program like theFree-Serial-Port-Monitor), the specificparameters and their functions can bedetermined This information can then
be modified to change your servo performance characteristics
At some point, someone will takethe time and, using the steps present-
ed here, compile a complete list of all
of the parameters and their functionsfor the different HSR servos and publish them to make our lives easier
At 19200 baud, it will take about 4
ms of time to send the seven byte datapackage This takes about twice aslong to command a servo than usingthe traditional pulse width method Butthe command only needs to be sentonce, the 20 ms servo update is nolonger needed, velocity is now a control parameter, and with the feedback information from the servos,true closed loop positional and velocitycontrol of these servos can easily
3DLQH6WUHHW_3RZD\_&DOLIRUQLD___ZZZKLWHFUFGFRP
>_j[Y Ej^[h8hWdZ
.EW
+656*
6SHHGVHF 7RUTXHR]LQ 6WHHO*HDUV
+656*
6SHHGVHF 7RUTXHR]LQ 6WHHO*HDUV
+657*
6SHHGVHF 7RUTXHR]LQ 7LWDQLXP
$//63(&,),&$7,216$792/76
Trang 21Know of any robot competitions I’ve missed? Is your
local school or robot group planning a contest? Send an
email to steve@ncc.com and tell me about it Be sure to
include the date and location of your contest If you have a
website with contest info, send along the URL as well, so we
can tell everyone else about it
For last-minute updates and changes, you can always
find the most recent version of the Robot Competition FAQ
at Robots.net: http://robots.net/rcfaq.html
— R Steven Rainwater
8-10 Singapore Robotic Games
Singapore Science Center, Republic of Singapore
A plethora of events including Micromouse,autonomous Sumo, RC Sumo, robot soccer, wallclimbing, pole balancing, underwater robots,legged robot marathon, legged robot obstaclerace, and a robot colony contest
http://guppy.mpe.nus.edu/sg/srg25-27 TechFest
Indian Institute of Technology, Bombay, India
Lots of events for autonomous and remote controlled robots including standard Micromouseand several events unique to TechFest: Pixel, acontest for vision-equipped bipeds; Full Throttle:
Grand Prix, remote-controlled, internal combustionpowered cars race on a concrete track; Vertigo, aremote-controlled robot and an autonomousrobot must work together to move blocks around;
Prison Break, remote-controlled robot mustclimb out of a pit and survive a fall to escaperobot-jail; U-571, an obstacle avoidance contestfor underwater robots
http://techfest.org/competitions/department
24-28 APEC Micromouse Contest
Austin Convention Center, Austin, TX
Amazingly fast little autonomous robot crittersrace to solve a maze in this competition If
you’ve never seen one of these events, go seethis one You won’t believe how fast thesethings are
www.apec-conf.org
15-16 Manitoba Robot Games
Tec Voc High School, Winnipeg, Manitoba, Canada
Included in this competition are a mix of eventsfor autonomous and remote-controlled robotsincluding Japanese style mini-Sumo, Western styleSumo, a robot Mini-Tractor Pull, Super Scramble,line following, and the Robo-Critters contestfor kids
www.scmb.mb.ca
Send updates, new listings, corrections, complaints, and suggestions to: steve@ncc.com or FAX 972-404-0269
Trang 22EZPZ23-HR1 Piezo Motor Servo
The fully intelligent controllers,
measure just 2.25 “ x 2.25“ The Nanomotion HR1 motor,
nine pin DSUB connector plugs directly into the controller
A single four wire bus, containing two power wires and
two communications wires, links up to 16 such piezo
motor controllers in a daisy chain Commands can be
issued from any serial terminal program (such as
HyperTerminal) or from the EZ Servo/Stepper Windows
application
The commands are intuitive and simple For example,
the command A10000 will move the servo motor to the
absolute position 10000 (This communications protocol
is compatible with devices that use the Cavro DT or
OEM protocol.)
The EZ Servo is also capable of stand-alone operation
with no connection to a PC It can be set to execute a
preset string of commands upon power-up (i.e., only
power is required in this mode) The commands include
nested loops and execution halt pending a switch closure,
which is useful in stand-alone applications
Using AllMotion Starter Kits, a first-time user is able to
make the HR1 piezo motor servo in less than half an hour
• RS-232, RS-485, or USB based communications
• Four quadrant operation
• On-board EEPROM for user program storage
• Stand-alone operation with no connection to a PC
• Execution Halt/Branch pending switch closure
• Pre-wired for OptoSwitch inputs
• Position velocity and torque modes
• Industry standard communications protocol
• Homes to an opto or encoder index with a single command
• Fully programmable ramps and speeds
• Quadrature encoder based feedback for position mode
• Velocity mode possible with only Hall sensors forfeedback
• Switch selectable device address
• Software selectable max currents
• 4 MHz max encoder frequency
• Two one amp on/off drivers included
• Optional step and direction mode; 4 MHz step frequency
• Four ADC inputs; Halt/Branch on ADC value
For further information, please contact:
TReX Jr Dual-Motor Controller
Pololu introducesits new TReX JrDual-Motor Controller, aversatile DC motor controllersuited for mixed autonomous andradio control of small- and medium-sized robots Three independent interfaces are offered:radio control (RC) servo pulse interface, analog voltage,and asynchronous serial The serial interface can switchinstantly with one of the other two interfaces, allowingmixed autonomous and remote control For example, arobot could be configured to run autonomously most ofthe time, but a human operator could override theautonomous function if the robot gets stuck or into a dangerous situation If the serial mode is selected as theprimary interface, high-resolution measurements of all five
RC inputs are made available to the autonomous robotcontroller, allowing for complex and unlimited mixing ofoperator control and sensor input
The TReX Jr motor controller operates from 5 to 24 V,and the two primary outputs provide bi-directional controlwith peak currents of 5 A and continuous currents of 2.5
A while a unidirectional auxiliary output delivers over 10 A(continuous) A fourth control channel for invertible robotsallows improved control if the robot does get turnedupside-down, and the fifth control channel determineswhich interface controls the motors The unit measuresapproximately 1.75” x 1.75” x 0.5”, and it is available fullyassembled or in kit form
New Products
MOTOR CONTROLLER
510•471•4000 Fax: 510•471•4003 Email: info@allmotion.com Website: www.allmotion.com
AllMotion
Trang 23For further information, please
contact:
Advanced Features
for Robot Remote
Control
InRob Ltd a leader in advanced
wireless control systems for
unmanned ground vehicles (UGV),
has announced advanced and
innovative features for its remote
control units for military robots
and UGVs
These features include:
• Secure, clear, and uninterrupted
wireless transmissions in most
operating environments
• Intuitive touch screen for more
efficient operations in the field
• Graphic screen display showing
critical data of the robot, including
fuel level, engine RPM, status of
tools in action, such as cameras, etc
• Networking technology with
option for a single operator to
simultaneously control and
coordi-nate multiple robots
• Advanced safety features for
weapon platforms This feature
is particularly important for
law enforcement and Homeland
Security use, where the robots may
be used near crowds
For further information, please
contact:
REMOTE CONTROL
6000 S Eastern Ave.
Suite 12-D Las Vegas, NV 89119 Tel: 877•7•POLOLU
or 702•262•6648 Fax: 702•262•6894 Email:
www@pololu.com Website:
PP:KLWH ZDWHUFOHDU
/('9
PFG $%
7KH9HOOHPDQ3HUVRQDO6FRSH
LVQRWDJUDSKLFDOPXOWLPHWHU EXWDFRPSOHWHSRUWDEOH RVFLOORVFRSHDWWKHVL]HDQG FRVWRIDJRRGPXOWLPHWHU +36
7KHURERWIURJPRYHVIRUZDUG ZKHQLWGHWHFWVVRXQGDQG UHSHDWV VWDUWPRYHIRUZDUG ! VWRS!OHIWWXUQ!VWRS!ULJKW WXUQ!VWRS 65
6ROGHULQJ
UHTXLUHG
7KRXVDQGV PRUHLWHPVRQ RXUZHEVLWH
$146.
Ask for our FREE 96 page catalog
VISIT OUR ONLINE STORE AT
www.allelectronics.com
WALL TRANSFORMERS, ALARMS, FUSES, CABLE TIES, RELAYS, OPTO ELECTRONICS, KNOBS, VIDEO ACCESSORIES, SIRENS, SOLDER ACCESSORIES, MOTORS, DIODES, HEAT SINKS, CAPACITORS, CHOKES, TOOLS, FASTENERS, TERMINAL STRIPS, CRIMP CONNECTORS, L.E.D.S., DISPLAYS, FANS, BREAD- BOARDS, RESISTORS, SOLAR CELLS, BUZZERS, BATTERIES, MAGNETS, CAMERAS, DC-DC CONVERTERS, HEADPHONES, LAMPS, PANEL METERS, SWITCHES, SPEAKERS, PELTIER DEVICES, and much more
Trang 24Featured This Month:
Technical Knowledge
by James Baker
Feature
for a Sponsor? by Chad New
Product Review
Power V2 E-Logger and
Power Panel LCD Display
by Don Hebert
ROBOT PROFILE – Top
Ranked Robot This Month:
29 G.I.R. by Kevin Berry
Events
Many people think that theopposite of a robot with akinetic energy spinner is anarmored push-bot I disagree The
KE spinner puts energy into arotating mass as it spins up over aperiod of time Once the energy isthere, delivering it is a very crudeaffair Our friend Isaac Newtontells us that when this spinningweapon hits the opponent, theopponent hits back with equaland opposite force The classic
“immovable object” push-botmeeting our “unstoppable force”
spinner, thus delivers equal energy
to both machines
Once impact occurs, it isout of the driver’s control as toexactly where on the opponentthe energy goes, and how muchenergy is used up In my opinion,this makes spinners and armoredbots the same Neither can besure of where impact occurs,neither decides how much energy
is imparted, and both suffer thesame violent, chaotic energytransfer
An opposite to this would be
a robot that can choose where onthe opponent it attacks, and cancontrol the amount of energy ittransfers to that chosen area over a period of time selected bythe driver This perfectly describesthe crusher
TECHNICAL
KN WLEDGE
● by James Baker
Crushers
Trang 25usable range of motion
within the weight limit; 100
tons over one inch is easily
possible, but that is of no
use in combat In all weight
classes, it is the robot
chassis that sets the limits
for crushers
Return of the
Crusher
The UK has a long love affair
with crushers We have had many
heavyweight machines successfully
use crushing weapons The
feather-weight class however, rarely saw
the type, as effective crushing
weapons are heavy Circumstances
in the UK at the moment are such
that high kinetic energy spinners
have very few opportunities to
fight Combined with the extra 1.6
kg now allowed in the featherweight
class, it has opened the floodgates
for robots that could never afford
weight for crushing weapons to
make their entrance There are
several crushers being built right
now, and Dragons Claw is the first
of many
Dragons Claw
Tony Booth, a good friend of
mine, decided to build a high power
crusher after winning an eBay
auction for a Linak LA34 linear
actuator This particular item can
deliver a reliable 10,000 newtons
of force at 24 volts, so it’s perfect
for featherweight combat robots
Tony did the right thing
when designing an unfamiliar type
of robot He asked
everyone he could for
advice, listened to the
advice, and used that
advice when designing
the robot It’s amazing
how many people
refuse to do this
Based on a welded
aluminium chassis,
Tony never
underesti-mated the forces
involved in crushing your opponent
He conducted many tests with atemporary chassis and claw,before deciding on the currentconfiguration
Supplying the actuator withthe (quite modest) current itneeds are two packs of 12V NiMHbatteries (in series giving 24V),through a simple servo-operatedDPDT switch and failsafe Thesebatteries also supply the RobotPower Scorpion XL speed controllerwhich, in turn, runs the 18V drillmotor based drive system
This mix of components isproving to be very effective Therobot is fast, turns quickly, and(more importantly) rotates aroundits weapon due to having the driveright at the front The electron-ics are small, light, and overspecification for their currentuse Dragons Claw has beentested and proven itself to be avery effective combat robot Ithas successfully pierced 10
mm plastics, 2 mm titanium,and 6 mm aluminium, to name but a few examples
In fun events, it has provenitself capable of catching its
opponent and bringing the weapondown to pin or crush (Catching theopponent was initially a concern asthe actuator has a speed of just 5
mm per second.)Dragons Claw is able to controlits opponent once it captures them
A light squeeze holds the opponent
in place so it can be taken to arenahazards or for other robots to attack.Increasing the power to crush theopponent puts a full 1,000 kg intothe Hardox claw, and onto the targetrobot through an interchangeabletitanium tip In testing this process,Tony bent the 10 mm steel pivotpins, so they are now 0.5 inchtitanium
So, the robot is ready then? Not quite
CAD of Dragons Claw.
CAD of claw mechanism.
Dragons Claw’s frame.
Prototype claw.
Making weight equals drilling holes.
Trang 26So you think that you are
ready to get some sponsors,
do you? Have you typed out
your letter and arranged some
nice pictures thinking that you
are ready to rake in the sponsors?
Think again; getting a sponsor,
keeping a sponsor, and mostimportantly making that sponsorhappy with you is much moreinvolved than an email and a fewnice shots!
In this article, I will giveyou some basic guidelines which
may help increase your chances forsuccessfully getting yourself asponsor This will hopefully helpoffset the cost of this sport andalso give you equipment that may
be able to take your robots to thenext level
The cheapest option is to drill holes, which is what Tony did A fullkilogram (2.2 lb.) was lost by takingaluminium away, but you have to becareful not to weaken the chassis somuch that it cannot handle those bignumbers when you hit the “squashhim” button
Thankfully at the same time Tony was drilling holes, the UK robot
combat governing body (theFighting Robot Association)was changing the rules Theextra 1.6 kg now allowed,combined with the manyholes drilled, meant DragonsClaw was now underweight,and ready for its titaniumarmor This was bolted inplace to nylon pillars, allowingflex and deformation A beautiful paint job later andDragons Claw was ready to enter itsfirst competition I have foughtagainst this robot with my fun-bots, and as you can see in thephotos, Dragons Claw is a seriouslycompetitive machine
Robots are never finished Theywill evolve and change to suit theenvironment and their predators orprey This assisted evolution meansthat Dragons Claw may well havechanged again by the time you readthis article, so you can get updatesand further information about it on
Tony Booth’s website at www.team dragon.org.uk SV
SO YOU THINK YOU’RE READY FOR A SP NSOR?
● by Chad New
Weapon control.
Lifting works, too.
Paint matters!
Leverage also matters.
Finished Dragons Claw Crushing the opponent.
Trang 27The When
As a newbie robot builder, you
have a very low chance at landing
himself a sponsor You are unproven,
your name is not known, and chances
are that your robots are not yet up to
par with your competition It is not an
impossible task, however, your
chances are much greater once you
gain some experience The
appropri-ate time to seek sponsorship is when
you can prove that you know what
you are doing Can you build a robot?
Talk about it; tell a person what all the
parts are, what they do, and how
they are going to work better next
time Have you been to several events
and come home with a robot that you
can still drive, or better yet, a win?
If you can answer “yes” to these
questions, then you might be able to
realistically consider getting yourself a
sponsor You have built up some
cred-ibility that you must now project to
the companies which you would like
to attempt to gain sponsorship from
The Why
Why would anybody sponsor
you? Companies will sponsor who is
willing to work for them They are
not going to shower you with parts
and money for free, no matter how
good your emails are Companies
need testers, feedback, good
com-munication, pictures, and marketing
tools What they need is a person
committed to help sell their product
When a new product comes out,
they need people that know whatthey are doing to test it and givethem feedback, telling them how itcan be made better and the weakpoints of the item When setting up
a booth, they need robots to displayand pictures for their website
Combat robots are great for ing! If Product X can take the abusefrom a combat robot, then inside anR/C car it should last forever! If youmake it clear that you are willing towork for your sponsorship and arenot just looking to be handed some-thing, then you have a chance
market-The How
It all starts with one email or aphone call First impressions are themost important, so you better make it
a good one If you are going to call,have a list of facts ready to talk about;
list the points that you want to makeand most importantly how you canhelp them If you choose to send anemail, make it short and to the point
You do not want the reader to loseinterest and shoot your mail to thetrash bin Again, list the points thatyou really want to emphasize andwhat you have accomplished Youmay also include some pictures ofyour robots However, do not attach avideo because that may take a longtime to download Also, don’t forget
to list what you can do for them!
Ready?
Take all of these tips and
combine them into one great email
or phone call If you are able to scoresome free parts, make sure you putthem to good use! Do not take themand run Give your sponsors updates,feedback, and check to see if theyneed your help with anything With alittle effort and some luck, you toocan have parts for the cost of a littlecomputer work! SV
Iwas always very thorough about
monitoring current draw and amp
hours in my robots Current and
voltage tests can determine the
compatibility of a motor/batterycombination Studying the results led
me to my favorite voltage/amphour/motor combination
At first, an AstroFlight wattmeter would go for a ride, secured
on top of the robot Reading the display while the robot was moving
Quick Tips
1) DO use spell check! You don’twant to sound incompetent
2) Don’t say: “Hi, I would like to build
a robot Please give me parts.”
3) DO follow-up on your emails andcalls Just a simple “hey, just checking
to see if you got my message” works fine
4) Don’t send long random emailsthat have no point
5) DO be polite, even if the answer is
no Next time they need a tester, theymight email you!
6) Don’t be a pest! Do not send people dozens of emails That is anassured no!
7) DO be patient Just because youdon’t get an immediate responsedoesn’t mean the answer is no
8) Don’t give up Work harder at it! Build better robots, take better pictures, and refine your sponsor-ship pitch
PR DUCT REVIEW
Eagle Tree Systems Micro Power V2 E-Logger and
Power Panel LCD Display
● by Don Hebert
Trang 28was difficult It would move too fast,
so most of my measurements were
done with the wheels up or against a
wall, wheels spinning Wheels-up
testing detected gearbox problems
effectively Bad mechanical
conditions showed higher that
normal amps
This worked okay for most of myneeds But as my lifter got more
powerful, I found the need for faster
measurement Some events, like the
1/2 second of the lift, were not
visible in the display of the watt
meter A data collection device with
sufficient samples per second was
needed The Micro data logger from
Eagle Tree Systems fit the bill
The Micro Power E-Logger from
Eagle Tree Systems (www.eagle
treesystems.com) can measure
±100 amps and 4.5–45 volts It
calculates amp hours and watts All
this is recorded in memory forlater retrieval Sampling rate is
10 per second Data retrieval isvia a supplied USB cable The
PC software is also provided(see Figures 1 and 2)
Real-time amps, volts, watts, andamp hours can be displayed with theoptional Power Panel LCD Think of it
as a dashboard for the robot (seeFigure 3)
The entire combination is halfthe size of the Astro watt meter Figure 4 shows installation in
a 12 lb robot
Preliminary setup prior to firstuse is required The data logger hasmany add-on devices What isinstalled — like the LCD display —must be declared for them to work
For my tests, the LCD was the onlyextra device The current and voltagedetectors on the data logger arealways available
The instructions for what data tocollect is also required I displayedvolts, current, amp hours, andwattage Volts and amps are directfrom the on-board sensors Wattage
is calculated from volts and amps
Amp hours are calculatedfrom amps and time
With the LCD panel,you may conduct realtime monitoring such as awheels-up test You donot have to retrieve thecollected data If thebuffer gets full data, collection simply stops
The real-time display ofdisplayed volts, current,amp hours, and wattagewill continue (Just this is
pretty cool.) The unit is small and willfit anywhere I usually use maskingtape to hold everything in place
A new recording session is
start-ed each time the logger is turnstart-ed on.Plug it in to the battery circuit afterthe power switch I find it helpful toscript the sequence of events ahead
of time Once the data is extracted,current draw will be your only indica-tion to tie the section of the trace tothe test event A wheels-up test atfull power may be indistinguishablefrom full speed reversals on theground or from wheel spin againstthe wall So noting which test wasdone first allows you to link the firstpeak in current draw with that test.After the tests are done, turn offthe power Remove the data loggerfrom the robot and bring it to your computer Start the software.Connect to your PC with the providedUSB cable The connection will power-
up the data logger and connectionwill be established We now have toexplicitly request data from the device.Until the memory is full, you mayplug the logger again and again tocollect more data Each power-on iseasily distinguished as a new session
in the graph For example, I couldsave five separate test sessions in thedata logger before I had to clear dataand start over I saved the data to thesame file name and each time I didanother test, all of the data from theprevious test was still in there Noproblem! The saved file just got larg-
er each time I saved to the hard drive(see the sample graph in Figure 5)
I encountered one problem afterclearing data memory and running afew more data collections I retrieved
FIGURE 1 Micro Power Data Logger.
FIGURE 3 Power panel.
FIGURE 4 Installation
in a robot This is small!
FIGURE 2 Main screen.
Trang 29the data and saved it to the
previous-ly named file I expected a
concate-nation of the data already saved and
the new data just retrieved But the
new data completely overwrote all of
the previous data; the original data
was gone This was a mistake on my
part, I now know better But there
are no warnings that you are about
to overwrite data
There is a live mode that uses
the main screen of the PC as a
real-time display There are also
additional sensor modules to monitor
RPM and temperature
In conclusion, I heartily endorse
this product The MicroPower V2
E-Logger retails for $69.95, and the
Power Panel LCD Display for $39.95
It records data accurately and meets
my needs Even if you do not use the
data collection, it is still a handy little display SV
ROBOT PR FILE
● by Kevin Berry
FIGURE 5 Graph screen.
Contact the Author
Don can be reached via email at
dhebert562@charter.net
TOP RANKED ROBOT THIS MONTH
Historical Ranking: #1 Weight Class: 6 lb "Mantis"
Team: Chaos Robotics Builder: Dirk Stonehouse Location: Saskatoon, Saskatchewan, Canada
BotRank Data Total Fights Wins Losses
Trang 30G.I.R has competed in WBX II,WBX III, WBX IV, Kilobots IX,
Kilobots X, and Kilobots XI More
details are listed below:
• Frame: 1-1/2” x 3/4” aluminum
channel, milled to reduce weight
and welded
• Base plate: 1/16” Garolight
• Drive train: Four B62 gearhead
motors
• Voltage: 14.8
• Wheels: 2 inch 1/10 scale pan car
foam tires
• Configuration: Invertible box with
thresher and hinged titanium wedge
• Drive ESC: Two Traxxas EVX
• Drive batteries: Two 2.1 Ah, 7.4V Thunder Power lithium packs
• Weapon: 1-3/4” inch drum thresherwith six two-tooth blades driven atthe center with a dual “O” ring beltconfiguration
• Weapon battery: One 2.1 Ah, 7.4V Thunder Power lithium pack
• Weapon motor: 27 turn stock 540
• Weapon ESC: Tekin Titan
• Armor: Titanium in the front
• Future plans: Upgrade from the 540 weapon motor to a Hacker A30-10XL
Design Philosophy
“I designed G.I.R to be a powerful pusher with the ability to withstand shell and bar spinners Also, to inflict some damage with the drum and be invertible So far, it has proven to be a fairly good design
to be ranked #1.” SV
Photo and information are courtesy of Dirk Stonehouse All fight statistics are
courtesy of BotRank (www.botrank.com)
as of November 13, 2007 Event attendance data is courtesy of The Builder’s
Database (www.buildersdb.com) as of
November 13, 2007.
Results from Oct 14
through Nov 11, 2007
2007 Halloween Robot Terror was
presented by California Insect
Bots in Gilroy, CA on 10/27/2007
Go to www.calbugs.com for more
information Results are as follows:
● 150 Gram Flea Weights — 1st:
“Crisp,” Team Misfit, driven by Orion
Beach; 2nd: “Atom Bomb,” Team
Misfit, driven by Daniel Chatterton
● 1 Pound Ant Weights — 1st:
“Baron Underbheit,” Team Misfit,
driven by Kevin French; 2nd:
“Pooky,” Team ICE, driven by David
Liaw; 3rd: “Mash Potato,” Team ICE,
driven by Pui Shan Wong
● 3 Pound Beetle Weights — 1st:
“Unknown Avenger,” Team ICE, driven by David Liaw; 2nd: “Impact,”
Team Target Practice, driven by DonHebert; 3rd: “Queen of Kings,” TeamMisfit, driven by Shannon Muha
Franklin Institute Robot Conflictwas presented by North EastRobotics Club, Inc., in Philadelphia,
PA on 10/20/2007 Go to www.
nerc.us for more information
Results are as follows:
Bob,” Robotic Hobbies; 2nd:
“TriPolar,” Team Brain Damage; 3rd:
“The Interloper,” Team Interloper
● Sportsmans (30 lb) — 1st: “Bounty
Hunter,” Team Hammertime; 2nd:
“Upheaval,” Team Mad Scientist;3rd: “Mangi,” Team HFA
HORD Fall 2007 was presented bythe Ohio
Robot Club inBrecksville, OH
on 11/3/2007
Results are asfollows:
● Flea Weights — 1st: “Little Buzz,”
Richard Kelley, Team Kelley; 2nd:
“0–2,” Even Gandola, Team Probotics
● Ants — 1st: “Dusty, the Evil Dust
EVENTS
Results and Upcoming Events
Trang 31Pan,” Jeff Gier, Team Mechanical
Advantage; 2nd: “Heman I,” Evan
Gandola, Team Probotics; 3rd:
“Rumble,” Heman I, Evan Gandola,
Team Probotics
● Beetles — 1st: “D2,” David Timothy,
Team D2; 2nd: “The Box,” Richard
Kelley, Team Kelley; 3rd: “Rumble,”
Sweaver, Greg Shay, Team Fishneck
Robots Live presented a show in
London for the MCM Expo,
10/20-21/2007 Go to www.robots
live.co.uk for more information.
presented by Chicago Robotic
Combat Association in Rosemont, IL
on 10/19-21/2007 Go to www.the
crca.org for more information.
Robowars Metro was presented
by RoboWars in Oakleigh, South
Victoria, Australia on 11/06/07 Go
to http://robowars.org for more
information
Upcoming Events for
January and February
2008
2008 will be presented by
Western AlliedRobotics inSeattle, WA on2/9/2008 Go to
www.western alliedrobotics.
com for more information.
The event will be held at theMonroe County Fairgrounds (near
expo.com/Directions.html) The
event will be held from 6:00pm and safety inspection from9:00am-11:00am If a lot of robotsregister, they may start safety andfights earlier Class: 1, 3, 12, and 30*
11:30am-pound robots (30 lb weapons not allowed) Format:
spinning-Double Elimination or Round Robin(RFL Rules), no ICE or open flames
Entry Fee: $40 for first 30 lb or 12 lbrobot $25 for first 3 lb or 1 lb robot
Additional robots are half price
Special entry fee considerations forbuilders who are under 18 Arena:
12 x 12 with 18” x 18” pit in one corner surrounded by a 2” high wall making it very difficult to accidentally drive into it
Motorama 2008 will be
present-ed by North East RoboticsClub, Inc., in Harrisburg, PA, from
2/15-17/2008 Go to www.nerc.us
for more information
This will be a 150 g to 30 lb combat event Fairies and Ants fight
in 8’ box on Friday; Beetles throughFeatherweights fight in 16 x 16 box
on Saturday and Sunday All
complet-ed forms and entry fees must bereceived by 1/2/07 This is going to
be another awesome event at theFarm Show Complex!
Robots Live will present an event
at the Hermitage Leisure Centre,Whitwick, Leicestershire on 2/2-
3/2008 Go to www.robotslive co.uk for more information.
For the first event of the year,Robots Live heads back to their hometown of Whitwick in Leicestershire.Not only is this their hometown but also their birthday! Come andcelebrate two years of Robots Live!
Robowars has tentatively uled their national title event inOakleigh, South Victoria, Australia
sched-on 1/12-13/2008 Go to http://rob owars.org for more information SV
Tormach PCNC 1100 Features:
Q Table size 34" x 9.5"
Q R8 Spindle 1.5 hp variable speed to 4500 RPM Q Computer controlled spindle speed and direction Q Precision ground ballscrews
QDigitizing and tool sensing support
Q4th axis and high speed spindle options
3 Axis Mill
$6800
plus shipping
When you’re serious about hardware, you need serious tools
Whether milling 0.020” traces on prototype PCBs or cutting ½”
steel battle armor, this CNC mill can do it all Weighing in at more than 1100 lbs, the PCNC can deliver the hardware end of your combined hardware & software projects.
Precision CNC Machining
Mill includes Control, CAD and CAM software Optional stand, coolant system, computer and accessories are extra
Product information and online ordering at www.tormach.com
Trang 32Because I get to put together all
kinds of neat stuff And, when
I’m done playing with my new
garage-brewed toys, I get to show
them to you and tell you all about
them So, get your soldering irons
hot and stuff your face into that
illumi-nated desktop magnifier We are going
to build an intelligent stepper motor
controller from scratch that is based on
the Allegro MicroSystems A3979
So What??
YIPEE Another stepper controller
NOT! This stepper controller is compact
and when properly heatsinked, handles
two ampere motor loads The Allegro
A3979 is an upgraded version of the
venerable A3977 All of the easy to use
motor control knobs and dials youwere used to on the A3977 are alsopresent on the A3979 DMOS driver
We can even use the same externalcomponents in an A3979 design that
we would use in an A3977 design Thebig difference in the two DMOS drivers
is the addition of 16th stepping capability to the A3979 If you thinkyou’re about to read about a rehashedversion of the A3977 circuits you canget from various Internet points, sitdown, shut up, and read on
Getting Small
If you have ever worked with theA3977, you probably used the 44-pinPLCC version of the part The PLCC is bigand relatively easy to put down on a
printed circuit board (PCB) You can’tget the A3979 in a 44-pin PLCC package; it only comes in a 28-pinTSSOP package Instead of dissipatingheat though pins as the PLCC-packagedA3977 does, the A3979 has an exposedheatsink pad on its belly A woodpeckerwould see that pad on the underside ofthe A3979 in the perspective of Photo 1.The A3979 can be crammed into
a very tiny space if you’re not driving stepper motors the size ofwatermelons The only design pointthat increases the size of the A3979
by Fred Eady
The Super
STEPPER DRIVER
PHOTO 1 Don’t think that you can’t access this
heatsink pad without special soldering equipment.
A few holes in the printed circuit board under the
belly of the A3979 provides access.
PHOTO 2 This was a challenging build as I had to be extra careful not to short the SMT 0805 components on the ground plane extensions under some of the SMT parts A fine tipped soldering iron and an illuminated magnifier are must-have tools for this project.
Trang 33PCB is heatsinking Thus, as you can see in Photo 2,
I’ve gone all out on the heatsinking of the A3979 by
laying out a ground/heatsink plane onto the entire
top side of the A3979 stepper driver PCB
To keep things simple, I also spread out all of the
A3979’s supporting components in my design If you
trash the serial port and squeeze the PIC18F2620 in
towards the A3979, you can push this stepper
driver/controller into a very small form factor
Let’s Get Started
The very first thing we must do is design and lay
out a suitable PCB to support the A3979 and its
subor-dinate components I want you to be able to build this
stepper controller in your shop I used ExpressPCB and
their tool suite for the PCB fabrication To make
parts-gathering easier for you, I’ve sourced all of the A3979
motor driver board’s components from Mouser and
Digi-Key The A3979 motor driver board ExpressPCB layout
sans ground plane can be seen in Screenshot 1
In that the A3979 has a built-in translator, the computing
support requirements are low Let’s stop here and define
“translator.” Without a built-in translator, we would have to
write every little bit of code required to interpret command
inputs and convert them to motor movements That includes
writing code to correctly phase and drive the A3979’s
H-bridges We would also find ourselves constructing phase
tables for use in the microstepping process The phase tableswould be used to modulate a PWM signal that is fed into aDAC (Digital-to-Analog Converter) The DAC would generatevoltage levels relative to the modulated PWM signal (Trust
me We want to use a translator if at all possible.) Thus, atranslator is — in this context — a combined package of special-ized hardware and firmware that resides in the A3979 silicon.The purpose of the translator is to convert incoming motorcommands into motor actions or A3979 control actions A
REF PFD
MS2 MS1
SLEEP STEP RESET
RXIN
TXOUT RX
RXIN
TXOUT TX
VBB
+5VDC
+5VDC +5VDC
.1uF
C14 1uF
C10 22uF
R5 2
C17 1uF
C8 1uF
11 13
OUT1A
PFD REF
OUT2A MS1
C15
.1uF
R1 50K
R9 10K
U3
ST3232
13 8 10 1
3 4
5
2 6
12 9 14 7 15
16 R1IN T2IN C1+
C2+
C1- V+ V-
C2-R1OUT T1OUT VSS
VDD
C18 1uF R2
50K
OPTIONAL ACTIVITY LED
OPTIONAL 330
ICSP CONNECTOR
1 3 4
6
1 3 4 6
R7 100
C13 1uF
21 23 25 27
28
11 13 15 17
10 9
RB0 RB2 RB4 RB6/PGC RB7/PGD
RC0 RC1/CCP2 RC3 RC5 RC6/TX RC7/RX
OSC2/RA6
MCLR RA4/T0CKI RA5
GND VDD
C19 047uF
BIPOLAR STEPPER MOTOR C12 22uF
C3 001uF
C22 33uF R8 1K
C20 33uF
C21 33uF
R3 30K
C11 22uF C5
.1uF
C9 1uF
1 3 5 7 9
R4 30K
C1 1uF
R6 2
SCREENSHOT 1 This is art However, my wife won’t let me put anything like this up in a frame in the living room It looks better on a computer display, anyhow.
SCHEMATIC 1 The A3979’s translator
is fully serviced by the PIC18F2620 and there are still plenty of spare I/O lines for your use I added an RS-232 port to allow you to control motor movement from a laptop or desktop PC.
Trang 34motor action is the instigation of motor movement such as
clockwise rotation, counter-clockwise rotation, and halting the
motor The A3979 command inputs STEP and DIRECTION are
used to invoke motor action A3979 control actions include
putting the A3979 silicon to sleep, resetting the A3979’s
inter-nal systems, or enabling or disabling the A3979’s interinter-nal
H-bridges Control actions are also spawned by A3979 command
inputs, which are logic levels applied to the translator command
input subsystem The A3979 translator also provides some
use-ful output in the form of a HOME signal HOME is defined in
A3979 terms as the initial state of the translator The translator
will put the step sequence in the HOME position at power-up
Picking up on the idea that the A3979 doesn’t need an
IBM mainframe to operate efficiently, all we really need to
control the stepper motor by way of the A3979 is a small
microcontroller, such as the PIC18F2620 The PIC18F2620
hookup details can be seen in Schematic 1 As you can
see, it has more than enough I/O to support the A3979 The
ability of the PIC to clock itself internally leaves two more I/O
lines (RA6-RA7) at our disposal
There are only eight A3979 translator I/O lines we need
to deal with The A3979 ENABLE line is optional here and is
put into a permanent enabled state That leaves us with only
seven translator lines to tie to the PIC Since the plan is to
cover the top side of the A3979 PCB with a ground plane, all
of the communication lines between the PIC and the A3979
are routed on the bottom side of the A3979 PCB Note also
that the translator I/O lines are routed as far away from the
power circuitry as possible
The largest current carrying trace needs to be 0.025
inches wide, which will transfer two amperes As you can see
in Screenshot 1, that is a tall order in terms of the A3979 pins
So, we do the best we can and attach the widest trace
possi-ble as close as possipossi-ble to the A3979 motor output pins It is
important to keep the thin traces as short as possible to keep
the trace resistance to a minimum Once we have attached a
trace to the A3979 motor driver pins, we can increase the
copper area to accommodate the higher currents we may
encounter at the A3979 motor output terminations I used
large copper planes instead of traces on the bottom side of the
PCB to connect the A3979’s motor output pins to the four-pin
motor terminal block Copper planes are one of my favorite
fea-tures of the ExpressPCB printed circuit board layout program
The final critical design point is to place the current sense
resistors as close to the A3979’s current sense pins as possible
We also need to consider routing the current sense resistors’
ground return paths The ground return paths to the A3979
from the current sense resistors need to be electrically
unhin-dered I placed the current sense resistors as close as possible
to their respective A3979 current sense pins and used the
vastness of the ground plane as the sense resistors’ ground
return path The A3979 datasheet says to provide a separate
ground path for each sense resistor However, from experience
I’ve found the ground plane method to have no adverse
effects on the operation of the A3979 H-bridge circuitry
Again, I could have saved some board space by
installing fixed resistor voltage dividers for the PFD and REF
potentiometers Having the pots here allows you to adjustthe symmetry of the stepper motor current waveform (PFD)and select the amount of current you want to supply to thestepper motor (REF) with the twist of a screwdriver
No project of mine would be complete without an RS-232port and a standard issue Microchip ICSP programming/debugging portal Note that I’ve used the ST3232 in a five-voltconfiguration in this project The ST3232 can be used in 3.0volt and 5.0 volt environments by simply changing the chargecapacitor values Normally, 0.1 μF charge capacitors would besurrounding the ST3232 in a 3.3 volt project As you can see
in Schematic 1, the 0.1 μF charge capacitors are replaced with0.33 μF charge capacitors and a 0.047 μF charge capacitorbetween the ST3232’s pins 1 and 3
I used a reflow oven to reflow-solder the A3979 motordriver board’s SMT components If you don’t have access to
a reflow oven, you can assemble the A3979 board with a finetipped soldering iron If the reflow process intrigues you, youmay want to investigate the Stencils Unlimited site
(www.stencilsunlimited.com) There you will find all kinds
of SMT soldering aids The A3979’s pins are fine and require
a stencil setup for reflow soldering Because I want you to beable to build the A3979 motor driver board without having
to procure specialized tools, I didn’t go the stencil route thistime and used my Metcal soldering system to manually connect the A3979 pins to the PCB
The Metcal (www.metcal.com) soldering system is a
quick heating precision solder station If you don’t haveaccess to hot air soldering equipment, you’ll need to addsome holes to your PCB layout under the belly of your A3979.The additional holes will allow you to flow solder throughfrom the bottom of the board onto the A3979’s exposedheatsink pad, which must be thermally connected to theground plane I’ve included the A3979 motor driver boardExpressPCB file in the SERVO A3979 project download
package at www.servomagazine.com so you can use it
as a base for your custom A3979 project The A3979ExpressPCB file will reveal the presence of the ground planepassing underneath the A3979 providing a soldering pointfor the A3979’s exposed heatsink pad
Coding the A3979 Motor Driver Firmware
Everything depends on the PIC18F2620 clock At
power-up, the PIC will default to a 1 MHz internal RC clock as wehave specified that it use its internal clocking subsystem.Ultimately, we want to run the PIC at its maximum clockspeed of 32 MHz To do this, we must first load the OSCCONregister with 0x70 This will change the PIC’s internal clockspeed to 8 MHz Then, we enable the 4x PLL to boost theclock speed to 32 MHz This is done by writing a 1 to thePLLEN bit Once the clocking has been taken care of, we canassign the PIC’s port I/O to input or output according to theport pin’s required usage For the PIC18F2620, a 1 identifies
an I/O pin as an input while a 0 is used to define an I/O pin
as an output Here’s the clock and port I/O TRIS code:
Trang 35For now, we won’t be employing the services of the PIC
‘s analog-to-digital converter (ADC) subsystem So, we’ll just
turn it off If you want to use the ADC in your version of this
project, you can do so as portions of the PIC18F2620’s
PORTA and PORTB I/O subsystem can become ADC inputs
Since we’re not using the ADC, here’s the ADC “OFF” code:
//*******************************************************
//* CONFIGURE A2D AND COMPARATORS
//*******************************************************
ADCON1 = 0b00001111; //all port I/O is digital
ADON = 0; //ADC off
CMCON = 0x07; //comparators off
The ADC OFF code also turns off the PIC18F2620
comparators with a write to the CMCON register
The PIC is endowed with a multitude of timers/counters
So, why not use them? I’ve coded up timer routines for
TIMER1 and TIMER3 Each of the aforementioned timers will
trigger an interrupt every millisecond I’ve set up TIMER1 as
a general-purpose timer that can resolve milliseconds,
seconds, and minutes TIMER3 leans towards being a
real-time clock and if you add an LED to RA7, TIMER3 will
drive the LED at one blink per second The timer setup code
is pretty simple and looks like this for TIMER1:
//************************************************
//* CONFIGURE AND START TIMER1
//* SET TO OVERFLOW EVERY 1mS
//* CONFIGURE AND START TIMER3
//* SET TO OVERFLOW EVERY 1mS
Screenshot 3 is a CleverScope capture of the
TIMER3 1 ms clock driving I/O pin RA7 In the TIMER3
interrupt code, I count 1,000 of these to mark seconds,
which clocks the RA7 LED if it is present in your design
I’ve provided the full code package for the A3979 motordriver board via the SERVO website If you’re interested in the
way the timers interact during an interrupt, you can perusethe download package source code to study the timer interrupt service routines in detail
The final steps of the A3979 motor driver board initialization process include activating the interrupts and setting up the stepper motor:
//******************************************************* //* CONFIGURE EXTERNAL INTERRUPTS
//*******************************************************
quarter_step; //quarter-step mode step_HALT; //stop the motor rst_step = 0; //reset the A3979 mdelay1(100); //delay 100mS rst_step = 1; //bring A3979 out of reset slp_step = 1; //put A3979 to sleep step_HALT; //make sure motor is stopped
The millisecond delay routine (mdelay1()) is actually a Cmacro and its source code can also be found in the downloadcode package The same can be said of the interrupt enablemacros There are a couple of additional macros (quarter_stepand step_HALT) in the stepper motor initialization code thatneed to be defined for you at this time Check this set ofA3979 translator input definitions against Schematic 1:
#define rst_step LATC5
#define slp_step LATC4
#define dir_step LATC0
#define ms1 LATA3
#define ms2 LATA5
Let’s see, there’s a RESET translator input, a SLEEP lator input, a DIRection translator input, and the step resolu-tion selection (ms1-ms2) translator inputs Now you can go
trans-SCREENSHOT 2 To get this shot, I simply toggled the RA7 line every time
a TIMER3 interrupt occurred Using the 1 mS interrupt clock as a time base, I can count the 1 mS pulses to create timings for seconds, minutes, hours, and days.
Trang 36back to the stepper motor initialization code and resolve the
usage of rst_step and slp_step However, you still don’t have
enough information to decipher quarter_step In fact, you
can’t decrypt any of the ms1 or ms2 logic combinations until
you fix your eyes on the following truth table macro code:
The step resolution definitions you’ve just seen are actually
C macros, which assign logic levels to the ms1-ms2 translator
inputs The macro quarter_step should make sense to you now
If you’re still a bit foggy on the concepts, I suggest getting a copy
of the A3979 datasheet and referencing it as you study the
source code I’m presenting The A3979 logic is very simple and I
guarantee that if you relate what you’re reading here to what
you see in the A3979 datasheet, it will all come together for you
We could write some bit-bang code to feed the A3979
translator’s STEP input However, why do that when we can
conjure up a set of never-ending step pulses from the
PIC18F2620’s PWM generator? And, using the PIC18F2620’s
PWM is easier than writing step code The first step in getting
a string of step pulses out to the A3979 involves setting up
yet another one of the PIC18F2620’s timers for PWM duty:
The values I have loaded into the TIMER2 and PWM
registers worked fine to spin my LIN Engineering (www.lin engineering.com) 5718 series stepper motor You may have
to juggle the PR2 and CCPR1L values for your particular motor.The A3979 will accept step pulses as narrow as 1 μs Iobtained a 1.6 μs step pulse like the one you see in Screenshot
3 by loading CCP1CON with 0x1F and CCPR1L with 0x00.CCPR1L and the two least significant bits of CCP1CON’s uppernibble hold the 10-bit PWM duty cycle value I obtained the1.6 μs step pulse with the PWM duty cycle binary value of0b0000000001 The PWM duty value you see in the codeexample translates to binary 0b0101000001 The lower nibble
of CCP1CON is used to enable or disable the PIC18F2620’sPWM engine as shown in the code snippet that follows:
#define pwm_ON CCP1CON = 0x3F
#define pwm_OFF CCP1CON = 0x00
#define step_CW slp_step = 1; \
dir_step = CW; \ mdelay1(10); \ pwm_ON;
#define step_CCW slp_step = 1; \
dir_step = CCW; \ mdelay1(10); \ pwm_ON;
#define step_HALT slp_step = 0; \
pwm_OFF
If you need to use all 10 bits of PWM resolution, you’ll need
to alter the two least significant bits of the upper nibble of thedefault 0x3F value I’ve posted in my example code I’ve alsogiven the A3979 ten times (10 ms) more wakeup-from-sleeptime (mdelay1(10)) than the 1 ms the datasheet demands.The A3979 download code package also contains an inter-rupt driven EUSART driver for the PIC18F2620 A menu system
is incorporated that will allow you to connect the A3979 motordriver board to a laptop or desktop PC and control the move-ment of the stepper motor We don’t have the page space here
to talk about the EUSART driver in detail However, I describethe EUSART driver down to the bit level in the RS-232 chapter
in my book Networking and Internetworking with Microcontrollers The neat thing about the EUSART
driver is that you can easily drop it into any PIC cation that needs robust RS-232 communications
appli-Firing Up the A3979 Motor Driver Board
It is important that you don’t adjust the REF pot
to get a voltage above four volts on the REF pin So,before you fire up your A3979 motor driver board,
be sure to adjust the REF pot’s wiper to be nearer tothe grounded pot pin It’s a good idea to simply center both of the pots as they will produce around2.5 volts on the PFD and REF pins upon power-up.Once you’ve powered up successfully, adjustthe REF pot to put 1.6 volts on the REF pin This willlimit the stepper motor current to one ampere The
SCREENSHOT 3 This shot was taken with my CleverScope This is as tight a
pulse as I could get with the circuitry we are using.
Trang 37stepper motor current formula to determine the REF voltage
for a desired stepper motor current limit value is:
REF voltage = 1.6 * Maximum Current Limit Value
The A3979 is rated to handle a maximum motor current
of 2.5 amperes Plugging that into our formula gives us:
REF voltage = 1.6 * 2.5 = 4 volts
Now you know why you don’t want to exceed four volts
at the A3979’s REF pin
You can experiment with the PFD pot setting as the
voltage on the PFD pin determines the symmetry of the motor
current waveform Ideally, you want your motor current
waveform to look like the sinusoidal motor current waveforms
in the A3979 datasheet A trick I’ve picked up is to listen to the
motor as you adjust the PFD pot If the motor sounds like it’s
trying to kill itself, your motor current waveform is not right
Adjust the PFD pot to get the smoothest and quietest sound
from your motor at the desired REF voltage Plug this code into
your main service loop to adjust the PFD and REF voltages:
Spinning Out
That’s all there is to it I’ll include a BOM (Bill ofMaterials) file with the A3979 firmware download soyou can scrounge up the parts you’ll need to buildyour own A3979 motor driver board Who knows, theA3979 just may be the answer you’ve been looking for
to complete those small robotic motor control jobs Asalways, if you have any questions about the A3979 orthe A3979 motor driver board, fire off an email to me.Have fun! SV
For further reading, check out this book, available on the SERVO website:
www.stmicro.com
ST3232 Saelig Corporation
www.saelig.com
CleverScope The A3979 motor driver board
code was written with the
HI-TECH PICC-18 C compiler.
Resources
Fred Eady can be reached via email at fred@edtp.com
Contact the Author
Trang 38My particular application — as
we discuss here — is in filtering
input data used to calibrate
the odometer in a road rally computer
After computing a best-fit line using a
linear regression on a set of data
points, square roots are needed to
compute the distance of each data
point from the line If a data point is
too far off the line, it is discarded on
the assumption of human error and the
line is recalculated
Square Root on a PIC in the
November ‘06 issue of Nuts & Volts
(www.nutsvolts.com) demonstrated
a simple algorithm for computing
square roots While the
implementa-tion was very compact, the algorithm
has a significant performance issue — it
gets extremely slow as the argument to
the square root function gets large
This is because the algorithm
sequen-tially computes each square starting
at 1 until it finds the one closest to
the argument
Let’s look at an alternative method
of computing square roots It has the
advantage of taking nearly constant
time, regardless of argument — about
150 microseconds for a 32-bit input on
a 20 MHz PIC18 This makes it practical
to compute square roots in a robot
control loop running 100 times per
second, for example Code size is
about 35% larger, but still well under
Figure 1 shows asample long divisionproblem The basicsteps for each digitare:
• Make a guess of the digit
• Multiply the trial digit by the divisor
• Try to subtract that product from the current remainder
– If the product is larger than theremainder, make a new guess with
a smaller digit
– If the subtraction produces aresult larger than the divisor, make
a new guess with a larger digit
In the case of Figure 1, the guessfor the first digit (estimated from 62÷8)initially turned out to be too large The
first trial digit and product are crossedout and a new set was tried
The description for binary long division is the same, but the only twochoices for the trial digit are 0 and 1.This makes it very easy to make the rightguess, and also very easy to computethe trial * divisor
product that is to
be subtracted fromthe remainder
Figure 2 shows
a sample binarydivision problem
By definition
of square root, ifthe divisor equalsthe quotient, then
we have thesquare root of thedividend The algorithm for square roottakes the form of binary division wherethe divisor is continually changed tomatch the quotient
The square root of an N-bit number has N/2 bits; in our example,we’ll be taking the four-bit square root
of an eight-bit number From our binary division viewpoint, we’ll be looking for the square root of the dividend We start with a divisor at themidpoint of the possible result range: a
1 followed by N/2 – one zero; in ourcase, a 1 followed by three zeros
Square roots have a number of possible
applications in microcontroller systems
Square roots have a number of possible
applications in microcontroller systems
√ by Tim Paterson
6 79 897)62518 6279 -5382 8698 -8073 625
1101 1001)1111001 -1001 1100 -1001 0110 -0000 1101 -1001 100
Figure 1.
Decimal long division example.
Figure 2 Binary long division example.
Trang 39The first half
of Figure 3 shows
an example withthe first bit calcu-lated Notice inthe figure how
we don’t knowthe divisor yet, so I’ve substituted “xxx.”
The binary division procedure requires
multiplying the guess by the divisor, so
“0” is used for each “x” for now
The second half of Figure 3 shows
the partially-completed calculation of
the second bit We make a guess of 1,
multiply the trial bit by the divisor
(which is 11xx now to stay equal to our
quotient), and subtract from the
remainder We must also account for
what we should have subtracted when
we computed the previous bit Back
then, we only subtracted 1000 Now
we have a divisor of 11xx, so we should
have subtracted 1100 before I’ve put
this make-up value to be subtracted on
an additional line Because we’re
shift-ed right one bit, it’s written as 1000,
but you can follow the “1” bit up the
column and see it’s in the right place
So at this point, we have two values
to subtract — 1100 and 1000 — whose
binary total is 10100 This total amount
to subtract is larger than our current
remainder of 1110, so we must
con-clude the trial was too big — instead of
trial bit and the
divisor, and also
The remainder is big enough, so thetrial bit is correct
The second half of Figure 4 showsthe calculation of the final bit Notehow that extra value we subtract (tocorrect for previously subtracting thewrong value) has more “1” bits in it
Each of the 1 bits corresponds to a subtraction for a previous quotient bitwhere we didn’t subtract the bit we’reworking on now So, for each 1 bit inthe quotient (not counting the trial bit),there will be a corresponding 1 bit inthe extra value to subtract to accountfor not subtracting it originally
Once more: For each 1 bit in thequotient, there will be a 1 bit in theextra value to subtract This is the same
as saying the extra value to subtractequals the quotient (and divisor) before
setting our trial bit So, we subtract thedivisor with the trial bit, and we subtractthe divisor without the trial bit Addingthat up, we subtract 2 * divisor + trial.That’s it Since the divisor and quotient are always equal, I’m going tostart calling them the root To calculateeach bit of the root, try to subtract twotimes the root plus the trial bit from thecurrent remainder If it fits, the trial bit
is part of the root; if not, that bit is zero
Square Roots
Listing 1 represents this algorithm
as a function in C You don’t need toknow C to understand it if you look inthe sidebar for the explanation of theoperators This algorithm also includesthe extra step of rounding the resultbased on whether the next bit would
be 0 or 1 This function has been compiled and tested for both Windowsand the AVR microcontroller
101 101x)01111001 -1000 1110 -0000 11100
- 1010
- 1000 1010 1011 1011)01111001 -1000 1110 -0000 11100
- 1010
- 1000 10101
- 1011
- 1010
Figure 4 Third
and fourth bits of
square root being
calculated.
1 1xxx)01111001
-1000
111 11 11xx)01111001
-1000
1110 -1100 -1000
Figure 3 First and second bits of square root are being calculated.
typedef unsigned long UINT;
#define INT_BITS ((sizeof(UINT)) * 8) UINT SquareRoot(UINT arg)
{ UINT trial;
UINT root;
trial = 1 << (INT_BITS - 1); // set up 100000 binary root = 0; // Inside loop, really root * 2 do
{ trial >>= 1; // move trial to next position in root root |= trial; // combine trial bit into root
if (arg < root) // does trial root bit fit?
root ^= trial; // no, remove trial bit else
{ arg -= root; // root fits, remove it from arg root += trial; // double the trial bit
} root >>= 1; // move both root & trial to next trial >>= 1; // position within arg
} while (trial != 0);
// Compute rounding // See if next bit computed would be 1; round up if so.
if (arg > root) root++;
return root;
}
LISTING 1 Fast square root algorithm in C.
Trang 40The function starts by initializingthe variable trial which contains thecurrent trial bit The function isdesigned to be easily targeted for 16-bit or for 32-bit integers (or anyother size), which explains the some-what complicated-looking expressionthat initializes trial I’ll assume we’reusing 32-bit integers, in which case trialgets initialized to 0x80000000 — a 1 inthe MSB and the rest 0 Note that thefirst thing that happens inside the loop
is that trial is shifted right one bit, sothe first trial bit value is 0x40000000
In the main loop, the variablenamed root actually keeps the value oftwo times the current root Combiningtrial into root gives us the amount tosubtract from the current remainder(called arg) if it fits If it doesn’t fit, theexclusive-OR operation is used to clearthe trial bit in root If it does fit, we need
to double the trial bit so that, as part ofthe new root, it will be root times two
At the bottom of the loop, rootand trial are each shifted right one bit.This moves them to the next bit position for which we’ll be computingthe root Looking back at Figure 4, youcan see how the subtraction for eachbit is shifted right compared to the previous bit Conveniently, when it’stime to end the loop, this right shift of
I have never seen any description of
this algorithm published before I don’t
mean that it’s original with me — in fact, I
believe this algorithm is widely used in
floating-point hardware I became aware
of the algorithm many years ago when
reading about a particular computer
architecture that included hardware
square root.
I have an old Pentium manual that
lists the time to perform a floating-point
divide as 39 clock cycles, and the time to
perform square root as 70 clock cycles –
less than twice as long The only way that
could be happening is if the
floating-point unit implements this algorithm in
hardware.
For a processor that has hardware
divide but no hardware square root, the
most common way to compute square
root is with Newton-Raphson iteration.
This algorithm is very simple:
1) Make a guess at the root.
2) Divide the guess into the argument.
3) Average the quotient with the guess to make the next guess.
This method converges very fast;
every iteration doubles the number of digits (or bits) of accuracy The trick is
to come up with a good initial guess
This is difficult for integer or point arithmetic, where it may take one iteration to get one bit correct Then the subsequent iterations give you 2, 4, 8, and 16 bits of accuracy — typically five total iterations for a 16-bit root of a 32-bit number.
fixed-When using floating point arithmetic, it’s easy to get an accurate initial guess because of the “normalized” format of the numbers With an eight-bit multiply and addition, you can come up with a guess accurate to almost five bits Then only three iterations are needed to achieve single-precision accuracy.
I used this technique when I wrote
the x87 emulator for Microsoft in 1991 This program provided floating-point arithmetic back in the days before it was built into every processor; it hasn’t been needed since the 486SX It is still widely distributed, included as WIN87EM.DLL with every 32-bit operating system Microsoft has shipped.
While researching for this article, I found another square root algorithm
on the Microchip website posted in Application Note TB040 for PICs that have hardware multiply The general idea is to set a trial bit in the root, square the root, and see if it was too big The algorithm calculates the result bit by bit, with one square (multiply) operation per bit According to the app note, with a 32-bit input this method would take 200 microseconds
at 20 MHz, and the code size appeared
to be over 200 bytes So it is both bigger and slower than the algorithm I present.
Square Root Algorithms
SquareRoot:
clrf32 root ; root = 0 clrf16 trial ; trial = 0x80000000 clrf trial+2 ; "
; Didn't fit, remove trial bit
xor32 root,trial ; root ^= trial bra ShiftRight
RootFits:
sub32 arg,root; arg -= root add32 root,trial ; root += trial ShiftRight:
bcf STATUS,C; Clear C flag for following rotate rrf32 root ; root >>= 1 - Always leaves C flag clear rrf32 trial ; trial >>= 1
bnc RootBit ; if trial bit shifted out, we're done
#if ROUND
; Compute rounding Note that root always fits in 16 bits here,
; but it could round up to 17 bits.
movf arg+2,f ; see if bits 17-23 are non-zero bnz IncResult ; if non-zero, arg is big, always > root cmp16 arg,root; if (arg > root) - C flag set if root < arg bnc Done ; "
...101 101x )011 11 001 -1000 1110 -0000 11100
- 1010
- 1000 1010 1011 1011 )011 11 001 -1000 1110 -0000 11100
- 1010
- 1000 1010 1
-... Paterson
6 79 897)62518 6279 -5382 8698 -8073 625
1 101 1 001) 1111 001 -1 001 1100 -1 001 0110 -0000 1 101 -1 001 100
Figure 1.
Decimal... pulse with the PWM duty cycle binary value of0b0000000 001 The PWM duty value you see in the codeexample translates to binary 0b0 1010 00 001 The lower nibble
of CCP1CON is used to enable