Cover.qxd
1/5/2005
4:20 PM
Page 84
Vol. 3 No. 2 SERVO MAGAZINE RECYCLABLE ROBOT SOFTWARE February 2005
Circle #106 on the Reader Service Card.
CoverInside.qxd
1/4/2005
9:42 PM
Page 2
Remember when... ...electronics stores were stocked to the rafters with every component imaginable and there was
ALWAYS
a knowledgeable person there to help you?
®
Think those days are gone?
1-800-455-6119
Well they’re not!
You just need a little Jameco@Home. Call for a FREE catalog today. We have the electronic components and knowledgeable Technical Support people who can help bring back the fun in your electronics hobbies, inventions, and DIY projects. Circle #60 on the Reader Service Card.
Be sure to visit our new website at
www.Jameco.com/nvb
Jameco @ Home —where electronics is still fun!
Circle #32 on the Reader Service Card.
Full Page.qxd
12/9/2004
Circle #81 on the Reader Service Card.
3:22 PM
Page 3
TOC.qxd
1/4/2005
4:46 PM
Page 4
Departments 6 7 44 50 62 63 70 82
Publisher’s Info Bio-Feedback New Products Robo-Links Events Calendar Robotics Showcase SERVO Bookstore Advertiser’s Index
Take a Sneak Peek!
W alk This W ay, Ey!
Coming 3.2005 4
SERVO 2.2005
Columns 6 8 12 17 24 43 64 66 72 78 81
Mind/Iron Rubberbands Robotics Resources Assembly Line Brain Matrix Menagerie Robytes Ask Mr. Roboto Lessons From the Lab GeerHead Appetizer
Thanks to Sozbots (www.sozbots.com) for the photo of RoboOne on the cover!
SERVO 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. APPLICATION TO MAIL AT PERIODICALS POSTAGE RATE IS PENDING AT CORONA, CA AND AT ADDITIONAL ENTRY MAILING OFFICES. POSTMASTER: Send address changes to SERVO Magazine, 430 Princeland Court, Corona, CA 92879-1300 or Station A, P.O. Box 54,Windsor ON N9A 6J5.
[email protected]
TOC.qxd
1/4/2005
8:13 AM
Page 5
SERVO
2.2005 VOL. 3 NO. 2
Features & Projects
19
Recycle Your Robot’s Code
26
Step Up and Get Motorvated!
37
A Cut Above
46
PIC Your Speed
51
The Core of the Atom, Part 2
57
Hats Off to RoboSapien
by Steven Grau
by Peter Best
by Michael Simpson
by Dennis Volrath
by Kerry Barlow
by Henry Pfister
SERVO 2.2005
5
JanPages6&7.qxd
1/5/2005
8:41 AM
Page 6
Published Monthly By The TechTrax Group — A Division Of T & L Publications, Inc. 430 Princeland Court Corona, CA 92879-1300 (951) 371-8497 FAX (951) 371-3052 www.servomagazine.com
Mind / Iron by Alexandra Lindstrom I’ve seen creative writers refuse to discuss their new work until it’s safely in print. At races and car shows, I have witnessed people acting as if their hoods were hermetically sealed. Academics often neglect to teach about a new thought until they have safeguarded their intellectual property. Yet, robot builders will practically gut their creations in order to show someone how to replicate their builds. They publish their code and parts lists online and in the pages of this magazine. This trait, at first, seems at odds with the sentiments Dave Calkins writes about in this month’s “Appetizer.” Dave discusses the competitive programming of the human race and, therefore, robot builders. As I read Dave’s article, I agreed with him wholeheartedly; robotic events offer the best means to learn, be inspired, and meet likeminded individuals. I began to wonder why — in such a competitive hobby as robotics — the community remains so open about the methods used to create the prize-winning bots seen at these events. When you think about it, is competition really at odds with the open exchange of ideas? I don’t believe it is. A true competitor will tell you that winning only counts when the challengers are evenly matched. Still, it can’t be that simple; even in a relatively young field — like robotics — skilled competitors can be found. Upon reflection, I believe that this openness in the robotic community stems from a common goal to further the field. We all know that robotics will, one day, revolutionize the world as we know it and we want to be a part of that wave of social and cultural
6 SERVO 02.2005
transformation. In order to accomplish such a goal, the minds of the community have to share their inspirations, failures, and successes. To paraphrase Marleen Barr, the noted critic of science fiction literature, only by questioning the established knowledge and practices of a community can we ever hope to move beyond the present knowledge base and advance to the goals we all claim to support and work toward. That sentiment finds its validation in the upcoming robotic generation. Almost any given issue of SERVO highlights the successes of those who aren’t even old enough to vote, yet find new ways to push the boundaries of the field. In addition, the people behind High Tech High saw a need to open a new campus in Los Angeles, CA, that caters to lower-income students who would, otherwise, not be able to access such an intensive eduction in robotics and technology. As a community, we see that young minds which haven’t yet learned what we say can’t be done are, in fact, the basis of our future. As we share our trade secrets, they will take us up on the challenge of moving forward, using the knowledge and information that found its root in others. When that day comes where the robotics revolution has firmly taken hold, it may be those who now look forward to being old enough to compete in FIRST who lead the way, but their inspiration and education will be founded on what others shared openly in an effort to create a wellrounded community of equally matched and like-minded individuals who are at the robot events today. SV
Subscription Order ONLY Line 1-800-783-4624
PUBLISHER Larry Lemieux
[email protected] ASSOCIATE PUBLISHER/ VP OF SALES/MARKETING Robin Lemieux
[email protected] MANAGING EDITOR Alexandra Lindstrom
[email protected] CIRCULATION DIRECTOR Mary Descaro
[email protected] WEB CONTENT/STORE Michael Kaudze
[email protected] PRODUCTION/GRAPHICS Shannon Lemieux COVER ART Michele Durant STAFF Kristin Rutz Dawn Saladino OUR PET ROBOTS Guido Mifune Copyright 2005 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 subscription orders, correspondence, UPS, overnight mail, and artwork to: 430 Princeland Court, Corona, CA 92879.
JanPages6&7.qxd
1/5/2005
11:19 AM
Page 7
Dear SERVO, From what I have read, I think I like SERVO Magazine better than Nuts & Volts. I have never subscribed to N&V, but I have purchased it from time to time from a local Border’s bookstore. SERVO Magazine seems more appealing to me. While I am not an active robotics enthusiast, I do like controlling things with embedded microcontrollers. That is the reason for my main interest in SERVO Magazine. I am not particularly a BASIC Stamp fan. I prefer the MC68HC11 and the Atmel AVR breeds of microcontrollers but, what information SERVO provides is directly applicable to those other kinds of microcontrollers, too. Carl W. Livingston, via Internet Dear SERVO, Great magazine and excellent articles! I’m looking forward to some Roomba hacks. I just hope you don't go "tango uniform" like the other magazines I used to receive. Steven Canning via Internet
Dear SERVO, I enjoyed Jack Buffington's “Rubberbands and Bailing Wire” article regarding the addition of an LCD to a robot (January 2005). It was well written and had some good tips. My biggest comment is simply that these displays (parallel) are a pain in the butt! Yes, they have a few good points, which were mentioned in the article. However, for the novice builder using a display for the first time, I would highly recommend starting out with a serial display. Granted, they are a little more expensive, but they are much easier to use and only take up one pin on the PIC (or STAMP or whatever). If you don't have an "official" serial port on the processor, you can always do some bit banging. Keep up the good work. Paul Kafig via Internet Dear SERVO, I must say that I am a bit disappointed in your coverage of your much promoted and anticipated Tetsujin competition. As an avid reader, I must admit I was expecting a bit more than
Circle #70 on the Reader Service Card.
two pages of captioned pictures and a vague promise of more to come (of which I see nothing in the January issue). The electrical engineering journal we subscribe to at work covered the event almost as well as you have (they gave it a whole two sentences). I'm not sure what else I expected from the coverage of this event, but it was definitely more than I've gotten from your last two issues. Thanks for your time. Jason Urban via Internet Dear Jason, In our goal to provide interesting and informative reading for our diverse audience, we decided to spread the coverage of Tetsujin over several issues rather than one. Future issues will feature articles by or interviews with the Tetsujin competitors. These articles will contain details about their builds and the successes and trials they found along the road to Tetsujin. The December issue of SERVO featured an “Appetizer” column by Tetsujin winner Alex Sulkowski as a forerunner of the content to come. — Editor
SERVO 02.2005
7
Rubberbands.qxd
1/3/2005
4:14 PM
Page 8
by Jack Buffington
Bars and Batteries: Displaying Your Robot’s Battery Level on an LCD Display
month’s column is a bit of a mixed bag. The first part Thisexpands on last month’s column, which described how to
To create a special character, you will need to issue a command to set the character generator RAM address. communicate with an alphanumeric LCD display. This month, There are 64 bytes of character generator RAM. Each charyou’ll learn how to create custom characters. Using these acter is built by using eight of those bytes, which represent characters, you’ll learn how to draw bar graphs. The second the pixel rows in the characters. Only the lowest five bits part of this column will use one of the bar graphs and a are used. If you set a bit high, its corresponding pixel little extra circuitry connected to your microprocessor to will turn black when that character is displayed. To build a allow you to monitor the battery voltage of your robot. character, you will specify the first character generator Let’s dive right in and start with custom characters. A RAM address that you want to write to and then you custom character is any character you might create that is will send data corresponding to the pixel rows for that not part of the standard character set. As you can see in character. Each byte sent will represent a lower row of Figure 1, there are plenty of different characters to choose pixels in the character. from, but — if you can’t find the character that you want — Figure 2 shows a character and the data that you would then the HD44780 can let you create up to eight special charsend to define it. If you sent a character generator address acters of your own design to be displayed. These characters of zero and then wrote eight bytes of data, then you will are mapped into the spots on the left side of the chart in have completely defined the first character. If you send an additional byte, then you will have written to the top row Figure 1. Some potential uses for custom characters would of the second character. You can change the character be to display things such as a square, diagonal arrow, Greek letters, a moving clock icon, or bar graphs. generator address at any time, so you could choose to write to the first character and then skip to the third charFigure 1. The standard characters of the Figure 2. A smiley face and the bytes that you HD44780 and their character codes. can use to create it. acter, if you wanted to. Our first example will be to create special characters that will let you create vertical bar graphs of any height. To make this easy to integrate into a program, the bar graph code is implemented in two subroutines and one look-up table. The look-up table holds Figure 3. A look-up table for a vertical bar graph. the bytes of data used to initialize const int8 vGraphBytes[] = {0,0,0,0,0,0,0,31, the characters, the 0,0,0,0,0,0,31,31, first subroutine 0,0,0,0,0,31,31,31, 0,0,0,0,31,31,31,31, writes those bytes 0,0,0,31,31,31,31,31, to the character 0,0,31,31,31,31,31,31, generator RAM, 0,31,31,31,31,31,31,31, 31,31,31,31,31,31,31,31}; and the second subroutine draws
8
SERVO 02.2005
Rubberbands.qxd
1/3/2005
4:16 PM
Page 9
Rubberbands and Bailing Wire a bar graph for you. The vertical bar graph routine will draw a bar graph up to four characters high on the column that you specify. This routine accepts an eight-bit value for its magnitude, which it scales for you to the appropriate value that it needs. It makes reference to a subroutine called lcdMoveTo(). You can find details about this routine in last month’s column. You can pack a lot of vertical bar graphs into an LCD screen, but you can only display 32 different values this way, so you may want to use a horizontal bar graph. With a horizontal bar graph, you can display 200 different values. This can give you a clearer indication of an eight-bit value. Here are the look-up table and subroutine that draw a horizontal bar graph. So far, you have been shown how to draw bar graphs, but nothing has been said about how you could go about using them. Some ways that you could make use of a bar graph could be as a sound level meter, a speedometer, a graph of how many times something has happened over a certain duration, or as a progress indicator for lengthy calculations. If you used multiple vertical bar graphs, you could build a strip chart to show the value of some variable over time. The example shown here will be how to use a bar graph to display the current level of your robot’s batteries. You might think that having your robot measure the state of its own batteries would be a tricky process, but it is actually quite simple. All that it requires is that you have one free analog to digital (A/D) input pin and two resistors! The example here shows how to measure the state of a 9 volt battery, but other voltages can be measured using simple changes to the circuit and program. To create the circuit, you will take two resistors and connect them together to create a voltage divider, as shown in Figure 7. The PIC in the example is running at 5 volts. The PIC can use its input voltage as the reference voltage for its A/D converter, so — in this set-up — it will be able to measure from 0 to 5 volts. In this example, the voltage level of a 9 volt battery is being measured, so a voltage divider that has two equal value resistors is being used. This will
TECH TIDBIT Do you keep burning your table or workbench with your soldering iron? Here’s an easy-to-make holder that you can build that works just like the ones in expensive soldering stations. Go to your local craft or hobby store and ask for aluminum armature wire. You can get it in several diameters, but 1/4” seems to work the best. Wrap the armature wire around a broomstick or dowel rod to create the spiral and then bend the base by hand.
void lcdMakeVbarGraphCharacters() { // vertical bar graph int8 temp8; output_low(RS); output_low(RW); output_high(E); portB = 0b01000000; delay_us(20); output_low(E); lcdBusy(); for(temp8 = 0; temp8 < 64; temp8++) { lcdPutChar(vGraphBytes[temp8]); } }
Figure 4. A subroutine that sets up the characters for the vertical bar graph.
result in the voltage of the battery being divided in two, which shifts the voltage into a range that the PIC’s A/D converter can read. If you are using the circuit in Figure 7, then you will start to lose accuracy as the battery voltage drops near 5 volts. At this point, the voltage regulator will start to output a voltage less than 5 volts, which throws off the calculation. Still, if the voltage has dropped to 5 volts, then the battery is very close to dead anyway. Let’s look at how you can calculate and display the battery’s voltage on your LCD display. The A/D value that is read is an eight-bit value. Since the processor is running at 5 volts and the circuit is using a voltage divider that divides the input voltage by two, the maximum voltage that can be Figure 5. A subroutine that draws a vertical bar graph. void vBarGraph(int8 magnitude, int8 column) { //draws a vertical bar graph. Magnitude is 0-255 int16 temp16; int8 temp8; temp16 = magnitude; temp16 *= 32; temp16 /= 255; // temp16 now contains 0-32 for(temp8 = 4; temp8 != 0; temp8—) { lcdMoveTo(temp8,column); if(temp16 > 7) { lcdPutChar(7); // solid block temp16 -= 8; } else if (temp16 > 0) { lcdPutChar(temp16 - 1); // partial block temp16 = 0; } else lcdPutChar(32); // space character } }
SERVO 02.2005
9
Rubberbands.qxd
1/3/2005
4:16 PM
Page 10
Rubberbands and Bailing Wire read is 10 volts. If you divide 10 volts into 256 equal parts, then you will be able to resolve the battery’s voltage to within .039 volts. That is sufficient for most things, but you could also set up the PIC to read analog voltages with 10-bit precision, which would let you resolve your battery voltage to within .009 volts. That is overkill for this application, so eight-bit resolution will be used. There are three ways that you can calculate your battery’s voltage. There is no right or wrong way to do it, but there are better and worse methods. Let’s look at the obvious first choice, which is to use floating-point math. This makes
writing the C code easy, since floating point automatically figures out the decimal point for you and you can simply use a printf() statement to get your result. To find the voltage, you could simply use the following equation: read voltage = (reading/255) * the maximum readable voltage. In this case, the maximum readable voltage would be 10 volts. The BIG downside of using floating-point math is that it compiles into a gargantuan amount of machine code. Floating-point may be perfectly fine on a desktop computer, but — on a PIC with very limited resources — you will find that using floating-point math is an option of last resort, since it will run slowly and will take up much of the ROM space that Figure 6. The look-up table and subroutine to draw a horizontal bar graph. you could otherwise use for the const int8 hGraphBytes[] = {16,16,16,16,16,16,16,16, rest of your program. 24,24,24,24,24,24,24,24, A much faster and more 28,28,28,28,28,28,28,28, 30,30,30,30,30,30,30,30, compact method of arriving at 31,31,31,31,31,31,31,31}; the battery’s voltage is to use integer math. Figure 8 shows how you would convert void hBarGraph(int8 magnitude, int8 line) { between your A/D value and a int8 temp8a; value of 0 to 1,000, which repreint16 temp16a; sents 10.00 volts. This method of // draws a horizontal bar graph the width of the screen on the specified line calculating the voltage is simple, // pass 0-255 in magnitude lcdMoveTo(line,0); compiles to a small amount of code, and runs quickly. There is temp16a = magnitude; one problem with it, though. temp16a *= 100; The variable ‘volts’ needs to be a temp16a /= 255; // scale it to the range of 0-85 32-bit variable. This is because temp8a = 0; you will get overflow errors in while(temp16a >= 5) // draw in the solid bars first the ‘volts’ variable as temp8a { goes higher than 65. Using a lcdPutChar(4); 32-bit variable may not be a temp16a -= 5; temp8a++; problem if you have lots of RAM } available, but — if you don’t — switch(temp16a) // make the last character be the right number of vertical bars there is a third method that { only requires a 16-bit variable to case 0: lcdPutChar(32); // space calculate the battery voltage. break; Figure 9 calculates the case 1: voltage without the need to lcdPutChar(0); worry about overflow errors. In break; case 2: this case, the code is multiplying lcdPutChar(1); by the fraction 125/32, which is break; really a simplified version of case 3: the first equation, where the lcdPutChar(2); break; numerator and denominator case 4: were both divided by eight. This lcdPutChar(3); version will not overflow past break; the limits of a 16-bit variable. } temp8a++; You may still have a few questions about why the A/D while(temp8a < 20) // overwrite remaining characters in the row with spaces reading was multiplied and { divided by the numbers that we lcdPutChar(32); used. Let’s look at what these temp8a++; } numbers are doing. Since Figure } 8 is the unsimplified version of
10
SERVO 02.2005
Rubberbands.qxd
1/3/2005
4:17 PM
Page 11
Rubberbands and Bailing Wire the fraction, we’ll use it for this example. It might be simpler to think of the order of operations as dividing the reading volts = temp8a; volts *= 1000; by 256 and then using that value to multiply by a number volts /= 256; representing the maximum voltage. Let’s first look at how the value is divided by 256. This is Figure 8. Calculating because the A/D reading divided by 256 will result in a value the battery voltage from 0 to 1 (actually .996 because the maximum A/D value using integer math. is 255). If you multiply this value with another value that represents your maximum measurable voltage, then you will volts = temp8a; arrive at your answer. For example, in Figure 8, if 2,250 was volts *= 125; used instead of 1,000 on the second line, then that would volts /= 32; represent 22.50 volts. You would need to adjust the values of your voltage divider to output 5 volts when the input was Figure 9. Calculating 22.5 volts, as well, in order to measure up to 22.5 volts. The the battery voltage Figure 7. The wiring needed to using a 16-bit variable. measure your battery’s voltage. reason that the multiplication happens first is because — if you divide your A/D value by 256 — you will always have a result of 0, since you are working in integer math. integer = 0; while(volts > 99) You now are able to have your microcontroller figure { out its battery voltage. If you are simply using this figure for volts -= 100; internal calculations, then you could stop here. If you want integer++; to be able to display it on your LCD screen, then you will } probably want to add a decimal point to the value so that it decimal = volts; is more easily understood. hBarGraph(temp8a,1); Figure 10 shows a chunk of code that lets you figure out lcdMoveTo(2,0); an integer portion and a decimal portion of the value and printf(lcdPutChar,”%u.%02u volts”, integer,decimal); then print it out on the screen. It also prints out a horizontal Figure 10. How to display the battery voltage. bar graph above the reading as a quick way that you can visually read the battery voltage. by 57, you get 4.49, which is the voltage of your battery. As a final wrap-up on this topic, here are two other ways A 1 volt reference makes the calculation easy, but the of measuring battery voltages. If you are looking to measure math isn’t too much harder if you use a different voltage the voltage of a battery that does not power the processor, reference. you just need to tie its ground to the processor’s ground. This will allow you to measure its voltage. If you are trying to This month’s column showed you how to draw bar graphs measure the voltage of a battery that is powering your and how to measure your robot’s battery’s voltages. Now, you processor directly without a voltage regulator between the can build robots that have an actual user interface and that battery and the processor, then you will need to use a circuit can know when their batteries are getting low so that they like the one shown in Figure 12. can seek out a way to recharge or at least shut down graceThis circuit uses a fixed voltage reference as the input fully. This should give you quite a bit to play around with until to the A/D converter. A voltage reference of 1 volt or some next month’s column, where we’ll show you how to give your other low voltage will work fine. As your battery voltage robot speech output so drops, the A/D reading will increase. Let’s say that that it can talk to you! SV Figure 12. Measuring the voltage when the battery you were using a voltage reference of 1 volt powers the processor directly. and your A/D reading was 57. If you divide 256 Figure 11. The final result.
RESOURCES www.ccsinfo.com Source of the C compiler for PIC processors used in this column. www.digikey.com Source for electronic parts. www.mpja.com Sells the LCD module used in this article. SERVO 02.2005
11
RoboResources.qxd
1/3/2005
1:24 PM
Page 12
Robotics Resources:
BEYOND THE FIVE SENSES by Gordon McComb
A
robot without sensors is just a fancy machine. If “clothes make the man” (this applies to women, too, of course), then sensors make the robot. Many robots have basic mechanical and optical sensors — touch switches for detecting a collision with an object, for example, or infrared sensors that sense nearby objects. In this column, you’ll find sensors that extend beyond basic touch and infrared. There’s a whole world of unique sensors — originally designed for medicine or industry — that can be applied to robotics. These sensors can be quite expensive and several high-end variations are listed in the sources that follow. However, most of the resources presented here are either on the affordable end of things or offer concepts (with data sheets and application notes) that you can study as you learn how the various sensor technologies work. Note that, while some sensor manufacturers will sell directly to the public, those that do often have minimum order requirements. If you see a sensor that you’d like to try, consider contacting the manufacturer and asking for a sample. Try their website for a list of distributors and be sure to check out the usual sources of electronics parts, including Jameco, Mouser, Acroname, BG Micro, Digi-Key and other advertisers in this magazine. You’d be surprised what goodies you can find if you dig deep enough. Some sensor categories that aren’t included are tilt and accelerometer (see “Robotics Resources,” June 2003 in Nuts & Volts Magazine). We’ll also skip video vision sensors and incremental encoders this time around, as these are
special types worthy of their own future column.
General Sources for Sensors Here are sources for general industrial sensors, which include mechanical and electronic (usually peizoelectric) gyroscopes, ultrasonic sensors, inductive sensors, and impact sensors. Most of these sources are manufacturers and offer fairly high end products for medical and industrial applications (think $$$). However, even if you can’t afford a $450.00 gyro, you can read through the application notes and spec sheets for ideas.
Baumer Electric, Ltd. www.baumerelectric.com Baumer makes industrial sensors: inductive capacitive, photoelectric, retro-reflective, thru-beam, ultrasonic, proximity, and rotary encoders. This stuff isn’t cheap, but — if you need quality — this is where you’ll find it. The web page is in English and German.
Carlo Gavazzi Holding AG www.carlogavazzi.com High end industrial automation components. Sensors (proximity, photoelectric), solid-state relays, and motor controllers.
Crossbow Technology, Inc. www.xbow.com Crossbow is into industrial sensors. Among their product line are inertial and gyro systems, accelerometers, wireless sensor networks, tilt sensors, and magnetometers.
RoboResources.qxd
1/3/2005
1:26 PM
Page 13
ROBOTICS RESOURCES Davis INOTEK www.inotek.com Sensors (Omron proximity, others), test equipment, and RFID.
Entran Devices, Inc. www.entran.com Manufacturer of strain gauges, load cells, accelerometers, and pressure sensors — not cheap. The website is in English, French, German, and Spanish.
Honeywell International, Inc. www.honeywell.com Honeywell is a manufacturer of automation and control products. Several of their products are available through distributors. The company also sells some products direct.
Measurement Specialties, Inc. www.measurementspecialties. com Measurement Specialties makes and sells sensors, particularly peizo sensors using Kynar plastic. These sensors can be used for such things as ultrasonic measurement, touch or vibration sensors, and as accelerometers. The company provides online buying, but the minimum order is $100.00. Some of their products are also sold by other distributors.
Murata Manufacturing Co. www.murata.com Makers of pyroelectric infrared sensors, peizoelectric gyroscopes, peizoelectric ceramics sensors, thermistors, magnetic pattern recognition sensors, shock sensors, and peizoelectric sound components. Lots and lots of data sheets. Offices are in Japan, North America, and Europe.
Robot Electronics www.robot-electronics.co.uk Robot Electronics — also known as Devantech — manufactures unique and affordable robotic components, including miniature ultrasonic sensors, an electronic compass, and a 50 amp H-bridge for motor control. The company’s SRF08 high performance ultrasonic rangefinder
module can be connected to almost any computer or microcontroller and provides real time, continuous distance measurements using ultrasonics. The measurement values are sent as digital signals and are selectable between microseconds, millimeters, or inches.
SensComp www.senscomp.com Ultrasonic sensors, including (what were) the Polaroid electrostatic transducers and driver boards. SensComp bought out the Polaroid division that made these transducers and is now the source for these excellent products.
Sensors, Inc. www.sensorsincorporated.com Sensors, what else? Online retailer/ distributor for Hohner (encoders), Carlo Gavazzi (proximity), CutlerHammer, SICK, and others.
SICK, Inc. www.sickoptic.com SICK is a manufacturer of high end industrial sensors and electronic measurement systems, including laser proximity scanners, barcoders, and 2-D laser radar. Technical white papers are available on the site.
Sunx Sensors USA www.sunx-ramco.com Specialty miniature sensors for industrial control applications: photoelectric, fiber optic, inductive proximity, micro-photo, laser beam, color and mark detection, ultraviolet, ultrasonic, pressure, and vacuum. Spec sheets are in Adobe Acrobat PDF.
Vishay Intertechnology, Inc. www.vishay.com Vishay is a leading manufacturer of all sorts of electronic components, including motion sensors, optical sensors, conductive plastic rotation sensors, and more. Their website lists the major categories of products — complete with PDF data sheets. Spend a few hours browsing and you’re sure to find some interesting stuff!
GPS Sensors GPS stands for global positioning satellite, a system of special communications satellites used to pinpoint locations on the ground. Though once strictly for use by the military and select commercial applications, GPS systems are now routinely available for consumer use. Several GPS receivers come ready-made for connection directly to a computer, which — with
yEngineering HobbyEngineering
The The technology technology builder's builder's source source for for kits, kits, components, components, supplies, supplies, tools, tools, books books and and education. education.
Robot Robot Kits Kits For For All All Skill Skill Levels Levels
ICs, ICs, Transistors, Transistors, Project Project Kits Kits Motors, Motors, Frame Frame Components Components and and Scratch Scratch Builder Builder Supplies. Supplies. Order Orderby byInternet, Internet,phone, phone,fax faxor ormail. mail.
www.HobbyEngineering.com www.HobbyEngineering.com
Books Books and and Educational KK
ponents BEAM Kits and Components
1-866-ROBOT-50 1-866-ROBOT-50 1-866-762-6850 1-866-762-6850 1-650-552-9925 1-650-552-9925 1-650-259-9590 1-650-259-9590 (fax) (fax)
[email protected] [email protected] 180 180 El El Camino Camino Real Real Millbrae, Millbrae, CA CA 94030 94030
Visit Visit our our store store near near SFO! SFO!
Most Most orders orders ship ship the the day day received! received! World-wide World-wide shipping. shipping. Convenient Convenient pay payment options..
SERVO 02.2005
13
RoboResources.qxd
1/3/2005
1:29 PM
Page 14
ROBOTICS RESOURCES proper software — can interpret the positioning signals. GPS receivers can be used with outdoor robots to give them a sense of exactly where they are in the world.
positioning satellite (GPS) equipment, including receivers, antennas, differential GPS modules, OEM GPS kits, and books. They also provide seminars on GPS.
Garmin, Ltd. www.garmin.com
Synergy Systems, LLP www.synergy-gps.com
Garmin is a major manufacturer of GPS systems, including OEM modules. A popular GPS unit that is used in robots is the eTrex miniature GPS handheld. You can buy accessories (data cables, mounting brackets, etc.) from Garmin, but the GPS units themselves are only sold through resellers. Online resellers include GPS City, GPS Discount, and others.
OEM and board level GPS systems, using Motorola modules. Sells starter kits for quick prototyping and developing.
GPS City www.gpscity.com Sells GPS units for all occasions. Among many products, they sell the Garmin GPS 35 OEM sensor, which can be connected to any PC or microcontroller through an RS-232 serial interface.
Lowrance Electronics, Inc. www.lowrance.com Lowrance is in the business of GPS and sonar devices. Check out their GPS Tutorial.
Magellan/Thales Navigation www.magellangps.com Manufacturer of GPS systems.
National Marine Electronics Association (NMEA) www.nmea.org A technical association that helps set standards for marine electronics. One such standard of importance to amateur robot builders is NMEA0183. This is a voluntary standard followed by many manufacturers of global positioning satellite receivers. It allows the GPS module to interface with other electronics, such as a computer.
Navtech Seminars and GPS Supply www.navtechgps.com Navtech is a reseller of global
14
Circle #25 on the Reader Service Card.
Optical Sensors Optical sensors use light to detect objects. Depending on the sensor technology used, it’s possible to use light to not only determine if an object is near (proximity), but also how far away an object is (distance). These resources specialize in optical sensors, which include infrared, passive infrared (like the kind used in motion detectors), and ultraviolet. Each variation has its own unique applications.
Glolab Corp. www.glolab.com Glolab manufactures and sells multi-channel wireless transmitters and receivers, along with encoder and decoder modules (to permit controlling more than one device through a wireless link). They also provide pyroelectric infrared sensors and suitable Fresnel lenses. An amplifier and hook-up diagram for the PIR sensor are available on the site.
Hamamatsu Corp. www.hamamatsu.com The main Japan office is listed; the web page is provided in many languages and local offices are in many countries, including the US, France, the UK, Germany, and Italy. Provides: photonics detectors, flame detectors, photo-multiplier tubes, imaging systems, and optical linear arrays. Products are available in limited sample quantities and are sold through distributors. Some items of particular interest are (app notes provided for many sensor types): flame
RoboResources.qxd
1/5/2005
10:47 AM
Page 15
ROBOTICS RESOURCES sensors (UV TRON), CdS photoconductive cells, infrared detectors, and photo ICs.
RFID, Inc. www.rfidinc.com
Leica Disto www.disto.com
Makers and sellers of RFID receivers and transponder tags. Offer relatively inexpensive starter kits with sampler tags and receiver.
Manufacturers of handheld laser range finders. The cost isn’t exactly cheap, but reasonable for a high end bot. Part of the worldwide Leica Geosystems group (address provided is for the US office); products are available from distributors or online.
RFID Sensors RFID stands for radio frequency identification, which is a kind of sensor that is similar in purpose to barcodes, but is meant to operate over longer distances, and even through other objects. (Implantable biochips — like the kind used for pets and now people — are miniature RFID units.) Applications in robotics are both obvious and numerous: you can use RFID for robot-to-robot identification, robot-tohuman identification, navigation, beacon systems, and much more. A benefit of RFID is that the sensitivity of the reader electronics can be varied, so that you can directly control maximum working distances. In this way, a room could be full of RFID elements, yet your robot will only “see” the one closest to it. As yet, there are few RFID systems within affordable reach of most amateur robot builders; still, it’s an interesting technology and it’s only a matter of time (perhaps just months) before affordable entry-level solutions become available. If nothing else, you can use the resources to learn more about this technology.
Strain Gauges and Load Cells Strain gauge sensors — and their close cousin, the load cell — are used to measure a variety of physical attributes, including pressure, torque, tension, and bending. They are routinely used in commercial products, such as bathroom scales and automotive digital torque wrenches. Though industrial strain gauges and load cells are quite expensive (upwards of $500.00 for even a basic unit), there are a number of sources for low precision sensors that are quite well-suited for robotics. These and other sources for strain gauges and load cells are provided here. (However, note that possible minimum order requirements exist.)
Interlink Electronics, Inc. www.interlinkelec.com Touch sensors and pads for laptop mice. The touch sensors use strain gauge (they call it a force sensing resistor) technology. They sell developer’s kits online (though they’re
CopyTag Limited www.copytag.com Makers of RFID receivers and tags (transponders).
Microchip Technology www.microchip.com Microchip makes a broad line of semiconductors, including the venerable PICmicro microcontrollers. Their website contains many data sheets and application notes on using these controllers and you should be sure to download and save them for study. The company is also involved with RFID, selling readers and tags, as well as developer’s kits.
OMRON Corp www.omron.com Omron is a multi-talented company, manufacturing a wide array of sensors and semiconductors. Of note are their RFID tags and readers and machine vision products: RFID — www.omron.com/card/rfid/ Machine vision — http://oeiweb.omron.com/machinevision.shtm Circle #37 on the Reader Service Card.
15
RoboResources.qxd
1/3/2005
1:31 PM
Page 16
ROBOTICS RESOURCES a bit expensive) and provide free literature on how it all works. The company also manufacturers and sells (via their online store) consumer products, including keyboards and mice.
Measurement Systems, Inc. www.measurementsystemsinc. com
Semtech Corporation www.semtech.com Makers of encoders for “pointing stick” style laptop strain gauge pointing devices. The website offers data sheets and application notes. Items are available in sample quantities and from distributors.
The popular 1490 outputs eight digital compass positions (N-NE-E-SE-S-SW-WNW). The 1525 sensor outputs a continuous analog sine/cosine signal capable of being decoded to any degree of accuracy.
Figaro USA, Inc. www.figarosensor.com
Manufacturer of joysticks and miniature joysticks.
Miscellaneous Sensors
Makers of toxic gas and oxygen sensors.
OMEGA Engineering, Inc. www.omega.com
The following are makers and sellers of miscellaneous sensor types, such as optical mouse sensors, magnetic sensors, and toxic gas sensors.
PNI Corp./Precision Navigation www.pnicorp.com
Agilent Technologies, Inc. www.semiconductor.agilent.com
TAOS www.taosinc.com
Makes and sells unique optical sensors for use in desktop computer mice.
TAOS manufactures low cost optical array and colormetric sensors. Their linear sensors can be used in such applications as line following, pattern recognition, and odometry. The color sensors detect the color of objects and can be used for rudimentary object recognition. Parallax (www. parallax.com) packages the TAOS TCS230 color sensor on a convenient project board for use with the BASIC Stamp and general robotics projects.
Omega makes sensors and data acquisition equipment. Of primary importance to us robo-builders are their line of low cost, general-purpose strain gauges. These miniature sensors can be used to indicate stress or strain on an object, like the pad of a foot in a walking robot. The sensors are sold in packs of 10 and their per-piece cost is $5.00 to $8.00 for many sizes. This is considerably less than the average strain gauge that is designed for super-precise industrial measurements. The company website provides copious amounts of data sheets, app notes, and engineering articles.
Banner Engineering Corp. www.bannerengineering.com Manufacturer of industrial photoelectric and fiberoptic sensors.
Dinsmore Instrument Co. www.dinsmoresensors.com Dinsmore manufactures inexpensive digital and analog compass sensors.
FIGURE 1. TAOS provides a variety of unusual (yet reasonably priced) imaging and color sensors.
PNI makes compass, radar, magnetometer, and inclinometer sensors.
Xilor, Inc. www.rfmicrolink.com Check out their ZOFLEX ZL series material — a pressure-activated conductive rubber. According to the website, the resistance change with pressure is very drastic. The material is at high resistance (30 Mohms) when pressure is below the actuation pressure. Resistance drops to 0.1 ohms or less when the material is at or above the activation pressure. The pressure required is too much for a “soft touch” sensor, but other applications are possible. SV
About the Author Gordon McComb is the author of several best-sellers about robotics. In addition to writing books, he operates www.budgetrobotics.com which is dedicated to low-cost amateur robotics. He can also be reached at
[email protected]
16
SERVO 02.2005
AssemblyLine.qxd
1/3/2005
1:17 PM
Page 17
by James Antonakos
Part Inspection — Round # 1: The Miniature Components
L
ast time, we examined the five requirements for the Uno robot design — an update of a 1950s light-sensing, collision-detecting robot. Two of the five requirements developed for the Uno robot project are listed in Table 1. These two requirements both utilize miniature electronic components. One source of electronic components is Jameco Electronics (www.jameco.com). Jameco’s online catalog makes it easy to locate any item in their large inventory. Table 2 shows the Jameco information for the miniature components identified in Table 1. Figure 1 shows the actual size of the two components. Their miniature nature suggests that care should be used when working with them. This includes handling (dropping them or bending the leads excessively), construction (lead soldering time and temperature must be limited), and operation (proper amount of biasing current). When the parts arrived in the mail from Jameco, it was too tempting to resist playing with them. In particular, a series of tests was performed on the photocell, all designed to watch its resistance change in relation to the amount of light presented. A digital ohmmeter was connected across the photocell and the photocell was placed 6 feet from an ordinary 40
W light bulb. With the surface of the photocell facing the light bulb, the resistance measured 7.6K ohms. Leaving the photocell alone, the 40 W bulb was replaced with a 100 W bulb. The new photocell resistance measured 4.4K ohms. The resistance dropped due to an increasce in the light intensity. Grabbing a very bright flashlight and shining it directly into the photocell from only inches away caused the photocell resistance to drop to 150 ohms. Again, the brighter the light intensity, the smaller the resistance. This is because the material used to Requirement
construct the photocell is receptive to the photons that make up light. More photons mean more energy, which leads to more current flow (and, thus, less resistance). With all lights off, the photocell measured 300K ohms. As we might now expect, the dimmest light has produced the largest resistance. Table 3 summarizes these intensity results. The initial intensity results from Table 3 show what we might expect to see as a maximum range of operation for the photocell. Remember that Uno will be in a room with at least one bulb illuminated, so we will never Uno Component
Seek a light source
A photoresistor for sensing brightness. An analog-to-digital converter will digitize the intensity level.
React when encountering an obstacle
Tilt switch used to detect the bump of a collision with an obstacle.
Table 1. Two miniature-sized components used in Uno’s construction. Component
Part Number
Description
Price
Photocell
202366
CDS (Cadmium Sulfide) Photocell 90 mW, 150 Vp. 0.3 M min dark
$1.69
Tilt Switch
235926
Switch,Tilt,Vibration sensor SPDT 0.5 A, 24 VDC
$1.49
Note that Jameco refers to photocells and not photoresistors, but that these two terms are interchangeable. Table 2. Jameco Electronics catalog information.
SERVO 02.2005
17
AssemblyLine.qxd
1/4/2005
12:59 PM
Page 18
THE ASS EMB L Y L INE Light Intensity
Photocell Resistance
Dark room
300K ohms
40 W bulb at 6 feet
7.6K ohms
100 W bulb at 6 feet
4.4K ohms
Flashlight from inches away
150 ohms
Table 3. Initial intensity versus resistance test results. Figure 1.To the left of the dime is the tile switch sensor. On the right is the CDS photocell.
approach the dark resistance of 300K ohms. A second test was performed on the photocell to see how resistance changed as a function of distance. In this test, a single 40 W bulb was used. The photocell was moved to various distances and its resistance was recorded. These values are shown in Table 4. The nice spread of resistance indicates that we will easily be able to sense when the light intensity is changing. The last test performed on the photocell checked its response to the angle of light rays striking its surface. Here, the photocell was moved so that light struck it at 0°, 30°, 45°, 60°, and 90°. A 40 W bulb was kept at a distance of Distance
Photocell Resistance (Ohms)
6 feet during the test. Table 5 shows the results. Clearly, light must fall directly on the photocell to have the greatest effect. It was interesting to see that — even with the photocell facing totally away from the 40 W bulb — there was still only 23 K ohms of resistance, much less than the 300 K ohms when there is no light at all. One more aspect of the photocell requires investigation. Recall from Table 2 that the rated power for the photocell is 90 mW. Let us think about what this means. Suppose you want to put the photocell into a 5 volt biasing circuit and the design allows all of the 5 volts to develop across the photocell. Furthermore, suppose we are shining a bright light on the photocell when there is 5 volts across it. The low resistance of the photocell (100 ohms, see Table 4) will cause 250 mW of power to be delivered: P=
V2 5V2 = = 250 mW R 100Ω
2 inches
100
1 ft
675
2 ft
1.1K
3 ft
2.5K
4 ft
3.6K
5 ft
5.8K
6 ft
7.8K
0
5K ohms
7 ft
8.7K
30
5.1K ohms
8 ft
10.7K
45
5.8K ohms
9 ft
11.3K
60
6.2K ohms
10 ft
13K
90
9.5K ohms
20 ft
35K
180
23K ohms
Table 4. Resistance change for each foot of distance from photocell.
18
SERVO 02.2005
That will surely do a nice job of burning up the unfortunate photocell, which is only rated for 90 mW, maximum. Thus, care must be used in our Angle (Degrees) Photocell Resistance
Table 5. Effect of angle of incidence on photocell resistance.
biasing circuit so that the maximum power delivered to the photocell is always less than 90 mW. If we limit the power to 45 mW (operate at half-load to extend the device’s life), we can solve the power equation backward to find the maximum voltage allowed across the photocell (for its 100 ohm operating point at high intensity): V = √P•R = √45 mW•100Ω = 2.1 V Knowing the limits, we can then design the biasing circuit in a way that protects the photocell while still leaving it sensitive to light. The tile switch is a fascinating device. If its body is tilted above the horizontal axis, its internal switch closes and there is a low resistance (around 1 ohm) between the device terminals. However, tilt the body of the device down so that its axis is below the horizontal and the switch opens up. Thus, we have a straightforward binary condition: Tilted = Closed, Not-tilted = Open. The leads of the tilt sensor are springy. This will allow us to mount it so that any collisions will cause it to temporarily spring into the tilted position, then spring back to its normal, untilted position. Next up will be the motors and the microcontroller and all of the required interfacing. When the hardware interface is finished, the software design will take over. SV
ABOUT THE AUTHOR James Antonakos is a Professor in the Departments of Electrical Engineering Technology and Computer Studies at Broome Community College. You may reach him at antonakos_j@ sunybroome.edu or visit his website at www.sunybroome.edu/~antonakos_j
Grau1.qxd
1/3/2005
3:03 PM
Page 19
by Steve Grau
W
hen it comes to building hobby robots, there are many great resources and products you can rely on for the mechanics and electronics that will become your robot. Whether it’s a chassis, wheels, motors, a compass, a range sensor, or a controller board, there is no shortage of products to choose from. However, when it comes to the software that will form your robot’s intelligence, the choices are much more limited. Few plug-and-play software components exist. Without pre-built software components, you must either write all of your robot’s control software from scratch or cobble it together by modifying and integrating various snippets of code others have published. With the advent of several object-oriented programming languages — Java™ and C# (pronounced C sharp) — the software industry has made great strides in moving toward industry-wide reuse of pre-built components. Both of these languages provide the ability to build and package software components that can be used in a wide range of applications without modification. This is the first in a series of tutorials on building reusable robotics software components. In each article, we will develop new components that add to the intelligence of a robot named the RidgeWarrior II. A few of the interesting components we will develop are: a shaft encoder to measure wheel rotation using an infrared photoreflector sensor, an odometer to keep track of a robot’s position, and a navigator to successfully move a robot from place to place. We will strive to make the components reusable, so you can put them to use in other robotics projects.
The Robot Platform The focus of this series is building software components; therefore, we will use an off-the-shelf kit — the IntelliBrain™Bot kit from RidgeSoft (www.ridgesoft.com) — as the chassis and controller for the RidgeWarrior II, rather than
Figure 1 delving into the mechanical and electronic aspects of building robots. An assembled IntelliBrain-Bot is shown in Figure 1. The IntelliBrain robotics controller will provide the brain-power for our RidgeWarrior II robot. This controller will allow us to implement software using a modern, objectoriented programming language — Java. In addition to its object-oriented nature, Java has built-in support for multi-threading and floating point arithmetic — both features that will facilitate creating interesting robotics software components that are reusable.
A Little Background The RidgeWarrior II robot we will be developing is a follow -up to the original RidgeWarrior robot, which was modeled after the Rug Warrior robot discussed in the book Mobile Robots: Inspiration to Implementation by Jones, Flynn, and Seiger. The Rug Warrior robot was based on the Motorola 68HC11 microcontroller and the Interactive C programming language to implement a behavior-based robot. The original RidgeWarrior robot used the MIT Handy Board controller, also based on the 68HC11 microcontroller, but it was programmed in Java using the RoboJDE™ robotics software development environment instead of Interactive C. For the RidgeWarrior II robot, we will use the IntelliBrain robotics controller, which is similar in functionality to the Handy Board, but is based on the Atmel ATmega128 microcontroller. The IntelliBrain controller has significantly more computing power and memory than the Handy Board, which will allow us to take greater advantage of Java’s object-oriented programming and multi-threading features. The IntelliBrain-Bot kit is the combination of the Parallax Boe-Bot™ chassis and the IntelliBrain robotics controller. As we program the RidgeWarrior II, we will build on software SERVO 02.2005
19
Grau1.qxd
1/3/2005
3:05 PM
Page 20
Creating Reusable Robotic Software Components components that already exist in the RoboJDE library and we will create our own new software components.
be built once, packaged, and shared without end users needing to be concerned about any of these things.
Creating Reusable Software Components
Enough Theory!
Our goal is to create software components that are both useful and easy to reuse in future robotics projects without modification. Three keys to achieve this goal are: 1. Creating components that are cohesive and provide useful functionality. 2. Creating the components such that they have minimal interdependencies — in other words, they are loosely coupled to the rest of the system. 3. Designing generic interfaces to components that promote interchangeability. The hobby servo is a wonderful electromechanical example of a reusable hardware component exhibiting these three characteristics. A motor, gears, electronics, and packaging form a cohesive component: a servo. It provides a very useful function — a controllable means for converting electrical energy to motion. While the servo packs a lot of functionality into a small package, it does so in a way that allows it to be loosely coupled to the rest of the robot. Furthermore, servos implement a simple, generic interface to other components of the system: three wires for power and control, a rectangular case with four mounting tabs, and an output shaft with splines. The simplicity and utility of this interface has facilitated a multitude of interoperable and interchangeable products. Unfortunately, there aren’t many robotics software components that hobbyists can incorporate into their projects as easily as they can incorporate hobby servos and other popular mechanical and electronic components. To date, many of the most popular robotics software development tools and languages have lacked built-in features to facilitate creation and reuse of software components. Fortunately, Java does!
Java and Software Reusability Java was designed from the ground up to support objectoriented programming, a software development paradigm that is ideal for developing cohesive software components and loosely coupled software systems. In addition to being object-oriented, Java supports multi-threading, making it much easier to implement multi-tasking, real time systems — such as a robot — with minimal coupling between components. Java has a built-in mechanism for defining and using software interfaces, allowing a variety of software components that implement an interface to be used interchangeably. Java also provides a means to share pre-built software components without dependencies on vendor specific development tools — like a compiler or assembler — or dependencies on a specific microcontroller. Instead, pre-built components can
20
SERVO 02.2005
Okay, you’re probably ready to get on with creating some components. We will skip over the robot assembly and other “getting started” steps, as these things are described in detail in the IntelliBrain-Bot Assembly Guide, the IntelliBrain User Guide, and the RoboJDE User Guide, all of which come on CDROM in the IntelliBrain-Bot kit and are also available on RidgeSoft’s website. Throughout this series, we will develop a number of interesting software components for the RidgeWarrior II robot. Let’s start by developing a few components to create a user interface framework. By developing the user interface framework first, we will be able to use it throughout the project to test and debug other components we build.
User Interface Requirements As with anything, there are many ways to implement a user interface. For this project, we will implement our user interface based on the following requirements: 1. Display output using the IntelliBrain controller’s two line LCD module. 2. Provide for multiple screens displaying different groups of data. 3. Allow the active screen to be selected using the IntelliBrain controller’s thumbwheel while the program is running. 4. Periodically update the currently displayed screen without interfering with what the robot is otherwise doing. 5. Allow the robot operator to select one of several preprogrammed functions for the robot to perform. The RoboJDE class library — which contains foundation software components (Java classes) — provides a class named “Display.” This class interfaces to the IntelliBrain’s LCD display and provides a method for printing text strings to either of the two lines of the display. We need to add the ability to create multiple screens. Each screen must have the ability to display its data on the screen when it is told to update the display. To accomplish this, the screen interface only needs one function — or “method,” as they are typically called in object-oriented programming languages. We will name this method “update” and create the following generic definition for a “Screen” class: public interface Screen { public void update(Display display); }
With Java, the source code for a class or interface is normally stored in its own file with a “.java” extension. Therefore, our newly defined interface should be in its own file, named
Grau1.qxd
1/4/2005
2:02 PM
Page 21
“Screen.java.” We can create this file with RoboJDE using the File->New Class menu item and entering the name “Screen” as the class name. One other thing we have to do is let the Java compiler know where to import the Display object from. We do this by adding an import statement at the beginning of the file. The complete code for the class is:
ur o Y FY ings! I N v MAtGical Sa Op
a division of Edmund Optics
! NEW
import com.ridgesoft.io.Display; public interface Screen { public void update(Display display); }
Now that we’ve defined the Screen interface, it’s time to create a class that implements it. Let’s create a screen class that just displays two lines of unchanging text. This will enable us to have the program display its name and version number. We can do this by again using RoboJDE’s File->New Class menu item and creating the “StaticTextScreen” class, as follows: import com.ridgesoft.io.Display; public class StaticTextScreen implements Screen { private String mLine1; private String mLine2;
EXPERIMENTAL & COMMERCIAL GRADE LENSES
l for or cal log! e n i l on cata Order ree optics f
✓ Start Up ✓ Research ✓ Prototype ✓ Single Unit Applications ✓ Educational Applications ✓ Initial Run Requirements Over 5000 seconds, overruns & overstocks ready for delivery at big savings!
ANCHOR OPTICAL SURPLUS www.AnchorOptical.com
public StaticTextScreen(String line1, String line2) { mLine1 = line1; mLine2 = line2;
.
Dept. B051-X914, 101 E. Gloucester Pike, Barrington, NJ 08007 Tel:1-856-573-6865 Fax:1-856-546-1965 E-mail:
[email protected] Circle #44 on the Reader Service Card.
} public void update(Display display) { display.print(0, mLine1); display.print(1, mLine2); } }
Because this class declares that it implements the “Screen” interface, it is required to implement the “update” method defined by the Screen interface. Our update method simply prints predefined text strings to each line of the display. In addition to the required method, our class also defines two member variables: private String mLine1; private String mLine2;
which refer to each of the strings and a constructor: public StaticTextScreen(String line1, String line2) { mLine1 = line1; mLine2 = line2; }
which allows an instance of a StaticTextScreen to be created and initialized.
Managing Multiple Screens Our next step is to create a class that will manage several
screens and allow selection among screens to display while the program is running. We will create a Java class named “ScreenManager” to do this. We will extend Java’s “Thread” class, which is part of the base Java class library. This will allow the screen updating code to be implemented independent of other portions of the program. Running different parts of a program on different threads really makes it much easier to create components that are loosely coupled and easy to reuse. Java’s threading system takes care of scheduling when each thread runs and allows higher priority threads to preempt lower priority threads. In a single threaded system, we would need to write code to manage the scheduling and prioritization of the robot’s activities. We would also need to write the program in such a way that screen updates wouldn’t interfere with other more important and time critical tasks, like avoiding running into a wall. Instead, we will just give the ScreenManager thread a low priority, so it will only execute when there isn’t anything more important to do. We will need to create the ScreenManager class, similar to how we created the StaticTextScreen class. We will need to declare that the ScreenManager extends the Thread class as follows: public class ScreenManager extends Thread
We also need to create member variables to keep track of the Display object, the list (array) of screens that can be displayed, and the input that will be used to select which SERVO 02.2005
21
BrainMatrix.qxd
1/3/2005
3:30 PM
Page 24
budget digital multimeters e nc ita ac ap C e nc ta sis Re y ac ur cc A nt re ur C y AC ac ur cc A nt re ur C C y D ac ur cc A ge lta Vo y AC ac ur cc A ge lta Vo C D el od M
B&K Precision www.bkprecision.com
e am tN uc od Pr
SUPPLIER
BK 2704B Tool Kit DMM Mini-Pro Multimeter
750
1.5 200 mA
1
2A
1.2
2405A
2
600
2.9
10 A
3
N/A
N/A 20 Mohm
600
Fluke www.fluke.com
Protek www.protektest.com
20 µF
0.9
600
1.9
10 A
1.5
10 A
2.5
Digital Multimeter
M-2785 750
0.5
750
1
20 A
1
20 A
1.5 200 Mohm 200 µF
MV110 MultiView Series MV110 1,000 0.5 Digital Multimeter
750
0.8
2A
1.2
2A
1.8 200 Mohm
700
1.5
20 A
1.2
20 A
2
0.7
600
1
20 A
1
10 A
1.5
40 Mohm
9,999 µF
D980 1,000 0.5
750
2
30 Mohm
N/A
Fluke 110 Digital Multimeter 3-3/4 Digit 3,200 Count Value-Priced DMM With Bargraph 2,000 Count, Advanced DMM
RadioShack www.radioshack.com
N/A
M-1700 600
MultiPro Multimeter
MT310 1,000 0.5 110
410
600
1,000 0.8
750
1.2 300 mA 1.2 300 mA
1
10 A
20 Mohm
20 µF
Digital Multimeter Elenco www.elenco.com
Extech www.extech.com
20 Mohm
2704B 1,000 0.5
N/A
40 Mohm 100 µF
1
10 A
2
20 Mohm
N/A
2
N/A
N/A
2 Mohm
N/A
15 Range Digital Multimeter
22-810 500
0.8
500
1.5 200 mA
29 Range Digital Multimeter
22-813 600
0.8
600
1.2
10 A
1.5
10 A
2
40 Mohm
N/A
42 Range Digital Multimeter With Electric 22-811 600 ±0.8% 600 ±1% Field Detection
10 A
1
10 A
1.2
4 Mohm
400 µF
2
20 Mohm
N/A
2.5
40 Mohm
4,000 µF
5XP Digital Multimeter
5XP
1,000
1
35XP Digital Multimeter
35XP 1,000 0.5
750
1.5 200 mA 1.5 200 mA
750
1.5
Wavetek www.metermantesttools.com
24
SERVO 02.2005
2A
2
2A
BrainMatrix.qxd
1/4/2005
12:48 PM
Page 25
by Pete Miles
Upcoming topics include SBCs and H-bridges, sensors, kits, and actuators. If you’re a manufacturer of one of these items, please send your product information to:
[email protected] Disclaimer: Pete Miles and the publishers strive to present the most accurate data possible in this comparison chart. Neither is responsible for errors or omissions. In the spirit of this information reference, we encourage readers to check with manufacturers for the latest product specs and pricing before proceeding with a design. In addition, readers should not interpret the printing order as any form of preference; products may be listed randomly or alphabetically by either company or product name.
) (g
e ic Pr st Li
oz t, gh ei W
er w Po
s rie so es cc A
m ,m ns sio en im D
rd da an St
e od M ff O t o es ut A rT to ld sis o H an Tr ata re D tu ra pe er m nd Te tU es ck yT he C er tt k ty ui Ba ec h tin C e on y C od i nc D ue eq Fr
Yes
No
No
No
Yes
No
Test Leads, Battery, Rubber Boot Protection
9V
150 x 79 x 33
Yes
No
Yes
No
No
No
No
Test Leads, Battery
9V
143 x 68 x 47
20 MHz Yes
Yes
No
No
No
Yes
No
Holster,Test Leads, Fuse, Battery
9V
151 x 70 x 38
7 (200)
$49.95
20 MHz Yes
Yes
No
No
Yes
Yes 30 min Test Leads, Rubber Holster
9V
90 x 190 x 35
12 (340)
$66.50
Yes
Yes
Yes
No
No
Yes 15 min
9V
189 x 85 x 32
9.7 (300) $39.00
10 MHz Yes
Yes
No
No
Yes
No 30 min Test Leads, Rubber Holster
9V
88 x 178 x 33
11 (315)
50 kHz Yes
Yes
No
No
Yes
No 20 min
Holster,Test Leads, Battery
9V
15 MHz Yes N/A
N/A
Test Leads
9 (250)
$59.00
7.3 (200) $27.00
$79.00
460 x 960 x 160 12 (350) $109.00
N/A
Yes
Yes
No
No
Yes
No
No
Test Leads, Holster
2 x AAA
165 x 76 x 38
11 (300)
$75.00
N/A
Yes
Yes
No
Yes
Yes
Yes
No
Test Leads with Aligator Clips,Type K Thermal Couple
9V
178 x 84 x 33
9 (250)
$31.00
N/A
Yes
No
No
No
No
No 30 min
Test Leads, Case
12 V
118 x 80 x 18
N/A
Yes
Yes
Yes
No
Yes
No 30 min
Test Leads, Fuse
3 x AAA
150 x 74 x 38
4 MHz Yes
Yes
No
No
Yes
No 30 min
Test Leads, Fuse
9V
Yes
Yes
Yes
No
Yes
No
Holster,Test Leads, Battery, Fuse, Magnetic Strap
9V
155 x 72 x 32
7.4 (210) $39.95
40 MHz Yes
Yes
No
Yes
Yes
Holster,Test Leads, Battery, No 10 min Fuse, Magnetic Strap,Type K Thermal Couple
9V
155 x 72 x 32
14 (400)
N/A
No
3.5 (100) $19.99 6 (170)
$29.99
161 x 80 x 39.5 6.8 (195) $49.99
$79.95
SERVO 02.2005
25
Best.qxd
1/5/2005
2:45 PM
Page 26
Step Up to the Motorvator. Step Up to the Motorvator. Step Up to the Moto
Best.qxd
1/5/2005
2:47 PM
Page 27
p to the Motorvator. Step Up to the Motorvator. Step Up to the Motorvator.
STEP Up to the Motorvator by Peter Best riving a stepper motor with a microcontroller is pretty much old hat these days, as there are a multitude of Internet entries that tell you exactly how to make that happen. That’s great if just wildly turning the shaft of the stepper motor is all you want to do. If you plan to use the stepper motor in an application that requires precision control of the angular motion generated by the stepper motor, you’ll have to add a bit more code to those basic sequence-oriented motor driver routines that you downloaded from the net. In addition to writing some pretty hairy stepper motor driver code, you’ll have to put on your highvoltage-high-current-analog-digital hardware designer’s hat, as well.
D
For precision applications, just driving a MOSFET or transistor switch circuit for each stepper motor winding with basic stepper motor sequence code won’t cut it. You’ll need some extra external hardware to make sure the stepper motor goes where you want it to go and stops where you want it to stop. Also, you’ve got to do this without burning up the motor windings or smoking your motor drive electronics. The burden of designing an X-Y stepper motor driver system is doubled as your application is running both X and Y axes, which requires two motors, two motor drivers, plus the common driver firmware, and the microcontroller or pair of microcontrollers to oversee it all. If precision positioning in two dimensions is your goal, chances are you’ll need a minimum of two stepper motors, which dictate the use of the equivalent of a pair of stepper motor drivers. For those of you out there who have visions of home-brew precision X-Y tables, getting past the electronic hardware design can be just as tough as writing the firmware for your mechanical X-Y table design. I can’t help each of you with the unique mechanics of your particular X-Y table design, but I can “step” you through the design and realization of a dual microstepping stepper motor driver based on a pair of Allegro Semiconductor’s A3977SED Microstepping DMOS Driver/Translators. SERVO 02.2005
27
Best.qxd
1/3/2005
2:36 PM
Page 28
Step Up to the Motorvator. Step Up to the Motorvator. Step Up to the Moto The A3977SED Although the bulk of the on-chip A3977SED analog and digital subsystems are important support structures for driving the A3977SED’s pair of internal low rDS(on) DMOS H-bridges, the A3977SED translator subsystem puts the A3977SED in a stepper motor driver IC class of its own. The A3977SED translator subsystem eliminates the need for additional microcontroller firmware and I/O lines that must be incorporated to realize complete control of motor step and direction when using other stepper motor driver ICs. Without a translator, the stepper motor driver designer must incorporate DACs (Digital to Analog Converters), comparators, and various low-pass filters to regulate and control PWM (Pulse Width Modulation) current flow to the stepper motor being driven. Incorporating the A3977SED into your stepper motor design virtually eliminates the need for the external components and circuitry I just mentioned. A simple low-to-high logical transition applied to the A3977SED’s translator STEP input pin results in a single step or microstep of the bipolar stepper motor under tow behind the pair of A3977SED DMOS H-bridges. Changing the stepper motor’s rotational direction using an A3977SED is just as easy. Clockwise or counterclockwise motor rotation is achieved by presenting a logical high or logical low to the A3977SED’s translator DIR input pin. The A3977SED logic subsystems can be powered by voltages in
the range of +3.0 VDC to +5.5 VDC and draw very little current. That makes the A3977SED compatible with most any microcontroller you want to include in your stepper motor driver design. Being able to easily drive your stepper motor in full step mode has advantages in certain situations. However, the ability to microstep your stepper motor is an absolute necessity if you want to move an axis of your X-Y table with extreme precision. So, in addition to being capable of driving a stepper motor in its native full step mode, the A3977SED translator provides a pair of microstepping inputs (MS1 and MS2) that — when stimulated with a predetermined pattern of logical input voltages — force the bipolar stepper motor being driven to operate in full-, half-, quarter-, or eighth-step modes. The microstepping truth table for the MS1 and MS2 translator inputs is shown here: MS1 L H L H
MS2 L L H H
Resolution Full Step Half Step Quarter Step Eighth Step
28
SERVO 02.2005
-
+
GATE DRIVE
CONTROL LOGIC
TRANSLATOR
VCP
-
+
CP1
VREG
CP2
The A3977SED translator is also capable of shutting down the DMOS H-bridge outputs and setting itself to a known state, which is referred to as the home state in the Allegro documentation. This is done by applying a logical low to the translator’s RESET pin. While in the RESET mode FIGURE 1. This is a simplified block diagram of the A3977SED internals. It looks busy until you understand what everything really does. (RESET pin held low), the translator’s HOME output signal LOAD SUPPLY goes low and all STEP inputs are ignored. The A3977SED HOME 2V REGULATOR VCP signal is not really a physical VDD CHARGE PUMP UVLO AND FAULT BANDGAP “position,” but is a unique state VBB1 in which the stepper motor coil SENSE1 REF positive phase currents are DAC DMOS H BRIDGE balanced evenly. HOME is also the logical starting point for the RC1 translator. Changes to step STEPPER MOTOR PWM TIMER mode can be made while in the OUT1A 4 STEP OUT1B HOME state, as doing so will DIR RESET not disrupt the integrity of the MS1 driving current waveform. MS2 The rest of the A3977SED’s HOME SENSE1 tweakable knobs are linked VBB2 SLEEP directly to its internal control SR logic subsystem. An active low ENABLE ENABLE input enables all of the PFD OUT2A DMOS H-bridge outputs. Since PWM TIMER OUT2B RC2 the ENABLE input is under control of the A3977SED’s control 4 logic subsystem, all of the transDMOS H BRIDGE SENSE2 lator motion control inputs DAC (STEP, DIRECTION, MS1, and MS2) are active, even when the ENABLE pin is presented with a
Best.qxd
1/3/2005
2:38 PM
Page 29
p to the Motorvator. Step Up to the Motorvator. Step Up to the Motorvator. logical high, which disables the DMOS H-bridge outputs. By allowing the disabled state to coexist with an active translator state, you can step the stepper motor to a particular point in the physical X-Y axis movement program and then reenable the DMOS outputs at that point. In addition to the ENABLE input, the control logic subsystem is responsible for initiating SLEEP and WAKEUP states for the A3977SED’s internal logic. An active low SLEEP input to the on-chip control logic subsystem gives the stepper motor driver designer full control of the SLEEP and WAKEUP features of the A3977SED. Probably the most important job the control logic subsystem has is the management of the sequencing of the individual DMOS devices. This sequence management process is called synchronous rectification and is enabled by presenting a logical low to the control subsystem’s SR input pin. In most cases (including the design we will be discussing in this article), synchronous rectification eliminates the need for external current steering diodes. There are many other A3977SED internals we need to talk about and the best way to describe them is to examine them as we assemble some A3977SED-based stepper motor driver hardware that I call the Motorvator.
Designing and Building the Motorvator
PHOTO 1. The Motorvator PCB includes pads for external current steering diodes and a fully pinned out PIC18F8520 for those that want to walk on the wild side.
than its fixed-voltage cousins. The A3977SED is designed to drive a stepper motor from incoming motor voltages as high as +35 VDC at motor currents up to ±2.5 Amperes. With input motor voltages ranging from +8 VDC to +35 VDC, a pair of filter and bypass capacitors along with a couple of 1% tolerance resistors are all that you need to set the output of the LM317 at a rock-solid +5 VDC. The LM317 is capable of delivering up to 1 A of current to a load, when properly heatsinked. The Motorvator’s LM317 is mounted on a heatsink pad on the Motorvator PCB (printed circuit board). The PIC18F8520, the pair of
The Motorvator is centered around a PIC18F8520 that holds court over a pair of Allegro Semiconductor A3977SED stepper motor driver ICs. The PIC18F8520 is a member of Microchip’s 80-pin high-performance microcontroller family. Running at 40 MHz and packing 32K of program Flash, the FIGURE 2. The idea here is to convey that the step angle of the phase currents has absolutely nothing to do with the step angle of the stepper motor shaft. PIC18F8520 has more than enough I/O, data memory, analogRADIUS = 1 to-digital converter inputs, and sin(0°)=0.0 timers to control and even pick 0.0° cos(0°)=1.0 up after the pair of A3977SED 0.0° stepper motor drivers. sin(45°)=0.7071067811 Home State = 45° 45.0° cos(45°)=0.7071067811 As most of the motor 45.0° driving work will be done by the sin(90°)=1.0 90.0° A3977SED ICs, the PIC18F8520 cos(90°)=0.0 90.0° will be primarily concerned PHASE 1 with providing logic levels to CURRENT the A3977SED subsystems and (cos) acting as an interface between external controls (switches, potentiometers, etc.), the stepper motor driver ICs, and the stepper motors. Power for the A3977SED PHASE 2 logic and the PIC18F8520 is proCURRENT (sin) vided by an LM317 adjustable voltage regulator, which receives its raw input voltage from the motor power supply. The LM317 was chosen because of its ability to handle higher input voltages SERVO 02.2005
29
Best.qxd
1/3/2005
2:40 PM
Page 30
Step Up to the Motorvator. Step Up to the Motorvator. Step Up to the Moto sheet (www.allegromicro.com) and using it to supplement the BVB BVB A3977SED information that I will provide for you in this discussion. A A B B A = OFF B = OFF A = OFF B = OFF Within the A3977SED data sheet, you will find some familiar concepts that we’ve already discussed, such as the translator and the control logic D C D C C = OFF C = OFF D = ON D = OFF subsystems. With that, follow along using the A3977SED functional SENSE SENSE block diagram in Figure 1 as I continue to describe the remaining design points we’ll need to cover to Toff Toff Toff bring the Motorvator to life. Tfd At power-up or with the initiation of a reset via the RESET pin, the transItrip Itrip Itrip lator uses its pair of four-bit DAC control lines to force the output of the pair of DACs into the home state. Motor phase current polarities for each motor phase are also set to their MIXED DECAY SLOW DECAY FAST DECAY home state conditions and the current regulators for both of the motor FIGURE 3. You can clearly see here that the slow-decay mode ripple is very low phases are set to mixed-decay mode. when compared to the fast-decay mode current ripple. The A3977SED uses The idea here is to step the the best of both decay worlds to produce a sinusoidal current drive to the stepper motor attached to its pair of H-bridges. motor as smoothly as possible. This smooth stepping action is achieved A3977SEDs, and all of the Motorvator’s LEDs and voltage when the motor is driven with a sinusoidal current waveform. dividers don’t even come close to taxing the LM317’s current Within the A3977SED, this sinusoidal waveform is quadrature output capacity. During testing of the Motorvator, I found in nature, meaning that the phase current waveforms are 90° that — at low input voltages (+12 VDC to +18 VDC) — out of phase. I’ve put together a graphic in Figure 2 that the LM317 never got much more than warm to the touch. The gives you a feel as to how the motor phase currents relate to same goes for the A3977SEDs, which are heatsinked by the each other and the A3977SED HOME state. massive amount of ground plane area on the Motorvator PCB. If you visualize the phase current waveforms as sine and The A3977SEDs are attached to the PCB heatsink/groundcosine functions and relate that to what the A3977SED plane by 12 internally grounded heatsink pins. calls the HOME state, the math in Figure 2 says it all. HOME A look at my Motorvator in Photo 1 reveals the state is defined as a point in the sinusoidal phase current PIC18F8520, the 40 MHz oscillator, the LM317 logic power waveforms where both motor phase current levels are supply, and the 10-pin Microchip ICSP programming/debug70.71% of the maximum phase current value. Check our ging socket sandwiched between an identical pair of math against the A3977SED data sheet and you’ll find that A3977SED stepper motor drivers designated logically as Driver HOME state is located at the 45° position of each of the A and Driver B. The four six-pin right-angle header assemblies phase current waveforms. Don’t confuse the 45° position closest to the quartet of 10-turn trimmer pots form a microwith an angle on the motor shaft. This position is an angular controller input portal for all of the external control inputs. position in the phase current waveforms. For instance, if we External control inputs can be just about anything the move 45° positively away from HOME position, the PHASE1 user deems necessary to gain control of the movement of the CURRENT level is at 0 while the PHASE2 CURRENT level is at stepper motors via the PIC18F8520. Motor and logic input 100% of the maximum phase current. power is obtained from the center pins of either of the single Since the HOME position is the translator’s beginning six-pin right-angle stepper motor interface headers that point in a step sequence and 360° constitutes a full cycle, it surround the LM317 voltage regulator. A single ULN2003 would be safe to say that we’ll end up at the 45°, or HOME Darlington array is used instead of discrete transistor position, at the end of one full cycle. switches to drive the Driver A and Driver B, HOME LEDs, and In full step mode, a two-phase stepper motor requires an auxiliary SPDT +5 VDC coil relay. four steps to complete one full phase cycle. That’s 90° per I’ve supplied a full schematic depiction of the step. If the stepper motor is running in half-step mode, the Motorvator. However, to help make things a bit clearer as number of steps required to move from HOME position to I describe the details of the Motorvator hardware the next HOME position is eight steps. Get the idea? A and firmware, I suggest downloading the A3977SED data stepper motor running in eight-step mode needs 32 steps to SLOW-DECAY MODE
30
SERVO 02.2005
FAST-DECAY MODE
Best.qxd
1/3/2005
2:40 PM
Page 31
p to the Motorvator. Step Up to the Motorvator. Step Up to the Motorvator. traverse the 360° between adjacent HOME positions in the phase current waveform. The A3977SED automatically employs mixed-decay mode, which results in a motor current waveform that closely approximates the ideal sinusoidal current waveform we need to smoothly power our stepper motor. Mixed-decay mode is the product of slow-decay mode and fast-decay mode. Decay is defined as the time it takes to get the recirculating current out of a motor winding. The weird noises you hear coming from stepper motors are caused by distortions in the sinusoidal current waveform. The distortion is caused by the improper selection of a decay mode during a particular angular time within the sinusoidal current flow. Let’s take a look at what decay is and how it is handled by the A3977SED. Figure 3 depicts typical H-bridge configurations with VBB representing the incoming motor power. To apply current across the motor winding, the DMOS devices are activated diagonally. For instance, by turning on the A and D DMOS devices, current can flow from the VBB source through the A DMOS device, which has shorted out its body diode, through the coil and across DMOS device D, which has also shorted
out its body diode through the SENSE resistor to ground. The current can also flow in the same manner — but in the opposite direction — by energizing DMOS devices B and C. The A3977SED H-bridges are driven by a fixed-off-time PWM current control circuit. The load current limit (ITRIP) is also controlled by the PWM current control circuit. Another look at Figure 1 shows us that the A3977SED DAC output voltages and the voltages across the H-bridge current-sense resistors are fed into current-sense comparators that report to the A3977SED’s PWM generators. When the voltage across the sense resistor equals the voltage that is being generated by the DAC, the PWM latch within the PWM Timer subsystem is reset. At this point, the H-bridge enters one of the decay modes. The motor current will recirculate and decrease until the fixed-off time expires. The act of automatically routing the recirculating motor winding current using the DMOS device’s body diodes and one of the decay modes is synchronous rectification. When the A3977SED’s translator SR input pin is presented with a logical low, synchronous rectification is automatically performed by the logic within the A3977SED.
SCHEMATIC 1. The PIC18F8520 has much more I/O, program memory, and data memory than a basic Motorvator needs. The good news is that there are plenty of microcontroller resources left for you to do with as you please. +5VDC
PGC
8 VDD 40MHz 4 5 GND CLKOUT
ICSP
UND1 AUTO UND3 UND2 UND5 +5VDC UND4 LS2 LS1 ROTARY MOTION SPEED C16 .1uF
RH2 RH3 RE1 RE0 RG0 RG1 RG2 RG3 MCLR RG4 VSS VDD RF7 RF6 RF5 RF4 RF3 RF2 RH7 RH6 +5VDC
PIC18F8520
21 22 23 SRB 24 25 26 27 28 29 30 31 32 33 34 RESETB 35 STEPB 36 37 MS2B SLEEPB 38 39 40
+5VDC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61
U2 STOP START CONST REV1
.1uF
NC
AUXO RELAY ENABLEA DIRA
C20 D9 .1uF 1N5819
1
CURLIMBA CURLIMB
PGD
C14
RH1 RH0 RE2 RE3 RE4 RE5 RE6 RE7 RD0 VDD VSS RD1 RD2 RD3 RD4 RD5 RD6 RD7 RJ0 RJ1
10K
1 2 3 4 5 6 7 8 9 10
RH5 RH4 RF1 RF0 AVDD AVSS RA3 RA2 RA1 RA0 VSS VDD RA5 RA4 RC1 RC0 RC6 RC7 RJ4 RJ5
MCLR
R10
C19 .1uF
HOMEA SLEEPA MS1A STEPA MS2A SRA RESETA
J5
+5VDC
+5VDC 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41
RJ2 RJ3 RB0 RB1 RB2 RB3 RB4 RB5 RB6 VSS OSC2 OSC1 VDD RB7 RC5 RC4 RC3 RC2 RJ7 RJ6
+5VDC
C18 .1uF
+5VDC
VBB
+5VDC
VR1 LM317 VIN
VOUT ADJ
HOMEB
AUXO RELAY HOMEA
1 2 3 4 5 6 7 8
U3 IN1 OUT1 IN2 OUT2 IN3 OUT3 IN4 OUT4 IN5 OUT5 IN6 OUT6 IN7 OUT7 GND CLMP
HOMEB_LED +5VDC AUXO_PIN HOMEA_LED
K1 5 1 3
4
NC
6
NO
3 R11
+ C21 10uF
R13 470
2
240 PWR LED
COMMON 16 16 14 13 12 11 10 9
STOP START CONST REV1 UND1 AUTO UND3 UND2 UND5 UND4 LS1 LS2
10K PULLUP RESISTORS
C15 .1uF
ENABLEB DIRB HOMEB MS1B
1
C22 .1uF
.1uFC17
LINEAR MOTION SPEED
R10 - R21
R12 715
RELAY SPDT
SERVO 02.2005
31
Best.qxd
1/3/2005
2:44 PM
Page 32
Step Up to the Motorvator. Step Up to the Motorvator. Step Up to the Moto Slow-decay mode is entered when the source drivers (A and B) are turned off and the sink driver D is turned on. The current in the motor coil is dissipated slowly by being forced to recirculate through the resistances offered by the coil itself and the body diode of DMOS device C. If you’re wondering if DMOS device C can be energized and conducting in this mode, the answer is yes, but it’s not necessary, as the DMOS device C body diode allows the current to circulate through the motor winding. Since back EMF from the motor winding can override the operation of slow-decay mode on the falling slope of the current sine wave and cause distortion of the current waveform (which causes the motor to chatter), slow-decay mode is employed on the rising quadrants of the sinusoidal current waveform. Turning off all of the DMOS devices puts the H-bridge into fast-decay mode. Fast-decay mode allows for the rapid dissipation of the latent motor winding current. As you can see in Figure 3, the body diodes of diagonal pairs of DMOS devices form the escape path for the recirculating motor current. Fast-decay mode produces much more current ripple than slow-decay mode and, thus, heats the motor a bit more than slow-decay mode does. The ideal situation would be to have the power to mix the slow-decay and fast-decay modes to fine-tune our sinusoidal current waveform that is driving our stepper motor. This condition would produce a tradeoff between the high and low ripple currents and provide enough recovery speed to help drive the stepper motor with a pretty accurate sinusoidal current waveform. The good news is that we do have the power and the resultant mode is called mixed-decay mode. As you have already surmised, mixed-decay mode is an optimal mixture of slow-decay mode and fast-decay mode and — eventhough mixed-decay mode is automatic with the A3977SED — we have some control over how it operates. Let’s begin by determining the value of the H-bridge sense resistors, which directly affects the maximum ITRIP current value. Since the A3977SED can handle a maximum of ±2.5A, let’s set up our H-bridge current sense resistors to meet the maximum current value that the A3977SED can process. The value of the sense resistors is computed as follows: Rs = 0.5/ ITRIP max Where: Rs = sense resistor value ITRIP max = 2.5A Rs = 0.2Ω The only “gotcha” to watch out for is to make sure you select a sense resistor that has very low inductance. I’ve specified a suitable resistor for the Motorvator in the Parts List. Now that we’ve chosen a sense resistor value, we can use a voltage divider consisting of a standard 10-turn 10K ohm pot to provide a voltage to the A3977SED REF pin that will dial in our desired amount of current limiting that can be less than, but not greater than, our ITRIP max value of 2.5A. The desired current limit reference voltage is calculated using
32
SERVO 02.2005
the following transconductance function: ITRIP max = VREF / (8Rs) Substituting a value of 2.5 A for ITRIP maximum and a value of 0.2 ohm for Rs yields a maximum value of 4.0 volts for VREF. If you’re wondering where the eight multiplier for the sense resistor value comes in, take a look at Figure 1. The voltage applied to the A3977SED REF pin is divided by 8 before being handed to the DACs. Take another look at the Figure 2 graphic. The phase current sine waves appear to be smooth. In reality, there are very tiny steps all along the phase current sine waves that represent a function of the DAC output voltages versus a percentage of the ITRIP max value. The ITRIP current at each step along the way of the phase current sine waves can be calculated with the following formula: ITRIP = (%ITRIP max/100) x ITRIP max A table of ITRIP max percentages versus their appearance in the phase current sine wave is provided in the A3977SED data sheet. Let’s get back to exercising our little bit of control over the decay mode process. Another quick look at Figure 3 shows us that the fixed-off time of the PWM current control circuitry is defined as TOFF. The PWM fixed-off time is determined by an external RC circuit tied to a one-shot within the PWM current control circuitry. A minimum fixed-off time of 30 µS is specified by the A3977SED data sheet. To meet that minimum fixed-off time, I mounted a pair of RC circuits to the A3977SED’s RC1 and RC2 pins. I determined the values of the components you see in the Motorvator schematic with the following formula: TOFF = R2C2 for RC1 and TOFF = R4C4 for RC2 Do you recall my mention of additional low pass filtering that would be needed if we were not going to implement the A3977SED? The A3977SED gets around having to include a filter between the sense resistor and the current sense comparator by blanking the output of the current sense comparator when the current control circuitry switches the outputs. The blanking function is dependent upon the value of the capacitor in the fixed-off time RC circuitry and is approximated as follows: TBLANK = 1900 x (C2 or C4) TFD in Figure 3 represents the fast-decay time of the mixed-decay mode. As you can see in the mixed-decay graphic portion of Figure 3, TFD is the time within the PWM current control fixed-off time that the fast-decay mode will be invoked. Fast-decay mode begins when the ITRIP threshold is reached and remains in effect until the voltage on the RCx pin decays to the voltage presented at the PFD pin. Once the fast-decay time is depleted, the decay mode switches to slow-decay mode for the remainder of the PWM current control fixed-off time.
Best.qxd
1/3/2005
2:47 PM
Page 33
p to the Motorvator. Step Up to the Motorvator. Step Up to the Motorvator. TFD is a function of the PWM current control fixed-off time and a voltage applied to the A3977SED’s PFD input pin, which feeds both of the PWM timers. The setting of the PFD voltage depends on how you want to run your stepper motors. So, to provide an easy means of adjusting the TFD timing threshold, I’ve placed another 10-turn 10K ohm pot across the PFD pin. The following formula, actual voltage, and component values I used on my version of the Motorvator will give you an idea of what my Motorvator TFD value looks like: TFD = R2C2(ln(0.6Vcc/VPFD) Where: R2 = 30K Ω C2 = .001 µF Vcc = 5.0 VDC VPFD = 2.5 VDC TFD = 5.47 µS That does it for things that we can control using formulas
and their resultant component values. The remainder of the A3977SED’s supporting components are specified in the A3977SED data sheet and are reflected in the Motorvator schematic. So, let’s write some HI-TECH PICC-18 C code to put all of that stepper motor driver theory and hardware to work.
The Motorvator Firmware Writing the Motorvator firmware was loads of fun. I’ve written some code to demonstrate some of the concepts we discussed in the early stages of this article. I’m not going to post all of the code I wrote here, but will instead provide it to you as a download from the SERVO website (www.servo magazine.com). However, I will give you a jist of what I did and show you how to use the HOME position output signal to back-up what I told you about how the translator uses the HOME state. The very first thing I did was to assign a meaningful C name to each of the A3977SED interface pins. I then related the names of the A3977SED pins to the pins that they
SCHEMATIC 2. This is a schematic of the A-side motor driver. All of the components that support the A3977SED in this depiction match those found in the B-side motor driver schematic. MG1 BIPOLAR STEPPER MOTOR
+5VDC
2
+5VDC PFD R1 10K C1 C2 R2 30K C4
.1uF .001uF
.001uF
R4 30K
D1-D8 NOT MOUNTED WHEN SR IS ACTIVE
A3977SED
C11 .22uF
38
37
VBB
CP2
HOME DIR SR RESET STEP *ENABLE *SLEEP MS1 MS2 PFD RC1 REF RC2
.1uF .22uF
CP1
RD1 RD0 RD6 RD7 RD4 RE7 RD2 RD3 RD5
4 5 26 27 31 41 42 20 19 9 10 14 15
VDD
U1
16
.1uF
C23 .1uF
C9
C13
36
C5
43 VBB1 25 VBB2
R9 332
VBB
C12 100uF
OUT2B 4
OUT2A 3
+5VDC C6 10uF
VCP
16 16 14 13 12 11 10 9
D2
D4
D1
D3
D6
D8
D5
D7
C10 .22uF VREG
32
6 OUT1A 18 OUT2A 40 OUT1B 28 OUT2B 3 SENSE1 21 SENSE2
1 2 GND 44 GND GND 11 12 GND 13 GND GND 22 23 GND 24 GND GND 33 34 GND 35 GND GND
OUT1 OUT2 OUT3 OUT4 OUT5 OUT6 OUT7 CLMP
+
IN1 IN2 IN3 IN4 IN5 IN6 IN7 GND
OUT1B
HOME A
+
1 2 3 4 5 6 7 8
1
DRIVER A
LED1 U3
OUT1A
C8
R8
C7
R7
.1uF
.02
.1uF
.02
+5VDC
R5 20K RH1 REF R3 10K C3 .1uF
SERVO 02.2005
33
Best.qxd
1/3/2005
2:48 PM
Page 34
Step Up to the Motorvator. Step Up to the Motorvator. Step Up to the Moto attached to on the PIC18F8520. For instance, Driver A’s RESET pin is designated as pRESETA and defined as LATD7, while Driver B’s RESET pin is identified as pRESETB attached to LATC1 on the PIC18F8520. Any C reference that begins with a “p” denotes that the reference is actually a physical pin on either the PIC18F8520 or the A3977SED. To keep things from getting too confusing, I used the actual A3977SED data sheet pin names in my descriptions where I could. Once all of the pin assignments were defined, I went about putting together simple macros that used the pin definitions to form functional blocks of code. For example, pRELAY is attached to LATE6 of the PIC18F8520. A logic high applied to pin 6 of the ULN2003 drives pin 11 of the ULN2003 low and provides a ground path for the relay coil. The following code definitions can be used in your application code to control the relay:
In a similar manner, the RESET function of the A3977SED can be simplified with the following code: #define RESET_A
pRESETA = 0; Delay_ms(50); pRESETA = 1;
\ \
#define RESET_B
pRESETB = 0; Delay_ms(50); pRESETB = 1;
\ \
I needed a delay source for both the RESET and STEP functions. So, I implemented a millisecond timer using the PIC18F8520’s TIMER0. At 40 MHz, each instruction cycle accounts for 100 nS of time. That means that every microsecond of delay time I need requires me to expend 10 instruction cycles. One millisecond is 1,000 microseconds. So, I need to expend 10,000 instruction cycles for every millisecond of delay I need in my routines. By dividing or prescaling the timer clock cycles by 16, my multiplier for 1 millisecond of delay time is 625.
#define RELAY_ON pRELAY=1; #define RELAY_OFF pRELAY=0;
SCHEMATIC 3. Here’s a schematic depiction of the B-side motor driver. Note the differences in the PIC pins that drive the A3977SED and the U3 drive for the HOME B LED. Every other component is identical to the ones used by the A-side motor driver. +5VDC
MG1 BIPOLAR STEPPER MOTOR DRIVER B
LED1 U3
OUT1B
2
PFD R1 10K C1 C2 R2 30K C4 .001uF +5VDC
R5 20K RH0 REF R3 10K C3 .1uF
SERVO 02.2005
R4 30K
D1-D8 NOT MOUNTED WHEN SR IS ACTIVE
A3977SED
38 CP2
37
VBB
CP1
36
16 VDD
HOME DIR SR RESET STEP *ENABLE *SLEEP MS1 MS2 PFD RC1 REF RC2
C11 .22uF
.1uF .22uF
D2
D4
D1
D3
D6
D8
D5
D7
C10 .22uF VREG 32
OUT1A OUT2A OUT1B OUT2B
6 18 40 28
SENSE1 3 SENSE2 21
1 2 GND 44 GND GND 11 12 GND 13 GND GND 22 23 GND 24 GND GND 33 34 GND 35 GND GND
+5VDC
4 5 26 27 31 41 42 20 19 9 10 14 15
C9
C13
.1uF
RC3 RC4 RF0 RC1 RC0 RC5 RC7 RC2 RC6
.001uF
+
C5
U1
.1uF
C12 100uF
OUT2B 4
C6 10uF
VBB
43 VBB1 25 VBB2
R9 332
OUT2A 3
+5VDC
VCP
16 16 14 13 12 11 10 9 C23 .1uF
34
1
HOME B
IN1 OUT1 IN2 OUT2 IN3 OUT3 IN4 OUT4 IN5 OUT5 IN6 OUT6 IN7 OUT7 GND CLMP
+
1 2 3 4 5 6 7 8
OUT1A
C8
R8
C7
R7
.1uF
.02
.1uF
.02
Best.qxd
1/4/2005
4:52 PM
Page 35
p to the Motorvator. Step Up to the Motorvator. Step Up to the Motorvator. The PIC18F8520 timers count positively and overflow to zero. My delay routine simply puts enough counts into the timer to allow it to count up the desired number of milliseconds and overflow. I watch for the overflow using the TIMR0IF (TIMER0 Interrupt Flag) bit, which signals the end of my selected millisecond timing period. Here’s what the delay code looks like: void Delay_ms(unsigned int mticks) { //use with prescaler set for 1:16 WRITETIMER0(0xFFFF -(mticks * 625)); TMR0IF = 0; while(!TMR0IF); }
I then integrated the delay timer function into a STEP function. The basic STEP macro looks like this: #define STEP_Ams(x)
#define STEP_Bms(x)
pSTEPA = 1; Delay_ms(x); pSTEPA = 0; Delay_ms(x);
\ \ \
pSTEPB = 1; Delay_ms(x); pSTEPB = 0; Delay_ms(x);
\ \ \
As I alluded to earlier, a low-to-high transition on the STEP input pin produces a single step or microstep. The speed of the motor is determined by the length of the delay. The A3977SED’s maximum step rate is commanded with an interstep delay of 2 microseconds. Here’s a bit of code that counts the number of steps between successive HOME states. Recall that a stepper motor stepping in eighth-step mode will take 32 steps between a starting HOME state and the following
N
e
HOME state. unsigned int stepcount; void main(void) { unsigned int j; //used for a breakpoint position T0CON = 0b10000011; INIT_3977(); EIGHT_B; ENABLE_B; DIRB_CW; stepcount=0; do { STEP_Bms(1); ++stepcount; }while(pHOMEB); ++j; }
//start Timer0 with a 1:16 //prescaler //init the A3977 //enable eighth-step mode //enable the Driver B H-bridge //turn the motor clockwise //zero the step counter
//step every 1 millisecond //increment the step count //look for the HOME signal to go //low //stop here with a breakpoint
When the motor stops and the breakpoint is reached, you’ll find that the variable stepcount contains the value of 32. Replacing EIGHT_B with FULL_B will result in a final stepcount value of 4. My VEXTA stepper motor steps in 1.8° increments. Thus, it would take 1,600 steps to complete one shaft revolution using the eight-step mode. Here’s what should happen when you compile and run the code below. The Driver B HOME indicator LED will be dark following the initialization routine indicating that the A3977SED translator has put the driver into HOME state. Once the steps start, the HOME indicator LED will blink off as it passes through every successive HOME state (every 32 steps). When the 1,600 steps have been taken, the stepper motor shaft will have traversed one revolution and the HOME indicator LED will again go dark indicating that it has returned to a HOME state.
w
KHR-1 Robo-One Robot Kit These awesome kits are the latest craze in Japan. Robot has 17 motors for fluid movements. Programed and Controlled via PC. Upgradable to Bluetooth wireless.
BROUGHT TO YOU BY WWW.SOZBOTS.COM Circle #63 on the Reader Service Card.
SERVO 02.2005
35
Best.qxd
1/4/2005
4:54 PM
Page 36
Step Up to the Motorvator. Step Up to the Motorvator. Step Up void main(void) { unsigned int i,j;
DIRB_CW; while(1){ for(i=0;i<1600;++i) { STEP_Bms(1); } if(pDIRB) pDIRB = CW; else pDIRB = CCW; }
//use j for a breakpoint posi//tion
T0CON = 0b10000011; prescaler INIT_3977(); EIGHT_B; ENABLE_B; DIRB_CW; for(i=0;i<1600;++i) { STEP_Bms(1); } ++j; }
//start Timer0 with a 1:16 //init the A3977 //enable eighth-step mode //enable the Driver B H-Bridge //turn the motor clockwise //step 1 full shaft revolution //step every 1 millisecond
//use i as a loop counter
T0CON = 0b10000011; prescaler INIT_3977(); EIGHT_B; ENABLE_B;
//start Timer0 with a 1:16 //init the A3977 //enable eighth-step mode //enable the Driver B H-bridge
2005 March 6–10, 2005 Austin Hilton Austin, TX
THE PREMIER GLOBAL EVENT IN POWER ELECTRONICS Visit the conference web site below for continual updates
www.apec-conf.org
www.apec-conf.org The MicroMouse Contest Monday, March 6 starting at approximately 8:00 PM SPONSORED BY
//step every 1 millisecond //check the direction bit and //reverse the direction
}
Stepping Out
//stop here with a breakpoint
A slight variation on the full shaft rotation code uses the resultant state of the pDIRB translator pin to reverse the direction of the stepper motor after one full shaft rotation. void main(void) { unsigned int i;
//turn the motor clockwise //do forever //step 1 full shaft revolution
Before I go and leave you to build your own Motorvator, I’ve got one more trick I want to show you. Recall that we can use the voltage at the A3977SED REF input to limit the maximum current we deliver to a stepper motor. With the addition of a single resistor and one PIC18F8520 I/O pin, we can dump a dormant motor into low-current hold and instantly return to our original maximum current value when stepping resumes. I placed a 30K resistor in series with the REF pot and attached a PIC18F8520 I/O line at that junction. When the PIC18F8520 I/O line is an output and is at a logical high, +5 VDC is supplied as usual to the REF pot and the REF pot voltage divider controls the voltage presented at the A3977SED REF pin. Transitioning the PIC18F8520 I/O line to an input state allows the 30K resistor to become part of the REF voltage divider. This results in a lower voltage presented to the A3977SED REF pin, which results in a lowered ITRIP max value. I’ll leave you with the current limit macros: #define CURLIMA_OFF TRISH1 = 0; pCURLIMA = 1; #define CURLIMB_OFF TRISH0 = 0; pCURLIMB = 1; #define CURLIMA_ON TRISH1 = 1; #define CURLIMB_ON TRISH0 = 1;
SERVO 02.2005
\
For those of you who want to experiment with your own Motorvator, the PCB and all of the associated parts are available from EDTP Electronics, Inc., at www.edtp.com As always, if you have any questions or comments, I’m always available to you via Email
[email protected]. See you next time ... SV
SOURCES A3977SED, ULN2003, Allegro Microsystems www.allegromicro.com Motorvator printed circuit board, EDTP Electronics, Inc. www.edtp.com HI-TECH PICC-18 Compiler, HI-TECH www.htsoft.com PIC18F8520, Microchip www.microchip.com
36
\
Simpson.qxd
1/3/2005
1:02 PM
Page 37
by Michael Simpson
I
was working on a book project and needed to create several walker robot prototypes with several small, curved parts of various shapes and sizes. I have a large band saw, but it was just too difficult to cut the small curves and details needed and there was no way to make the inside cuts required for many of the pieces. Several years ago, I had a small 15” scroll saw and tried to cut acrylic, but just could not achieve a smooth cut. The plastic would melt and fuse back together behind the blade. Recently, at a local tool show, I managed to talk some of the scroll saw exhibitors into letting me cut some scrap plastic I had with me. After a few tips, I was cutting expanded PVC and acrylic like a pro.
SERVO 02.2005
37
Simpson.qxd
1/3/2005
1:08 PM
Page 38
let’s take a look at each saw and see how all of them performed the task.
Ryobi SC164VS
The Ryobi SC164VS.
I decided it was time to look into purchasing a scroll saw and visited a few local retail stores in my area. After a bit of research, I found that the following three saws represented a good mix of what was available for $400.00 or less: • Ryobi SC164VS 16” scroll saw • Dremel 1800 18” scroll saw • Dewalt DW788 20” scroll saw I decided to purchase all three and give each a whirl. I also picked up several blade types so I could see which ones would work best for this project. Scroll saw blades come 12 to the pack and are rated by the number of teeth per inch. With three saws and 480 blades, I decided to build three complete bots on each saw. This would get me past the learning curve and help me get a real feel for the saw and its capabilities. Two of the bots would be made from 1/8” Baltic birch plywood — the kind you get from craft stores. This plywood has no voids and finishes up very nicely. It is lighter and firmer than expanded PVC and is more heat resistant. Even if you plan to build a robot in expanded PVC or acrylic, I recommend using the Baltic birch plywood for the prototype. I also cut the parts for a walker bot out of expanded PVC. I did enough parts for one bot on each saw. Now, The custom birchwood insert.
This was the least expensive saw I tested. While it worked okay and I was able to build the three walker bots, I found myself constantly at odds with this saw. The removable key lock The Dremel 1800. is a nice feature if you have small children running around the shop. The saw is also the lightest and the easiest to transport. Unfortunately, these are the only nice things I have to say about this saw. The blade tension is adjusted at the rear of the saw. I found this irritating, as I had to reach around the saw to tension the blade. I don’t like saws where the power and speed controls are located under the table. This makes them difficult to reach in an emergency shutdown. There are three problems that stand out with this particular saw: 1. There is very little room under the table to access the blade clamps and thumb screws. This makes blade changes very difficult. 2. The table was very rough. No amount of waxing could smooth it out. This makes turning tight corners difficult. I eventually made a top out of waxed 1/8” plywood and attached it with double-sided tape. While this is not the only solution to the rough surface, it worked quite well for me. 3. The rubber knob that tightens the table tilt mechanism is very easy to break. The knob on this saw broke with only one use. Thereafter, I had to use a wrench to loosen and tighten the table. This was not much of a problem, since you won’t be tilting the table with most robotic projects. The Dewalt DW788. This saw represents the low-end class for scroll saws. You will find saws in this class that are very similar in size, shape, and design. Many of them may have been built in the same factory. I just can’t see these or other low-end saws holding up to everyday use.
38
SERVO 02.2005
Simpson.qxd
1/3/2005
1:10 PM
Page 39
Dremel 1800 Dremel calls this an 18” Scroll Station. While the included 5” disk sander is an added feature, you won’t be using it much on your robotics projects. I did not use it once on the three walker bots I built using this saw. You would be better off purchasing the optional flex shaft and using one of the Dremel sanding drums. The disk is somewhat of a pain to get on and off, so you will have to choose one or the other. Like the Ryobi, this saw will accept both pin and plainend blades. There is a hinged access drawer that makes changing the blades a bit easier than with the Ryobi. The saw has almost twice the weight of the Ryobi and, with this, it vibrates much less. The table is polished cast iron and only took four layers of paste wax to get to a silky smooth surface. For blade storage, there is a small drawer under the table, but I don’t recommend it for serious users. Most blades are impossible to tell apart, so I suggest some type of sorting tubes for your blades. The controls are all up front, on top of the saw, so it’s very easy to access them. One really nice feature is a small LED light located on the saw. While it won’t illuminate your work surface, it will keep a beam on your saw line. The saw has a flexible air tube that puts out quite a bit of air that will keep your saw line free of sawdust. However, when I cranked the RPMs up past 1,000, the vibration caused the flex tube to eventually drop to the table surface. Using a scroll saw stand or bolting the saw to the table will help alleviate this problem. Another area that is of concern to me was the large blade insert. It had very large blade grooves and did not sit flush with the table surface. Luckily, the design was simple and, by tracing the insert on to 3 mm birch plywood, I was able to create an insert that I could wax and then drill a very small hole for blades. This was perfect for the small pieces I cut for my walker bot projects. The saw has small vinyl covers on the power and light switches. These are used to keep dust out of the switch mechanisms. They both eventually came off during use and I found it made using the switches much easier. The saw weighs in at over 50 lbs, so you won’t be toting it around the shop, but there is a handle on the top just in case you feel up to it. I liked this saw. It worked very well on wood, expanded PVC, and acrylic. Dremel also makes a 16” scroll saw with a cast iron table and a 45 degree tilt both ways. It’s about $80.00 less, so you may want to look into that one if you want something a bit smaller and less expensive.
Dewalt DW788 A high end scroll saw can cost you well over a $1,000.00. Are they worth it? Well, that depends upon your use of the saw. If you use it once or twice a year, it may be better to purchase a smaller, less expensive saw. If, on the other hand, you plan on using the saw everyday, a high end
The open design of the Dewalt.
saw is right for you. The Dewalt scroll saw has a $399.00 street price and is the closest thing to the high end saws that I could find locally. The saw is actually manufactured in Canada by the same company that manufactures the Excalibur (high end) line of scroll saws. All scroll saws vibrate; it’s just a matter of how much. From the $60.00 saw to the most expensive $3,000.00 saw, it’s the nature of the beast. The saw’s mass will affect vibration; the heavier saws don’t vibrate as much as the lighter weight saws. You can also lower the vibration by bolting the
STEER WINNING ROBOTS WITHOUT SERVOS!
P
erform proportional speed, direction, and steering with only two Radio/Control channels for vehicles using two separate brush-type electric motors mounted right and left with our mixing RDFR dual speed control. Used in many successful competitive robots. Single joystick operation: up goes straight ahead, down is reverse. Pure right or left twirls vehicle as motors turn opposite directions. In between stick positions completely proportional. Plugs in like a servo to your Futaba, JR, Hitec, or similar radio. Compatible with gyro steering stabilization. Various volt and amp sizes available. The RDFR47E 55V 75A per motor unit pictured above. www.vantec.com
Order at (888) 929-5055 SERVO 02.2005
39
Simpson.qxd
1/3/2005
1:11 PM
Page 40
the fact that the saw weighs in at over 70 lbs and you get a very smooth running saw. The Dewalt is the epiphany of simplicity. Things just don’t get simpler. The open design under the table means you can access and change a blade in a matter of seconds. If you check out other high end saws, they all seem to have this open design. The Dewalt is so open that they have actually added a small guard in front of the clamp mechanism. This is to keep you from accidentally pinching a finger while the saw is running. Blade clamps are in a fixed position so they are easy to tighten and loosen. This also means less blade deflection. The dust blower is sturdy and does not change position during operation. The table is cast iron and was so smooth that I only needed two coats of paste wax. The table has a Clip lights are inexpensive and make your work easier. small hole for the blade, which is perfect for the small pieces you will be cutting. You won’t have to worry about making a saw to a heavy table or stand. Design can affect vibration, as new insert. well. For instance, on the Dewalt, the pivot points for the All controls for the saw are up front and, with this arms are up front near the blade. This provides for less design, you can adjust the blade tension while the blade is in moving mass and yields much less vibration. Couple this with motion. The tension lever is also indexed, so you can get the exact same blade performance each time you remove and attach a blade — which is very MATERIALS important for inside cuts. Of the three saws I tested, the Dewalt was The three materials I tend to work with the most when building my robots and prototypes are wood, expanded PVC, and acrylic. the only saw with no dust collection port. This did not bother me, as I had not planned on using a On occasion, I have also cut softer metals. connected dust collector with any of the saws. Scroll saws have small blowers that keep the Wood I used 1/8” Baltic birch plywood for most of the bots in this Steps to making an inside cut. project. You can purchase 12” x 24” sheets for $4.00 at most craft and hobby stores. You can also cut up to 2” thick pine with ease. Hardwoods, such as oak and maple, will start to get more difficult as the thickness increases and you will need to use a larger blade. Expanded PVC Expanded PVC is very easy to work with. When this material is cut, the edges will yield a dull, coarse surface. While the finest blade will create an ultra smooth surface, you will never get the glossy type finish as you do on the flat surface of the plastic. I use a #1 blade when cutting 1/8” and 1/4” stock. When stacking expanded PVC greater than 1/4”, you will need to use a #4 or larger blade. Acrylic You cut acrylic much like you do expanded PVC. The surfaces of the acrylic must be covered. When purchased, the surfaces are normally covered. You can also use masking tape for this. On 1/8” stock, I use a #1 blade. On 1/4” stock, you have to move up to a #4. Metal To cut metal on a scroll saw, you must use special hardened metal cutting blades. I prefer to use the smaller, thinner blades like a #0 metal cutting blade. Just slow the saw down and take it slow. I have cut up to 1/8” aluminum with these blades.
40
SERVO 02.2005
Simpson.qxd
1/3/2005
1:14 PM
Page 41
scroll line clear, so they tend to blow a bit of dust in the air. The simplest and most effective solution for dealing with the airborne dust is to use a small window fan with a filter taped to the front of it. This tends to capture all the airborne dust and is fairly quiet.
Saw Choice Conclusions Sample shape transition pieces. No adhesive required! The fit and finish on all three saws was very nice. All three saws had no problems cutting the wood, plastic, and acrylic needed for my walker bots. However, there was no way my boss (wife) was going to let me keep all three saws, Inside Cuts so I had to choose only one. Making an inside cut with a scroll saw is very easy: I decided on the Dewalt saw, mainly because I see myself using the saw on just about every robot project in the future. Step 1: This saw features full ball bearings and less overall mainteLay out your cut. In this case here, we are cutting a servo nance than the other saws. Factor this with the ultra low mount. vibration and my choice was made for me. Had the cost been more of a factor, I would have chosen the Dremel 1800. Cutting multiple pieces saves time. If you decide to purchase a scroll saw, here are some of the features to look for:
Techniques
• • • • •
Table finish. Variable speed Plain-end blade support Ease of blade change Blower for clearing stock line
You will also want to pick up some sort of light. I like the inexpensive $7.00 clip-on lights. You can add as many as you want. Use a 40 watt bulb to keep the heat down.
SCROLL SAW BLADES Scroll saw blades come with plain-end and pin-end configurations. Most high end scroll saws only use the plain-end type. There are many more types of scroll saw blades available in the plain-end configuration. Generally, pin-end blades should be easier to change; however, on the saws I tested, I found this to not be true. The Ryobi and Dremel accept both types of blades, but are a bit more complicated because they accept both the blade connectors. Once you decide on the blade end configuration, there are many types of blades available in various widths and tooth
patterns. These range from skip tooth to reverse tooth types. There are even spiral blades that will cut in any direction. There is a universal number system used to reference plain-end blades. Most manufacturers use it and it’s a good guide when selecting the finish type and cutting radius of a scroll saw blade. The smaller the universal number, the thinner the blade and the more teeth per inch. I have found that a #1 blade works very nicely in 1/8” plywood or plastic. It leaves a very fine finish and requires no clean-up. You can just about turn in place to cut extremely tight corners. SERVO 02.2005
41
Simpson.qxd
1/3/2005
1:16 PM
Page 42
Step 2: Drill a small hole in one of the corners, just touching two of the sides. This hole should be large enough to insert the saw blade. As an option, you can drill four holes, one in each corner. Step 3: Unclamp the blade at one end. Insert the blade through the hole and then clamp the blade back in place. You can release the top or bottom of the blade; it does not matter. Step 4: Cut the stock. Once cut, unclamp the blade and remove the stock. In this case, I drilled the holes with a drill press.
Shape Transitions There are times when you want a vertical piece to
transition to a horizontal piece. In this case, we are making a bot leg that will be connected to a servo. We could apply heat and bend the leg, but bending is not an option in many situations. For instance, with expanded PVC, it would yield a leg that’s just not rigid enough to support the weight of the bot. If you are using plywood, heat alone is not enough to bend the leg. In this case, I cut two pieces with slots where the pieces will overlap. The slot is half the length of the overlap. The width of the slot is the thickness of the stock. Once cut, the pieces are joined together by sliding the slots into each other. This makes for a very strong and rigid leg. In most cases, you won’t even need to use an adhesive to hold them together. While this technique works well for both wood and expanded PVC, it is a bit more difficult when using acrylic. Acrylic is a little more brittle and will break if the slots are too tight. In this case, you are better off cutting the joints a bit larger and laying down a bead of hot glue.
Ryobi SC164VS
Dremel 1800
Dewalt DW788
16”
18”
20”
Variable 400-1,600
Variable 500-1,700
Variable 400-1,750
5”
5”
5”
Blade Types
Plain, Pin
Plain, Pin
Plain
Blade Stroke
3/4”
3/4”
3/4”
2”
2”
2”
Table Tilt Right
45 Deg
45 Deg
45 Deg
Table Tilt Left
N/A
5 Deg
45 Deg
Shipping Weight
33 lbs
53 lbs
73 lbs
Motor Amperage
1.2 A
1.6 A
1.3 A
120 V 60 Hz
120 V 60 Hz
120 V 60 Hz
Good
Good
Excellent
Table Material
Aluminum
Cast Iron
Cast Iron
Table Surface
Poor
Good
Excellent
3”
3”
N/A
Blade Change
Poor
Good
Excellent
Tension Adjustment
Good
Excellent
Excellent
Dust Collection Port
Yes
Yes
No
Good
Good
Excellent
No
Yes
Option
Includes six blades
Disc Sander, Blade drawer, Includes 12 blades
Full Ball bearings, Low maintenance, Includes two blades
$87.00
$239.00
$399.00
Saw Model Size Speeds (SPS) Blade Size
Cutting Capacity
Motor Voltage Vibration
Blade Insert
Air Blower Light Other Features Street Cost
COMPARISON CHART 42
SERVO 02.2005
Cutting Multiple Pieces There are times you need to cut multiple pieces that are the same shape. To do this, stack several of the pieces together using thin strips of doublesided tape. Carpet tape works nicely. If you are cutting expanded PVC or acrylic, you will also want to coat the top with masking tape. Not only does the tape aid in the cutting of the stock, but it also gives you a surface to transfer your pattern onto. Once the pieces are cut, you can do all your sanding while they are still connected. There are some disadvantages to bulk cutting. If you make a mistake, you will ruin all your pieces — not just one. Also, you will have to use a coarser blade, which will yield a rougher cut. To cut the stock shown here, I had to use a #4 blade verses the #1 I normally use. SV
ABOUT THE AUTHOR Michael Simpson has been an avid woodworker for 20 years. He runs the MGS Woodworking site at www.mgsweb.com/woodworking He also runs the Kronos Robotics website at www.kronosrobotics.com Kronos Robotics caters to beginner electronic enthusiasts, as well as seasoned engineers.
Menagerie.qxd
1/5/2005
8:34 AM
Page 43
Send us a high-res picture of your robot with a few descriptive sentences and we'll make you famous. Well, mostly.
[email protected]
Roverbot Orestis Kalantzis
Roverbot is an autonomous robotic platform that moves on wheels and has the ability to be self-guided or remote-controlled (locally or via a wireless LAN or the Internet). Its basic principles are two independent motor wheels (and a third one — a smaller, free-turning wheel — for support). The speed divergence of the wheels makes Roverbot turn just like a tracked vehicle, eliminating the need for the use of a steering gear and, therefore, facilitating spatial placement. I also found it necessary to use a PC instead of any other computer system (microcontroller-based or PLC) due to the wide range of developing software, operating systems, networking capabilities, and peripherals in general. Characteristics: Dimensions: Length: 22.5 in Height: 15 in Width: 22.5 in Weight: about 88 lbs Cost: about $864.00 (expected to reach $2,000.00). History: I started designing Roverbot in 1992. I wanted to experiment and acquire some real experience in robotics, but also to build a platform for further experimenting in self-direction, automated map-making, and other applications of Artificial Intelligence and Neural Networks. Simulation appeared to be an alternative course, but one I had to reject because of the obvious danger of being driven to wrong or non-applicable conclusions (due to its inevitable distance from reality), but also because it would deprive me of the chance of designing/developing electronic and mechanical hardware. Beside the subsystems of stepper motors and their drive circuits that I designed (and built as prototypes) in 1996, all the rest was manufactured between May and October of 2002. For more information, please visit http://roverbot.netfirms.com where you can find photos, videos, VRML 3-D models, and more.
SERVO 02.2005
43
FebNewProducts.qxd
1/4/2005
12:44 PM
Page 44
New Products
New Products to modify servos for wheeled platforms. • Modular mechanical connection — front and side axle attachments and side and rear mounting points.
MOTORS Smart Servos Put It All Together
Each motor incorporates a microprocessor to support these capabilities with an easy-to-use interface. Each motor includes two cables for daisy-chaining and 11 different mechanical links. Innumerable configurations are possible, such as two-wheel platforms, dogs, and humanoids with few or no additional mechanical parts. Both motors operate from 5 to 10 VDC and offer three softwareconfigurable range/resolution modes:
G
arage Technologies, Inc., has announced that AI Motors are now available in the US. AI Motors combine a serial bus control interface, modular mechanical connections, and position and loading readout. As true robotics motors, they provide the functionalities of a servo, gear motor, wheel encoder, and motor interface. Special capabilities include:
• 332° at 1.3° resolution • 166° at 0.65° resolution • 360° continuous rotation at 15 different speeds.
• Simple serial interface (RS232 at TTL levels) — no need for a multi-channel PWM interface. Up to 31 motors can be placed on a single four-wire bus. • Position readout — no need for a position encoder. • Current readout. Motor current provides a reading proportional to mechanical loading. Each motor also provides overload protection by shutting down in the event of over current. • In addition to commanding position and speed, you can set over current limits, motion limits, and control-algorithm coefficients individually for each motor. • Full 360° rotation mode under software control — no need
At 9.5 V, the AI-701 provides 7 kg*cm stall torque and a maximum of 80 RPM and the AI-1001 provides 10 kg*cm torque and 60 RPM. Configuration GUI and example source code are available for free download. The AI-701 is priced at $65.00 each and the AI-1001 at $90.00. Complete evaluation and humanoid robot kits are also available. For further information, please contact:
Garage Technologies, Inc.
93 Norton Ave. San Jose, CA 95126 Tel: 408•347•0556 Email:
[email protected] Website: www.Garage-Technologies.com
Circle #124 on the Reader Service Card.
Need a small, full-featured robot controller? Meet Orangutan: Want to build a small robot that doesn’t look like a PCB on wheels? Orangutan is small enough for integrating into a small robot, rather than being the small robot. With motor drivers, buttons, display, and buzzer, all you need to add is your own chassis, sensors, software, ... you know, the fun stuff.
(actual size)
8x2 LCD
programming connector buzzer
Atmel MEGA8/168 microcontroller
three pushbuttons
1.85” dual bidirectional motor driver 2.00”
Find out more at www.pololu.com or by calling 1-877-7-POLOLU.
44
SERVO 02.2005
two motor ports
reset button power switch power LED
trimmer pot 12 I/O ports with power and LED on I/O line ground for easy sensor connection
Circle #111 on the Reader Service Card.
FebNewProducts.qxd
1/5/2005
8:37 AM
Page 45
ROBOT KITS Binary Player Robot
O
WI introduces the second generation of its binary navigating robot kit. Binary Player Robot is a very predictable twowheeled robot. An internal program stored on a memory disk created by the user ascertains its predictability. Therein, however, lies the fun. Binary Player Robot is easily re-programmable by the controller ... you. Binary Player Robot is controlled by black and white patterns on a disk, which are read by an infrared sensor. Particular patterns activate either of two wheels to turn left, right, forward, or pause. These on/off commands illustrate the basic principles of binary coding. To change a movement program, the operator simply creates a new disk pattern and/or changes the speed variation on the three-speed gearbox. This is a good beginner’s robot. The battery-controlled kit can teach the basic principles of robotic sensing and locomotion. It features a pre-assembled printed circuit board (PCB), hardware, and mechanical drive system that can be handled by almost anyone. Only basic hand tools are required for assembly. An infrared sensor and PCNB controls the robot. Easy-to-assemble, this OWIKit beginner building level robot makes a great entry for robotic competitions, science fair projects, robotic workshops, science enrichment camps, and classroom activities. The suggested retail price is $34.95. For further information, please contact:
OWI, Inc.
17141 Kingsview Ave. Carson, CA 90746 Tel: 310•515•1900 Fax: 310•515•1606 Website: www.owirobot.com
Circle #135 on the Reader Service Card.
Take Education Off Road
R
o g u e Robotics introduces the new Rogue ATR ERS™ (ATR — All Terrain Robot, ERS — Educational Robotics System) robot kit. This system is the first of its kind for high school classrooms and hobbyists, providing robotics, electronics, and object-oriented programming in one system, while offering unparalleled all-terrain mobility. Rogue ATR ERS features an 8” base with rubber tracks, Rogue’s universal sensor mount system, dual DC gear motors, extra level capability for expansion, and a 1.1 A dual H-bridge module, extra level capability for expansion, a 7.2 V NiCad battery, and an OOBoard™ educational development board as its brain. The Rogue ATR ERS is made from the same lasercut, powder-coated aluminum as the popular Rogue Blue robot base. The kit is bundled with a curriculum text full of experiments, a parts kit, and a plastic storage box to house the fully assembled robot neatly in a classroom or under your workbench. Powering the Rogue ATR ERS is the OOBoard, with an embedded OOPIC® object-oriented processor, which can be programmed in C, Java™, or Basic syntax. The kit includes a CD ROM that contains the programming editor for the OOBoard, as well as samples and curriculum materials. The Rogue ATR ERS is the SUV of Educational Robots; small objects, uneven floors, and cables are not barriers for this robot. The Rogue ATR ERS robot kit sells for $324.95 and the OOBoard sells for $119.00. For further information, please contact:
Rogue Robotics
103 Sarah Ashbridge Ave. Toronto, ON M4L 3Y1 Canada Tel: 416•707•3745 Fax: 416•238•7054 Email:
[email protected] Website: www.roguerobotics.com
Circle #148 on the Reader Service Card.
SERVO 02.2005
45
Volrath.qxd
1/3/2005
2:23 PM
Page 46
Build a PICChip Electronic Speed Control by Dennis Volrath odern electronic speed controls (ESCs) incorporate very versatile microcontrollers — a microprocessor type of device that is entirely self contained. This project describes an ESC that uses the Microchip 16F873
M
The PICChip and connections.
microcontroller. This device includes five analog inputs and two pulse width modulation (PWM) outputs. The ESC firmware listing is available through the SERVO website (www.servomagazine.com) and is somewhat unusual; it includes eight different functions, as described in the Sidebar below. This ESC is designed for the higher power cobalt brush type motors, although any of the cantype motors can also be used. The total cost of all parts — excluding the circuit board — is about $35.00. The ESC function can be built in several different voltage ranges. The standard range is 7 to 15 NiCad cells (8.418 volts). By exchanging diode D1 for a resistor, R13, it allows operation from 16 to 21 NiCad
cells (19.2-25.2 volts). The 7 to 21 cell versions will handle 35 amperes continuously, with a peak capacity of 50 amperes for 60 seconds. The final ESC measures 1.9 by 2.5 by about 1/2 inch and weighs about 1-1/4 ounces without lead wires. With the addition of several more components and component changes, this ESC can be constructed to handle 40 NiCad cells (48 volts) with a maximum current rating of about 35 amps. The addition of heatsinks for the FETs will allow substantially higher maximum current ratings.
Build the ESC The three ExpressPCB circuit boards (board layouts are at www.servomagazine.com)each have two ESC boards for a total of six ESC circuit boards. The boards must
In-depth Info on the ESC Mode The ESC mode includes the following items: 1. Reduction of maximum available motor power levels on low battery condition. 2. Switching speed of 2,500 Hz (cycles per second). 3. Linear motor POWER versus transmitter stick operation for propeller drive. 4. Motor power down on wrong signal from RC receiver. 5. Automatic calibration of the low and high transmitter throttle positions. 6. Nine volt doubler circuit for the HEXFET gate driver circuit.
46
SERVO 02.2005
7. Error counting at the rate of 30 counts per second to a maximum of 65,000 for receiver errors. (Binary error output is on pins 15 and 16.)
1,200 Hz beep.
8. Receiver Battery Elimination Circuit (BEC) for 7 or 8 cell operation.
14. Pin 23 changes to 5 volts DC on the high beep.
9. Output 0 or 5 volt signal on pin 19 for an optional brake function (not covered).
15. Pin 24 changes to 5 volts DC after an accumulated loss of radio signal of about 10 seconds.
10. Valid receiver monitor indicator on pin 27 that reads 0 volts DC for no signal or wrong signal and 5 volts for valid radio signal.
16. Pin 25 changes to 5 volts DC after an accumulated loss of radio signal of about 2 seconds.
11. Output on pin 28 that will read 0 volts and will change to 5 volts DC after the PICChip is “armed.” 12. Pin 21 changes to 5 volts DC on the
13. Pin 22 changes to 5 volts DC on the middle beep.
17. Pin 26 changes to 5 volts DC after an accumulated loss of radio signal of about 1/2 second. (These status pins can drive an LED through a 680 ohm resistor.)
Volrath.qxd
1/3/2005
2:24 PM
Page 47
Build a PICChip Electronic Speed Control be cut in half before assembly. The simplest way to cut them is to lightly clamp a steel edge to the middle of the circuit board. Then use a small coping saw with a thin blade to cut against the steel edge to separate the two ESCs from the board. Make absolutely certain that the steel edge is placed such that no copper foil patterns are cut. Next, the ESC will be constructed. Load the “Connections plus parts.pcb” (at www.servomagazine .com) into the ExpressPCB program. Refer to the photograph and parts layout drawing for the location of all parts. First, insert all parts, installing the four transistors last. Be especially careful with the orientation of the transistors, diodes, and capacitors. The 3 amp diode is “standing on end.” Switching the 2N2904 (NPN switching transistor) with a 2N2906 (PNP switching transistor) or installing these transistors backward will cause all sorts of troubleshooting problems. Also note that the various diodes and capacitors must not be accidentally
Download the “Connections plus parts.pcb” for the PICChip. reversed. For the record, a reversed tantalum capacitor may not fail until months after construction of this project. Note that the 2N2904 and 2N2906 transistors have been discontinued. RadioShack has equivalent transistors available in bulk. Just make certain
that whatever transistors are used are configured as “Emitter-Base-Collector” and are of the TO-18 type. Next, install the HEXFETs. Note that they have the two outside lead wires soldered. The center lead is not used. The two outside HEXFET leads
The schematic for the PICChip Speed Controller.
SERVO 02.2005
47
Volrath.qxd
1/3/2005
2:25 PM
Page 48
Build a PICChip Electronic Speed Control are soldered through the circuit board. The third connection is through the four 4-32 screws, lock washers, and nuts that hold the HEXFET to the circuit board. Note that the negative motor lead is connected directly to one of the four 4-40 screws that secure the HEXFETs to the circuit board. If this ESC is going to be used in a poorly ventilated area, heatsinks should be inserted under the HEXFETs. A small piece of aluminum — a few inches wide — will suffice. Lastly, note that the layout drawing calls for either a small jumper wire or a small switch for “turning off the ESC.” This same switch will also turn off the battery elimination circuit (BEC) if the ESC is so configured. This switch completely turns off the ESC and will result in zero battery drain. Remove all flux from both circuit
2 of the PIC. Adjust trimmer resistor R1 to set this voltage to 3.3 volts DC. (The PIC will not allow the voltage on pin 2 to exceed 5.5 volts DC, appx.) The voltage between the battery minus and both pins #1 and #20 of the PIC should measure 5.0 volts DC. If the BEC is being used, check for 5 volts between the black and red wire of the servo connector. Disconnect the battery and install the PIC. Do not install the PIC upside down. Reconnect the 9 volt NOTE: This ESC will be susceptible to moisture. If it is to be used in a float battery and verify that the ESC current plane, take precautions against water. drain is about 12 mA. If all looks well, connect the ESC Use the following procedure to microcontroller board to the receiver. check out the ESC microprocessor If the ESC does not include the BEC board. Remove the PIC from the board. connection, connect a four cell NiCad Next, connect a 9 volt alkaline battery pack to the R/C receiver. Power-up the to the ESC red and black battery lead transmitter, receiver, and ESC. Check wires. Connect a DC voltmeter for 9 volts between the motor battery between the battery black wire and pin negative black wire and test point “Z.” This ESC controller was designed for use with high perPICChip’s Built-in Programs formance model airplanes powered by electric motors. The typmechanical stops.) The different modes of operation have ical motor used involves an also been assembled on the popular RadioShack perf boards listed in the parts 6. Read-back functions with LCD display that Astroflight Cobalt 40 size motor list. The wiring and connection diagrams read the error log from items 1 and 2. with a gear box that can be run are all available through the SERVO on 22-2.4 Ah NiCad cells at curwebsite (www.servomagazine.com). 7. The LCD displays the receiver pulse rent levels of 40 A. This is a very The PICChip has the following eight width measurement and the receiver significant amount of power; programs built in: pulse width output from 0.01 to 2.54 the Astroflight motor will turn a milliseconds with 0.01 millisecond resolu13 inch (10 inch pitch) propeller 1. Standard ESC with low battery motor tion. at about 7,800 RPM. Be aware power-down and receiver error detection. that this can cause significant 8. Servo test mode with LCD display with injury to the unwary. 2. Receiver error monitoring with one left, center, and right repeated tests, along Because of this, this ESC PICChip, one ceramic resonator, and one with three different servo ramp-up and requires an “Arming” process or two other parts. ramp-down rates to test servos. each and every time the ESC is powered down and powered 3. Battery voltmeter with LCD display with These different modes are configured a range from 6 to 20.46 VDC with 0.02 volt by the input voltage to three of the PICChip back up by battery power. The resolution. inputs during power-up. Items 4 through 8 ESC verifies proper receiver are constructed on one “Hole board” from signal on power-up. After about 4. Servo DRIVER, allowing the PICChip to RadioShack. The different functions are set 1 second of valid signal with the provide the signals to operate a servo. This up with those little PC shorting blocks, also throttle set at less than 50%, function has an optional LCD that directly available from RadioShack. the ESC sends a 1,200 Hz very displays the servo output signal with a The PICChip used in this project can low power “beep” to the range from 0.85 to 2.12 milliseconds. be programmed with the PICSTART PLUS motor. (If the throttle is over programmer, available from Digi-Key. 50%, nothing will happen!) 5. Servo DRIVER configured for 0.01 to 2.55 The PIC16F873 has a set-up configuration After this, quickly move the milliseconds. This mode was used to bit file for the PIC16F873 device. This throttle to full throttle, wait for a design the ESC. (Be careful when using configuration file must be set up where the medium pitched motor beep, Oscillator function “XT” and everything the 0.01 to 2.55 millisecond configuration then move the throttle to minielse is turned off or disabled. with a servo. It will run the servo past its mum and wait for a high pitched
48
SERVO 02.2005
boards with pure alcohol or appropriate solvent. Pay particular attention to the connections around the crystal resonator and pins 9 and 10 of the PIC. Any water or solder flux residue in this area can prevent the crystal from starting, preventing operation of the microcontroller. Shake off all solvent and blow the board dry with the output of a vacuum cleaner or hair dryer.
Volrath.qxd
1/3/2005
2:26 PM
Page 49
Build a PICChip Electronic Speed Control motor beep. The ESC PIC 877 Speed Control Parts List has just memorized the high and low throttle Part ID Part No. Quantity positions. The next FET (7 to 21 cells) IRL3705N-ND HEXFET (Price reduction at 10 pcs) 4 throttle movement will 5 V REG LM2940CT-5.0-ND 1 A low drop reg 1 run the motor. This C1 272-1029 220 µF cap 1 P2022-ND 2.2 µF cap 3 whole process takes less C2, C4, C5 C3, C7 272-134 0.047 µf 1 than 10 seconds. C6, C8 272-123 100 PF cap 1 This ESC was 276-1101 1 amp diode (7 to 15 cells) 1 designed to power an D1 D2, D3 SD103ACT-ND 400 MW 40 V Schottky diode 2 electric motor under pro- D4 (7 to 21 cells) 1N5822-ND 1N5822 3 amp Schottky diode 1 peller loads. The horse PCB Per ESC article power to turn a propeller PIC PIC6F873-04/SP-ND PICChip (Must be programmed!) ** 1 is related to the RPM Q1, Q2, Q4 2N2904 2N2904 (RadioShack 276-1617) 3 2N2906 2N2906 (RadioShack 276-1604) 1 ratio raised to the third Q3 CT94W203-ND 20 K 10 turn pot 1 power. The PIC uses a R1 470 QBK-ND 470 ohm (16 to 21 cells) 1 look-up table for the R13 pulse width modulation R2, R12 22K EBK-ND 22 Kohm 1/8 watt 5 output that accounts for R3, R10, R11 47K EBK-ND 47 Kohm 1/8 watt 5 the propeller effect. If R4, R5, R6, R7 150 EBK-ND 150 ohm 1/8 watt 5 this ESC is to be used for R8, R9 10K EBK-ND 10 Kohm 1/8 watt 5 other purposes, the look- XTL PX400MC-ND 4 MHz resonator ** 1 276-1999A 14-pin socket (two end-to-end) 2 up table can be modified SOCKET 1 to provide any throttle Digi-Key (All -ND parts) Remaining parts from verses power output. 701 Brookes Ave South RadioShack and Note that the ESC does Thief River Falls, MN 56701 local hobby shops not provide motor 800-344-4539 reversing. The web page includes a linear assem- Resistor Note: Digi-Key minimum order on 1/8 watt resistors is five pieces. ** DO NOT SUBSTITUTE!! bly file for drives not involving propellers. Next, connect the ESC, fully many different functions in robotics the limits are only defined by your charged motor battery, and motor and other hobbyist applications; imagination. SV without a prop per the ESC wiring diagram. Connect a DC voltmeter between the motor battery black wire and pin 2 of the PICChip. Adjust the trimmer resistor R1 to set this voltage to 3.3 volts DC The final step is to securely mount the motor and prop, fire up the radio and ESC, and run the motor battery down to about 0.9 volts DC per cell. Then, adjust R1 so that the motor battery stays at 0.9 volts per cell or the low battery voltage of your choice. The ESC will shut off drive power to the motor when the PICChip pin 2 is less than 2.30 VDC. It allows full power to the motor when pin 2 is over 2.50 VDC. Between these two voltage levels, the ESC allows 20%, 40%, 60%, or 80% power output. In conclusion, this project has Circle #75 on the Reader Service Card.
SERVO 02.2005
49
Robolinks.qxd
1/5/2005
1:17 PM
Page 50
T E X A S A R T RO B OT S H A N D M A D E
I N T E L L I G E N C E
UNIQUE LIMITED EDITIONS INTELLIGENT & AUTONOMOUS HAND CRAFTED
.
Electronic Parts & Supplies Since 1967
.
WWW A RT BOTS COM
Meccanisms
www.gatewayelectronics.com (Electronically Speaking, Gateway’s Got It!) MAIL ORDERS CALL TOLL-FREE-1-800-669-5810
Maximum Power Control 4 Motors, 2 Servos, 3 Relays 6 Analog & 8 Digital Inputs. Adv. O/S & Development Environment. Plug-In Connectors, No Soldering
Minimum Fuss
www.meccanisms.com
For the finest in robots, parts, and services, go to www.servomagazine.com and click on Robo-Links to hotlink to these great companies.
50
SERVO 02.2005
TM
Barlow2.qxd
1/3/2005
4:27 PM
Page 51
— BY KERRY BARLOW —
I
n last month’s article, I spoke about many features of the Atom and I began to talk about how I used the Atom in my robot (pictured here). This month, I will go into further detail on code that is specific to the Atom microprocessor (see Figure 1). I encourage you to download my program examples from the SERVO website or from my own website (see the Resources sidebar).
The Program After spending much time, making many additions to my code, and watching the code grow larger with every revision, I am extremely happy I chose the
Atom processor. To give you some idea of what my program is doing before I go into detail on the Atom specific code, a diagram of the program is in order. I encourage readers to download the full program and keep it on hand while reading this article. It is not my intent to describe the full robot program here, just the sections pertinent to the Atom. The following code summary is laid out exactly as it is written in the full program: Hardware Interrupts initiated and set running in background Main Loop Check for Interruptflag If the Hardware Interrupt has been activated, branch to object detected.
SERVO 02.2005
51
Barlow2.qxd
1/3/2005
4:28 PM
Page 52
THE ATOM 24-PIN MICROPROCESSOR It should be noted that Basic Micro states that the hardware interrupts will occur between lines of code. This means that, if you have something like a pause 5000 (5 seconds), the hardware interrupt will not be processed during this pause routine. A long sound statement or some similar line of code that takes extra time to run will also cause the interrupt code to wait while it executes this line. This is not normally a problem if a person is aware of it and designs the main loop code to avoid such problems. For example, if you do need a long pause, then — instead of a pause 5000 — break this down into a small for-next loop, such as:
FIGURE 1 Read four SRF04 Sonar and store values into sonar variables Branch to four subroutines and store values into sonar variables. Read GP2D02 and store value in variable Decision statement if range is too low Check if GP2D02 has returned a short range. Set up sonar flags into a binary truth table using IF statements If Ldist <= 10, then Lflag = 8. Stop tracks if Sonar returns any detection. If Lflag = 8, c1flag = 4, c2flag = 2, or Rflag = 1, then gosub stoptrack. If any flags are set, then gosub StopTrack. Add all binary values together for Sonar sensors Objectflag = Lflag + c1flag + c2flag + rflag. Check Light sensor Gosub lightincenter and perform subroutine functions. Check for robot being trapped If the robot becomes trapped, it may swivel around for awhile looking for an opening. In this case, gosub backup and find the proper direction to turn. Do Binary calculation for direction subroutines If objectflag = 0, then gosub forwardtrack. If objectflag = 1, then gosub left15. Additional IF decision lines ... Return to Main Hardware interrupts disabled
Interrupt Loop The reader should note that, at the same time the main loop is running, the hardware interrupts are also running. At any time while the program is within the main loop and an IR edge sensor outputs a 0, then the hardware interrupt pin will initiate an interrupt to the main loop and send control to a special subroutine. In this subroutine, I stop all motors and search for an opening around the robot. Once an opening is found, I resume the interrupt subroutine and continue with my main loop’s code. I wish to emphasize that this interrupt occurs in hardware and is much more reliable than software solutions to implementing interrupts.
52
SERVO 02.2005
for I = 1 to 50 pause 100 next I The Atom interrupts would then be active on each of the three lines of code and only a pause 100 (.1 second) would then cause the interrupts to be disabled. As far as speed of execution, I cannot say empirically how fast the Atom is compared to other processors. On paper it is, indeed, faster (33 K instructions/second), but I am sure the readers would like some real world proof. All I can say to this is that, after reading four SRF04 sensors, detecting a GP2d02, checking a light sensor, and making decision statements, I notice no lag in object detection whatsoever. Lag or detection in a program such as this is going to be hard to measure because, sometimes, it is unknown whether an object simply was not detected or the robot drove past an object before its code could detect it. For the hardware interrupts, I test them while the robot is moving by holding a narrow yardstick in the robot’s path. As far as I can tell, the instant I place the yardstick within range of an edge sensor, I have detection and the robot code stops the tracks. I know this is not scientific, but it is my real world observation. The final and working version of the robot has the following hardware installed. The program is available online at the SERVO website or from mine. • Four SRF04 sonar range finders using a 4502 multiplexor (see Figure 2). • One GP2D02 range I/R finder. • Three CDS light sensors using the A/D input (see Figure 3). • One PIR heat sensor: currently not working. • Six I/R wall edge sensors, interrupt controlled. • One speaker. • One LCD. • One rotating sensor head. • Dual motor track drive.
Program Detail Let’s go into detail on sections of the program that are unique to the Atom. A few of my program routines may be hard to understand, so I will also review sections of the code that need explanation. The main loop has been detailed
Barlow2.qxd
1/3/2005
4:29 PM
Page 53
THE ATOM 24-PIN MICROPROCESSOR previously, so I will not belabor that point again. I cannot talk about all of the sections of my program at this time. If anyone has questions on the complete robot program, please feel free to write me or post a question on the Nuts & Volts Forum (www.nutsvolts.com select Bulletin Board).
4052 Multiplexor and SRF04 Code As readers may have guessed by now, I was running out of I/O lines quickly. When I decided to use four sonar sensors, I had to make a design decision. I could have used the modern SRF08 sensor on the Atom’s I2C bus; however, I could not afford the additional price of the sensors. I did not have enough I/O lines to waste on four sonar sensors, either. The 4052 is a four-channel analog chip controlled by two logic lines. This was made to order for my application (see Figure 2). The connections are straightforward and I am sure all readers will be able to follow the schematic easily. Simply put, the four channels are connected to the input channels, depending on binary logic applied to their A and B control lines. For example, if a low or 0 is placed on both the A and B control lines, then the Y and X lines are connected internally to the Y0 and the X0 lines. In my schematic, this would be SRF04 sensor 1 enabled. Software code then would call the SRF04 normally. The 4052 chip will come with a logic truth table for its four states. The code to implement an SRF04 on an Atom is a bit different than the code on a BS2. The code will bring the Init line high and then low to initialize the SRF04, then the echo
may be read in using the pulsin command. A pause 10 is used to ensure that the echo is received properly and to prevent ringing of the transducers. For an example of using the multiplexor with the SRF04 sensors, please download the SRF04 program.
Servo Code Using a servo with the Atom is very straightforward. This was a feature I was very happy to find out about after purchasing the Atom. The entire servo command consists of three statements on one line: SERVO PIN, ROTATION, REPEAT SERVO PIN is the I/O port on the Atom that you want the servo connected to. ROTATION is a variable or degree you wish the servo rotated to (-1,200 to 1,200) and REPEAT is the number of times you wish the command repeated internally. All servos will be different. On my servo, a command of servo 15, 0 will drive the servo on pin 15 to center. This is all that is necessary to drive a servo on the Atom processor. To move the servo a full clockwise rotation, use the command servo 15, 750.
GP2D02 CODE The Sharp GP2D02 code is identical to that of the BS2. Bringing the Sharp’s clock line low will enable the sensor to take readings. The Atom’s Shiftin command is then used to
FIGURE 2 SERVO 02.2005
53
Barlow2.qxd
1/3/2005
4:30 PM
Page 54
THE ATOM 24-PIN MICROPROCESSOR CODE 1 'CODE1.BAS 10/4/2004 'NOTE higher value is darker location tempax0 var word tempax1 var word tempax3 var word clk con 2 main adin ax0,clk,ad_ron,tempax0 'a/d port 1 adin ax1,clk,ad_ron,tempax1 'a/d port 2 adin ax3,clk,ad_ron,tempax3 'a/d port 3 debug ["one ", dec tempax0, " two ", dec tempax1, " three ", dec tempax3,13] goto main
In my program, you will see that I have used names for the command fields as follows: adin ax0,clk,ad_ron,tempax0 Ax0 refers to the port for A/D. The Clk option sets the sampling time for the A/D conversion. The name ad_ron is used to set up the options available with the ATOM hardware; this is described in the Atom documentation. In my example, I have chosen right justified input to give a real number output that is easier to read in my program. Tempax0 is a variable name I have chosen to store my CDS value.
read in the information:
Hardware Interrupt Code
shiftin datainput,cl,MSBPOST,[val02]
As mentioned previously, the Atom has several interrupt sources, which can occur from internal or external sources.
Datainput is the Sharp’s output pin and CL would be the Sharp’s clock input pin. MSBPOST will tell the Atom what format to read in the data. In this case, sample the bits after a clock pulse and put this into the variable called val02.
A/D CODE The special built-in hardware-driven A/D code is quite easy to use. Basic Micro has a nice demo program in their documentation. Refer to Code 1 to see my example of using a CDS light sensor. Refer to Figure 3; you can see how simple the CDS cells connections to the Atom’s A/D pins are. Code 1 will read all three light sensors and output the value to the Atom’s debug screen. Pin names for the three inputs are called ax0, ax1, and ax3. This can be confusing at times. Pin ax2 can only be used as an I/O port, but — if you wish — you may reference it as ax2 in your software and enable one extra I/O port on your Atom. This is digital I/O — no A/D on ax2. Simply call this pad ax2 instead of a different pin name — such as pin 1 — as you normally would. The command to read a CDS cell may be shown in a single line, as follows:
External sources: EXTINT: An external interrupt may be detected on Pin 0, either through a high to low change (used in my program) or through detecting a low to high change. RBINT: Upon change, an interrupt can occur on P4, P5, P6, or P7. This interrupt will trigger if a pin state changes from low to high (or high to low). Internal sources: Internal interrupts have many variants. These are extensively documented by Basic Micro. Some of these are: TMR0INT, TMR1INT, TMR2INT: An interrupt occurs whenever a timer overflows; this is useful for creating a real time clock on the Atom. There are three internal timers that may be set in the Atom. ADINT: ADInt interrupt occurs when A/D conversion finishes. It is used in conjunction with the ADin command. RCINT: RCInt interrupt occurs when a byte is received by the Hardware USART.
ADIN pin, clk, adsetup, var TXINT: TXInt interrupt occurs when a byte finishes transmitting from the Hardware. USART: This interrupt is disabled if you are using HSERIN/HSEROUT. CCP1INT, CCP2INT: CCPInt Capture/Compare/Period match.
interrupt
occurs
on
EEINT: EEInt interrupt occurs when a byte is finished writing to the onboard EEPROM.
FIGURE 3
54
SERVO 02.2005
Basic Micro provides a few examples of interrupt usage in their documentation. One of these examples is a real time onboard clock. In my robot, I used an interrupt on pin 0 for my edge detectors. Interrupt code must be written in the correct
Barlow2.qxd
1/3/2005
4:31 PM
Page 55
THE ATOM 24-PIN MICROPROCESSOR manner as prescribed by Basic Micro or they say you can have stack overflow. I can attest to the fact that this is true. I spent quite awhile initially debugging my robot program and could not figure out why I was getting resets after 30 seconds of run time. An astute person on the Atom forum was able to diagnose my problem and correct it for me. To start using an interrupt, three lines of code are necessary to enable hardware interrupts. One line of code is used to disable interrupts below a certain point in your program. The actual subroutine branch point and a resume command are the final lines of code necessary to use External Interrupts. These code lines are: Oninterrupt interrupt source, label Oninterrupt is an operator used to tell your program where to go if a specified interrupt occurs. Interrupt source specifies what type of interrupt to act on. Label is used to specify the place to jump to in a program if the interrupt occurs. SetExtInt mode SetExtInt sets the external interrupt pin to input and sets the state that will cause an interrupt (EXTINT must be enabled). Mode is the setting that will trigger the actual interrupt. There are two choices available: EXT_H2L = Will activate when pin is pulled low (from high). EXT_L2H = Will activate when pin is pulled high (from low). Enable {Interrupt Source}
FIGURE 4 Enable interrupt is used to turn on the interrupt system. If no interrupt is given, all interrupts set up using ONINTERRUPT are enabled. Enable interrupt can be used to turn on specific interrupts. Your program code goes here ... disable extint ‘ Disable interrupt can be used to turn off specific interrupts or all interrupts at once. If no interrupt is
Circle #87 on the Reader Service Card.
SERVO 02.2005
55
Barlow2.qxd
1/5/2005
10:43 AM
Page 56
THE ATOM 24-PIN MICROPROCESSOR given, all interrupts are disabled. Your subroutines and additional user program code ... ProgInt ‘ This is the subroutine that the interrupt branches you to. User code ’ This does whatever you wish your subroutine to do inside this code. resume ‘ This returns you to main program flow where the interrupt occurred. In my robot program, the code is written as follows: Oninterrupt Extint, Progint ‘ Extint tells the Atom that I will have an interrupt occurring on pin0. Progint is the subroutine I jump to if an interrupt occurs. SetExtInt EXT_H2L ‘ This will generate an interrupt if pin 0 goes from high to low. Enable Extint ‘ This enables interrupts from this point down in the program. This line is necessary to actually turn on the interrupt function of the Atom. Main ‘ The start of your main loop. while 1 The main loop code of your program goes here ...
wend disable extint ‘ Disable interrupt can be used to turn off specific interrupts or all interrupts at once. If no interrupt is given, all interrupts are disabled below this line. User Subroutines ‘These are the additional program codes and all of your subroutines. ProgInt ‘ This is the subroutine branched to after an interrupt occurs. low motora1 ‘ Turn off all my track motors. low motora2 low motorb1 low motorb2 resume ‘ Note that this is a special command to tell the Atom to resume from where the interrupt occurred. You may do anything you wish after an interrupt has occurred. In this particular program, I set an interrupt flag that I check after returning to my main loop. If this flag is set, then I branch to my object detection subroutine and process the code.
Future Plans There is a lot more that can be done with this robot. I still have many unused functions on the Atom. Future plans include better sound functions to show what is actually happening to the robot for debug purposes. The LCD display is good, but hard to read while the bot is moving around. Morse code or a voice output chip would solve this problem. Onboard temperature reading is planned for the I2C bus of the Atom. I hope to someday get a working PIR sensor installed. Additional sonar and I/R sensors need to be added. I cannot emphasize this enough: In my experience, you can never have too many sensors on a robot. There need to be additional forward sensors, as well as rear side sensors and more aft sensors. This may require the addition of another processor or an extra multiplex chip. I hope these articles have shown you some of the many capabilities of the Basic Micro Atom 24-pin microcontroller and all the possibilities that using it opens up. SV
RESOURCES I/R receiver www.parallax.com/detail.asp?product_id=350-00014 SRF04, PIR Sensor, and GP2D02 http://acroname.com SN754410 and CD4052 www.mouser.com A/D wiring, Program, and Author Contact http://mntnweb.com/hobby/bolo/ Atom 24 and Manual www.BasicMicro.Com
SERVO Magazine www.servomagazine.com
56
SERVO 02.2005
Pfister.qxd
1/3/2005
4:23 PM
Page 57
Smart Hat for a Stylish RoboSapien
M
y wife gave me a RoboSapien as a birthday gift in June, 2004. She found it at Fry’s Electronics in California shortly after they became available. After playing with it, I was convinced it was not just another cute remote controlled toy. It could form the basis for a low cost autonomous mobile robot. Like many other electronic hobby experimenters, in the past I have destroyed a great many devices by trying to make them work better, so I was reluctant to experiment on the RoboSapien. Then the August issue of SERVO Magazine announced the Hack-a-Sapien contest. I decided to take a chance and build an autonomous controller for the robot. The controller would have sensors to inform the robot, a processor to analyze the sensor data, and a command generator to control the RoboSapien in performing autonomous tasks. This evolved into a Smart Hat that is put on the robot to let it achieve autonomous operation. At first, I planned to mount everything inside the robot body by making extensive changes to the mechanics, sensors, and wiring. This was a huge effort and I feared this approach had the potential of joining my growing
collection of partially finished projects. Instead, I considered following a small set of design goals for the contest entry:
also suits my philosophy of value engineering for low cost experiments, which translates into “make it cheap and cheerful.”
• Make no permanent modifications or internal changes to the RoboSapien.
The Parts
• Use only a simple autonomous microcontroller programmed using a PC. • Use only off-the-shelf sensors and actuators — no custom electronics or mechanics.
For the microcontroller, I used a Kronos Robotics preassembled Dios circuit board that has proved successful on many other small projects. This PCB is small (2.5 x 3 inches), lightweight, low power, and very easy to program from a PC serial port. It has a very impressive 10 Mips PIC microcontroller with built-in analog to digital
• Use only the remote IR optical input to the robot for sendFigure 1. Smart Hat has side IR sensors, a front servo ing commands. • Make the final result look good and be in the style of the RoboSapien design.
mounted ultrasonic sensor, and a programmable controller while keeping the face visible.
As always, I chose to salvage existing parts from other projects rather than buy or build anything new. This meant I would use components that I was familiar with from other applications. It SERVO 02.2005
57
Pfister.qxd
1/3/2005
4:24 PM
SERVO Magazine
Page 58
Hack-a-Sapien
Second Place Winner
Figure 2. Parts for the Smart Hat — Dios processor, IR sensors, and batteries.
conversion, serial communication, and many other features, such as only requiring a 9 volt battery to operate autonomously. The controller choice drove the size of the add-on to the robot. It was a bit too big to be placed inside the body without major modification. I experimented with both a backpack and a waist pack for mounting, but these displaced the center of gravity and limited the walking agility of the robot. To preserve the existing robot motions, the center of gravity would have to be carefully maintained and was a definite mechanical constraint on the possible design choices. For sensors, I planned to use two Sharp GP2D12 IR range sensors that interface easily to the microcontroller. These give a reasonable range reading using an analog signal that is very reliable. My first thought was to mount them on the front of the robot, but I had one more sensor I wanted to use. This is an SRF08 ultrasonic ranging sensor from Devantech that uses an I2C interface bus available on the Dios microcontroller. It was a perfect choice for the front of the robot, both in
function and looks. I had been using it mounted on a standard size hobby servo to scan a 180 degree field of view and was confident in its performance. By going to a smaller and lighter micro servo, I could mount it on the robot, but this would require another battery pack for the servo power — and more weight. One night, I dozed off pondering different designs. I needed a good idea for mounting the controller, sensors, servo, and batteries. I woke up the next morning with the concept of removing the robot head and replacing it with a new one. Unfortunately, this violated my first design rule. The simple solution was that I would not remove the head, but add a hat to the robot instead: a smart and stylish hat with sensors, batteries, a servo, and a controller that only sits over the robot head with no connections other than an optical IR transmitter LED for command output. It would mount directly over the robot’s center of gravity and would have only a minor effect on the motion of the robot.
The Hat Design
Figure 3. Plastic parts for the Smart Hat with a CAD drawing and paper fit test.
58
SERVO 02.2005
For a while, I have wanted to use Pololu Corporation’s plastic laser cutting design service, just to see how it works. This was my chance; since I already had all of the other parts, it was not a big investment to buy some
custom-cut plastic parts. I began to experiment on part layouts using my favorite free CAD program, CadStd, to produce some potential designs. I looked at other laser cut projects and plastic parts and began to simplify my concept. Curved surfaces were out. I would concentrate on a simple, open box style with four sides and a top. I tried a few designs, printed them out, and then cut out paper models to test the fit, look, and feel. In the end, the CAD design was reviewed and a $16.00 cost quoted by Pololu. It was cut once, air mailed in two days, and fit perfectly. This may be the first time I have ever had anything I designed work on the very first try. The Smart Hat design is a box cut from 1/8 inch ABS plastic. White colored ABS often has brown edges from the laser cutter, so Pololu suggested using black stock with a smooth side and a textured side. The top is recessed to mount the PCB, the servo battery pack of four AAA cells, and the 9 volt battery for the PCB; in addition, it provides rear access to the serial port and a power connection. All hat parts are symmetric so that either the smooth side or the textured side can be used as the outside surface of the hat. The accuracy of the laser cutter is about 0.01 inch and provides a very tight fit with no loose joints. The back of the hat extends into the neck slot of the robot and the front extends down to the chest with holes for mounting screws. A major control problem is that the RoboSapien rocks from side to side up to 30 degrees as it moves. This makes the side-looking IR range sensor measurements very inaccurate. The solution was to use a mercury switch to detect the upright position of the body and to only do the side range measurements during the upright time period. The front-looking ultrasonic sensor is not as subject to errors from the rocking motion, but it can also use the upright detection data to trigger the sensor operation. In the final design, connector pins to the Dios ultra board mount to a RadioShack prototype circuit board.
Pfister.qxd
1/3/2005
4:25 PM
Page 59
SERVO Magazine This board holds the micro servo, the SRF08 ultrasonic sensor, a mercury switch tilt sensor, an IR LED for communication to the robot, and connectors for the GP2D12 IR sensors. The Dios board rests on the top plastic panel with a four cell AAA battery pack attached by screws and a 9 volt logic battery for the Dios controller. The GP2D12 IR range sensors are mounted at the top of each side panel. The circuit for the Smart Hat consists of connecting interface pins to sensors and actuators. No external digital logic or analog interfaces are required. Inputs to the Dios board are two analog channels from the IR range sensors and a digital line from the mercury switch tilt sensor. Outputs from the board are one control line for the servo and one control line for the IR transmitter LED. A logic power plug is provided along with a screw type interface for the servo battery pack. Communication with the ultrasonic range sensor is over the built-in I2C bus that uses two wires for clock and data. The final Smart Hat weighs 400 grams. The robot weighs 900 grams for a total of 1,300 grams or just under three pounds. The hat batteries are rechargeable NiMH and last for about an hour with proper sensor management. The hat is attached to the robot by sitting in the back neck slot and resting on adjustment screws on the front.
Hack-a-Sapien
Second Place Winner
Rubberbands can be placed under the arms to provide a solid, stable mounting. The hat does not touch the robot head and the front hole lets the robot face and eyes see the world.
The Program In 1977, the IEEE held the first micro mouse contest in New York, where the goal was to produce an autonomously controlled robot mouse to find its way through a maze. By using the simple rule of hugging the left wall, a mouse can get through a simple maze. This is to be the first autonomous test program for the Smart Hat: to simply emulate the historic robot mouse. Many Figure 4. Circuit connections to the Dios processor for the Smart Hat board. more complex behaviors will follow, but this first one is a necessary step for learning 1. Start up and initialize the program and activate robot. about the control characteristics of the 2. Detect if the robot is active by reading robot. the mercury switch. The structure of the program is 3. Measure the side range distances with a simple repeating loop with the the IR sensors. following steps:
SERVO 02.2005
59
Pfister.qxd
1/3/2005
4:26 PM
SERVO Magazine
Page 60
Hack-a-Sapien
Second Place Winner
and a rigid syntax. In addition, your design has to be compatible with the real time constraints imposed by the system. In the case of the Smart Hat, no severe real time constraints exist and the Dios language Figure 5. Robot controller and a simple TV remote with receive and transmit test circuit. provides an easy program development for robot control. Best of all, it is provided free 4. Rotate the servo beginning from left for use with the Dios products. to a start angle. 5. Read the ultrasonic range for the rotation angle. 6. Move the servo and repeat step 5 until end of rotation. My RoboSapien fitted with a 7. Based on side ranges and forward Smart Hat is being tested to determine obstacles, choose a command. how well it moves on both carpet and 8. Send a command to the robot using wood surfaces. This requires sensing a the IR transmitter LED. sidewall, detecting any front obstacles, 9. Wait for a brief period of time and determining the command to transmit sample tilt switches. to the robot, and then transmitting this 10. Repeat, starting at step 3. command continuously. The Smart Hat monitors the movements of the robot This program is implemented and updates the commands as using the Dios programming lanrequired. guage. The language provides an When it detects a movement extensive library of built-in functions anomaly, it halts the program and for the I2C bus, IR modules, servo stores a diagnostic readout in the control, LEDs, and switches. A large EEPROM memory for future PC amount of sample code is provided to analysis. In general, the robot moves make program construction a very slowly on carpet and faster on smooth easy task. surfaces. It can turn and maintain a I estimate my programming time fixed distance from a sidewall and can to be 10 times faster than with C and detect and avoid large, fixed obstacles 100 times faster than with assembly in its path. The Smart Hat is now ready language. As in all object-oriented softto autonomously control a robot ware systems, there is a learning curve and to be programmed to do many
The Operation
The Sources Kronos Robotics P.O. Box 4441, Leesburg, VA 20175 www.kronosrobotics.com Pololu Corporation 6000 S. Eastern Ave., Suite 5-E, Las Vegas, NV 89119 www.pololu.com Devantech, Ltd. (Robot Electronics) Unit 2B Gilray Road, Diss, Norfolk, IP22 4EU, England www.robot-electronics.co.uk
60
SERVO 02.2005
Visit the Smart Hat website for demonstration programs, mpeg movies, and detailed technical information for design and construction. www.sosrobots.com CAD Standard drawing program by John Apperson www.cadstd.com Robo-Hoops 2004 at Penn State, Abingdon on December 4, 2004 www.ecsel.psu.edu
other useful things.
The Future I have some future plans and ideas for using the Smart Hat RoboSapien. A simpler first project will be to add a standard TV remote IR receiver, as shown in the circuit diagram. This will allow the use of a much simpler remote, such as my favorite — the six button RadioShack model URC-1030B01. This will let someone control the Smart Hat robot motions without having to master the complex controller supplied with the RoboSapien. This interface can also be used to provide low rate, low power, and limited range wireless computer communications. Another intriguing project is to make a second Smart Hat RoboSapien and then program the pair to compete and cooperate, similar to the MIT 6.270 student autonomous design competition class. I plan to use a pair of proven IR beacon kits from Pololu for mutual robot location. Another robot contest is RoboHoops 2004, held at Penn State, Abingdon in December of 2004. They had a special innovation challenge using a RoboSapien that is autonomously controlled. It must dunk a four inch foam ball in a 10 inch hoop, located 12 inches above the ground. One definite experimental research objective of the Smart Hat is to develop behavior-based autonomous robot control programs. The goal is to allow the implementation of modern computing concepts on a PC and transmit the programs to the Smart Hat for embodied operation. Some concepts include finite state machines, fuzzy logic, neural networks, and other machine learning techniques for intelligent robotics. In summary, the combination of a RoboSapien for under $90.00, along with a Smart Hat for under $100.00 and a PC can provide an experimental autonomous robot system with great capability. At this low cost, multiple robots can be used to cooperate and compete in a wide range of experimental environments. SV
Full Page.qxd
1/5/2005
7:56 AM
Page 61
"The resounding success of the 2004 conference is an indication that there is a growing new market for personal, service and mobile robotics. From its academic and research nascency, robotics technology is moving into a number of diverse consumer and business-to-business applications."
Profiting from the 1st New Industry of the 21st Century
Colin Angle, Co-founder and Chief Executive Officer, iRobot
SECOND ANNUAL
Conference and Exposition The Nation’s Premier Business Development Event for Mobile Robotics and Intelligent Systems May 10-11, 2005 Hyatt Regency Cambridge Cambridge, MA
www.roboevent.com Produced by:
Premier Sponsor
Corporate Sponsors
Media Sponsors
RoboticsTrends Association Sponsors
SERVO 02.2005
61
Events.qxd
1/3/2005
3:54 PM
Page 62
Send updates, new listings, corrections, complaints, and suggestions to:
[email protected] or FAX 972-404-0269 Have you been thinking about participating in the DARPA Grand Challenge this year? If so, don't forget that February 11 is the deadline for teams to complete part one of the five-part application process. Basic team information and certification of funding must be completed by the 11th. The deadline for the next part of the process is March 11th, when vehicle specifications and a video must be submitted. If you're not up for the Grand Challenge, don't worry. There are plenty of smaller robot events scheduled for the coming months. — R. Steven Rainwater For last minute updates and changes, you can always find the most recent version of the complete Robot Competition FAQ at Robots.net: http://robots.net/rcfaq.html
F e b ru a r y 2 0 0 5 4-6
Robotix IIT Khargpur, West Bengal, India Organized for students of IIT Khargpur, this contest includes events for both autonomous robots and radio-controlled machines. www.robotixiitkgp.com/
19
DPRG Table Top and Fire Fighting Competitions The Science Place, Dallas, TX The DPRG is combining their spring Table Top robotics event with the regional Trinity Fire Fighting Robot Competition this year. The Table Top contest offers a variety of events for small autonomous robots. www.dprg.org/
March 2005 6-10
19-20 Manitoba Robot Games Manitoba Museum of Man and Nature, Winnipeg, Manitoba, Canada A variety of events, including sumo, a robot tractor pull, and Atomic Hockey. www.scmb.mb.ca/
24-27 ROBOlympics San Francisco State University, San Francisco, CA Lots of events, including sumo, BEAM, Mindstorms, FIRA, and robot combat. www.robolympics.net
A p r il 2 0 0 5 9-10
Creative Design Contest University of Illinois at Urbana-Champaign, IL SERVO 02.2005
Trinity College Fire Fighting Home Robot Contest Trinity College, Hartford, CT Could the fire have been set by a robot builder frustrated with the voluminous rules? www.trincoll.edu/events/robot
12-14 DTU RoboCup Technical University of Denmark, Copenhagen, Denmark Imagine your typical line following contest. Now add forks in the line, ramps, stairs, gaps in the line, shifts from indoor to outdoor lighting, reversals of the line shading (white to black), and 50 cm "gates" though which the robot must pass. www.iau.dtu.dk/robocup/about_robocup.html
15
Carnegie Mellon Mobot Races Wean Hall, CMU, Pittsburgh, PA The traditional Mobot slalom and MoboJoust events. www.cs.cmu.edu/~mobot/
16
UC Davis Picnic Day Micromouse Contest University of California at Davis, CA Every year, UC-Davis has a campus-wide event
APEC Micromouse Contest Hilton Hotel, Austin, TX This will be the 18th annual APEC Micromouse event. www.apec-conf.org/
11-12 AMD Jerry Sanders
62
The design problem for this contest is new and different each year. Check the website for the latest news and details. http://dc.cen.uiuc.edu/
Events.qxd
1/5/2005
12:02 PM
Page 63
Machine It Yourself & Save...Guaranteed! Tired of PAYING for Machining?
Put a COMPLETE MACHINE SHOP on Your Bench Top! known as Picnic Day. Every Picnic Day includes the annual micromouse contest. The event follows standard micromouse rules. w w w. e c e . u c d av i s . e d u / umouse/
23
RoboFest Lawrence Technological University, Southfield, MI A competition and exhibition of autonomous LEGO robots. Designed to spur students’ interest in science, engineering, programming, and technology. http://robofest.net/
Now 7 Models! • 3 Tools in 1 – Lathe, Mill Drill • Versatile – Machine Metals, Plastic, More • Precise – Built to tolerances up to 0.0005 inc h • CNC Compatible – Models ma nu factured to easily adapt CNC systems • EASY to Use – Full Instructions & Lifetime Tech Support
And ONLY the Smithy is... • GUARANTEED to Pay for Itself or Your Money Back!
Get Your FREE FACT KIT!
Call Today 1-80 0-476-4849 Ask for operator SER
THOUSANDS OF ELECTRONIC
PA R T S A N D S U P P L I E S
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, BREADBOARDS, RESISTORS, SOLAR CELLS, BUZZERS, BATTERIES, MAGNETS, CAMERAS, DC-DC CONVERTERS, HEADPHONES, LAMPS, PANEL METERS, SWITCHES, SPEAKERS, PELTIER DEVICES, and much more....
O R D E R TO L L F R E E
1-800-826-5432 Ask for our FREE 96 page catalog
Robotics Showcase
27-29 Singapore Robotic Games Republic of Singapore An amazing assortment of events, including pole balancing, legged robot obstacle course, legged robot marathon race, wall climbing robot race, micromouse, sumo, robot soccer, robot gladiator competition, and the robot colony competition. http://guppy.mpe.nus.edu. sg/srg/
M ay 2 0 0 5 10-11 RoboBusiness Conference Hyatt Regency, Cambridge, MA The nation’s premier business development event for mobile robotics and intelligent systems, dedicated to commercialization and application of robotic systems. www.roboevent.com SERVO 02.2005
63
Robytes.qxd
1/4/2005
12:54 PM
Page 64
Robytes everal weeks ago, shortly before Godzilla’s induction to the Hollywood Walk of Fame (coincidence?), Dave Calkins disappeared, leaving behind only a box of LEGOs, a blown-out pair of K-Mart headphones, and half a case of Guiness. Sensing the gravity of the moment, the SERVO staff shifted into emergency mode and promptly drank the remaining stout. Later, possibly still under the influence, they recruited me to fill in for Dave. To submit related press releases and news items, please visit www.jkeckert.com And good luck, Dave, wherever you are. — Jeff Eckert
S
AUV Travels from Woods Hole to Bermuda
The Spray ocean glider. Photo courtesy of Scripps Institution of Oceanography.
In a voyage that ran from September 11 until early November of last year, an underwater robot traveled from about 100 miles south of Nantucket Island, MA, to Bermuda. Developed by scientists at the Scripps Institution of Oceanography (at the University of California, San Diego) and the Woods Hole Oceanographic Institution, with support from the Office of Naval Research, the “Spray” autonomous underwater vehicle (AUV) is a 6 ft long ocean glider with a 4 ft wingspan. A perceptive reader will note that no external means of propulsion is visible and, in fact, it needs none. Spray glides up and down through the water on a preprogrammed course by pumping mineral oil between two bladders, one inside the aluminum hull and the other outside. This changes the volume of the glider, making it denser or lighter than the surrounding water and the vehicle floats up and sinks down while using its wings to provide lift and forward motion. Batteries power buoyancy change, onboard computers, and other electronics. In a typical cycle, it might descend 1,000 m (3,300 ft) and travel 5 km (3 mi) laterally in about 10 hrs. Between cycles, it spends about 15 minutes on
by Jeff Eckert the surface to relay its position and information about ocean conditions such as temperature, salinity, and pressure via satellite back to the home base. In theory, Spray has a range of 6,000 km (3,500 mi), which would allow it to cross the Atlantic Ocean. This means that it can remain at sea for months, allowing scientists to observe large-scale changes in the ocean environment that might otherwise not be detected. The vision is to build a fleet of AUVs that can be equipped with customized arrays of sensors that measure such things as dissolved oxygen, carbon dioxide, alkalinity, salinity, turbidity, and nutrients in the water. For details, visit spray.ucsd.edu
Robo Dog Gets Video Capability
The Spray ocean glider. Photo courtesy of Scripps Institution of Oceanography. The AIBO®. Courtesy of Sony Corp.
So let’s say you’re planning a romantic evening with Paris Hilton. You’ve actually taken a shower, put on something nicer than the stained cut-offs and Budweiser-soaked Elvis T-shirt, and slid something in the oven that doesn’t say “Hungry Man” on it. The game plan includes candles, soft music, and a box of fine sangria. It suddenly occurs to you: there’s no one to hold the video camera to prove to your friends that you are capable of finding a date!
64
SERVO 02.2005
Robytes.qxd
1/3/2005
2:52 PM
Page 65
Robytes Never fear! The latest upgrade to Sony’s AIBO® canine robot includes — among less important things — video recording capabilities. Using a combination of the new AIBO Entertainment Player (AEP) and AIBO MIND 2 (a software application on 32 MB Memory Stick® media), you can actually choose among several customized recording modes — continuous, time lapsed, motion-activated, and sound-activated. The MIND 2 upgrade is available to existing AIBO owners for about $100.00. If you don’t already have the digital dog, you can buy him for about $1,900.00. And, yes, he responds to voice commands, dances, plays digital music files, and so forth. I can’t help but wonder, though. If AIBO lifts his leg, do drained batteries come out? The answer may be available at www.sonystyle.com
Swarm Intelligence Symposium Scheduled for June A perpetual objective in robotic technology has been to expand on the machines’ ability to operate autonomously. However, if your interests lie with the little insect-like robots, you may instead be thinking in terms of how large numbers of extremely simple “bugbots” might interact to solve complex problems, much like swarms of virtually brainless creatures in nature somehow pool their mental resources to build sophisticated nests, coordinate mass migrations, establish schemes for division of labor, and find their ways to *NSYNC concerts. If so, check out the 2005 IEEE Swarm Intelligence Symposium, scheduled for June 8-10, 2005 at the Westin Hotel in Pasadena, CA. Co-sponsored
by the IEEE Computational Intelligence Society, the IEEE Communications Society, and the IEEE Robotics and Automation Society, with cooperation from the Jet Propulsion Laboratory, it will, “focus primarily on theoretical foundations of swarm intelligence, models and analysis of collective behavior in natural societies, and design, control, and optimization of collective artificial systems based on principles of swarm intelligence.” There will also be two panel discussions focused on, “growing commercial interests in swarm intelligence applications and research funding opportunities in government.” (Translation: How to sell this stuff to industry and suck up more federal bucks.) Participants will also have an opportunity to tour the Jet Propulsion Lab. For more information, visit www.ieeeswarm.org SV
Affordable Motion Control Products Robot Building Blocks Motor Speed Control PID Motor Position Control Solutions Cubed Phone 530-891-8045 www.solutions-cubed.com
Solutions Circle #94 on the Reader Service Card.
3
SERVO 02.2005
65
MrRoboto.qxd
1/3/2005
2:56 PM
Page 66
Our resident expert on all things robotic is merely an Email away.
[email protected] 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
Q A
.I was wondering if Lithium Ion or Ni-MH cell phone batteries are of any use to power robots? — Marcu Knoesen South Africa
.Cell phone batteries happen to be a rather popular choice for powering smaller-sized robots because of their size and higher energy densities when compared to Ni-Cd and Alkaline batteries. Many times, these batteries are taken apart and their sub-cells are placed in robots that fit in the palm of your hand. First off, you need to determine if the batteries work properly. Most cell phones are discarded because their batteries no longer hold a good charge. Lithium Ion batteries are very poplar (to the manufacturing community) because of their smaller size and the fact that they have a finite shelf life of around 2 to 3 years. Ni-MH batteries are more durable than Lithium Ion batteries, but they are larger and heavier. These batteries can tolerate heavy current drains and can tolerate rapid recharging better than Lithium Ion batteries. Lithium Ion batteries require special charging circuits to safely charge. Most Lithium Ion cell phone batteries have special circuits
built into them to limit charging and discharging rates. You should use these circuits if you use these batteries. Most Lithium Ion cell phone batteries have a 3.6 volt output and some have a 7.2 volt output. Ni-MH cell phone batteries have a wider variety of voltages: 4.8, 6.0, 7.2, and 9.6 volts. This requires you to use some sort of a voltage regulator/conditioner to supply the proper voltage to your robot’s electronics. To get a good idea on how many different types of cell phone batteries there are, just visit eBatts.com (www.ebatts.com). They sell hundreds of different cell phone batteries and they also provide a set of simple specifications for the batteries. The main drawback to using cell phone batteries is that you will have to make a custom battery holder for them because the batteries are designed to fit inside specific cell phones. They don’t have any simple physical attachment points or electrical connections. You can take them apart to get to the core battery, but they are still difficult to work with because they won’t fit in traditional battery holders. Though cell phone batteries may be difficult to use, they do make good batteries for the smaller-sized robots, especially when they are disassembled and placed inside the robot’s small compartments.
Thickness
oz/in2
gm/cm2
10 cm Mini Sumo
20 cm 3 kg Sumo
Part No. for a 12” square sheet
1/24” (0.042”)
0.267
1.173
117
469
9032K111
1/16” (0.062”)
0.394
1.731
173
692
9032K112
3/32” (0.094”)
0.597
2.623
262
1,049
9032K113
1/8” (0.125”)
0.794
3.489
349
1,396
9032K114
3/16” (0.188”)
1.194
5.246
524
2,098
9032K115
1/4” (0.25”)
1.588
6.978
698
2,791
9032K116
1/2” (0.50”)
3.176
13.955
1,396
5,582
9032K117
Table 1. Available lead sheets from McMaster Carr and their impact on sumo robots.
66
SERVO 02.2005
Q
.I saw a couple of people cutting lead sheets to make weights for their mini sumo robots at last year’s PDXBot. What I really liked about this was that it was a large sheet and it was custom-cut to shape with scissors. Do you know where I can get this stuff? — Josh Portland, OR
A
.I like to use these lead sheets in my sumo robots. This stuff is pretty amazing and easy to
MrRoboto.qxd
1/5/2005
9:42 AM
Page 67
work with. Table 1 shows a list of different thicknesses that are available from McMaster Carr (www.mcmaster.com), along with masses per unit area in English and Metric units. The table also includes a couple of columns that give an idea on how a single layer of the lead will increase the weight of the sumo robot if the sheet covered the maximum area of the robot. Lead’s density of 6.352 oz/in3 (10.99 gm/cm3) makes it an ideal material for adding weight to a sumo robot. I purchased a 12” square piece of the 1/24” thickness for $5.99 several years ago and I am still using it for my robots. These sheets can be purchased for sizes from 12” square up to 4’ x 6’. The thinner sheets (1/8” or less) can easily be cut with regular scissors, the 1/8” to 1/4” thick sheets can be easily cut with tin shears, and you will probably want to use a saw to cut the 1/2” thick sheets. This lead can be cut, drilled, bent, folded, and twisted to fit any opening inside your robot. For fine-tuning, an X-acto knife can clean things up. While writing this, a really cool idea came to mind. Why not use these lead sheets to make disks that fit inside the popular mini sumo wheels that most people are using? There is a recess that is about 0.10” deep on both sides of these wheels. Filling this recess with lead can greatly increase the weight of the mini sumo and put all the weight where it counts the most — on the wheel that is in contact with the sumo ring, which helps to improve traction. Table 2 shows the weight impact of using three of the different lead sheet thicknesses and Figure 1 shows a photo of the disks being made. Double these values when placing them on the inside of both mini sumo wheels. Depending on how much weight you need to reach the maximum weight, you could use different thicknesses or you could make smaller diameter disks. What makes this approach attractive is that it doesn’t take up any space inside the robot body and it is out of the way of any maintenance operations.
Figure 1. Cutting out lead to make a disk to fit inside a mini sumo wheel. Thickness
Ounces
Grams
1/24” (0.042”)
1.059
30.0
1/16” (0.062”)
1.563
44.3
3/32” (0.094”)
2.370
67.2
Table 2. Mini sumo wheel weight changes due to adding lead disks to their insides. circuit using a BASIC Stamp 2 from Parallax (www.parallax .com) that I use and it works quite well. The program listing shown in Listing 1 is what I use for controlling the directions of the motors. There’s not much to it. Now, with that said, you need to be aware that the L293D does transmit current back to the Stamp through the input lines when the motor directions are suddenly changed. I have measured voltage spikes when there shouldn’t be any. Every now and then, the Stamp would reset. I don’t know if the resetting was due to the voltage spikes or a drop in the
Figure 2. Motor direction control using an L293D and a BASIC Stamp.
Q
.I’ve been thinking of using the L293D H-bridge IC to control two DC motors for both forward and reverse. Will a BASIC Stamp be able to drive the IC without any other components? Will I be able to go straight from an I/O pin to an input of the L283D? — John Ringenary via Internet
A
.The short answer is yes. Figure 2 shows a simple
+5V
Vdd
3 4 5 ENABLE 1
BASIC STAMP 2
+V LOGIC
0 INPUT 4
INPUT 1
1
OUTPUT 1
2
OUTPUT 4
15 MOTOR 470 ohm
GN OUTPUT 2
L293D
GN
MOTOR
OUTPUT 3
Vcc INPUT 2 +V MOTOR
INPUT 3 ENABLE 2
SERVO 02.2005
67
MrRoboto.qxd
1/4/2005
4:50 PM
Page 68
voltage supply to the Stamp (yes, the voltage supply to the motor was a different source). This problem has never
Listing 1 ‘ {$STAMP BS2} ‘ L293D Motor Control Demonstration Program M1_Enable M1_Pin1 M1_Pin2 M2_Enable M2_Pin1 M2_Pin2
CON CON CON CON CON CON
0 1 2 3 4 5
HIGH 15 Init: GOSUB M1_Stop GOSUB M2_Stop
‘ ‘ ‘ ‘ ‘ ‘
Motor Motor Motor Motor Motor Motor
1 1 1 2 2 2
Enable pin, pin 1 on L293D Input 1, pin 2 on L293D Input 2, pin 7 on L293D Enable pin, pin 9 on L293D Input 3, pin 10 on L293D Input 4, pin 15 on L293D
shown up when I take the Enable line low prior to any motor direction change and then take it high after the motor direction has been set. I have never heard of anyone damaging their Stamps when using the L293D, but you should be aware that it might happen. If you are really concerned about protecting your BASIC Stamp, then you should consider using an Optical Isolator circuit between the Stamp’s I/O lines and the L293D. Figure 3 shows how to do this. Again, I have used the L293D to drive small motors for years by directly attaching them to my BASIC Stamps and have never damaged them.
‘ LED to show that the Stamp to ‘ indicate that the Stamp is on ‘ Put the motors in a known state
Main: GOSUB M1_Fwd GOSUB M2_Rev PAUSE 2000 GOSUB M1_Rev GOSUB M2_Fwd PAUSE 2000 GOSUB M1_Stop GOSUB M2_Stop PAUSE 2000 GOTO Main
‘ Cycle the motors, forward, reverse, ‘ and stop
M1_Fwd: LOW M1_Enable HIGH M1_Pin1 LOW M1_Pin2 HIGH M1_Enable RETURN
‘ Motor 1 Forward ‘ Disable Motor before changing directions
M1_Rev: LOW M1_Enable LOW M1_Pin1 HIGH M1_Pin2 HIGH M1_Enable RETURN
‘ Motor 1 Reverse
M1_Stop: LOW M1_Enable LOW M1_Pin1 LOW M1_Pin2 RETURN
‘ Motor 1 Stop
M2_Fwd: LOW M2_Enable HIGH M2_Pin1 LOW M2_Pin2 HIGH M2_Enable RETURN
‘ Motor 2 Forward
M2_Rev: LOW M2_Enable LOW M2_Pin1 HIGH M2_Pin2 HIGH M2_Enable RETURN
‘ Motor 2 Reverse
M2_Stop: LOW M2_Enable LOW M2_Pin1 LOW M2_Pin2 RETURN
‘ Motor 2 Stop
68
Q
.The latest listing of popular gear motors for robotics use was interesting. However, can someone address the issue of units on torque? Specifically: 1. I’m assuming 1 in/lb torque rating means that it should be able to lift 1 lb if suspended from a string wrapped around a pulley 1” in radius. Is that correct? 2. If that is true, is 1 ft/lb = 16*12 oz/in? Obviously, an oz/in would be much less than a ft/lb, but what’s the proper conversion factor?
‘ Enable motor to move forward
SERVO 02.2005
3. Can you give a decent rule of thumb for how much torque is needed for a given robot? Glossing over friction, if I have a 3” diameter wheel on a 6 lb robot and I want it to be able to go over “small” bumps (1/4” or less and handle carpet), what torque range would be reasonable? Assuming I have two drive wheels and a third castor, I could take a wild guess that each wheel supports approximately 2 lbs (more or less). If torque is force x distance, would I want 3 in/lbs (1.5” radius x 2 lbs dead lift) in each of the drive motors? I’m guessing the real world isn’t nearly that easy to quantify. So, again, is there a simple rule of thumb for how much torque is needed? — John M. via Internet
A
.Your understanding for torque is correct. Technically, torque is defined as the movement created by a force acting on a body where the perpendicular distance between the line action of the applied force and the center of rotation is multiplied by the perpendicular component of the applied force. When it comes to wheels (or pulleys), it is simplified to force multiplied by the distance of the axle (in this, case the wheel/pulley radius) to the applied force. The unit of torque is force multiplied by distance — such as ounces, pounds, and newtons — multiplied by inches, feet, centimeters, and meters. Many times,
MrRoboto.qxd
1/4/2005
10:27 PM
Page 69
motor torque is represented as gram+5V L293D POWER centimeter and kilogram-centimeter. Though technically incorrect, since it is a mass multiplied by distance (as opposed to 1K the proper force multiplied by distance), it is commonly used because converting these numbers to newton-meter yields a very large number. STAMP I/O PIN 1K Table 3 is a conversion table that will help convert the units of torque from one system to another. For example, to convert a L293D LOGIC PIN 5 kg-cm torque motor into inch-pound, multiply the 5 by 0.8680 (the number under GENERIC OPTICAL ISOLATOR the in-lb column that intersects the same row i.e. PS2501-2 as the kg-cm) to get 4.34 in-lb. Estimating how much torque you will need for your robot to move always proves STAMP GROUND L293D GROUND to be more challenging than you think. First off, any wheeled vehicle must have Figure 3. Optical isolation circuit. friction to move. Without friction, the wheels will just spin in place. The first thing that you should decide on is whether you want the wheels required to go over a bump is a fairly complicated process to stall if the robot runs into an immovable object. If you and a good understanding of physics is needed, but here are allow to wheels to stall, then the motor current draw will couple of general rules of thumb: be at its maximum and chances of burning out the motors and the motor controller are very likely. However, this 1. A wheel won’t self-drive over a bump whose height is more than 30% of the wheel radius. Self-drive means that stall condition does tell you a lot about your robot’s the wheel is pulling itself over the bump. performance. Next, estimate how much weight will be on each wheel 2. If the motor’s stall torque is greater than 70% of the (including casters). Your assumption of evenly dividing the robot’s weight on that wheel multiplied by the wheel radius, weight distribution across the wheels and caster is good to then it will be able to drive over bumps with heights up to use for quick and dirty estimating. The next thing I like to 30% of the wheel’s radius. do is assume that the coefficient of friction between the wheel and ground is 1.0. This simplifies the calculations and, in most cases, it represents a worst case situation. A worst case torque estimate (robot weight divided Thus, the stall motor torque will just be the robot’s weight by the number of wheels in contact with the ground and on that wheel multiplied by the wheel radius. In your case, multiplied by the wheel’s radius) will enable the robot to go the 3 in-lbs (1.5” wheel radius x 2 lbs dead lift) is a good over rough terrain. A lower motor stall torque will still estimate. allow a robot to move around, but smaller bumps will be Now, if you chose a motor that had a greater stall able to stop the robot much more easily. The motor specs torque than this, then the wheels will spin if the robot ran shown in the November 2004 issue of SERVO Magazine into an immovable object. Keep in mind that, as long as the represent the stall torque. If you need more stall torque from wheels are spinning, you will not be drawing the maximum a motor, then you will have to increase the applied voltage motor current. Having a motor with more torque than to the motor. SV this does not improve its pushing ability or how well it will move, other than in-lb ft-lb g-cm kg-cm N-m oz-in accelerating faster. oz-in 1 0.0625 0.0052 72.008 0.0720 0.0071 Now, if the motor’s stall torque is less than this, you will probably stall the in-lb 16 1 0.0833 1152.1 1.152 0.1130 motors when your robot runs into something. Remember, all robots will move ft-lb 192 12 1 13826 13.826 1.3558 just fine along flat, smooth surfaces g-cm 0.0139 0.0009 0.00007 1 0.001 0.0001 with motors whose stall torques are significantly less than the wheel stall kg-cm 13.887 0.8680 0.0723 1000 1 0.0981 torque described here. I personally use this as my rule of thumb for sizing N-m 141.61 8.8507 0.7376 10197 10.197 1 motors. Table 3. Torque unit conversion factors. Estimating how much torque is SERVO 02.2005
69
BookstoreFeb05.qxd
1/4/2005
andy Mind Cday’s For To ticist Robo
1:02 PM
Page 70
The SERVO Bookstore
ROBOT DNA SERIES Three Volume Pack
Everything you need to program your robot controller: • Microcontrollers in Robots • Software Development • The Microchip PICmicro Microcontroller • Microcontroller Connections • Designing the Robot System • Going Forward Everything you need to build your own robot drive train: • The Basics of Robot Locomotion • Motor Types: An Overview • Using DC Motors • Using RC Servo Motors • Using Stepper Motors • Motor Mounting • Motor Control • Electronics Interfacing • Wheels and Treads • Locomotion for Multipods All the data you need to build your own robot base: • Mechanical Construction • Electrical Construction • Operating Power • Robot Designs • Constructing a Two-Wheeled Rover Robot • Selecting the Right Materials • Glossary of Terms • Tables, Formulas, and Constants
Subscribers: $62.99 Non-subscribers: $69.99 Limited time only! Offer expires January 31, 2005!
Robot Programming by Joe Jones / Daniel Roth Using an intuitive method, Robot Programming deconstructs robot control into simple and distinct behaviors that are easy to program and debug for inexpensive microcontrollers with little memory. Once you’ve mastered programming your online bot, you can easily adapt your programs for use in physical robots. $29.95
70
SERVO 02.2005
Industrial Robotics by Harry Colestock With so many industries taking advantage of the tremendous advances in robotics, entities ranging from small family businesses to large corporations need assistance in the selection, design, set-up, maintenance, and economic considerations of industrial automation. Industrial Robots shows how to achieve maximum productivity with robotics, classifies robots according to their complexity and function, and explains how to avoid common automation mistakes. $39.95
Electronic Gadgets for the Evil Genius
Build Your Own All-Terrain Robot by Brad Graham / Kathy McGowan Remotely operated robots are becoming increasingly popular because they allow the operators to explore areas that may not normally be easily accessible. The use of video-controlled technology has sparked a growing public interest not only in hobbyists, but also in the areas of research, space, archeology, deep sea exploration, and even the military. Inside Build Your Own All-Terrain Robot, the writers enable even total newcomers to robots to construct a rugged, video-controlled, talking, seeing, interacting explorer bot with a range of over a mile for under $200.00! $29.95
by Robert Iannini The do-it-yourself hobbyist market — particularly in the area of electronics — is hotter than ever. This book gives the “evil genius” loads of projects to delve into, from an ultrasonic microphone to a body heat detector, all the way to a Star Wars Light Saber. This book makes creating these devices fun, inexpensive, and easy. $24.95
Robot Building for Dummies by Roger Arrick / Nancy Stevenson Ready to enter the robot world? This book is your passport! It walks you through building your very own little metal assistant from a kit, dressing it up, giving it a brain, programming it to do things, even making it talk. Along the way, you’ll gather some tidbits about robot history, enthusiasts’ groups, and more. $21.99
Robot Builder's Bonanza by Gordon McComb Robot Builder’s Bonanza is a major revision of the bestselling bible of amateur robot building — packed with the latest in servo motor technology, microcontrolled robots, remote control, LEGO Mindstorms Kits, and other commercial kits. It gives electronics hobbyists fully illustrated plans for 11 complete robots, as well as all-new coverage of Robotix-based robots, LEGO Technicbased robots, Functionoids with LEGO Mindstorms, and location and motorized systems with servo motors. $24.95
We accept VISA, MC, AMEX, and DISCOVER Prices do not include shipping and may be subject to change.
Mobile Robotic Car Design by Pushkin Kachroo / Patricia Mellodge This thoughtful guide gives you complete, illustrated plans and instructions for building a 1:10 scale car robot that would cost thousands of dollars if bought off-the-shelf. But, beyond hours of entertainment and satisfaction spent creating and operating an impressive and fun project, Mobile Robotic Car Design provides serious insight into the science and art of robotics. Written by robotics experts, this book gives you a solid background in electrical and mechanical theory, and the design savvy to conceptualize, enlarge, and build robotics projects of your own. $29.95
BookstoreFeb05.qxd
1/5/2005
8:10 AM
Page 71
To order call 1-800-783-4624 or go to our website at www.servomagazine.com PIC Microcontroller Project Book by John Iovine The PIC microcontroller is enormously popular both in the US and abroad. The first edition of this book was a tremendous success because of that. However, in the four years that have passed since the book was first published, the electronics hobbyist market has become more sophisticated. Many users of the PIC are now comfortable paying the $250.00 price for the Professional version of the PIC Basic (the regular version sells for $100.00). This new edition is fully updated and revised to include detailed directions on using both versions of the microcontroller, with no-nonsense recommendations on which one serves better in different situations.$29.95
Robot Builder's Sourcebook by Gordon McComb Fascinated by the world of robotics, but don’t know how to tap into the incredible amount of information available on the subject? Clueless as to locating specific information on robotics? Want the names, addresses, phone numbers, and websites of companies that can supply the exact part, plan, kit, building material, programming language, operating system, computer system, or publication you’ve been searching for? Turn to the Robot Builder’s Sourcebook — a unique clearinghouse of information that will open 2,500+ new doors and spark almost as many new ideas. $24.95
Robotics Demystified by Edwin Wise There's no easier, faster, or more practical way to learn the really tough subjects. McGraw-Hill's Demystified titles are the most efficient, intriguingly written brush-ups you can find. Organized as selfteaching guides, they come complete with key points, background information, questions for each chapter, and even final exams. You'll be able to learn more in less time, evaluate your strengths and weaknesses, and reinforce your knowledge and confidence. $19.95
Build Your Own Humanoid Robots by Karl Williams Build Your Own Humanoid Robots provides step-by-step directions for six exciting projects — each costing less than $300.00. Together, they form the essential ingredients for making your own humanoid robot. $24.95
Robot Mechanisms and Mechanical Devices Illustrated
CNC Robotics by Geoff Williams Now, for the first time, you can get complete directions for building a CNC workshop bot for a total cost of around $1,500.00. CNC Robotics gives you step-by-step, illustrated directions for designing, constructing, and testing a fully functional CNC robot that saves you 80 percent of the price of an off-the-shelf bot and can be customized to suit your purposes exactly, because you designed it. $34.95
by Paul Sandin Both hobbyists and professionals will treasure this unique and distinctive sourcebook — the most thorough — and thoroughly explained — compendium of robot mechanisms and devices ever assembled. Written and illustrated specifically for people fascinated with mobile robots, Robot Mechanisms and Mechanical Devices Illustrated offers a one-stop source of everything needed for the mechanical design of state-of-the-art mobile ‘bots. $39.95
JunkBots, Bugbots, and Bots on Wheels: Building Simple Robots With BEAM Technology by Dave Hrynkiw / Mark W. Tilden From the publishers of BattleBots: The Official Guide comes this do-ityourself guide to BEAM (Biology, Electronics, Aesthetics, Mechanics) robots. They're cheap, ! simple, and can be built NEW by beginners in just a few hours, with help from this expert guide complete with full-color photos. Get ready for some dumpster-diving! $24.99
Machine Nature: The Coming Age of Bio-Inspired Computing by Moshe Sipper Despite being marvels of complexity and human ingenuity, computers are notoriously bad at learning new things and dealing with new situations. Researchers at the frontiers of computer science have turned to nature for solutions to the problem of machine adaptation and learning. By applying models of complex biological systems to the realm of computing machines, they have given rise to a new breed of adaptive software and hardware. In Machine Nature, computer scientist Moshe Sipper takes readers on a thrilling journey to the terra nova of computing to provide a compelling look at cutting-edge computers, robots, and machines now and in the decades ahead. $24.95
Check out our online bookstore at www.servomagazine.com for a complete listing of all the books that are available.
LINUX Robotics: Programming Smarter Robots by D. Jay Newman Robotics is becoming an increasingly popular field for hobbyists and professionals alike. The cost of the mechanics and electronics required to build a robot are low rder P r e - OW ! enough that almost O N anyone can afford it. The hardware that used to require government funding or a large university grant is now available to the average person. At the same time, programming is becoming a common skill. This book combines the most sophisticated parts of robotics and programming to fill a real gap in available information. Most robotics books today use microcontrollers as the “brains” of the robots. This approach is fine for smaller, less expensive projects, but has serious limitations. When attempting to build a robot with sophisticated movements, navigation, vision, and picture-capturing abilities, it is better to use Linux as the controller. This book is available for sale February 15, 2005. $34.95
SERVO 02.2005
71
LessonsFromTheLab.qxd
1/4/2005
10:16 PM
Page 72
// castling bonuses B8 castleRates[]={-40,-35,-30,0,5}; //center weighting array to make pieces prefer //the center of the board during the rating routine B8 center[]={0,0,1,2,3,3,2,1,0,0}; //directions: orthogonal, diagonal, and left/right from orthogonal for knight moves B8 directions[]={-1,1,-10,10,-11,-9,11,9,10,-10,1,1}; //direction pointers for each piece (only really for bishop rook and queen B8 dirFrom[]={0,0,0,4,0,0}; B8 dirTo[]={0,0,0,8,4,8}; //Good moves from the current search are stored in this array //so we can recognize them while searching and make sure they are tested first
— PART 7 — The Final Spex Check
W
hen we last left “The Spectacles” from the San Rafael Community Center, it was mid-October and they were preparing for their FIRST LEGO League (FLL) local tournament. As I write this, almost two months have passed, their first local tournament has come and gone, and a lot has changed in both their strategy and the overall robot design. Before I let you know how they did in their tournament, let’s take a look at some of the ideas and strategies they had during the course of this season. We’ll start with a recap of their robot
SERVO 02.2005
LESSONS FROM THE LABORATORY by James Isom
design and then take a look at how they addressed some of the challenges.
Changing the Specs on Spex In any competition where there are objectives in fixed locations, it is important for a robot to hit its mark — to be able to go where you need it to reliably without error. The Spectacles were very excited with their new “uber chassis” that they called “Spex” (profiled in the December 2004 issue of SERVO). Alas, their design had one fatal
Some of the team analyzing the problem with Spex 1.0.
72
A bi-month column ju ly st for kids!
flaw in that it couldn’t go straight for long. This can be a problem with LEGO robotics; a weak motor, a lack of symmetry, or a mistake in programming can cause your robot to drift off course. As fate would have it, Spex quickly became Spex 1.0-CrisisBot and a massive change to the design took place just after the last article went to press. So, the boys from team #8 would like to say, “Thanks for building our robot from the last article, but we didn’t end up using it. Sorry.” For information on how to build their new design, please go to their website at
A couple of Spex 2.0 chassis without the RCX.
LessonsFromTheLab.qxd
1/3/2005
3:40 PM
http://robotics.megagiant.com/fll/ The new design — Spex 2.0 — is a wider robot that has four wheels instead of three; more importantly, it can hit its mark quickly and accurately. To best describe Spex 2.0, I give you the words of one of its designers — Greg: “Our newest chassis has less than half of the pieces of Walker’s Spex 1.0. This chassis was designed on the theory that a new bot should have easily removable motors in case one motor began to spin slower than another. This was a problem we had with Spex 1.0 in that, despite its overall symmetry, it still couldn’t drive in a straight line. “In previous seasons, we have used a rotation sensor to measure the amount of rotations a motor spins over a certain number of seconds. We use the RCX data logging feature along with Robolab Investigator to make a graph of the motor speeds so that we could find matching motors. The removable motor idea proved to be a good one and this chassis will be used at the competition.” With the chassis crisis over, the team found itself in mid-October without a solid strategy for the game. The team organized itself into work groups. Each of these groups replicates the chosen chassis design for use in developing their part of the overall game strategy. Formulating a strategy is tricky; it takes careful planning and methodical execution to combine the nine objectives of this year’s challenge into the five programs the RCX can hold. They will only be able to use one robot at the competition, so they spend quite a bit of time during chassis development making sure there are ample places to connect their attachments for each objective. A major design change in the middle of objective development can throw the team into serious turmoil: a lesson learned from past seasons. Their goal is to reach the end of the season and have each group’s attachment connect perfectly with the chassis through this common interface. Once the work groups completed their individual chassis, the team sat down and plotted out the likely order in which they wanted to complete each
Page 73
The motors were tested in a small jig made from a few bricks and a rotation sensor. We could then review the graph of how many rotations each motor made over 5 seconds and match the motors with the closest values.
objective. The outcome was five work groups, each of which were assigned one or more of the nine challenge objectives. Work groups were comprised of one to three team members each and were responsible for the building and programming of their chosen objectives. As you will soon see, some of the objectives were completed quickly and yet others dogged the team all the way into their first competition.
into the white ring in the center of the basket.
The Challenges
4. Cereal Delivery — Deliver the cereal to the table.
2. CD and Glasses — Move the CD from its holder into the CD case area of the playing field and return to base with the glasses. 3. Bus Stops — Knock down the white bus stop sign without knocking over either of the red signs.
The FLL challenge is comprised of 5. Pet Food Delivery — Open the gate three or more rounds that are 2-1/2 minand get to the top of the stairs. utes long. Most challenges consist of objectives that deliver an object to or For more information on this year’s from a place on the playing field. Each challenge, visit www.firstlegoleague. round, the robot starts from within the org base — a square in one corner of the playing field. While in base, teams are allowed to touch their robots, change attachments, and run different programs. Once the robot leaves base, the This was chosen as the first objective team is not allowed to touch it without because getting the ball in the center incurring a penalty. The playing field ring is worth 50 points (the highest itself is a 4’ x 8’ rectangle. FIRST LEGO League Challenge 2004 — “No Limits.” Two teams compete at the same time in two back-toback playing fields with one shared objective. This year, it’s “Play Ball” — a basket straddles the field edge. The Spectacles’ strategy for the 2004 challenge was organized by program number and execution order and was:
Play Ball
1. Play Ball — Deliver a ball
SERVO 02.2005
73
LessonsFromTheLab.qxd
1/3/2005
3:42 PM
Page 74
basket with balls; additional balls on your side of the basket are worth five points each at the end of the round. The strategy was to run the program until the ball was placed in the center and then continue on to other objectives, returning to it for additional ball drops at the end of the round, as time permitted. Strengths: 1. Simple mechanism. 2. Simple program. 3. Fast. 4. Repeatable. The genius of the Play Ball block diagram is in its simplicity.
individual point value of the challenge) and, since there is only enough room for one ball in the center ring, our team wanted to be there first. This one came pretty easy. Greg built a tower the height of the basket with a lever mechanism similar to something they had used in previous seasons. It consisted of two axles running parallel to one another to hold the ball in place while a vertical
axle and a touch sensor served as the trigger. A couple of well-placed rubberbands provided tension to the mechanism, allowing it to return to its original state after dropping the ball off into the basket. The program for this objective is pretty simple. Go forward until you hit the basket and then back up into base. This program could be repeated over and over again as necessary to fill the
The CD and Glasses block diagram is more complex.
74
SERVO 02.2005
Weaknesses: 1. Not always accurate. Slamming into the basket to drop off the ball can cause problems when dropping the ball off or coming back to base. 2. Takes time to attach and detach the mechanism.
CD and Glasses The CD and Glasses team went through a variety of ideas before settling in on their final design. The objective is to remove the CD from a holder just outside of base and put it into a graphic of a CD case a short distance away on the mat. This is followed by a grasping maneuver on the eyeglasses before the robot returns to base. Zach and Jake first built a forklift that lifted the CD and placed it on the CD case. This particular design went through several variations and met with some success. Its biggest drawback was that it became difficult to control the CD once it was lifted off the holder. Sometimes, the CD would get caught up and flip off the forklift before they
LessonsFromTheLab.qxd
1/3/2005
3:43 PM
needed it to and, at other times, it was difficult to slide the CD off the forks once they reached the drop point. The second design addressed this problem by wrapping a cage around the forks to control the CD more precisely. Despite its early success, two things led to the abandonment of this particular design. First, it was slow; all that lifting, dropping, and maneuvering was taking up too much time. Second, what about the glasses? This one program had to accomplish both objectives in a single run and — despite their best efforts — the boys were having difficulty placing the forks into the eye holes of the glasses. Sometime during all this head scratching, one of the team members floated the idea of popping the CD off the holder and onto the CD case. This inspiration came from a wayward robot that had been maneuvering on the field and accidentally ran into the CD, flipping it across the table. After several ideas were played with, a sliding plow with two forks was settled upon. It worked pretty much from the start, once a bit of tweaking to the program was done. To grasp the glasses, Zach built a one-way latch made from a rotating axle and lever. He used a fixed pin that allowed the glasses to enter the latch, but not exit. His program was designed to simply run into the glasses hard enough that they would be caught behind the latch and carried back to base.
Page 75
The Bus Stop challenge presented some difficulties.
2. Depending on the robot’s approach, there is a slight chance that the glasses can slip through the latch mechanism.
Bus Stops Three bus stop signs sit in a line on top of one of the 2” x 4” edges that make up one side of the playing field. Two are red and the other is white. The objective is to find the white bus stop sign and knock it off its vertical default position without knocking over either of the red signs. The trick is that the white sign is placed in one of the three positions randomly by a judge at the start of each round. To explain the mechanism used in this challenge, I give to you the words of one of its creators — Gabe: “The attachment I
designed to flip down the bus stop sign is very simple, although it has gone through many radical changes. “The flipper started as a long beam with sliding pieces on the bottom and a rack gear on the top. A motor with a 24-tooth gear would spin and push the beam outward when a light sensor sensed white. It was placed on the top of the RCX. The sensor was stuck on another long beam; this one on the bottom of the robot. It was placed just beyond the wheel, so the beam would have enough time to move outward and flip down the sign. “This worked, but — after almost never-ending problems with the sliding beam system — I went to a much simpler and more reliable design: just a few beams stuck together to form a
Jake tackled the Food challenge.
Strengths: 1. Attaches and detaches quickly. 2. Simple, solid design that performs both objectives well. Weaknesses: 1. The program relies solely on timing and doesn’t have any sensor feedback. If the robot gets off course, it is off course for the whole run. Saving the off course robot can incur penalties.
SERVO 02.2005
75
LessonsFromTheLab.qxd
1/3/2005
3:45 PM
Page 76
levels for each motor at 2 (the maximum is 5). This setting and the timing provide just the right amount of momentum to deliver the food to the table without mishap.
Pet Food Delivery, Gate, and Stairs
Spex 2.0 in action at FLL.
long lance. The lance was again stuck to the top of the RCX, but facing forward this time — the direction the robot was driving. “The robot would drive out of base, far from the wall, and make a right turn when it sensed the white sign, flipping it down with the lance as it turned. It then just drove straight back into base without hitting any other signs. “Once I had the final idea, it was very easy to create a program around the attachment; it probably took about an hour. The final attachment and program works very consistently and very well.” Strengths: 1. Attaches and detaches quickly. 2. Uses a light sensor to find the objective. More accurate than just using timed steps.
from the beginning and stayed with it throughout the season. The mechanism he designed is similar to the one used in “Play Ball” in that there is a place to put the tray with a trigger hanging below. The idea is to drive into the table and push the trigger lever in to drop the food off. The mechanism as a whole doesn’t bend very much — just enough to start the bowl and tray to slide. The momentum of the food and tray, combined with the robot backing up, is just enough to gently slip the bowl and tray onto the table. This did not come easily at first. The tray would often get caught up on a chair, resulting in the bowl of food sliding off the table and onto the floor. The team eventually decided to approach the table at an angle in order to bypass the chair. Strengths: 1. Attaches and detaches quickly.
3. Simple and fast program. 2. Simple and fast program. Weaknesses: 1. Occasionally overturns and runs into the table on its return trip due to the high speed and width of the chassis.
Cereal Delivery Just outside the base sits a small table surrounded by three chairs. The objective of this challenge is to deliver a small tray of LEGO pieces (simulating food) to the top of the table without spilling it. Jake took this one on almost
76
SERVO 02.2005
3. Stable delivery mechanism. Weaknesses: 1. Can easily get caught up on the chair or the table. 2. If the forward momentum or approach is even slightly off, the food is thrown to the floor. If you are familiar with Robolab, you will notice that Jake set the power
The team knew from day one that this would be the most difficult of the programs to complete. It involves three objectives and the most maneuvering out of all the programs this season. The first of these three objectives is to deliver food (three round LEGO pieces) to a dog and a cat at the far end of the playing field. These pets are enclosed in an area surrounded by a stationary fence and a large gate. The gate itself is the second objective in the sequence. For full points, the gate needs to be opened completely so that a small latch catches the door. The final objective is to drive the robot off the playing field and onto a set of steps. For full points, the robot needs to be all the way on the top step at the end of the round. The initial strategy was to build a device similar to the mechanism used in both the “Play Ball” and “Food Delivery” objectives. The trigger mechanism was attached to the end of a long assembly of axles and would run into the fence and drop the food into the pet food area. The robot would then make a right turn, slamming the axle assembly into the gate door, popping it open, and then back up and turn so that it could drive to the top of the stairs. All this involved a lot of precision movement. In order to get where the robot needed to go, the team decided to use a rotation sensor. A rotation sensor is a bit like a measuring tape. You can roll the robot to a destination, note the number of rotations it took, and program the robot accordingly. They would simply count the number of rotations to each waypoint — in theory, that is. Unfortunately for the team, they
LessonsFromTheLab.qxd
1/3/2005
3:46 PM
were never able to get this one to work the way they wanted it to. Their first problem was that the robot was just too fast to execute turns accurately. This problem was made worse by the long axle assembly sticking out in front of the robot that often acted as a large pendulum, swinging it around too far in the direction it was turning. On those occasions when it did work and managed to move on to hitting the gate, the axle assembly wasn’t heavy enough to open the gate. To make matters worse, the axle assembly would get in the way as the robot attempted to climb the stairs. Dozens of variations were developed and tested all the way up to the day of the competition. The lack of success with this approach at the competition put this idea to rest once and for all and the team actively began working on a new idea while there. However, these things take time and it wasn’t quite ready to serve them consistently at the tournament. They are, however, still working on a solution and will post the results of their labors to their website when it is finished.
The Tournament FLL competition day is always a big day for the team. This is their third local competition. They have never made it to the state competition in previous
Page 77
seasons. The competition consists of much more than just the game itself. There is a presentation to be made and interviews with judges on programming and robot design. The team keeps a journal of their activity over the season. Each member takes turns interviewing fellow team members on their accomplishments and existing problems at the end of each practice session. Close to the competition day, they take this material and form it into a story board of sorts so that other teams, judges, and onlookers can see what the team has been up to during the competition season. This year’s board was dominated by their approaches to the challenges, along with information on all their chassis designs: Why they built them and why they abandoned them. All together, the team did an incredible amount of design and analysis this season and it surprised them when they built this year’s board. At the Contra Costa local tournament, they were amazed and awed at some of the other solutions teams had come up with. Overall, they played the game well, coming in fifth overall: a personal best in their book. However, where they really shined was in interviews with the judges. All those problems that had cropped up and all that thinking and testing was enough to earn them their
first Best Robot Design Award. Team #8 from the San Rafael Community Center finally made it to the state final competition. I would just like to say, as a coach, that FIRST LEGO League is a fantastic program for 9 to 14 year olds. Join or — better yet — start a team in your area today. You won’t regret it. You can go to www.firstlegoleague.org for details about next year’s challenge. I would like to congratulate my team and also the rookie year girls’ team from Miller Creek Middle School that I helped mentor with eighth grade science teacher Kim Asso. They made it to the state tournament, as well. Go RoboChicks! The state tournament is looming. To see how it all turns out, be sure to visit the Spectacles at their website http: //robotics.megagiant.com/fll/ SV
AUTHOR BIO James Isom is a part-time robotics teacher and general all-around geek. He has taught robotics to children and teachers in the US and abroad. His website with additional goodies (including the MLCAD file of this robot) can be found at ww.the roboticslab.com He can be reached at james @megagiant.com
SERVO 02.2005
77
Geerhead.qxd
1/3/2005
3:22 PM
Page 78
by David Geer
[email protected]
Paparazzi catches Koolio taking a stroll. Notice the unassuming look on his face and his casual style with cap and dreadlocks.
Koolio poses with creators Brian Pietrodangelo and Kevin Phillipson — three buds just being Koolio.
Koolio — Hip Bot, Drink Haven, and Mobile Butler oolio is a fully autonomous mobile bot with an ice-cold refrigerator for innards. Brian Pietrodangelo and Kevin Phillipson, students in the Machine Intelligence Lab (MIL) at the University of Florida at Gainesville created Koolio to service the third floor of the school’s Benton Hall, where the lab, classrooms, and professors’ offices are located. Not the least of Koolio’s impressive characteristics are the facial
K
78
SERVO 02.2005
expressions he can muster from beneath his long, black dreadlocks. Koolio’s personality beams across a 19” LCD monitor screen on which he can be programmed to smile, keep a straight face, or demonstrate other moods.
What’s a Thirsty College Kid to Do? All that studying, glued to the
books, no time to run down the hall to drop quarters in the machine, even less time to run down the street for a six pack. What’s a college kid to do when he or she needs a cold pop or beer? Necessity — in this case, perhaps desire — made invention its offspring. If you’re a college student and you get thirsty, it’s good to be an engineering major, so say Brian and Kevin.
Geerhead.qxd
1/3/2005
3:25 PM
Page 79
GEERHEAD Koolio Illustrated
Koolio can find his docking station from anywhere on the third floor and returns when he feels short on electricity.
Using Dr. Nechyba — Brian’s and Kevin’s professor in the Machine Intelligence Lab at UF — as a sample consumer, let’s walk through Koolio’s routine on the third floor of Benton Hall. Let’s say Dr. Nechyba is chained to his desk with work. He can’t afford to let it go long enough to get a pop from down the hall. He has another alternative. He logs on to the network via the computer at his desk and signals Koolio to bring him a pop. Koolio hears via wireless card and responds. Koolio determines which room houses the computer that the message came from. He leaves his docking station and finds his way down the hall. This is done using a variety of sensing equipment. Upon delivering the pop to Dr. Nechyba, Koolio leaves to return to his docking station. There, he recharges while waiting for his next request.
Koolio’s Fame and Future Koolio’s service to human kind has not gone unnoticed or unrewarded; this beverage-hauling bot has garnered loads of exposure from the press and tons of praise from a growing fan base. Why? Everybody wants one! Someday, they may get their wish. The two academic roboticists have a start-up company called RASTA Robotics — Robotic & Automated Systems Technical Associates. Though there are no immediate plans to mass-produce Koolio, the possibility is very much alive. Kevin and Brian are on the look-out for companies ready to license Koolio and bring him to the
Neat Notion’s Nitty-Gritty
Koolio’s “sleeping on the dock of the station, watching his eyes just roll away” or something like that.
display floors of chains or outlets or to offer him up by some other
RESOURCES The Koolio website — http://mil.ufl.edu/~brian/Koolio/Koolio.htm
Koolio is a mobile, fully autonomous bot that doles out drinks or food to the third floor around the clock and fills up on juice himself at his own, private docking station. Koolio hangs at his dock when he’s not needed for anything, just kickin’ and taking in a jolt of volts.
From the page above, you can go to a section for the press where you will find videos and information about Koolio. The RASTA company website — www.rastarobotics.com with other projects by Kevin and Brian.
TALKING TECH ON KOOLIO’S SPECS Koolio may sound simple, but he is the result of careful, logical design, using the following hardware and software. Koolio uses a Kontron Embedded PC/104+ Board for onboard vision processing — detecting objects and reading room numbers. The board controls the hosting behind a local website that select users can access. An Altera Max 3000 and Atmel Mega 128 chip make up Koolio’s brains. The Altera CPLD uses VHDL
algorithms to keep the control in the Atmel chip simple. The CPLD is better equipped to handle big data and to do it fast. Left to itself, the Atmel would be in over its head, slowing performance. Koolio, a big fan of open source code, runs the Red Hat Linux version 9.0 operating system. Other components include a 266 MHz Pentium MMX processor, 128 MB DRAM (RAM), and a Cisco Aironet 350 wireless card to communicate with
the network. The fridge is a Koolmate40, which can carry 52 cans of pop or beer. Sensors include a Sharp GP2D12 IR distance measuring sensor, which detects ranges between 10 and 80 cm, and a Devantech SRF08 Ultrasonic Range Finder, which determines ranges between 3 cm and 6 m. The bot also employs a CMPS03 magnetic compass. Its eye is a Creative Video Blaster II web cam. SERVO 02.2005
79
Geerhead.qxd
1/4/2005
12:51 PM
Page 80
GEERHEAD
Koolio is racing down the hall to answer someone’s call. Kind of reminds you of Batman answering the Bat Signal, except that Batman wasn’t outfitted with a Cisco wireless card.
means. Koolio could well follow in the footsteps of Roomba, serving homeowners and fitting seamlessly into their lifestyles. Koolio could go into the ad business, starring in commercials for canned and bottled beverage companies. He could also be distributed commercially as the new mobile Coke, Pepsi, or other beverage machine that comes to you instead of waiting down the hall or in the break
It’s bottoms up as we get a shot from the floor to the ceiling of Koolio and creators.
produced, you keep the larger project much simpler. By verifying the success of each individual module, you assure the success of the whole. If something goes wrong, you know which module to deal with and you only have to deal with that module, often simply by replacing it. This kind of approach enables direct and logical troubleshooting and debugging. Lesson two — practice makes ... Koolio: Koolio was the result of putting an education in engineering into practice. Getting your hands dirty and actually constructing a project based on your new-found knowledge, teaches you the practical applications of what you have learned.
room for you to come to it.
Adaptations
Hello Class, My Name Is Professor Koolio
Koolio can serve schools, homes, offices, factory workers — you name it. As long as he doesn’t face the challenge of climbing stairs or similar obstacles, he’s good to go. Koolio keeps you from being inconvenienced, waiting on you day and night as no real butler could do. Koolio may someday be used to serve those who are sick or disabled, as well. SV
What can we learn from the Koolio project? Lesson one — modularity: By taking a look at the larger project and breaking it up into proposed modules or perhaps components that can be easily conceptualized, understood, designed, and
WHAT YOU GET FROM GETTING INVOLVED Book learning only goes so far. You get an introduction to something, but you don’t necessarily become consumed by it. When you build your own robot, you are investing yourself with the goal of success. By getting involved, you learn why analog technologies are still important, why circuits, electronics, power, resistors, capacitors, and inductors still matter. You learn why it’s important to know computer science, digital logic, and the gambit
80
SERVO 02.2005
of electrical engineering. Every roboticist will commit errors now and then; what counts is finding and correcting the source of those errors. The Machine Intelligence Lab at the University of Florida provides a great deal of hands-on experience for its students. It’s highly recommended that serious roboticists find a club or engineering lab they can be a part of to get the thrill of that hands-on activity in a project they can relate to.
ABOUT THE INVENTOR Brian Pietrodangelo went on to at least two additional projects after Koolio — an autonomous submarine called the Subjugator — www.mil.ufl.edu/subjugator/ and an independent contract for a doctor in Tallahassee, FL. Having graduated from the University of Florida, Brian intends to go to graduate school.
Appetizer.qxd
1/3/2005
1:21 PM
Page 81
We Compete Because We’re Programmed to Compete — and That’s a Good Thing! by Dave Calkins lot of people ask me why I put on robot events. Most presume it’s to make money. (The sad truth is that I know of no event that actually makes money; it’s a question of how much money an organizer can afford to lose.) Event organizers put on robot events because they love robots. Certainly, that isn’t the only reason, though. No, most of us put on robot events because we love people — especially kids. When it comes down to it, the people who enter their creations at robot events do it because of an internal drive. Robot builders are preprogrammed to want to come with their robots. Like geese flying south for the winter, we are driven by internal programming. This programming comes down to three basic points.
A
Competition It’s more than the governing philosophy of capitalism and sports; it’s part of what makes us human — and ergo, one of the things that separates us from robots. One reason that I don’t think robots will take over the world is that they’ll simply never be able to emote on a level which includes that form of competition. They may function on a level of survival, perhaps, but not fear-based survival which inspires them to compete for space with us carbon types. But I digress. We humans are arrogant creatures. We love to show-up the other guys. If I buy a car, I want my car to be faster than yours. Or I want it to haul more stuff. Or be more fuel efficient
than yours. Or I want to have gotten a better deal on it. At work, we all want to make a bit more than the other guy, work a bit less, and have a bit more power. It’s part of our competitive nature. Of course, to every rule there is an exception, so I know that not everyone fits into the description above — but the great majority of humankind does. What does this have to do with robots? Darn it, Dave, your topics wander more than a line follower with a bad CDS cell! It has to do with robot competitions! Competitions like Tetsujin, for example. The prize money was sweet and it was certainly a big pull in getting people to enter; however, I’d bet that if the prize money had been cut in half — or even by 90 percent — SERVO would have gotten just as many entries. Oh, yes, we would have! I talked to all the competitors. Not one of them said that they came “for the money” as their first answer when asked why they were there. Oh, it was always number two or number three, but what they all really craved was to be the best engineer at the show — the smartest ones on the block. As Tetsujin winner Alex Sulkowski put it, “I often lack a specific, achievable goal and timeline to motivate me to complete my projects. Entering robot competitions provides this structure and direction; in addition, it provides an incentive, knowing that others will be struggling to solve the same problem.” I cut my chops building mini sumo robots — the 500 gram ones (1.1 pounds, if you haven’t been paying
attention). For the record, my most basic goal on the first bot I built was to learn PIC programming. However — like a great many bot builders — I arrogantly presumed that I could figure out the basics. My real goal was to build a better mini sumo than the other ones I saw. I had to study up on servos and motors and gears — and learn that (golly!) not all servos are created equally, so I should buy the better ones. Then, I learned that if I doubled the voltage I put into a servo, I squared the power! Hey! This was neat! Soon, using a few simple tricks — and burning out a few PICs and servos — I had a really good little robot. While a gift certificate from robot store.com is a nice benefit, taking first place is a far better thing. In addition, there’s nothing more humbling than spending a couple hundred dollars to fly up to Seattle, only to get creamed by a 12-year-old with his own homemade bot. That, however, is why robot competitions have become so popular. Most builders want to see how they measure up against their peers.
Education A very close second to beating the other guy is seeing what everyone else is doing that’s new. I think that the best thing that came out of ROBOlympics 2004 was seeing the jaws of US builders drop as they saw Robo-One robots for the first time. You can make that in your garage? Yes, Virginia, do-it-yourself androids SERVO 02.2005
81
Appetizer.qxd
1/3/2005
1:23 PM
Page 82
really do exist. One of my favorite things about any robot competition is seeing all of the new stuff that builders come up with. Ted Larson and Bob Allen decided to see if they could top Dean Kamen by building Bender — a self-balancing robot similar to a Segway, only at about a 1/100th of the cost. It does the same thing as the more expensive Segway, only they built it themselves. Bob and Ted’s excellent robot was the first of its kind — but now several people have made similar bots (see Francisco Lobo’s project in the July 2004 issue of SERVO). I don’t think it would occur to most people to just up and build a selfbalancing, two-wheeled vehicle, but — upon seeing Bob and Ted’s — lots of people’s mental light bulbs went off. The joy of education was transferred and our pre-programmed lust for knowledge kicked in. Keeping in the spirit of the competitive sub-routine, Trevor Blackwell went and built a self-balancing unicycle! Sure, a lot of people would call all of the self-balancers copy-cats, but most of human knowledge is copycat data — just creatively re-applied. “Rubberbands and Bailing Wire” author Jack Buffington likes to compete because, “it allows me to try out new things without risking failure on a paid project.” It also forces him to learn, as it, “sets a deadline for trying out new things. Without a deadline, I’m just not as motivated.” Most of the real learning goes on with the kids, of course, but not always in the way you might think. At a typical show, just as many adults are inspired by the robots that kids design and build as there are kids being inspired by adults’ robots. Kids have the wonderful privilege of not being as programmed
as we adults are. They have a much cleaner slate and, as such, don’t have tiny subroutines going on in the backs of their heads, telling them what cannot be done. In judging for FIRST LEGO League, I’m always amazed at the robots that kids build. When I look at some of the more radical designs, I tend to think about how it can’t work. I’ve clearly been programmed to restrict myself to certain designs. However, the kids are good at hacking my internal software and corrupting those old files. They do it by making wild designs that work — things that I would never have thought up and things that many older bot builders would not have tried. They also become the educators, while I become the student.
Social Programming No matter how geeky the builder is, we can’t just sit at home. The friends of most robot builders think that we’re a little nutty. While they like playing with our creations, they just don’t get the obsession. “It’s a great way to meet other builders,” says Jack. It’s true; you don’t tend to meet too many robot builders while shopping at the local strip mall. I think half of the friends I talk to regularly are people I’ve met at robot events. Be it a small club meeting or a world-wide competition like ROBOlympics, events for combat robots or LEGO Mindstorms bots, the people I meet at robot events are just more interesting and have more to offer than the ones I meet at the pub (which isn’t to knock hanging out at the pub — man does not live by bots alone). When we have guests for dinner these days, they tend to be robot builders. It’s not so
that I can schmooze my way into a robotics job, but just because they seem to have much more in common with me and my wife. Our conversations tend to last long into the night as we discuss the future. And so it goes at robot events. The greatest success of competitions like ROBOlympics and Tetsujin is getting builders from two different robot classes to start talking (say a combat robot builder and a Robo-One builder or a sumo robot creator and a Mindstorms hacker). You’d be amazed at how much they start learning from each other. Heck, they are amazed by how much they learn from each other.
Just Do It Yeah, yeah, yeah — I’ve become a sneaker billboard. But if you’re a robot builder and you haven’t gone to a robot competition, that needs to change! There is the “Events Calendar“ listing of robot events every month in SERVO. Even if you’ve never built a robot before, go to a show and get inspired. Compete against the people there. You can build a better bot! Learn from the people who show up. They are your very best resource for building robots. Meet new people. You already have something in common! Whether you go to a local monthly meeting with five guys showing off a half-completed robot or you fly to San Francisco, CA, to see ROBOlympics, robot competitions are already in your design. That database between your ears has far too many empty rows. Fill up your personal database and then put it to use. And then watch as my mini sumo kicks your mini sumo’s batteries to the curb. SV
Advertiser Index Jameco ..........................................................83 Anchor Optical Surplus ..............................21 Lemon Studios .............................................22 APEC 2005/MicroMouse Contest ..............36 Lynxmotion, Inc. ...........................................45 Net Media .......................................................2 Budget Robotics ...........................................56 Parallax, Inc. ...................................Back Cover CrustCrawler .................................................14 PCB123/PCBexpress ......................................3 E-Clec-Tech ....................................................15 Pololu Robotics & Electronics ....................44 Electronic Goldmine ....................................49 ROBOBusiness Conference & Expo ............61
Robotics Group, Inc. ....................................55
ROBOlympics ...............................................77
Zagros Robotics ...........................................63
All Electronics Corp. ....................................63
Hobby Engineering ......................................13
82
SERVO 02.2005
Rogue Robotics ..............................................7 Smithy.............................................................63 Solutions Cubed ...........................................65 Sozbots..........................................................35 Technological Arts .......................................59 Vantec ...........................................................39
CoverInside.qxd
1/4/2005
9:42 PM
Page 2
Remember when... ...electronics stores were stocked to the rafters with every component imaginable and there was
ALWAYS
a knowledgeable person there to help you?
®
Think those days are gone?
1-800-455-6119
Well they’re not!
You just need a little Jameco@Home. Call for a FREE catalog today. We have the electronic components and knowledgeable Technical Support people who can help bring back the fun in your electronics hobbies, inventions, and DIY projects. Circle #60 on the Reader Service Card.
Be sure to visit our new website at
www.Jameco.com/nvb
Jameco @ Home —where electronics is still fun!
Circle #32 on the Reader Service Card.
Cover.qxd
1/5/2005
4:20 PM
Page 84
Vol. 3 No. 2 SERVO MAGAZINE RECYCLABLE ROBOT SOFTWARE February 2005
U.S.
CANADA
$9.25 0 2>
0 Circle #106 on the Reader Service Card.
$5.50
74470 58285
4