ROBOT BUILDER’S BONANZA GORDON McCOMB MYKE PREDKO
THIRD EDITION
McGraw-Hill New York
Chicago San Francisco Lisbon London Madrid Mexico City Milan New Delhi San Juan Seoul Singapore Sydney Toronto
Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. All rights reserved. Manufactured in the United States of America. Except as permitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher. 0-07-148698-4 The material in this eBook also appears in the print version of this title: 0-07-146893-5. All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occurrence of a trademarked name, we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of the trademark. Where such designations appear in this book, they have been printed with initial caps. McGraw-Hill eBooks are available at special quantity discounts to use as premiums and sales promotions, or for use in corporate training programs. For more information, please contact George Hoare, Special Sales, at
[email protected] or (212) 904-4069. TERMS OF USE This is a copyrighted work and The McGraw-Hill Companies, Inc. (“McGraw-Hill”) and its licensors reserve all rights in and to the work. Use of this work is subject to these terms. Except as permitted under the Copyright Act of 1976 and the right to store and retrieve one copy of the work, you may not decompile, disassemble, reverse engineer, reproduce, modify, create derivative works based upon, transmit, distribute, disseminate, sell, publish or sublicense the work or any part of it without McGraw-Hill’s prior consent. You may use the work for your own noncommercial and personal use; any other use of the work is strictly prohibited. Your right to use the work may be terminated if you fail to comply with these terms. THE WORK IS PROVIDED “AS IS.” McGRAW-HILL AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIES AS TO THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK, INCLUDING ANY INFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OR OTHERWISE, AND EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. McGraw-Hill and its licensors do not warrant or guarantee that the functions contained in the work will meet your requirements or that its operation will be uninterrupted or error free. Neither McGraw-Hill nor its licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless of cause, in the work or for any damages resulting therefrom. McGraw-Hill has no responsibility for the content of any information accessed through the work. Under no circumstances shall McGraw-Hill and/or its licensors be liable for any indirect, incidental, special, punitive, consequential or similar damages that result from the use of or inability to use the work, even if any of them has been advised of the possibility of such damages. This limitation of liability shall apply to any claim or cause whatsoever whether such claim or cause arises in contract, tort or otherwise. DOI: 10.1036/0071468935
Professional
Want to learn more? We hope you enjoy this McGraw-Hill eBook! If you’d like more information about this book, its author, or related books and websites, please click here.
For more information about this title, click here
CONTENTS
Acknowledgments Introduction I.1 Inside Robot Builder’s Bonanza I.2 About the Third Edition I.3 What You Will Learn I.4 How to Use This Book I.5 Expertise You Need I.6 Conventions Used in This Book
xxv xxvii xxvii xxviii xxviii xxix xxx xxx
PART 1—ROBOT BASICS Chapter 1—The Robot Experimenter 1.1 The Building-Block Approach 1.2 Basic Skills 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5
Electronics Background Programming Background Mechanical Background Workshop Aptitude The Two Most Important Skills
1.3 Ready-Made, Kits, or Do-It-Yourself? 1.4 The Mind of the Robot Experimenter 1.5 From Here Chapter 2—Anatomy of a Robot 2.1 Tethered versus Self-Contained 2.2 Mobile versus Stationary 2.3 Autonomous versus Teleoperated 2.4 The Body of the Robot 2.4.1 Skeletal Structures 2.4.2 Frame Construction
3 4 4 5 5 6 6 6
7 7 8 9 10 10 11 12 12 12 iii
iv
CONTENTS
2.4.3 Size and Shape 2.4.4 Flesh and Bone
2.5 Power Systems 2.5.1 Types of Batteries 2.5.2 Alternative Power Sources 2.5.3 Pressure Systems
2.6 Locomotion Systems
13 13
15 15 16 16
17
2.6.1 Wheels 2.6.2 Legs 2.6.3 Tracks
17 17 18
2.7 Arms and Hands
19
2.7.1 Stand-Alone or Built-On Manipulators 2.7.2 Grippers
2.8 Sensory Devices 2.9 Output Devices 2.10 Smart versus Dumb Robots 2.11 The Concept of Robot Work 2.12 From Here Chapter 3—Structural Materials 3.1 Paper 3.2 Wood 3.3 Plastics 3.4 Metal Stock 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5
20 20
20 21 21 22 23 25 26 27 28 29
Extruded Aluminum Shelving Standards Mending Plates Rods and Squares Iron Angle Brackets
29 29 30 30 30
3.5 Quick Turn Mechanical Prototypes 3.6 Fasteners
30 31
3.6.1 3.6.2 3.6.3 3.6.4 3.6.5
Nuts and Bolts Washers All-Thread Rod Special Nuts Rivets
32 32 32 33 33
CONTENTS
3.6.6 Adhesives 3.6.7 Miscellaneous Methods
3.7 Scavenging: Making Do with What You Already Have 3.8 Finishing Your Robot’s Structure 3.9 From Here
v
33 33
35 36 38
Chapter 4—Buying Parts 4.1 Hobby and Model Stores 4.2 Craft Stores 4.3 Hardware Stores 4.4 Electronic Stores 4.5 Electronics Wholesalers and Distributors 4.6 Samples from Electronics Manufacturers 4.7 Specialty Stores 4.8 Shopping the Surplus Store
39 39 40 40 41 41 42 42 43
4.8.1 What You Can Get Surplus
44
4.9 Finding Parts on the Internet 4.10 From Here
44 45
Chapter 5—Electronic Components 5.1 Cram Course in Electrical Theory 5.2 Wire Gauge 5.3 Fixed Resistors 5.4 Variable Resistors 5.5 Capacitors 5.6 Diodes 5.7 Transistors 5.8 Grounding Circuitry 5.9 Integrated Circuits 5.10 Schematics and Electronic Symbols 5.11 From Here
47 47 49 52 53 54 56 57 60 61 61 62
Chapter 6—Tools 6.1 Safety 6.2 Setting Up Shop
63 64 64
vi CONTENTS
6.3 Basic Tools 6.3.1 Optional Tools
6.4 Electronic Tools 6.4.1 6.4.2 6.4.3 6.4.4
Static Control Digital Multimeter Logic Probes Oscilloscope
6.5 From Here Chapter 7—Electronic Construction Techniques 7.1 Soldering Tips and Techniques 7.1.1 7.1.2 7.1.3 7.1.4
7.2 7.3 7.4 7.5 7.6 7.7 7.8
Solder Safety Tools and Equipment How to Solder Solder Tip Maintenance and Cleanup
65 66
68 69 70 73 74
78 79 79 80 81 83 83
Breadboards Prototyping PCBs Point-to-Point Prototyping Wiring Wire-Wrapping Quick Turn Prototype Printed Circuit Boards Headers and Connectors Eliminating Static Electricity
84 85 86 87 87 88 89
7.8.1 Storing Static-Sensitive Components 7.8.2 Tips to Reduce Static
90 90
7.9 Good Design Principles 7.9.1 7.9.2 7.9.3 7.9.4
Pull-Up Resistors Use Bypass Capacitors Keep Lead Lengths Short Avoid Ground Loops
7.10 From Here
91 91 91 91 92
93
PART 2—ROBOT PLATFORM CONSTRUCTION Chapter 8—Plastic Platforms 8.1 Types of Plastics 8.2 Working with Plastics 8.2.1 How to Cut Plastic
97 98 100 100
CONTENTS
8.2.2 8.2.3 8.2.4 8.2.5 8.2.6 8.2.7 8.2.8 8.2.9
How to Drill Plastic How to Bend and Form Plastic How to Polish the Edges of Plastic How to Glue Plastic Using Hot Glue with Plastics How to Paint Plastics Buying Plastic Plastics around the House
8.3 Building the Minibot 8.3.1 8.3.2 8.3.3 8.3.4 8.3.5
Foundation or Base Motor Mount Top Shell Battery Holder Wiring Diagram
8.4 From Here Chapter 9—Wooden Platforms 9.1 Choosing the Right Wood 9.1.1 9.1.2 9.1.3 9.1.4
9.2 9.3 9.4 9.5
Plywood Planking Balsa Dowels
vii
101 102 102 103 104 104 105 105
105 106 106 108 108 109
110 111 111 111 113 113 114
The Woodcutter’s Art Cutting and Drilling Finishing Building a Wooden Motorized Platform
114 115 115 116
9.5.1 Attaching the Motors 9.5.2 Stabilizing Caster 9.5.3 Battery Holder
118 118 119
9.6 From Here Chapter 10—Metal Platforms 10.1 Working with Metal 10.1.1 10.1.2 10.1.3 10.1.4 10.1.5
Marking Cut Lines and Drill Hole Centers Cutting Drilling Bending Finishing
121 123 124 124 124 124 125 125
viii CONTENTS
10.2 Build the Buggybot 10.2.1 10.2.2 10.2.3 10.2.4 10.2.5
Framework Motors and Motor Mount Support Caster Battery Holder Wiring Diagram
10.3 Test Run 10.4 From Here Chapter 11—Hacking Toys 11.1 A Variety of Construction Sets 11.1.1 11.1.2 11.1.3 11.1.4 11.1.5 11.1.6 11.1.7 11.1.8 11.1.9
Erector Set Robotix LEGO CAPSULA Fischertechnik K’Nex Zoob Chaos Other Construction Toys
11.2 Specialty Toys for Robot Hacking 11.2.1 11.2.2 11.2.3 11.2.4
Robosapien Tamiya OWIKITS and MOVITS Rokenbok
11.3 Robots from Converted Vehicles 11.3.1 Hacking a Toy into a Robot
11.4 From Here
125 126 126 127 128 129
130 130 131 132 132 133 135 135 135 136 137 137 138
138 138 138 139 140
140 141
147
PART 3—COMPUTERS AND ELECTRONIC CONTROL Chapter 12—An Overview of Robot “Brains” 12.1 Brains from Discrete Components 12.1.1 BEAM Technology
12.2 Brains from Computers and Microcontrollers 12.3 Types of Computers for Robots 12.3.1 12.3.2 12.3.3 12.3.4
Microcontrollers Personal Digital Assistants Single-Board Computers Personal Computers
151 152 153
154 155 155 159 160 161
CONTENTS
12.4 Inputs and Outputs 12.4.1 12.4.2 12.4.3 12.4.4 12.4.5
Serial Communications Asynchronous Serial Communications Digital-to-Analog Conversion Pulse and Frequency Management Special Functions
12.5 From Here Chapter 13—Programming Fundamentals 13.1 Important Programming Concepts 13.1.1 13.1.2 13.1.3 13.1.4 13.1.5 13.1.6 13.1.7 13.1.8 13.1.9
Linear Program Execution Flowcharts Variables and I/O Ports Assignment Statements Arrays and Character Strings Decision Structures Subroutines and Functions Console I/O Comments
13.2 Robotics Programming 13.3 Graphical Programming 13.4 From Here Chapter 14—Computer Peripherals 14.1 Sensors as Inputs 14.1.1 Types of Sensors 14.1.2 Examples of Sensors
14.2 Input and Output Methodologies 14.2.1 Parallel Interfacing 14.2.2 Serial Interfacing
14.3 Motors and Other Outputs 14.3.1 Other Common Types of Outputs
14.4 Sample Output Circuits 14.5 Digital Inputs 14.5.1 Interfacing from Different Voltage Levels 14.5.2 Using Opto-Isolators 14.5.3 Zener Diode Input Protection
ix
164 164 166 167 167 168
168 169 170 170 171 173 176 180 181 183 185 185
186 187 189 191 191 192 192
193 193 194
195 195
195 198 198 199 201
14.6 Interfacing Analog Input
201
14.6.1 Voltage Comparator 14.6.2 Signal Amplification
201 202
x CONTENTS
14.6.3 Signal Buffering 14.6.4 Other Signal Techniques for Op-Amps 14.6.5 Common Input Interfaces
14.7 Analog-to-Digital Converters 14.7.1 14.7.2 14.7.3 14.7.4 14.7.5
How Analog-to-Digital Conversion Works Inside the Successive Approximation ADC Analog-to-Digital Conversion ICs Integrated Microcontroller ADCs Sample Circuits
14.8 Digital-to-Analog Conversion 14.9 Expanding Available I/O Lines 14.10 Bitwise Port Programming 14.10.1 Masking Values by ANDing 14.10.2 Converting a Value into a Binary-Format String 14.10.3 Summing Bits into a Decimal Value
14.11 From Here Chapter 15—The BASIC Stamp 2 Microcontroller 15.1 Choosing the Right Stamp for Your Application 15.2 Inside the BASIC Stamp 15.3 Developer’s Options 15.4 Understanding and Using PBASIC 15.4.1 15.4.2 15.4.3 15.4.4
Variable and Pin/Port Definitions Assignment Statements and Arithmetic Expressions Execution Flow and Decision Structures Built-in Functions
15.5 Sample Interface Applications 15.5.1 15.5.2 15.5.3 15.5.4 15.5.5
Basic BS2 Setup LED Outputs Adding Switches and Other Digital Inputs LCD Interface I/O Port Simulator
15.6 BS2 Application Design Suggestions 15.7 From Here
202 203 204
204 205 205 206 206 206
207 208 210 210 211 211
212 213 214 217 219 220 221 224 226 231
232 233 236 239 241 245
252 253
Chapter 16—Remote Control Systems 255 16.1 Controlling Your Robot with a PC Joystick or Control Pad 255 16.2 Building a Joystick Teaching Pendant 259 16.2.1 Possible Enhancements
263
CONTENTS
16.3 Commanding a Robot with Infrared Remote Control 16.3.1 16.3.2 16.3.3 16.3.4
A Typical Microcontroller Interface BS2 Interface Controlling Robot Motors with a Remote Control Going Further
16.4 Using Radio Control Instead of Infrared 16.5 From Here
xi
264 265 268 270 272
273 274
PART 4—POWER, MOTORS, AND LOCOMOTION Chapter 17—Batteries and Robot Power Supplies 17.1 Remember: Safety First! 17.2 Increasing Robot Performance 17.3 Combining Batteries 17.4 Types of Batteries 17.4.1 17.4.2 17.4.3 17.4.4 17.4.5 17.4.6 17.4.7
Zinc Alkaline High-Tech Alkaline Nickel Metal Hydride Nickel-Cadmium Lithium and Lithium-Ion Lead-Acid
17.5 Battery Ratings 17.5.1 17.5.2 17.5.3 17.5.4
17.6 17.7 17.8 17.9
Voltage Capacity Recharge Rate Nominal Cell Voltage
Battery Recharging Recharging the Robot Battery Care Power Distribution 17.9.1 Fuse Protection 17.9.2 Multiple Voltage Requirements 17.9.3 Separate Battery Supplies
17.10 Voltage Regulation 17.10.1 17.10.2 17.10.3 17.10.4
Zener Diode Voltage Regulation Linear Voltage Regulators Switching Voltage Regulation Power Distribution
277 278 278 279 280 280 281 281 281 282 282 283
284 284 285 286 287
287 288 288 289 289 290 291
292 292 294 295 297
xii CONTENTS
17.11 Battery Monitors 17.11.1 4.3 V Zener Battery Monitor 17.11.2 Zener/Comparator Battery Monitor 17.11.3 Using a Battery Monitor with a Microprocessor
17.12 A Robot Testing Power Supply 17.13 From Here Chapter 18—Principles of Robot Locomotion 18.1 First Things First: Weight 18.2 Tips for Reducing Weight 18.3 Beware of the Heavy Frame 18.4 Construction Robots with Multiple Decks 18.5 Frame Sagging Caused by Weight 18.6 Horizontal Center of Balance 18.7 Vertical Center of Gravity 18.8 Locomotion Issues 18.8.1 Wheels and Tracks 18.8.2 Legs
18.9 Motor Drives 18.9.1 Centerline Drive Motor Mount 18.9.2 Front-Drive Motor Mount 18.9.3 Caster Choices
18.10 Steering Methods 18.10.1 18.10.2 18.10.3 18.10.4
Differential Car-Type Tricycle Omnidirectional
18.11 Calculating the Speed of Robot Travel 18.12 Round Robots or Square? 18.13 From Here Chapter 19—Choosing the Right Motor 19.1 AC or DC? 19.2 Continuous or Stepping? 19.3 Servo Motors 19.4 Other Motor Types
298 298 300 300
300 303 305 305 306 307 307 308 310 311 311 311 312
313 313 313 315
318 318 318 319 320
320 322 322 325 325 326 327 327
CONTENTS
19.5 Motor Specifications 19.5.1 19.5.2 19.5.3 19.5.4 19.5.5
Operating Voltage Current Draw Speed Torque Stall or Running Torque
19.6 Gears and Gear Reduction 19.6.1 19.6.2 19.6.3 19.6.4
Gears 101 Establishing Gear Reduction Using Motors with Gear Reduction Anatomy of a Gear
xiii
328 328 329 330 331 331
333 333 333 335 337
19.7 Pulleys, Belts, Sprockets, and Roller Chain
339
19.7.1 More about Pulleys and Belts 19.7.2 More about Sprockets and Roller Chain
339 339
19.8 Mounting the Motor 19.9 Connecting to the Motor Shaft 19.10 From Here
339 341 342
Chapter 20—Working with DC Motors 20.1 The Fundamentals of DC Motors 20.2 Reviewing DC Motor Ratings 20.3 Motor Control
345 345 347 348
20.3.1 20.3.2 20.3.3 20.3.4 20.3.5
Relay Control Bipolar Transistor Control Power MOSFET Control Motor Bridge Control Relay versus Bipolar versus FET Motor Drivers
20.4 Motor Speed Control 20.4.1 Not the Way to Do It 20.4.2 Basic PWM Speed Control 20.4.3 Counter-Based PWM Speed Control
20.5 Odometry: Measuring Distance of Travel 20.5.1 20.5.2 20.5.3 20.5.4 20.5.5
Anatomy of a Shaft Encoder The Distance Counter Making the Shaft Encoder Mounting the Hardware Quadrature Encoding
20.6 From Here
348 351 355 357 359
359 360 360 365
367 367 367 368 371 371
374
xiv
CONTENTS
Chapter 21—Working with Stepper Motors 21.1 Inside a Stepper Motor 21.1.1 Wave Step Sequence 21.1.2 Four-Step Sequence
21.2 Design Considerations of Stepper Motors 21.2.1 21.2.2 21.2.3 21.2.4 21.2.5 21.2.6
375 376 376 376
378
Stepper Phasing Step Angle Pulse Rate Running Torque Braking Effect Voltage, Current Ratings
378 378 378 379 379 380
21.3 Controlling a Stepper Motor
380
21.3.1 21.3.2 21.3.3 21.3.4 21.3.5 21.3.6 21.3.7 21.3.8
Using a Stepper Motor Controller Chip Using Logic Gates to Control Stepper Motors Translator Enhancements Triggering the Translator Circuits Using Bipolar Stepper Motors Buying and Testing a Stepper Motor Sources for Stepper Motors Wiring Diagram
21.4 From Here
382 382 383 385 386 387 387 389
391
Chapter 22—Working with Servo Motors 22.1 How Servos Work 22.2 Servos and Pulse Width Modulation 22.3 The Role of the Potentiometer 22.4 Rotational Limits 22.5 Special-Purpose Servo Types and Sizes 22.6 Gear Trains and Power Drives 22.7 Typical Servo Specs 22.8 Connector Styles and Wiring
393 394 395 396 397 397 398 398 399
22.8.1 Connector Type 22.8.2 Pinout and Color Coding
400 401
22.9 Circuits for Controlling a Servo 22.9.1 Controlling a Servo via a 556 Timer Chip 22.9.2 Controlling a Servo via a BASIC Stamp 22.9.3 Using a Dedicated Controller
401 402 402 404
CONTENTS
22.9.4 Servo Voltage Margins 22.9.5 Working with and Avoiding the Dead Band 22.9.6 Going beyond the 1 to 2 Millisecond Pulse Range
22.10 Modifying a Servo for Continuous Rotation 22.10.1 22.10.2 22.10.3 22.10.4 22.10.5 22.10.6 22.10.7
Basic Modification Instructions Applying New Grease Testing the Modified Servo A Caution on Modifying Servos Software for Running Modified Servos Limitations of Modified Servos Modifying by Removing the Servo Control Board
22.11 Attaching Mechanical Linkages to Servos 22.12 Attaching Wheels to Servos 22.13 Mounting Servos on the Body of the Robot 22.13.1 Attaching Servos with Glue 22.13.2 Attaching Servos with Screws or Bolts
22.14 From Here
xv
405 405 406
406 406 407 407 408 408 408 409
409 410 411 411 411
413
PART 5—PRACTICAL ROBOTICS PROJECTS Chapter 23—Building a Roverbot 23.1 Building the Base 23.2 Motors 23.3 Support Casters 23.4 Batteries 23.5 Riser Frame 23.6 Street Test 23.7 From Here
417 418 420 424 425 426 429 430
Chapter 24—Building a Heavy-Duty Six-Legged Walking Robot 24.1 Frame 24.2 Legs 24.3 Motors 24.4 Batteries 24.5 Testing and Alignment 24.6 From Here
431 431 435 444 449 449 451
xvi CONTENTS
Chapter 25—Advanced Robot Locomotion Systems 25.1 Making Tracks 25.2 Steering Wheel Systems 25.3 Six-Wheeled Robot Cart 25.4 Building Robots with Shape-Memory Alloy 25.4.1 25.4.2 25.4.3 25.4.4
Basics of SMA Using SMA Shape-Memory Alloy Mechanisms Designing Robots for SMA Limitations
25.5 From Here Chapter 26—Reaching Out with Robot Arms 26.1 The Human Arm 26.2 Arm Types 26.2.1 26.2.2 26.2.3 26.2.4
Revolute Coordinate Polar Coordinate Cylindrical Coordinate Cartesian Coordinate
26.3 Activation Techniques 26.4 From Here Chapter 27—Building a Revolute Coordinate Arm 27.1 Design Overview 27.2 Shoulder Joint and Upper Arm 27.3 Elbow and Forearm 27.4 Refinements 27.5 Position Control 27.5.1 Potentiometer 27.5.2 Incremental Shaft Encoders
27.6 From Here Chapter 28—Experimenting with Gripper Designs 28.1 The Clapper 28.2 Two-Pincher Gripper 28.2.1 Basic Model 28.2.2. Advanced Model Number 1 28.2.3 Advanced Model Number 2
453 453 455 457 458 458 459 462 463
463 465 465 466 466 467 468 468
469 470 471 471 472 474 478 479 479 480
481 483 483 486 486 487 490
CONTENTS
28.3 Flexible Finger Grippers 28.4 Wrist Rotation 28.5 From Here
xvii
494 496 497
PART 6—SENSORS AND NAVIGATION Chapter 29—The Sense of Touch 29.1 Mechanical Switch 29.1.1 Microswitches
29.2 Switch Bouncing 29.2.1 Hardware Debounce 29.2.2 Software Debounce
29.3 Optical Sensors 29.4 Mechanical Pressure Sensors 29.4.1 Conductive Foam 29.4.2 Strain Gauges 29.4.3 Converting Pressure Data to Computer Data
29.5 Experimenting with Piezoelectric Touch Sensors 29.5.1 29.5.2 29.5.3 29.5.4 29.5.5
Experimenting with Ceramic Discs Experimenting with Kynar Piezo Film Attaching Leads to Kynar Piezo Film Using Kynar Piezo Film as a Mechanical Transducer Constructing a Kynar Piezo Film Bend Sensor
29.6 Other Types of Touch Sensors 29.7 From Here Chapter 30—Object Detection 30.1 Design Overview 30.1.1 30.1.2 30.1.3 30.1.4
Near-Object Detection Far-Object Detection Remembering the KISS Principle Redundancy
30.2 Noncontact Near-Object Detection 30.2.1 30.2.2 30.2.3 30.2.4
Simple Infrared Light Proximity Sensor Better IR Proximity Sensor Sharp Infrared Object Sensors Passive Infrared Detection
501 502 502
503 504 505
507 508 508 510 510
511 512 513 514 515 516
516 517 519 520 520 521 521 522
523 523 524 530 534
xviii CONTENTS
30.2.5 30.2.6 30.2.7 30.2.8
Using a New or Removed-from-Circuit Detector Hacking a Motion Detector Board Using the Focusing Lens Ultrasonic Sound
30.3 Contact Detection 30.3.1 30.3.2 30.3.3 30.3.4 30.3.5
Physical Contact Bumper Switch Whisker Spring Whiskers Pressure Pad Multiple Bumper Switches
30.4 Soft Touch and Compliant Collision Detection 30.4.1 Laser Fiber Whiskers 30.4.2 Piezo Disc Touch Bar 30.4.3 Other Approaches for Soft-Touch Sensors
30.5 From Here Chapter 31—Sound Input and Output 31.1 Cassette Recorder Sound Output 31.2 Electronically Recorded Sound Output 31.2.1 Hacking a Toy Sound Recorder 31.2.2 Using the ISD Family of Voice-Sound Recorders
31.3 31.4 31.5 31.6 31.7 31.8
Sirens and Other Warning Sounds Sound Control Audio Amplifiers Speech Recognition Speech Synthesis Sound Input Sensors 31.8.1 31.8.2 31.8.3 31.8.4
Microphone Amplifier Input Stage Tone Decoding Detection Building a Sound Source
31.9 From Here Chapter 32—Robot Vision 32.1 Simple Sensors for Vision 32.2 One-Cell Cyclops 32.3 Multiple-Cell Light Sensors
534 537 537 538
541 541 542 543 544 545
548 548 555 558
558 559 559 561 561 562
566 567 568 570 571 571 571 572 573 576
577 579 579 581 583
CONTENTS
32.4 Using Lenses and Filters with Light-Sensitive Sensors 32.4.1 Using Lenses 32.4.2 Using Filters
xix
586 586 588
32.5 Introduction to Video Vision Systems
588
32.5.1 Robot View Digital Camera
589
32.6 Vision by Laser Light 32.7 Going beyond Light-Sensitive Vision
593 595
32.7.1 32.7.2 32.7.3 32.7.4
Ultrasonics Radar Passive Infrared Tactile Feedback
32.8 From Here Chapter 33—Navigation 33.1 A Game of Goals 33.2 Following a Predefined Path: Line Tracing 33.2.1 Computer Controlled Line Following
33.3 Wall Following 33.3.1 33.3.2 33.3.3 33.3.4 33.3.5
Variations of Wall Following Ultrasonic Wall Following Soft-Contact Following with Foam Wheels Dealing with Doorways and Objects Coding Your Wall-Following Robot
33.4 Odometry: The Art of Dead Reckoning 33.4.1 33.4.2 33.4.3 33.4.4
Optical Encoders Magnetic Encoders The Function of Encoders in Odometry Errors in Odometry
33.5 Compass Bearings 33.6 Ultrasonic Distance Measurement 33.6.1 Facts and Figures 33.6.2 Interfacing a Polaroid 6500 Ultrasonic Range Finder
33.7 “Where Am I?”: Sighting Landmarks 33.7.1 33.7.2 33.7.3 33.7.4 33.7.5
Infrared Beacon Radio Frequency Identification Landmark Recognition Other Techniques for Beacons and Lighthouses Coupled Sonar and IR Light
595 595 596 596
597 599 599 601 603
607 608 609 609 609 610
612 612 612 613 613
614 616 617 618
621 621 622 623 624 625
xx CONTENTS
33.8 Exploring Other Position-Referencing Systems 33.8.1 Global Positioning Satellite 33.8.2 Inertial Navigation 33.8.3 Map Matching
33.9 From Here Chapter 34—Fire Detection Systems 34.1 Flame Detection
625 626 626 627
628 629 629
34.1.1 Detecting the Infrared Light from a Fire 34.1.2 Watching for the Flicker of Fire
629 631
34.2 Using a Pyroelectric Sensor to Detect Fire 34.3 Smoke Detection
631 632
34.3.1 34.3.2 34.3.3 34.3.4 34.3.5
Hacking a Smoke Alarm Interfacing the Alarm to a Computer Testing the Alarm Limitations of Robots Detecting Smoke Detecting Noxious Fumes
34.4 Heat Sensing 34.5 Firefighting 34.6 From Here
632 634 635 635 635
636 638 640
Chapter 35—Experimenting with Tilt and Gravity Sensors 641 35.1 Sensors to Measure Tilt 642 35.1.1 Building a Balance System with a Mercury Switch 35.1.2 Building a Balance System with a Ball-in-Cage Switch
35.2 Using an Accelerometer to Measure Tilt 35.2.1 35.2.2 35.2.3 35.2.4
What Is an Accelerometer? Additional Uses for Accelerometers Single- and Dual-Axis Sensing The Analog Devices’ ADXL Accelerometer Family
35.3 Constructing a Dual-Axis Accelerometer Robotic Sensor 35.3.1 35.3.2 35.3.3 35.3.4 35.3.5
Wiring Diagram Understanding the Output of the ADXL202 Orienting the Accelerometer Control Interface and Software Additional Uses
35.4 Alternatives to Store-Bought Accelerometers 35.4.1 Constructing the Piezo Disc Accelerometer 35.4.2 Limitations of the Piezo Disc Accelerometer
35.5 From Here
643 643
644 644 645 645 645
646 647 647 648 648 650
650 651 651
652
CONTENTS
Chapter 36—Home Robots and How Not to Chew Up Your Furniture 36.1 Sensing the Environment: Protecting the Furniture and the Robot 36.2 Movement Algorithms 36.3 Communicating with the Robot 36.4 From Here
xxi
653 654 655 657 659
PART 7—PUTTING IT ALL TOGETHER Chapter 37—Robot Tasks, Operations, and Behaviors 37.1 “What Does My Robot Do?”: A Design Approach 37.1.1 An Itinerary of Functions 37.1.2 Additional Features
37.2 Reality versus Fantasy 37.3 Understanding and Using Robot Behaviors 37.3.1 37.3.2 37.3.3 37.3.4 37.3.5
When a Behavior Is Just a Simple Action Wall Following: A Common Behavior? The Walt Disney Effect Robotic Functions and Error Correction Analyzing Sensor Data to Define Behaviors
37.4 Multiple Robot Interaction 37.5 The Role of Subsumption Architecture 37.6 From Here
663 664 664 665
666 666 667 667 668 668 669
669 670 671
Chapter 38—Integrating the Blocks 38.1 Basic Program Structure 38.2 Allocating Resources
673 673 674
38.2.1 I/O Pins 38.2.2 Internal Features
674 675
38.3 Getting a Program’s Attention Via Hardware 38.3.1 Timer Interrupt 38.3.2 Hardware Interrupt 38.3.3 Glass Half-Empty, Half-Full
38.4 Task-Oriented Robot Control 38.4.1 Programming for Tasks 38.4.2 Multitasking Error Modes for Optimal Flexibility
38.5 From Here
675 676 676 676
677 677 677
678
xxii CONTENTS
Chapter 39—Failure Analysis 39.1 Types of Failures
679 679
39.1.1 Mechanical Failure 39.1.2 Electrical Failure 39.1.3 Programming Failure
680 680 681
39.2 The Process of Fixing Problems
681
39.2.1 39.2.2 39.2.3 39.2.4 39.2.5 39.2.6
Documenting the Expected State Characterizing the Problem Hypothesizing about the Problem Proposing Corrective Actions Testing Fixes Implementing and Releasing the Solution
39.3 From Here Chapter 40—Setting Up Workshops, Demonstrations, and Competitions 40.1 Choosing the Venue 40.1.1 Venue Needs
40.2 Competition Events 40.2.1 Scrounging for Prizes
40.3 Alerting the Public and the Media 40.4 From Here Appendix A—Further Reading A.1 Hobby Robotics A.2 LEGO Robotics and LEGO Building A.3 Technical Robotics, Theory, and Design A.4 Artificial Intelligence and Behavior-Based Robotics A.5 Mechanical Design A.6 Electronic Components A.7 Microcontroller/Microprocessor Programming and Interfacing A.8 Electronics How-To and Theory A.9 Power Supply Design and Construction A.10 Lasers and Fiber Optics A.11 Interfacing to Computer Systems A.12 Magazines A.13 Classic Robot Fiction
682 682 684 685 686 686
687 689 689 690
691 693
693 694 695 696 696 697 697 698 698 699 700 701 701 701 702 703
CONTENTS
xxiii
Appendix B—Sources B.1 Selected Specialty Parts and Sources B.2 General Robotics Kits and Parts B.3 Electronics/Mechanical: New, Used, and Surplus B.4 Microcontrollers, Single-Board Computers, Programmers B.5 Radio Control (R/C) Retailers B.6 Servo and Stepper Motors, Controllers B.7 Ready-Made Personal and Educational Robots B.8 Construction Kits, Toys, and Parts B.9 Miscellaneous
705 706 707 709 712 713 713 714 714 714
Appendix C—Robot Information on the Internet C.1 Electronics Manufacturers C.2 Shape-Memory Alloy C.3 Microcontroller Design C.4 Robotics User Groups C.5 General Robotics Information C.6 Books, Literature, and Magazines C.7 Surplus Resources C.8 Commercial Robots C.9 Video Cameras C.10 Ultrasonic Range Finders C.11 LEGO Mindstorms Sources on the Web C.12 Servo and Stepper Motor Information C.13 Quick Turn Mechanical and Electronics Parts Manufacturers
715 716 716 716 717 718 720 720 720 721 721 721 722
Index
725
723
This page intentionally left blank
ACKNOWLEDGMENTS
Gordon McComb’s Acknowledgments for the Third Edition Only until you’ve climbed the mountain can you look behind and see the vast distance that you’ve covered, and remember those you’ve met along the way who made your trek a little easier. Now that this book is finally finished, after the many miles of weary travel, I look back to those who helped me turn it into a reality and offer my heartfelt thanks. To the gang on comp.robotics.misc, for the great ideas, wisdom, and support; to Scott Savage, designer of the OOPic; to Frank Manning and Jack Schoof of NetMedia for their help with the BasicX; to Tony Ellis, a real-life “Q” if I ever met one; to Scott Grillo and the editors at McGraw-Hill; to my agents Matt Wagner and Bill Gladstone; and last and certainly not least, to my wife, Jennifer.
Myke Predko’s Acknowledgments for the Third Edition I had no small measure of concern when I was offered the opportunity to work on the third edition of what is affectionately known as RBB. The book is a staple for both beginners and experts alike and is crammed with material and knowledge that come from a large number of disciplines. Undertaking this effort required a lot of support from a variety of different individuals. My editor, Judy Bass, who had the confidence that I could update RBB and do a credible job of it, and who kept her sense of humor and interest despite all the emails, questions, and ideas that are generated in a project like this. Judy always gives the confidence that all of McGraw-Hill is behind me. For technical information and ideas regarding the material in the book, I would like to recognize Ben Wirz, who has an amazing amount of background in robotics and has been the co-designer on the Tab Electronics robot kits; Joe Jones, a very special robot designer and author; and Ken Gracey of Parallax who seems to have dedicated himself to making robots easy for everyone. I want to thank all of you for your time, ideas, and energy toward the development of the third edition of this book. Over the past few years, I have been involved with the Ontario Science Centre along with Celestica, my daytime employer, helping to put on robot workshops for local families.
Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
xxvi ACKNOWLEDGMENTS
Through these workshops, I have learned a lot about what people want to get from robots and have seen their ideas take wing. All the volunteers involved, both Celestica and Ontario Science Centre employees, continue to give excellent suggestions, feedback, and support. I would especially like to thank Blair Clarkson, the special events coordinator of the Ontario Science Centre for his friendship, help, and prodding over the years to help create something that is truly unique. For those of you following my progress as a writer, you will know that I frequently consult my daughter, Marya, for ideas and a different perspective. Her support started out from just pressing buttons to watch lights flash and now has progressed to trying out a few of the projects and critiquing different aspects of the book. My wife Patience’s continual support and love are necessary ingredients of every book I have written. Her enthusiasm for my hobby despite the mess, time taken from the family, and occasional flames accompanied by loud obscenities is nothing short of wonderful. Nothing that I do would be possible without you. Lastly, I am indebted to Gordon McComb for all his hard work establishing the framework for Robot Builder’s Bonanza and the countless hours he has spent making sure this book is the best introduction to robotics there is. Thank you and I hope I have been able to pass along a bit of what you’ve given me.
INTRODUCTION
To the robotics experimenter, robot has a completely different meaning than what most people think of when they hear the word. A robot is a special brew of motors, solenoids, wires, and assorted electronic odds and ends, a marriage of mechanical and electronic gizmos. Taken together, the parts make a half-living but wholly personable creature that can vacuum the floor, serve drinks, protect the family against intruders and fire, entertain, educate, and lots more. In fact, there’s almost no limit to what a well-designed robot can do. In just about any science, it is the independent experimenter who first establishes the pioneering ideas and technologies. At the turn of the last century, two bicycle mechanics experimenting with strange kites were able to explain the basics of controlled flight. Robert Goddard experimented with liquid-fuel rockets before World War II; his discoveries paved the way for modern-day space flight. Alan Turning, tasked to create logic equipment to decrypt coded radio transmissions during the Second World War also worked at designing the basic architecture for the digital computer. In the 1950s a psychologist, Dr. W. Grey Walter, created the first mobile robots as part of an experiment into the operation of nerves as part of the decision processes in animals. Robotics—like flight, rocketry, computers, and countless other technology-based endeavors—started small. Today, robotics is well on its way to becoming a necessary part of everyday life; not only are they used in automotive manufacturing, but they are exploring the solar system and prototype robot servants are walking upright, just like humans, as they learn to navigate and interact with our world. What does this mean for the robotics experimenter? There is plenty of room for growth, with a lot of discoveries yet to be made—perhaps more so than in any other hightech discipline.
I.1 Inside Robot Builder’s Bonanza Robot Builder’s Bonanza, Third Edition takes an educational but fun approach to designing working robots. Its modular projects will provide the knowledge to take you from building basic motorized platforms to giving the machine a brain—and teaching it to walk, move about, sense what is going on around it, and obey commands. If you are interested in mechanics, electronics, or robotics, you’ll find this book a treasure chest of information and ideas on making thinking machines. The projects in Robot Builder’s Bonanza include all the necessary information on how to construct the essential building blocks of a number of different personal robots. Suggested alternative approaches,
Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
xxviii INTRODUCTION
parts lists, and sources of electronic and mechanical components are also provided where appropriate. There are quite a few excellent books that have been written on how to design and build robots. But most have been aimed at making just one or two fairly sophisticated automatons, and at a fairly high price. Because of the complexity of the robots detailed in these other books, they require a fairly high level of expertise and pocket money on your part. Robot Builder’s Bonanza is different. Its modular “cookbook” approach offers a mountain of practical, easy to follow, and inexpensive robot experiments and projects. Integrated together, the various projects presented in the book, along with ones you come up with on your own, can be combined to create several different types of highly intelligent and workable robots of all shapes and sizes—rolling robots, walking robots, talking robots, you name it.
I.2 About the Third Edition This new edition features a new author, Myke Predko, who has revised the second edition (published in 2001 and the original edition in 1987) from the perspective of an electrical engineer. Myke brings his experience as an electrical engineer that has worked with a wide variety of different computer systems as well as the development of low-level software designed for hardware interfacing. Many of the circuits presented in the earlier editions have been redesigned to both simplify them as well as make them more robust in robot applications. In the previous edition of this book, a number of different computer controls were presented while in this edition the projects have been consolidated on the Parallax BASIC Stamp 2, which is an excellent tool for new roboticists. The examples can also inspire the more experienced robot designers who already work with their favorite control hardware. The book has also been updated with new material on such topics as commercially available robots for the home as well as how to organize your own robot competitions.
I.3 What You Will Learn In the more than three dozen chapters in this book you will learn about a sweeping variety of technologies, all aimed at helping you learn robot design, construction, and application. You’ll learn about:
• • • •
Robot-building fundamentals. How a robot is put together using commonly available parts such as plastic, wood, and aluminum. Locomotion engineering. How motors, gears, wheels, and legs are used to propel your robot over the ground. Constructing robotic arms and hands. How to use mechanical linkages to grasp and pick up objects. Sensor design. How sensors are used to detect objects, measure distance, and navigate open space.
INTRODUCTION
• • •
xxix
Adding sound capabilities. Giving your robot creation the power of voice and sound effects so that it can talk to you, and you can talk back. Remote control. How to operate and train your robot using wired and wireless remote control. Computer control. How to use and program a computer or microcontroller for operating a robot.
Most important, you will gain new insights into problem solving and looking at devices, parts, and materials from a different perspective. No longer will you look at an old CD-player or toy as just junk, but as the potential starting point or parts source for your own creations.
I.4 How to Use This Book Robot Builder’s Bonanza is divided into seven main parts. Each section covers a major component of the common personal or hobby (as opposed to commercial or industrial) robot. The sections are as follows: 1. Robot Basics. What you need to get started; setting up shop; how and where to buy
robot parts. 2. Robot Platform Construction. Robots made of plastic, wood, and metal; working with
3. 4.
5. 6.
7.
common metal stock; converting toys into robots or using other mechanical odds and ends to create robots. Computers and Electronic Control. An explanation of computer operation; introduction to programming; interfacing computers and controllers to electronic devices. Power, Motors, and Locomotion. Using batteries; powering the robot; working with DC, stepper, and servo motors; gear trains; walking robot systems; special robot locomotion systems. Practical Robotics Projects. Over a half-dozen step-by-step projects for building wheels and legged robot platforms; arm systems; gripper design. Sensors and Navigation. Speech synthesis and recognition; sound detection; robot eyes; smoke, flame, and heat detection; collision detection and avoidance; ultrasonic and infrared ranging; infrared beacon systems; track guidance navigation. Putting It All Together. Discussion on the techniques for integrating different parts together into a single robot; finding and efficiently fixing the problems you encounter along the way; putting on a robot competition.
Many chapters present one or more projects that you can duplicate for your own robot creations. Whenever practical, the components were designed as discrete building blocks, so that you can combine the blocks in just about any configuration you desire. The robot you create will be uniquely yours and yours alone. The Robot Builder’s Bonanza is not so much a textbook on how to build robots but a treasure map. The trails and paths provided between these covers lead you on your way to building one or more complete and fully functional robots. You decide how you want your robots to appear and what you want your robots to do.
xxx INTRODUCTION
I.5 Expertise You Need Robot Builder’s Bonanza doesn’t contain a lot of hard-to-decipher formulas, unrealistic assumptions about your level of electronic or mechanical expertise, or complex designs that only a seasoned professional can tackle. This book was written so that just about anyone can enjoy the thrill and excitement of building a robot. Most of the projects can be duplicated without expensive lab equipment, precision tools, or specialized materials, and at a cost that won’t wear the numbers off your credit cards. If you have some experience in electronics, mechanics, or robot building in general, you can skip around and read only those chapters that provide the information you’re looking for. Like the robot designs presented, the chapters are very much stand-alone modules. This allows you to pick and choose, using your time to its best advantage. However, if you’re new to robot building, and the varied disciplines that go into it, you should take a more pedestrian approach and read as much of the book as possible. In this way, you’ll get a thorough understanding of how robots tick. When you finish the book, you’ll know the kind of robot(s) you’ll want to make, and how you’ll make them.
I.6 Conventions Used in This Book Mechanical drawings, schematics, and other diagrams have been created using standard conventions and should not look significantly different from other graphics found in different sources. The basic symbols used in the diagrams will be explained as you read through the book. If there continue to be symbols or components that are confusing to you, please look at the different reference material listed in the appendices. Integrated circuits are referenced by their part number. Remember that the part number and the operation of the part can vary when different technologies are used. This means that when you are given a TTL chip of a specific technology (i.e., LS) do not assume that other chips with the same part number, but different technology, can be used. Details on the specific parts used in the circuits are provided in the parts list tables that accompany the schematic. Refer to the parts list for information on resistor and capacitor type, tolerance, and wattage or voltage rating. In all full-circuit schematics, the parts are referenced by component type and number.
• • • • •
IC means an integrated circuit (IC). Some integrated circuits will be referenced by their part number or function if this simplifies the explanation of the circuit and there are many different substitute parts available. R means a resistor or potentiometer (variable resistor). All resistors are 1/4 W, 5% tolerance, unless otherwise specified. C means a capacitor. Capacitors can be of any type unless specified. D means a diode, a zener diode, and, sometimes a light-sensitive photodiode. Q means a transistor and, sometimes, a light-sensitive phototransistor.
INTRODUCTION
• • •
xxxi
LED means a light-emitting diode (most any visible LED will do unless the parts list specifically calls for an infrared or other special-purpose LED). XTAL means a crystal or ceramic resonator. Finally, S or SW means a switch; RL means a relay; SPKR, a speaker; TR, a transducer (usually ultrasonic); and MIC, a microphone. Enough talk. Turn the page and open your map. The treasure awaits you.
This page intentionally left blank
PA R T
ROBOT BASICS
Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
1
This page intentionally left blank
CHAPTER
1
THE ROBOT EXPERIMENTER
A
lone he sits in a dank and musty basement, as he’s done countless long nights before; pouring over plans, making endless calculations, and then pounding his creation into being. With each strike of his ball-peen hammer, an ear-shattering bong and echoes ring through the house. Slowly, his work takes shape and form—it started as an unrecognizable blob of metal and plastic, then became an eerie silhouette, then . . . Brilliant and talented, but perhaps a bit crazed, he is before his time—an adventurer who belongs neither to science nor fiction. He is the robot experimenter, and all he wants to do is make a mechanical creature that will ultimately become his servant and companion. The future hides not what he will ultimately do with his creation, but what his creation will do with him. Okay, maybe this is a rather dark view of the present-day hobby robotics experimenter. But though you may find a dash of the melodramatic in it, the picture is not entirely unrealistic. It’s a view held by many outsiders to the robot-building craft. It’s a view that’s over 100 years old, from the time when the prospects of building a humanlike machine first came within technology’s grasp. It’s a view that will continue for another 100 years, perhaps beyond. Like it or not, if you’re a robot experimenter, you are considered to be on society’s fringes: an oddball, an egghead, and—yes, let’s get it all out—possibly someone looking for a kind of malevolent power! As a robot experimenter, you’re not unlike Victor Frankenstein, the old-world doctor from Mary Wollstonecraft Shelley’s immortal 1818 horror thriller. Instead of robbing graves in the still of night, you “rob” electronic stores, flea markets, surplus outlets, and other spe3 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
4 THE ROBOT EXPERIMENTER
cialty shops in your unrelenting quest—your thirst—for all kinds and sizes of motors, batteries, gears, wires, switches, and other odds and ends. Like Dr. Frankenstein, you galvanize life from these “dead” parts. If you have not yet built your first robot, you’re in for a wonderful experience. Watching your creation scoot around the floor or table can be exhilarating. Those around you may not immediately share your excitement, but you know that you’ve built something—however humble—with your own hands and ingenuity. And yet if you have built a robot, you also know of the heartache and frustration inherent in the process. You know that not every design works and that even a simple engineering flaw can cost weeks of work, not to mention ruined parts. This book will help you—beginner and experienced robot maker alike—get the most out of your robotics hobby.
1.1 The Building-Block Approach One of the best ways to experiment with and learn about hobby robots is to construct individual robot components, then combine the completed modules to make a finished, fully functional machine. For maximum flexibility, these modules should be interchangeable whenever possible. You should be able to choose locomotion system “A” to work with appendage system “B,” and operate the mixture with control system “C”—or any variation thereof. As you start trying to create your own robots, using a building-blocks approach allows you to make relatively simple and straightforward changes and updates. When designed and constructed properly, the different building blocks, as shown in diagram form in Fig. 1-1, may be shared among a variety of robots. Most of the building-block designs presented in the following chapters are complete, working subsystems. Some operate without ever being attached to a robot or control computer. The way you interface the modules is up to you and will require some forethought and attention on your part (this book does not provide all the answers!). Feel free to experiment with each subsystem, altering it and improving upon it as you see fit. When it works the way you want, incorporate it into your robot, or save it for a future project.
1.2 Basic Skills What skills do you need as a robot experimenter? Certainly, if you are already well versed in electronics, programming, and mechanical design, you are on your way to becoming a robot experimenter. But intimate knowledge of these fields is not absolutely necessary; all you really need to start in the right direction as a robot experimenter is a basic familiarity with electronic theory, programming concepts, and mechanics (or time and interest to study the craft). The rest you can learn as you go. If you feel that you’re lacking in either beginning electronics or mechanics, pick up a book or two on these subjects at the bookstore or library (see Appendix A, “Further Reading,” for a selected list of suggested books and mag-
1.2 BASIC SKILLS
Drive Motors or Legs
Ultrasonic Ranger
Vision System
Arm
Central Computer or Control Circuitry
Obstacle Detectors
Gripper
Speech Synthesizer for Voice
Sound Generator: Music and Effects
5
FIGURE 1-1 The basic building blocks of a fully functional robot, including central processor (brain), locomotion (motors), and sensors (switches, sonar, etc.).
azines). In addition, you may wish to read through the seven chapters in Part 1 of this book to learn more about the fundamentals of electronics and computer programming.
1.2.1 ELECTRONICS BACKGROUND Start by studying analog and digital electronic theory, and learn the function of resistors, capacitors, transistors, and other common electronic components. Your knowledge need not be extensive, just enough so that you can build and troubleshoot electronic circuits for your robot. You’ll start out with simple circuits with a minimum of parts, and go from there. As your skills increase, you’ll be able to design your own circuits from scratch, or at the very least, customize existing circuits to match your needs. Schematic diagrams are a kind of recipe for electronic circuits. The designs in this book, as well as those in most any book that deals with electronics, are in schematic form. You owe it to yourself to learn how to read a schematic as there are really only a few dozen common schematic symbols you will have to familiarize yourself with. Several books have been written on how to read schematic diagrams, and the basics are also covered in Chapter 5, “Electronic Components.” See also Appendix A for a list of suggested books on robotics.
1.2.2 PROGRAMMING BACKGROUND Sophisticated robots use a computer or microcontroller to manage their actions. In this book you’ll find plenty of projects, plans, and solutions for connecting the hardware of your robot to any of several kinds of robot “brains.” Like all computers, the ones for robot con-
6 THE ROBOT EXPERIMENTER
trol need to be programmed. If you are new or relatively new to computers and programming, start with a beginners’ computer book, then move up to more advanced texts. Chapter 13, “Programming Fundamentals,” covers the programming basics. If you’ve never programmed before, you are probably expecting that there is a lot of knowledge that you must have to successfully program a computer. Actually there is about a half dozen basic programming concepts that once you understand completely you will be able to program just about any computer system in just about any programming language.
1.2.3 MECHANICAL BACKGROUND Some robot builders are more comfortable with the mechanical side of robot building than the electronic and programming sides—they can see gears meshing and pulleys moving. Regardless of your comfort level with mechanical design, you do not need to possess an extensive knowledge of mechanical and engineering theory to build robots. This book provides some mechanical theory as it pertains to robot building, but you may want to supplement your knowledge with books or study aids. There are a wealth of books, articles, and online reading materials on mechanical design equations and engineering formulas for you to draw upon when you are designing and building robots. This eliminates the need for this book to repeat this information, but like the information provided in electronics and programming, this book gives you many of the basics required to cobble together the robot’s mechanical systems.
1.2.4 WORKSHOP APTITUDE To be a successful robot builder, you must be comfortable working with your hands and thinking problems through from start to finish. You should know how to use common shop tools, and all related safety procedures, and have some basic familiarity with working with wood, lightweight metals (mostly aluminum), and plastic. Once more, if you feel your skills aren’t up to par, read up on the subject and try your hand at a simple project or two first. You’ll find construction tips and techniques throughout this book, but nothing beats hands-on shop experience. With experience comes confidence, and with both comes more professional results. Work at it long enough, and the robots you build may be indistinguishable from store-bought models (in appearance, not capability; yours will undoubtedly be far more sophisticated!).
1.2.5 THE TWO MOST IMPORTANT SKILLS Two important skills that you can’t develop from reading books are patience and the willingness to learn. Both are absolutely essential if you want to build your own working robots. Give yourself time to experiment with your projects. Don’t rush into things because you are bound to make mistakes if you do. If a problem continues to nag at you, put the project aside and let it sit for a few days. Keep a small notebook handy and jot down your ideas so you won’t forget them. If trouble persists, perhaps you need to bone up on the subject before you can adequately tackle the problem. Take the time to learn more about the various sciences and disciplines
1.4 THE MIND OF THE ROBOT EXPERIMENTER
7
involved. While you are looking for ways to combat your current dilemma, you are increasing your general robot-building knowledge. Research is never in vain.
1.3 Ready-Made, Kits, or Do-It-Yourself? This is a wonderful time to be an amateur robot builder. Not only can you construct robots from scratch, you can buy any of several dozen robot kits and assemble them using a screwdriver and other common tools. If you don’t particularly like the construction aspects of robotics, you can even purchase ready-made robots—no assembly required. With a readymade robot you can spend all your time connecting sensors and other apparatuses to it and figuring out new and better ways to program it. You might go for a third option: hacking an existing platform. With a bit of imagination and luck you can find a toy or some hardware that provides you with an excellent starting place for your own robot. The only limitation is to remember not to take something apart that somebody else values! Whether you choose to buy a robot in ready-made or kit form, or build your own from basic parts or the ground up, it’s important that you match your skills to the project. This is especially true if you are just starting out. While you may seek the challenge of a complex project, if it’s beyond your present skills and knowledge level you’ll likely become frustrated and abandon robotics before you’ve given it a fair chance. If you want to build your own robot, start with a simple design—a small rover, like those in Chapters 8 through 11. For now, stay away from the more complex walking and heavy-duty robots.
1.4 The Mind of the Robot Experimenter Robot experimenters have a unique way of looking at things. They take nothing for granted. For example, at a restaurant it’s the robot experimenter who collects the carcasses of lobsters and crabs to learn how these ocean creatures use articulated joints, in which the muscles and tendons are inside the bone. Perhaps the articulation and structure of a lobster leg can be duplicated in the design of a robotic arm . . .
• • •
At a county fair, it’s the robot experimenter who studies the way the egg-beater ride works, watching the various gears spin in perfect unison, perhaps asking themselves if the gear train can be duplicated in an unusual robot locomotion system. At a phone booth, it’s the robot experimenter who listens to the tones emitted when the buttons are pressed. These tones, the experimenter knows, trigger circuitry at the phone company office to call a specific telephone out of all the millions in the world. Perhaps these or similar tones can be used to remotely control a robot. At work on the computer, it’s the robot experimenter who rightly assumes that if a computer can control a printer or plotter through an interface port, the same computer and interface can be used to control a robot.
8 THE ROBOT EXPERIMENTER
• •
In the toy store, while children are looking at the new movie-based toys, the robot experimenter sees a vast array of different bases that can be used as the basis for a brand-new robot. When taking a snapshot at a family gathering, it’s the robot experimenter who studies the inner workings of the automatic focus system of the camera. The camera uses ultrasonic sound waves to measure distance and automatically adjusts its lens to keep things in focus. The same system should be adaptable to a robot, enabling it to judge distances and “see” with sound.
The list could go on and on. All around us, from nature’s designs to the latest electronic gadgets, is an infinite number of ways to make better and increasingly clever robots. Uncovering these solutions requires extrapolation—figuring out how to apply one design and make it work in another application, then experimenting with the contraption until everything works.
1.5 From Here To learn more about . . .
Read
Fundamentals of electronics and basics on how to read a schematic
Chapter 5, “Electronic Components”
Electronics construction techniques
Chapter 7, “Electronic Construction Techniques”
Computer programming fundamentals
Chapter 13, “Programming Fundamentals”
Robot construction using wood, plastic, and metal
Chapters 8 to 10
Making robots from old toys
Chapter 11, “Hacking Toys”
What your robot should do
Chapter 37, “Robot Tasks, Operations, and Behaviors”
CHAPTER
2
ANATOMY OF A ROBOT
W
e humans are fortunate. The human body is, all things considered, a nearly perfect machine: it is (usually) intelligent, it can lift heavy loads, it can move itself around, and it has built-in protective mechanisms to feed itself when hungry or to run away when threatened. Other living creatures on this earth possess similar functions, though not always in the same form. Robots are often modeled after humans, if not in form then at least in function. For decades, scientists and experimenters have tried to duplicate the human body, to create machines with intelligence, strength, mobility, and auto-sensory mechanisms. That goal has not yet been realized, but perhaps some day it will. Nature provides a striking model for robot experimenters to mimic, and it is up to us to take the challenge. Some, but by no means all, of nature’s mechanisms—human or otherwise—can be duplicated to some extent in the robot shop. Robots can be built with eyes to see, ears to hear, a mouth to speak, and appendages and locomotion systems of one kind or another to manipulate the environment and explore surroundings. This is fine theory; what about real life? Exactly what constitutes a real hobby robot? What basic parts must a machine have before it can be given the title robot? Let’s take a close look in this chapter at the anatomy of robots and the kinds of materials hobbyists use to construct them. For the sake of simplicity, not every robot subsystem in existence will be covered, just the components that are most often found in amateur and hobby robots.
9 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
10
ANATOMY OF A ROBOT
2.1 Tethered versus Self-Contained People like to debate what makes a machine a real robot. One side says that a robot is a completely self-contained, autonomous (self-governed) machine that needs only occasional instructions from its master to set it about its various tasks. A self-contained robot has its own power system, brain, wheels (or legs or tracks), and manipulating devices such as claws or hands. This robot does not depend on any other mechanism or system to perform its tasks. It is complete in and of itself. The other side says that a robot is anything that moves under its own power for the purpose of performing near-human tasks (this is, in fact, the definition of the word robot in many dictionaries). The mechanism that does the actual task is the robot itself; the support electronics or components may be separate. The link between the robot and its control components might be a wire, a beam of infrared light, or a radio signal. In an experimental robot from 1969 a man sat inside the mechanism and operated it, almost as if driving a car. The purpose of this four-legged lorry was not to create a selfcontained robot but to further the development of cybernetic anthropomorphous machines. These were otherwise known as cyborgs, a concept further popularized by writer Martin Caidin in his 1973 novel Cyborg (which served as the inspiration for the 1970s television series, The Six Million Dollar Man). The semantics of robot design won’t be argued here (this book is a treasure map after all, not a textbook on theory), but it’s still necessary to establish some of the basic characteristics of robots. What makes a robot a robot and not just another machine? For the purposes of this book, let’s consider a robot as any device that—in one way or another—mimics human or animal functions. How the robot does this is of no concern; the fact that it does it at all is enough. The functions that are of interest to the robot builder run a wide gamut: from listening to sounds and acting on them, to talking and walking or moving across the floor, to picking up objects and sensing special conditions such as heat, flames, or light. Therefore, when we talk about a robot it could very well be a self-contained automaton that takes care of itself, perhaps even programming its own brain and learning from its surroundings and environment. Or it could be a small motorized cart operated by a strict set of predetermined instructions that repeats the same task over and over again until its batteries wear out. Or it could be a radio-controlled arm operated manually from a control panel. Each is no less a robot than the others, though some are more useful and flexible. As you’ll discover in this chapter and those that follow, how complex your robot creations are is completely up to you.
2.2 Mobile versus Stationary Not all robots are meant to scoot around the floor. Some are designed to stay put and manipulate some object placed before them. In fact, outside of the research lab and hobbyist garage, the most common types of robots, those used in manufacturing, are stationary. Such robots assist in making cars, appliances, and even other robots! Other common kinds of stationary robots act as shields between a human operator or
2.3 AUTONOMOUS VERSUS TELEOPERATED
11
supervisor and some dangerous material, such as radioactive isotopes or caustic chemicals. Stationary robots are armlike contraptions equipped with grippers or special tools. For example, a robot designed for welding the parts of a car is equipped with a welding torch on the end of its arm. The arm itself moves into position for the weld, while the car slowly passes in front of the robot on a conveyor belt. Conversely, mobile robots are designed to move from one place to another. Wheels, tracks, or legs allow the robot to traverse a terrain. Mobile robots may also feature an armlike appendage that allows them to manipulate objects. Of the two—stationary or mobile— the mobile robot is probably the more popular project for hobbyists to build. There’s something endearing about a robot that scampers across the floor, either chasing or being chased by the cat. As a serious robot experimenter, you should not overlook the challenge and education you can gain from building both types of robots. Stationary robots typically require greater precision, power, and balance, since they are designed to grasp and lift objects—hopefully not destroying the objects they handle in the process. Likewise, mobile robots present their own difficulties, such as maneuverability, adequate power supply, and avoiding collisions.
2.3 Autonomous versus Teleoperated Among the first robots ever demonstrated for a live audience were the “automatons” of the Middle Ages. These robots were actually machines either performing a preset series of motions or remotely controlled by a person off stage. No matter. People thrilled at the concept of the robot, which many anticipated would be an integral part of their near futures. These days, the classic view of the robot is a fully autonomous machine, like Robby from Forbidden Planet, Robot B-9 from Lost in Space, or R2-D2 from Star Wars. With these robots (or at least the make-believe fictional versions), there’s no human operator, no remote control, no “man behind the curtain.” While many actual robots are indeed fully autonomous, many of the most important robots of the past few decades have been teleoperated. A teleoperated robot is one that is commanded by a human and operated by remote control. The typical tele-robot uses a video camera that serves as the eyes for the human operator. From some distance—perhaps as near as a few feet to as distant as several million miles—the operator views the scene before the robot and commands it accordingly. The teleoperated robot of today is a far cry from the radio-controlled robots of the world’s fairs of the 1930s and 1940s. Many tele-robots, like the world-famous Mars Rovers Sojourner, Spirit, and Opportunity, are actually half remote controlled and half autonomous. The low-level functions of the robot are handled by microprocessors onboard the machines. The human intervenes to give general-purpose commands, such as “go forward 10 feet” or “hide, here comes a Martian!” The robot is able to carry out basic instructions on its own, freeing the human operator from the need to control every small aspect of the machine’s behavior. The notion of tele-robotics is certainly not new—it goes back to at least the 1940s and the short story “Waldo” by noted science fiction author Robert Heinlein. It was a fantastic idea at the time, but today modern science makes it eminently possible. Stereo video cameras give a human operator 3-D depth perception. Sensors on motors and robotic arms
12
ANATOMY OF A ROBOT
provide feedback to the human operator, who can then feel the motion of the machine or the strain caused by some obstacle. Virtual reality helmets, gloves, and motion platforms literally put the operator “in the driver’s seat.” This book doesn’t discuss tele-robotics in any extended way, but if the concept interests you, read more about it and perhaps construct a simple tele-robot using a radio or infrared link and a video camera. See Appendix A, “Further Reading,” for more information.
2.4 The Body of the Robot Like the human body, the body of a robot—at least a self-contained one—holds all its vital parts. The body is the superstructure that prevents its electronic and electromechanical guts from spilling out. Robot bodies go by many names, including frame and chassis, but the idea is the same.
2.4.1 SKELETAL STRUCTURES In nature and in robotics, there are two general types of support frames: endoskeleton and exoskeleton. Which is better? Both: in nature, the living conditions of the animal and its eating and survival tactics determine which skeleton is best. The same is true of robots.
• •
Endoskeleton support frames are found in many critters, including humans, mammals, reptiles, and most fish. The skeletal structure is on the inside; the organs, muscles, body tissues, and skin are on the outside of the bones. The endoskeleton is a characteristic of vertebrates. Exoskeleton support frames have the “bones” on the outside of the organs and muscles. Common creatures with exoskeletons are spiders, all shellfish such as lobsters and crabs, and an endless variety of insects.
2.4.2 FRAME CONSTRUCTION The main structure of the robot is generally a wood, plastic, or metal frame, which is constructed a little like the frame of a house—with a bottom, top, and sides. This gives the automaton a boxy or cylindrical shape, though any shape is possible. It could even emulate the human form, like the robot Cylon Centurions in Battlestar Galactica. Onto the frame of the robot are attached motors, batteries, electronic circuit boards, and other necessary components. In this design, the main support structure of the robot can be considered an exoskeleton because it is outside the “major organs.” Further, this design lacks a central “spine,” a characteristic of endoskeletal systems and one of the first things most of us think about when we try to model robots after humans. In many cases, a shell is sometimes placed over these robots, but the “skin” is for looks only (and sometimes the protection of the internal components), not support. Of course, some robots are designed with endoskeletal structures, but most such creatures are reserved for high-tech research and development projects and science fiction films. For the most part, the main bodies of your
2.4 THE BODY OF THE ROBOT
13
robots will have an exoskeleton support structure because they are cheaper to build, stronger, and less prone to problems.
2.4.3 SIZE AND SHAPE The size and shape of the robot can vary greatly, and size alone does not determine the intelligence of the machine or its capabilities. Home-brew robots are generally the size of a small dog, although some are as compact as an aquarium turtle and a few as large as Arnold Schwarzenegger. The overall shape of the robot is generally dictated by the internal components that make up the machine, but most designs fall into one of the following categories:
• •
•
• • •
Turtle. Turtle robots are simple and compact, designed primarily for tabletop robotics. Turtlebots get their name from the fact that their bodies somewhat resemble the shell of a turtle and also from the Logo programming language, which incorporated turtle graphics, adapted for robotics use in the 1970s. Vehicle. These scooter-type robots are small automatons with wheels. In hobby robotics, they are often built using odds and ends like used compact discs, extra LEGO parts, or the chassis of a radio-controlled car. The small vehicular robot is also used in science and industry: the Mars Rovers, built by NASA, to explore the surface of Mars are examples of this type of robot. Rover. Greatly resembling the famous R2-D2 of Star Wars, rovers tend to be short and stout and are typically built with at least some humanlike capabilities, such as firefighting or intruder detection. Some closely resemble a garbage can—in fact, not a few hobby robots are actually built from metal and plastic trash cans! Despite the euphemistic title, garbage can robots represent an extremely workable design approach. Walker. A walking robot uses legs, not wheels or tracks, to move about. Most walker ’bots have six legs, like an insect, because they provide excellent support and balance. However, robots with as few as one leg (hoppers) and as many as 8 to 10 legs have been successfully built and demonstrated. Appendage. Appendage designs are used specifically with robotic arms, whether the arm is attached to a robot or is a stand-alone mechanism. Android. Android robots are specifically modeled after the human form and are the type most people picture when talk turns to robots. Realistically, android designs are the most restrictive and least workable, inside or outside the robot lab.
This book provides designs and construction details for at least one robot in each of the preceding types except android. That will be left to another book.
2.4.4 FLESH AND BONE In the 1927 movie classic Metropolis, an evil scientist, Dr. Rotwang, transforms a cold and calculating robot into the body of a beautiful woman. This film, generally considered to be the first science fiction cinema epic, also set the psychological stage for later movies, particularly those of the 1950s and 1960s. The shallow and stereotypical character of Dr. Rot-
14
ANATOMY OF A ROBOT
FIGURE 2-1 The evil Dr. Rotwang and the robot, from the classic motion picture Metropolis.
wang, shown in the movie still in Fig. 2-1, proved to be a common theme in countless movies. The shapely robotrix changed form in these other films, but not its evil character. Robots have often been depicted as metal creatures with hearts as cold as their steel bodies. Which brings us to an interesting question: are all “real” robots made of heavy-gauge steel, stuff so thick that bullets, disinto-ray guns, even atomic bombs can’t penetrate? Indeed, while metal of one kind or another is a major component of robot bodies, the list of materials you can use is much larger and diverse. Hobby robots can be easily constructed from aluminum, steel, tin, wood, plastic, paper, foam, or a combination of them all:
• • •
•
Aluminum. Aluminum is the best all-around robot-building material for medium and large machines because it is exceptionally strong for its weight. Aluminum is easy to cut and bend using ordinary shop tools. It is commonly available in long lengths of various shapes, but it is somewhat expensive. Steel. Although sometimes used in the structural frame of a robot because of its strength, steel is difficult to cut and shape without special tools. Stainless steel, although expensive, is sometimes used for precision components, like arms and hands, and also for parts that require more strength than a lightweight metal (such as aluminum) can provide. Tin, iron, and brass. Tin and iron are common hardware metals that are often used to make angle brackets, sheet metal (various thicknesses from 1⁄32 in on up), and (when galvanized) nail plates for house framing. Brass is often found in decorative trim for home construction projects and as raw construction material for hobby models. All three metals are stronger and heavier than aluminum. Cost: fairly cheap. Wood. Wood is an excellent material for robot bodies, although you may not want to use it in all your designs. Wood is easy to work with, can be sanded and sawed to any shape, doesn’t conduct electricity (avoids short circuits), and is available everywhere. Disadvantage: ordinary construction plywood is rather weak for its weight, so you need fairly large pieces to provide stability. Better yet, use the more dense (and expensive) multi-ply hardwoods for model airplane and sailboat construction. Common thicknesses are 1⁄4 to 1⁄2 in—perfect for most robot projects.
2.5 POWER SYSTEMS
•
•
•
15
Plastic. Everything is going plastic these days, including robots. Pound for pound, plastic has more strength than many metals, yet is easier to work with. You can cut it, shape it, drill it, and even glue it. To use plastic effectively you must have some special tools, and extruded pieces may be hard to find unless you live near a well-stocked plastic specialty store. Mail order is an alternative. Rigid expanded plastic sheet. Expanded sheet plastics are often constructed like a sandwich, with thin outer sheets on the top and bottom and a thicker expanded (air-filled) center section. When cut, the expanded center section often has a kind of foamlike appearance, but the plastic itself is stiff. Rigid expanded plastic sheets are remarkably lightweight for their thickness, making them ideal for small robots. These sheets are known by various trade names such as Sintra and are available at industrial plastics supply outlets. Foamboard. Art supply stores stock what’s known as foamboard (or foam core), a special construction material typically used for building models. Foamboard is a sandwich of paper or plastic glued to both sides of a layer of densely compressed foam. The material comes in sizes from 1⁄8 in to over 1⁄2 in, with 1⁄4 to 1⁄3 in being fairly common. The board can be readily cut with a small hobby saw (paper-laminated foamboard can be cut with a sharp knife; plastic-laminated foamboard should be cut with a saw). Foamboard is especially well suited for small robots where light weight is of extreme importance.
2.5 Power Systems We eat food that is processed by the stomach and intestines to make fuel for our muscles, bones, skin, and the rest of our body. While you could probably design a digestive system for a robot and feed it hamburgers, french fries, and other foods, an easier way to generate the power to make your robot go is to use commercially available batteries, connect the batteries to the robot’s motors, circuits, and other parts, and you’re all set.
2.5.1 TYPES OF BATTERIES There are several different types of batteries, and Chapter 17, “Batteries and Robot Power Supplies,” goes into more detail about them. Here are a few quick facts to start you off. Batteries generate DC current and come in two distinct categories: rechargeable and nonrechargeable (for now, let’s forget the nondescriptive terms like storage, primary, and secondary). Nonrechargeable batteries include the standard zinc and alkaline cells you buy at the supermarket, as well as special-purpose lithium and mercury cells for calculators, smoke detectors, watches, and hearing aids. A few of these (namely, lithium) have practical uses in hobby robotics. Rechargeable batteries include nickle-metal hydride (NiMH), nickel-cadmium (Ni-Cad), gelled electrolyte, sealed lead-acid cells, and special alkaline. NiMH batteries are a popular choice because they are relatively easy to find, come in popular household sizes (D, C, etc.), can be recharged many hundreds of times using an inexpensive recharger, and are safer for
16
ANATOMY OF A ROBOT
the environment than the other options. Gelled electrolyte (gel-cell) and lead-acid batteries provide longer-lasting power, but they are heavy and bulky.
2.5.2 ALTERNATIVE POWER SOURCES Batteries are required in most fully self-contained mobile robots because the only automatons connected by power cord to an electrical socket are found in cartoons. That doesn’t mean other power sources, including AC or even solar, can’t be used in some of your robot designs. On the contrary, stationary robot arms don’t have to be capable of moving around the room; they are designed to be placed about the perimeter of the workplace and perform within this predefined area. The motors and control circuits may very well run off AC power, thus freeing you from replacing batteries and worrying about operating times and recharging periods. This doesn’t mean that AC power is necessarily the preferred method. High-voltage AC poses greater shock hazards. Electronic logic circuits ultimately run off DC power, even when the equipment is plugged into an AC outlet, which makes DC power a logical choice. One alternative to batteries in an all-DC robot system is to construct an AC-operated power station that provides your robot with regulated DC. The power station converts the AC to DC and provides a number of different voltage levels for the various components in your robot, including the motors. This saves you from having to buy new batteries or recharge the robot’s batteries all the time. Small robots can be powered by solar energy when they are equipped with suitable solar cells. Solar-powered robots can tap their motive energy directly from the cells, or the cells can charge up a battery over time. Solar-powered ’bots are a favorite of those designers using the BEAM philosophy—a type of robot design that stresses simplicity, including the power supply of the machine.
2.5.3 PRESSURE SYSTEMS Two other forms of robotic power, which will not be discussed in depth in this book, are hydraulic and pneumatic. Hydraulic power uses oil or fluid pressure to move linkages. You’ve seen hydraulic power at work if you’ve ever watched a bulldozer move dirt from place to place. And while you drive you use it every day when you press down on the brake pedal. Similarly, pneumatic power uses air pressure to move linkages. Pneumatic systems are cleaner than hydraulic systems, but all things considered they aren’t as powerful. Both hydraulic and pneumatic systems must be pressurized to work, and this pressurization is most often performed by a pump. The pump is driven by an electric motor, so in a way robots that use hydraulics or pneumatics are fundamentally electrical. The exception to this is when a pressurized tank, like a scuba tank, is used to provide air pressure in a pneumatic robot system. Eventually, the tank becomes depleted and must either be recharged using some pump on the robot or removed and refilled using a compressor. Hydraulic and pneumatic systems are rather difficult to implement effectively, but they provide an extra measure of power in comparison to DC and AC motors. With a few hundred dollars in surplus pneumatic cylinders, hoses, fittings, solenoid valves, and a pressure supply (battery-powered pump, air tank, regulator), you could conceivably build a hobby robot that picks up chairs, bicycles, even people!
2.6 LOCOMOTION SYSTEMS
2.6
17
Locomotion Systems
As previously mentioned, some robots aren’t designed to move around. These include robotic arms, which manipulate objects placed within a work area. But these are exceptions rather than the rule for hobby robots, which are typically designed to get around in this world. They do so in a variety of ways, from using wheels to legs to tank tracks. In each case, the locomotion system is driven by a motor, which turns a shaft, cam, or lever. This motive force affects forward or backward movement.
2.6.1 WHEELS Wheels are the most popular method for providing robots with mobility. There may be no animals on this earth that use wheels to get around, but for us robot builders it’s the simple and foolproof choice. Robot wheels can be just about any size, limited only by the dimensions of the robot and your outlandish imagination. Turtle robots usually have small wheels, less than 2 or 3 in in diameter. Medium-sized rover-type robots use wheels with diameters up to 7 or 8 in. A few unusual designs call for bicycle wheels, which despite their size are lightweight but very sturdy. Robots can have just about any number of wheels, although two is the most common, creating a differentially driven robot (see Fig. 2-2). In this case, the robot is balanced on the two wheels by one or two free-rolling casters, or perhaps even a third swivel wheel. Larger, more powerful four- and six-wheel differentially driven robots have also been built. In these cases all the wheels on a side turn together and provide the robot with better stability and traction than just two wheels. There is a great deal of friction to be overcome, which necessitates powerful drive motors. Other common wheeled robots use a layout similar to a car or a tricycle. These robot chassis do not have the agility or stability of the differentially driven robot, but they can often be easily adapted from commercially available products such as toys.
2.6.2 LEGS A minority of robots—particularly the hobby kind—are designed with legs, and such robots can be conversation pieces all their own. You must overcome many difficulties to design and
Top View
Side View
Robot Midpoint and Center of Mass
Drive Wheel
Casters
Robot Base Drive Wheels
FIGURE 2-2 Design of an ideal differentially driven robot.
Robot Base Surface Robot Is Running on
18
ANATOMY OF A ROBOT
construct a legged robot. First, there is the question of the number of legs and how the legs provide stability when the robot is in motion or when it’s standing still. Then there is the question of how the legs propel the robot forward or backward—and more difficult still the question of how to turn the robot so it can navigate a corner. Legged robots create some tough challenges, but they are not insurmountable. Legged robots are a challenge to design and build, but they provide you with an extra level of mobility that wheeled robots do not. Wheel-based robots may have a difficult time navigating through rough terrain, but legged robots can easily walk right over small ditches and obstacles. A few daring robot experimenters have come out with two-legged robots, but the challenges in assuring balance and control render these designs largely impractical for most robot hobbyists. Four-legged robots (quadrapods) are easier to balance, but good locomotion and steering can be difficult to achieve. Robots with six legs (called hexapods) are able to walk at brisk speeds without falling and are more than capable of turning corners, bounding over uneven terrain, and making the neighborhood dogs and cats run for cover.
2.6.3 TRACKS The basic design of track-driven robots (as shown in Fig. 2-3) is pretty simple and is based on the differentially driven principle used with wheeled robots. Two tracks, one on each side of the robot, act as giant wheels. The tracks turn, like wheels, and the robot lurches forward or backward. For maximum traction, each track is about as long as the robot itself. Track drive is preferable for many reasons, including the fact that it makes it possible to mow through all sorts of obstacles, like rocks, ditches, and potholes. Given the right track
FIGURE 2-3 The TAB SumoBot is a tracked, differentially driven robot.
2.7 ARM AND HANDS
19
material, track drive provides excellent traction, even on slippery surfaces like snow, wet concrete, or a clean kitchen floor. Track-based robots can be challenging to design and build, but with the proper track material along with powerful motors they are an excellent base for robots and offer the advantages of two-wheeled differentially driven robots with greater stability and the ability to traverse uneven terrain.
2.7 Arms and Hands The ability to handle objects is a trait that has enabled humans, as well as a few other creatures in the animal kingdom, to manipulate the environment. Without our arms and hands, we wouldn’t be able to use tools, and without tools we wouldn’t be able to build houses, cars, and—hmmm—robots. It makes sense, then, to provide arms and hands to our robot creations so they can manipulate objects and use tools. A commercial industrial robot arm is shown in Fig. 2-4. Chapters 26 through 28 in Part 5 of this book are devoted entirely to robot arms and hands.
FIGURE 2-4 A robotic arm from General Electric is designed for precision manufacturing. (Photo courtesy General Electric.)
20
ANATOMY OF A ROBOT
You can duplicate human arms in a robot with just a couple of motors, some metal rods, and a few ball bearings. Add a gripper to the end of the robot arm and you’ve created a complete arm–hand module. Of course, not all robot arms are modeled after the human appendage. Some look more like forklifts than arms, and a few use retractable push rods to move a hand or gripper toward or away from the robot. See Chapter 26, “Reaching Out with Robot Arms,” for a more complete discussion of robot arm design. Chapter 27 concentrates on how to build a popular type of robot arm using a variety of construction techniques.
2.7.1 STAND-ALONE OR BUILT-ON MANIPULATORS Some arms are complete robots in themselves. Car manufacturing robots are really arms that can reach in just about every possible direction with incredible speed and accuracy. You can build a stand-alone robotic arm trainer, which can be used to manipulate objects within a defined workspace. Or you can build an arm and attach it to your robot. Some arm-robot designs concentrate on the arm part much more than the robot part. They are, in fact, little more than arms on wheels.
2.7.2 GRIPPERS Robot hands are commonly referred to as grippers or end effectors. We’ll stick with the simpler sounding hands and grippers in this book. Robot grippers come in a variety of styles; few are designed to emulate the human counterpart. A functional robot claw can be built that has just two fingers. The fingers close like a vise and can exert, if desired, a surprising amount of pressure. See Chapter 28, “Experimenting with Gripper Designs,” for more information.
2.8 Sensory Devices Imagine a world without sight, sound, touch, smell, or taste. Without these sense inputs, we’d be nothing more than an inanimate machine, like the family car or the living room television, waiting for something to command us to do something. Our senses are an integral part of our lives—if not life itself. It makes good sense (pardon the pun) to provide at least one type of sense into your robot designs. The more senses a robot has, the more it can interact with its environment and respond to it. The capacity for interaction will make the robot better able to go about its business on its own, which makes possible more sophisticated tasks. Detecting objects around the robot is a sensory system commonly given to robots and helps prevent the robot from running into objects, potentially damaging them or the robots themselves, or just pushing against them and running down their batteries. There are a number of different ways of detecting objects that range from being very simple to very sophisticated. See Chapters 29 and 30 for more details regarding different ways objects are detected.
2.10 SMART VERSUS DUMB ROBOTS
21
External sounds are easy to detect, and unless you’re trying to listen for a specific kind of sound, circuits for sound detection are simple and straightforward. Sounds can be control signals (such as clapping to change the motion of the robot) or could even be a type of object detection (the crunch of the collision can be heard and responded to). Sensitivity to light is also common, and trying to follow a light beam is a classic early robot control application. Sometimes the light sensed is restricted to a slender band of infrared for the purpose of sensing the heat of a fire or navigating through a room using an invisible infrared light beam. Robot eyesight is a completely different matter. The visual scene surrounding the robot must be electronically rendered into a form the circuits on the robot can accept, and the machine must be programmed to understand and act on the shapes it sees. A great deal of experimental work is underway to allow robots to distinguish objects, but true robot vision is limited to well-funded research teams. Chapter 32, “Robot Vision,” provides the basics on how to give crude sight to a robot. Simple pressure sensors can be constructed cheaply and quickly, however, and though they aren’t as accurate as commercially manufactured pressure sensors, they are more than adequate for hobby robotics. The senses of smell and taste aren’t generally implemented in robot systems, though some security robots designed for industrial use are outfitted with a gas sensor that, in effect, smells the presence of dangerous toxic gas.
2.9 Output Devices Output devices are components that relay information from the robot to the outside world. Common output devices in computer-controlled robots include audio outputs, multiple LEDs, the video screen or (liquid crystal display) panel. As with a personal computer, the robot communicates with its master by flashing messages on a screen or panel. Another popular robotic output device is the speech synthesizer. In the 1968 movie 2001: A Space Odyssey, Hal the computer talks to its shipmates in a soothing but electronic voice. The idea of a talking computer was a rather novel concept at the time of the movie, but today voice synthesis is commonplace. Many hobbyists build robots that contain sound and music generators. These generators are commonly used as warning signals, but by far the most frequent application of speech, music, and sound is for entertainment purposes. Somehow, a robot that wakes you up to an electronic rendition of Bach seems a little more human. Projects in robot sound-making circuits are provided in Chapter 31, “Sound Output and Input.”
2.10 Smart versus Dumb Robots There are smart robots and there are dumb robots, but the difference really has nothing to do with intelligence. Even taking into consideration the science of artificial intelligence, all
22
ANATOMY OF A ROBOT
self-contained autonomous robots are fairly unintelligent, no matter how sophisticated the electronic brain that controls it. Intelligence is not a measurement of computing capacity but the ability to reason, to figure out how to do something by examining all the variables and choosing the best course of action, perhaps even coming up with a course that is entirely new. In this book, the difference between dumb and smart is defined as the ability to take two or more pieces of data and decide on a preprogrammed course of action. Usually, a smart robot is one that is controlled by a computer. However, some amazingly sophisticated actions can be built into an automaton that contains no computer; instead it relies on simple electronics to provide the robot with some known behavior (such is the concept of BEAM robotics). A dumb robot is one that blindly goes about its task, never taking the time to analyze its actions and what impact they may have. Using a computer as the brains of a robot will provide you with a great deal of operating flexibility. Unlike a control circuit, which is wired according to a schematic plan and performs a specified task, a computer can be electronically rewired using software instructions—that is, programs. To be effective, the electronics must be connected to all the input and output devices as the feedback and control subsystems, respectively. This includes the drive motors, the motors that control the arm, the speech synthesizer, the pressure sensors, and so forth. This book presents the theory behind computer control and some sample projects in later chapters. By following some basic rules, using standard components and code templates, it is not terribly difficult to provide computer control in your robot. While most robot controllers are based on small, inexpensive microcontrollers, you can permanently integrate some computers, particularly laptops, into your larger robot projects.
2.11 The Concept of Robot Work In Czech, the term robota means “compulsory worker,” a kind of machine slave like that used by Karel Capek in his now classic play R.U.R. (Rossum’s Universal Robots). In many other Baltic languages the term simply means work. It is the work aspect of robotics that is often forgotten, but it defines a robot more than anything else. A robot that is not meant to do something useful is not a robot at all but merely a complicated toy or display piece. That said, designing and building lightweight demonstrator robots provides a perfectly valid way to learn about the robot-building craft. Still, it should not be the end-all of your robot studies. Never lose sight of the fact that a robot is meant to do something—the more, the better! Once you perfect the little tabletop robot you’ve been working on the past several months, think of ways to apply your improved robot skills to building a more substantial robot that actually performs some job. The job does not need to be labor saving. We’d all like to have a robot maid like Rosie the Robot on the Jetsons cartoon series, but, realistically, it’s a pretty sophisticated robot that knows the difference between a clean and dirty pair of socks left on the floor.
2.12 FROM HERE
2.12 From Here To learn more about . . .
Read
Kinds of batteries for robots
Chapter 17, “Batteries and Robot Power Supplies”
Building mobile robots
Part 2, “Robot Platform Construction”
Building a robot with legs
Chapter 24, “Build a Heavy-Duty Six-Legged Walking Robot”
More on robot arms
Chapters 26 to 28
Robotic sensors
Part 6, “Sensors and Navigation”
23
This page intentionally left blank
CHAPTER
3
STRUCTURAL MATERIALS
T
here is a thrill in looking in a hardware store, hobby shop, parts catalog, or even your basement workshop and contemplating the ways in which different things that catch your eye can be used in creating your own robot. New materials, while sometimes costly, can give your robot a professional look, especially when the time is taken to paint and finish the structure. At the other end of the scale, with a bit of imagination, some pieces of pipe could be built into the chassis of a robot, or some old steel shelving could be used as the basis for a gripper with the throttle linkage from an old lawnmower as the gripper’s actuator. Most robots end up being a combination of newly built and reclaimed parts that give them a Frankenstein look that, surprisingly enough, is quite endearing. In this chapter, you will be introduced to many of the different materials that are used in building robots along with some comments on attaching the various pieces together and finishing the final product. When you are starting out, remember to start small and don’t invest heavily in any one type of material or fastener. Each time you begin a new robot or feature, try a different material and see what works best for you. In Table 3-1, different materials that are often used for robots are listed along with their unique characteristics. This chart will be referred to throughout the chapter and is a good one to go back to when you are trying to decide what material would be best for your robot. Availability is how easy it is for you to get the materials. Although some materials obviously are superior, they can be difficult for you to find. The strength rating is relative; depending on the actual material purchased, it can vary considerably. Cutting indicates how easy it is to cut a material precisely and end up with a smooth edge. The measurement of how little
25 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
26
STRUCTURAL MATERIALS
TABLE 3-1
Robot Structural Materials Comparison Chart
MATERIAL
AVAILABILITY
COST
STRENGTH
CUTTING
STABILITY
VIBRATION
Wood
Excellent
Good
Poor– Excellent
Poor– Excellent
Poor– Excellent
Good
Plywood
Excellent
Fair
Excellent
Fair
Good– Excellent
Excellent
Steel
Good
Good
Excellent
Poor–Fair
Excellent
Good
Aluminum
Good
Fair
Good
Fair–Good
Excellent
Fair
G10FR4
Fair
Poor
Excellent
Poor
Excellent
Excellent
Particle Board
Excellent
Good
Fair–Good
Fair–Good
Poor–Fair
Poor
Cardboard
Excellent
Excellent
Poor–Fair
Excellent
Poor
Poor
Foamboard
Good
Good
Fair
Excellent
Poor
Excellent
Plexiglas
Good
Good
Fair
Poor–Fair
Good
Poor
Polystyrene
Good
Fair
Poor–Fair
Good– Excellent
Good
Poor
the material’s dimensions change over time or temperature is stability, and vibration lists how well a material will stand up to the vibration of working on a robot.
3.1 Paper Paper probably does not seem like a very likely material to use in the development of robots, but it, along with related products, are often overlooked as materials that are easy to work with and allow fast results. There are a variety of different paper products to choose from and by spending some time in an artists’ supply store, you will probably discover some products that you never thought existed. There are a number of different papers, cardboards, foam-backed boards, and so on that could be used as part of a robot’s structure. Like anything, it just takes a bit of imagination. You may not have thought of this, but paper and cardboard are excellent materials for building prototypes of your robots or different parts of them. Even if you have the correct tools for cutting and shaping wood and metal, you can still cut sample parts from a piece of cardboard much faster to ensure proper fit and clearances to other parts. Many people start by building a prototype structure out of the material they are going to use in the robot with the idea that they can cut, saw, drill, or sand the piece into shape as necessary. Experimenting on the actual robot material is a lot more work (and potentially more
3.2 WOOD
27
expensive) than first cutting out a piece of cardboard or foam-backed paper and trimming it (using either scissors or a hobby knife) into the correct shape. Once the cardboard has been trimmed to the correct shape, it can be pulled out and measured to find the exact changes, which are then transferred to the drawings used for cutting the real material into shape. Along with scissors and a hobby knife, you might want to also invest in a cutting board (which can be found at the artists’ supply store) designed to be impervious to the sharp edge of the knife and some white glue. An obvious way to ensure that the cardboard or foambacked paper is at the correct dimensions is to glue a printout of the piece that is going to be used in the robot. There is one area that can be a concern if paper products are used for prototyping robot structures and that is the thickness of the material. Only in very rare cases will the cardboard or whatever material you are using for prototyping be the same thickness as the final material. This isn’t a major concern because with a little bit of thinking ahead there will be no problem, but it is something to keep in the back of your mind.
3.2 Wood There are many different wood products to choose from for use in a robot’s structure and each one has its own characteristics that affect its suitability in different areas of the robot’s structure. The biggest advantages of wood are its ability to be worked using inexpensive hand tools and its fairly low cost. Even for more exotic hardwoods, which can be quite difficult to work and are relatively expensive, you will find that they can be shaped with patience along with care, and even if the piece ends up being ruined replacement pieces can be purchased for just a few dollars. When using woods as structural pieces in your robot, you are advised to use the hardest woods that you can find (such as maple, cherry, and oak). Very hard woods will obviously handle the greatest loads and, more importantly, will resist splitting at bolt attachment points. Soft woods like spruce and balsa should be avoided for obvious reasons. When fastening pieces of wood to other pieces, nuts and bolts should be used (and not screws which cut their own threads) to minimize the chance that the wood will be damaged and split or the holes will open up due to vibration. Along with solid pieces of wood, there are a number of composite products that you might want to consider. The most commonly used composite wood product is plywood (Fig. 3-1), which consists of several sheets of wood glued together in such a way that its strength is maximized. Plywood is often manufactured from softer woods (such as spruce) with the final product being much stronger than the sum of its parts. Home construction plywoods should be avoided; instead you should look at aircraft quality plywood (which can be found in small sheets at hobby stores). Aircraft quality plywood is manufactured from better quality woods to more exacting quality levels to ensure that they can withstand large forces and vibration at a fairly light weight—just what is desired in a robot. Other composite wood products include chipboard and particle board in which varying sizes of wood cuttings are glued together to form a sheet of material. These materials tend to be very heavy and do not have very good structural qualities in terms of mechanical
28
STRUCTURAL MATERIALS
Top View
Side View
Top Layer
Top Layer Middle Layer
Middle Layer
Bottom Layer Bottom Layer
Wood Grain Direction Indicator
FIGURE 3-1 Plywood is manufactured from thin sheets of wood called veneer glued together with their grains pointing in alternating directions to maximize the strength of the final piece of wood.
strength and vibration resistance. Some of the better quality particle boards may be suitable for use in large robots, but for the most part they should be avoided.
3.3 Plastics There are probably more different types of plastics than of paper products, woods, and metals combined. Determining the correct type of plastic for a specific application can be a very intensive task and take an unreasonably long period of time. Instead, you more likely will pick up a piece of plastic that you either find as raw material for sale or want to modify an existing product—which for all intents and purposes is the level of consideration required for most hobby robot projects. There are three major types of plastics you can consider: Thermoset plastics are hard and have a tightly meshed molecular structure. They generally cure or harden in a mold using chemicals, and during the process they tend to put out a lot of heat. Thermoset plastics can only be shaped by machining as heating them up will destroy the molecular bonds and render the material useless. Thermosets are used in hard plastic toys, appliances, and other products requiring structural strength. You have most likely encountered elastomer plastics and thought that they were rubber bands. Elastomers have a similar molecular structure to thermosets, but they are much
3.4 METAL STOCK
29
looser, resulting in elastic characteristics. Like thermosets, elastomers cannot be shaped by heating. Thermoplastics tend to be manufactured as sheets of material of varying thicknesses for a variety of different purposes. At one thickness extreme they are used for plastic bags; and at the other, Plexiglas. Thermoplastics have a long, linear molecular structure that allows them to change shape when heated (unlike the other two types of plastics). Along with Plexiglas, which could be used as a structural material for a robot, sheets of polystyrene (the same material used to make plastic toys and models) can be formed into covers and bodies for a robot using heat and a vacuum-forming process.
3.4 Metal Stock Metal stock is available from a variety of sources. Your local home improvement store is the best place to start. However, some stock may only be available at specialized metal distributors or specialized product outlets, like hobby stores. Look around in different stores and in the Yellow Pages and you’re sure to find what you need.
3.4.1 EXTRUDED ALUMINUM Extruded stock is made by pushing molten metal out of a shaped orifice. As the metal exits it cools, retaining the exact shape of the orifice. Extruded aluminum stock is readily available at most hardware and home improvement stores. It generally comes in 12-ft sections, but many hardware stores will let you buy cut pieces if you don’t need all 12 ft. Even if you have to buy the full 12-ft piece, most hardware stores will cut the pieces to length, saving you the trouble of doing it yourself. Extruded aluminum is available in more than two dozen common styles, from thin bars to pipes to square posts. Although you can use any of it as you see fit, the following standard sizes may prove to be particularly beneficial in your robot-building endeavors:
• • • •
1-by-1-by-1⁄16-in angle stock 57 ⁄64-by-9⁄16-by-1⁄16-in channel stock 41 ⁄64-by-1⁄2-by-1⁄16-in channel stock Bar stock, in widths from 1 to 3 in and thicknesses of 1⁄16 to 1⁄4 in
3.4.2 SHELVING STANDARDS You’ve no doubt seen those shelving products where you nail two U-shaped metal rails on the wall and then attach brackets and shelves to them. The rails are referred to as standards, and they are well suited to be girders in robot frames. The standards come in either aluminum or steel and measure 41⁄64 by 1⁄2 by 1⁄16 in. The steel stock is cheaper but considerably heavier, a disadvantage you will want to carefully consider. Limit its use to structural points in your robot that need extra strength. Another disadvantage of using shelving standards instead of extruded aluminum is all the holes and slots you’ll find on the standards. The
30
STRUCTURAL MATERIALS
holes are for mounting the standards to a wall; the slots are for attaching shelving brackets. If you are going to use shelving standards, plan to drill into the sides of the rails rather than the base with the holes and slots because this will make integrating them into robots much easier.
3.4.3 MENDING PLATES Galvanized mending plates are designed to strengthen the joint of two or more pieces of lumber. Most of these plates come preformed in all sorts of weird shapes and so are pretty much unusable for building robots. But flat plates are available in several widths and lengths. You can use the plates as-is or cut them to size. The plates are made of galvanized iron and have numerous predrilled holes to help you hammer in nails. The material is soft enough so you can drill new holes, but if you do so only use sharp drill bits. Mending plates are available in lengths of about 4, 6, and 12 in. Widths are not as standardized, but 2, 4, 6, and 12 in seem common. You can usually find mending plates near the rain gutter and roofing section in the hardware store. Note that mending plates are heavy, so don’t use them for small, lightweight robot designs. Reserve them for medium to large robots where the plate can provide added structural support and strength.
3.4.4 RODS AND SQUARES Most hardware stores carry a limited quantity of short extruded steel or zinc rods and squares. These are solid and somewhat heavy items and are perfect for use in some advanced projects, such as robotic arms. Lengths are typically limited to 12 or 24 in, and thicknesses range from 1⁄16 to about 1⁄2 in.
3.4.5 IRON ANGLE BRACKETS You will need a way to connect all your metal pieces together. The easiest method is to use galvanized iron brackets. These come in a variety of sizes and shapes and have predrilled holes to facilitate construction. The 3⁄8-in-wide brackets fit easily into the two sizes of channel stock mentioned at the beginning of the chapter: 57⁄64 by 9⁄16 by 1⁄16 in and 41⁄64 by 1⁄2 by 1⁄16 in. You need only drill a corresponding hole in the channel stock and attach the pieces together with nuts and bolts. The result is a very sturdy and clean-looking frame. You’ll find the flat corner angle iron, corner angle (L), and flat mending iron to be particularly useful.
3.5 Quick Turn Mechanical Prototypes It is very common to design and contract a quick turn, printed circuit assembly house to create custom PCBs for your robots, but up until just a few years ago it wasn’t possible to get the same service for mechanical parts built from metal or plastic. Today, there are a number of companies that will take your mechanical designs (some will even provide you with design software free of charge) and turn them into prototypes in just a few weeks (like the one in Fig. 3-2). Using a quick turn mechanical prototype shop for preparing plastic and
3.6 FASTENERS
31
FIGURE 3-2 A servo mounting bracket manufactured at a quick turn prototyping shop.
metal parts will save you the time and money needed to buy the comparable equipment and learn how to use it. The quick turn mechanical prototype process is still new and you can expect there to be changes over time as it matures. You may find that when you use the quick turn prototypes the choices for materials, finishes, and manufacturing processes are overwhelming. To learn about your options, you should go to your local library and look for references on mechanical design and structural metals and plastics. When you order your first prototypes, keep the order small to minimize costs and maximize the speed with which you receive the parts.
3.6 Fasteners Once you have decided upon the materials used to build your robot, you will now be left with the task of deciding how to hold them together. What do you think is the number one problem most robots have when they are brought out for a competition? Most people would think of things like dead batteries or codes that can’t work in the actual environment (problems with light background noise or the running surface), but it is very common for robots to fall apart or break because the different parts are not held together very well. Part of the problem is the use of an unsuitable material for the structure (like one that breaks during use), but the overwhelming problem is the use of inappropriate adhesives (glues) and fasteners for the robot’s structural parts.
32
STRUCTURAL MATERIALS
Staple
Nail
Nut and Bolt
Screw Rivet
FIGURE 3-3 Some of the different mechanical fasteners that can be used to hold different pieces of a robot’s structure together.
Fasteners is the generic term used to describe the miscellaneous nuts and bolts, nails, screws, and other devices that have been developed over the years to hold things together. Fig. 3-3 shows the operation of some common fasteners, and the more commonly used items are listed in the following sections.
3.6.1 NUTS AND BOLTS Number 6, 8, and 10 nuts and pan-head stove bolts (6⁄32, 8⁄32, and 10⁄24, respectively) are good for all-around construction. Get a variety of bolts in 1⁄2, 3⁄4, 1, 11⁄4, and 11⁄2 in lengths. You may also want to get some 2 and 3-in-long bolts for special applications. Motor shafts and other heavy-duty applications require 1⁄4-in 20 or 5⁄16-in hardware. Panhead stove bolts are the best choice; you don’t need hex-head carriage bolts unless you have a specific requirement for them. You can use number 6 (6⁄32) nuts and bolts for small, lightweight applications. Or for even smaller work, use the miniature hardware available at hobby stores, where you can get screws in standard 5⁄56, 4⁄40, and 2⁄20 sizes.
3.6.2 WASHERS While you’re at the store, stock up on flat washers, fender washers (large washers with small holes), tooth lock washers, and split lock washers. Get an assortment so you have a variety of nut and bolt sizes. Split lock washers are good for heavy-duty applications because they provide more compression locking power. You usually use them with bolt sizes of 1⁄4 in and above.
3.6.3 ALL-THREAD ROD All-thread comes in varying lengths of stock. It comes in standard thread sizes and pitches. All-thread is good for shafts and linear motion actuators. Get one of each in 8⁄32, 10⁄24, and
3.6 FASTENERS
33
1 ⁄4-in 20 threads to start. If you need small sizes, hobby stores provide all-thread rod (typically used for push-pull rods in model airplanes) in a variety of diameters and threads.
3.6.4 SPECIAL NUTS Coupling nuts are just like regular nuts except that they have been stretched out. They are designed to couple two bolts or pieces of all-thread together, end to end. In robotics, you might use them for everything from linear motion actuators to grippers. Locking nuts have a piece of nylon built into them that provides a locking bite when threaded onto a bolt. It is preferable to use locking nuts over two nuts tightened together.
3.6.5 RIVETS An often overlooked method of fastening structures together is the blind or pop rivet. This fastener consists of a flanged aluminum tube with a steel rod running through it and a ball at the end. When the ball is pulled into the tube, the tube distorts and flares outward, providing two wide ends to hold together pieces of material. When a certain amount of tension has been placed on the steel rod, it “pops” off, leaving a permanent fastener that is quite a bit shorter over the surface of the material than nuts and bolts. Rivets are quite vibration resistant, and despite being labeled as permanent, they can be drilled out in a few seconds.
3.6.6 ADHESIVES Adhesives is a ten-dollar word to describe glues. While many people dismiss glues as not being appropriate for use in robots, by following a few simple rules (namely keep the surfaces to be glued together clean, and rough them up with sandpaper to give more surface area for the glue to hold onto), they can be as effective as any of the other methods presented in this chapter and can be a lot easier to work with. Table 3-2 lists a number of the most commonly used adhesives and some of their characteristics and uses.
3.6.7 MISCELLANEOUS METHODS While the list of fastening methods in the previous sections seems comprehensive, there are still a number of different methods that you can use to hold your structural parts together that are useful in a variety of different applications. The following list describes methods used on different robots that have resulted in structures that are stronger, lighter, and easier to build than using the traditional methods previously described. Some of these suggested fastening methods may seem fanciful, but remember to “never say never”—there are situations where each one of these solutions will be optimal.
• •
Welding is useful for large heavy robots built on a steel frame or chassis. With the proper tools and training, robot structures can be precisely assembled quite quickly. Training is critical as all types of welding can be dangerous. Oxyacetylene torches can also be used for heating up and bending steel parts—but only if you know what you are doing. The next time you open a car’s hood to look in the engine compartment, take a look at
34
STRUCTURAL MATERIALS
TABLE 3-2
Adhesives and the Materials They Are Designed For
ADHESIVE
MATERIALS
COMMENTS
Weldbond
Wood/PCB
Excellent for tying down loose wires and insulating PCBs
Solvents
Plastics
Melts plastics together
Krazy Glue/Locktite
Metal/Plastic
Best for locking nuts
Carpenter’s glue
Wood
Works best on unfinished wood
5-minute epoxy
Everything
Very permanent
Contact cement
Flat, Porous
Good for bonding paper/laminates to wood or each other
Two-sided tape
Smooth surface
Good for holding components onto robot structure. Can leave residue during removal.
Hot glue gun
Everything
Not recommended due to poor vibration tolerance
•
• •
the myriad of fasteners in there. Cable ties and hose clamps are generally specialty items, but chances are you will run across a few applications that are helpful to the robots you are working on. Nothing has been written to say that robot structures have to be permanently fastened together. If you are unsure about the best configuration for the parts of your robot or if different parts are needed for multiple robots, why don’t you mount them with velcro, magnets, or in a way that allows them to be removed and replaced quickly and easily. There are a number of robots that are held together by steel cables and turnbuckles (threaded cable connectors that can be used to adjust the tension on a cable). These robots definitely have a unique look and can be made very light and very rigid. Finally, why do the parts have to be fastened together at all? A robot built from interlocking parts could be particularly fascinating and an interesting response to the need for coming up with robot components that can be taken apart and put back together in different ways. Electrical connections made when the parts are assembled together could provide wiring for the robot and prevent invalid configurations from being created.
3.7 SCAVENGING: MAKING DO WITH WHAT YOU ALREADY HAVE
35
3.7 Scavenging: Making Do with What You Already Have You don’t always need to buy new (or used or surplus) to get worthwhile robot parts. In fact, some of the best parts for hobby robots may already be in your garage or attic. Consider the typical used VCR, for example. It’ll contain at least one motor (and possibly as many as five), numerous gears, and other electronic and mechanical odds and ends. Depending on the brand and when it was made, it could also contain belts and pulleys, appropriate motor drivers, digital electronics chips, infrared receiver modules, miniature push buttons, infrared light-emitting diodes and detectors, and even wire harnesses with multipin connectors. Any and all of these can be salvaged to help build your robot. All told, the typical VCR may have over $50 worth of parts in it. Never throw away small appliances or mechanical devices without taking them apart and looking for usable parts. If you don’t have time to disassemble that CD player that’s skipping on all of your compact discs, throw it into a pile for a rainy day when you do have a free moment. Ask friends and neighbors to save their discards for you. You’d be amazed how many people simply toss old VCRs, clock radios, and other items into the trash when they no longer work. Likewise, make a point of visiting garage sales and thrift stores from time to time, and look for parts bonanzas in used—and perhaps nonfunctioning—goods. Scout the local thrift stores (Goodwill, Disabled American Veterans, Salvation Army, Amvets, etc.) and for very little money you can come away with a trunk full of valuable items that can be salvaged for parts. Goods that are still in functioning order tend to cost more than the broken stuff, but for robot building the broken stuff is just as good. Be sure to ask the store personnel if they have any nonworking items they will sell you at a reasonable cost. Here is just a short list of the electronic and mechanical items you’ll want to be on the lookout for and the primary robot-building components they have inside.
• •
•
•
VCRs are perhaps the best single source for parts, and they are in plentiful supply (hundreds of millions of them have been built since the mid-1970s). As previously discussed, you’ll find motors (and driver circuits), switches, LEDs, cable harnesses, and IR receiver modules on many models. CD players have optical systems you can gut out if your robot uses a specialty vision system. Apart from the laser diode, CD players have focusing lenses, miniature multicell photodiode arrays, diffraction gratings, and beam splitters, as well as micro-miniature motors and a precision lead-screw positioning device (used by the laser system to read the surface of the CD). Old disk drives (floppy and hard drives) also have a number of components that are very useful in robots. Along with the motor that turns the disk, the stepper motor that moves the head is well suited for use in robot arms or even small walking robots. Later in the book, opto-interrupters will be discussed and the typical disk drive has at least two of these that could be used in a robot. Fax machines contain numerous motors, gears, miniature leaf switches, and other mechanical parts. These machines also contain an imaging array (it reads the page to fax it) that you might be able to adapt for use as robotic sensors.
36
STRUCTURAL MATERIALS
•
•
Mice, printers, old scanners, and other discarded computer peripherals contain valuable optical and mechanical parts. Mice contain optical encoders that you can use to count the rotations of your robot’s wheels, printers and scanners contain motors and gears, and scanners contain optics you can use for vision systems and other sensors on your robot. Mechanical toys, especially the motorized variety, can be used either for parts or as a robot base. Remember to keep the motor drivers (as will be discussed later in the book). When looking at motorized vehicles, favor those that use separate motors for each drive wheel (as opposed to a single motor for both wheels), although other drive configurations can make for interesting and unique robots. Don’t limit yourself!
3.8 Finishing Your Robot’s Structure You can change your robot from appearing like something that you cobbled together in your garage over a weekend to a much more professional looking and polished piece of machinery by spending a few minutes over a few days putting on a paint finish. Few people think about finishing a robot’s structure, whether it’s made of wood or metal, but there are a number of tangible benefits that you should be aware of:
• • • • •
Eliminating the dust on the surface of the material, allowing for effective two-sided tape attachment (and removal). Smoothing wood surface and reducing the lifted fibers that appear when the wood gets moist or wet over time. Eliminating wood fibers will also produce more effective glue bonds. Eliminating splinters and minimizing surface splintering when drilling into wood. Allowing for pencil and ink marking of the surface to be easily wiped off for corrections. This is not possible with bare wood and many metals.
You should consider using aerosol paint to finish the structural pieces of your robot. When properly used there is very little mess and no brushes to clean up. From an auto-body supply house, you should buy an aerosol can of primer (gray is always a good choice) and from a hardware store buy an aerosol can of indoor/outdoor (or marine) acrylic paint (such as Krylon brand) in your favorite color. Red catches the eye, isn’t overwhelming, and if there is a blemish in the material or your work, it will become hidden quite nicely. The process outlined here is usable for metal and wood, although wood will tend to have more blemishes and its grain will be more visible than for the metal. Set up a painting area in a garage or some other well-ventilated space by laying down newspaper both on a flat surface as well as a vertical surface. Next, lay down some bottle caps or other supports for the materials you are going to paint. You will want to finish the ends of the material and don’t want to end up with paint flowing between the material and the support (or the newspaper for that matter). Lightly sand the surfaces that you are going to paint using a fine-grain sandpaper (200 grit at least). You may also want to sand the edges of the material more aggressively to take
3.8 FINISHING YOUR ROBOT’S STRUCTURE
37
off any loose wood or metal burrs that could become problems later. Once you have finished this, moisten the rag and wipe it over the surface you have sanded to pick up any loose dust. Shake the can of primer using the instructions printed on the can. Usually there is a small metal ball inside the can and you will be instructed to shake it until the ball rattles easily inside. Apply a light coat of primer; just enough to change the color of the material. Most primers take 30 minutes or so to dry. Check the instructions on the can before going on to the next step of sanding and putting on new coats of paint or primer. After the first application of primer, you will probably find that a wood surface is very rough. This is due to the cut fibers in wood standing on end after being moistened from the primer. Repeat the sanding step (along with sanding the ends of the wood and then wiping down with a damp rag) before applying another coat of primer. After the second coat is put down, let it dry, sand very lightly, and wipe down again. Now you are ready to apply the paint. Shake according to the instructions on the aerosol can and spray the material again, putting on a thin, even coat. You will probably find that the paint will seem to be sucked into the wood and the surface will not be that shiny. This is normal. Once the paint has dried, lightly sand again, wipe down with a wet cloth, and apply a thicker coat of paint. When this coat has dried, you’ll find that the surface is very smooth and shiny. Figure 3-4 shows what can be done with some strips of plywood over a couple of nights. Some of the grain of the wood will still be visible, but it will not be noticeable. You do not have to sand the paint again. The material is now ready to be used in a robot.
FIGURE 3-4 Finished plywood strips for use in a robot base.
38
STRUCTURAL MATERIALS
3.9 From Here To learn more about . . .
Read
How to solder
Chapter 7, “Electronic Construction Techniques”
Building electronic circuits
Chapter 7, “Electronic Construction Techniques”
Building mechanical apparatus
Part II, “Robot Construction”
CHAPTER
4
BUYING PARTS
B
uilding a robot from scratch can be hard or easy. It’s up to you. As a recommendation, when you are starting out, go for the easy route; life is too demanding as it is. The best way to simplify the construction of a robot is to use standard, off-the-shelf parts—things you can get at the neighborhood hardware, auto parts, and electronics store. Exactly where can you find robot parts? The neighborhood robot store would be the logical place to start—if only such a store existed! Not yet, anyway. Fortunately, other local retail stores are available to fill in the gaps. Moreover, there’s a veritable world of places that sell robot junk, probably close to where you live and also on the Internet.
4.1 Hobby and Model Stores Hobby and model stores are the ideal sources for small parts, including lightweight plastic, brass rod, servo motors for radio control (R/C) cars and airplanes, gears, and construction hardware. Most of the products available at hobby stores are designed for building specific kinds of models and toys. But that shouldn’t stop you from raiding the place with an eye to converting the parts for robot use. Most hobby store owners and salespeople have little knowledge about how to use their line of products for anything but their intended purpose. So you’ll likely receive little substantive help in solving your robot construction problem. Your best bet is to browse the store and look for parts that you can put together to build a robot. Some of the parts, par39 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
40
BUYING PARTS
ticularly those for R/C models, will be behind a counter, but they should still be visible enough for you to conceptualize how you might use them. If you don’t have a well-stocked hobby and model store in your area, there’s always the Internet.
4.2 Craft Stores Craft stores sell supplies for home crafts and arts. As a robot builder, you’ll be interested in just a few of the aisles at most craft stores, but what’s in those aisles will be a veritable gold mine! Look for these useful items:
• • • •
•
•
Foam rubber sheets. These come in various colors and thicknesses and can be used for pads, bumpers, nonslip surfaces, tank treads, and lots more. The foam is very dense; use sharp scissors or a knife to cut it. Foamboard. Constructed of foam sandwiched between two heavy sheets of paper, foamboard can be used for small, lightweight robots. Foamboard can be cut with a hobby knife and glued with paper glue or hot-melt glue. Look for it in different colors and thicknesses. Parts from dolls and teddy bears. These can often be used in robots. Fancier dolls use articulations—movable and adjustable joints—that can be used in your robot creations. Look also for linkages, bendable posing wire, and eyes (great for building robots with personality!). Electronic light and sound buttons. These are designed to make Christmas ornaments and custom greeting cards, but they work just as well in robots. The electric light kits come with low-voltage LEDs or incandescent lights, often in several bright colors. Some flash at random, some sequentially. Sound buttons have a built-in song that plays when you depress a switch. Don’t expect high sound quality with these devices. You could use these buttons as touch sensors, for example, or as a tummy switch in an animal-like robot. Plastic crafts construction material. This can be used in lieu of more expensive building kits, such as LEGO or Erector Set. For example, many stores carry the plastic equivalent of that old favorite, the wooden Popsicle sticks (the wooden variety is also available, but these aren’t as strong). The plastic sticks have notches in them so they can be assembled to create frames and structures. Model building supplies. Many craft stores have these, sometimes at lower prices than the average hobby-model store. Look for assortments of wood and metal pieces, adhesives, and construction tools.
There are, of course, many other interesting products of interest at craft stores. Visit one and take a stroll down its aisles.
4.3 Hardware Stores Hardware stores and builder’s supply outlets (usually open to the public) are the best sources for the wide variety of tools and parts you will need for robot experimentation. Items like
4.5 ELECTRONICS WHOLESALERS AND DISTRIBUTORS
41
nuts and bolts are generally available in bulk, so you can save money. As you tour the hardware stores, keep a notebook handy and jot down the lines each outlet carries. Then, when you find yourself needing a specific item, you have only to refer to your notes. Take an idle stroll through your regular hardware store haunts on a regular basis. You’ll always find something new and laughably useful for robot design each time you visit.
4.4 Electronic Stores Twenty or 30 years ago electronic parts stores were plentiful. Even some automotive outlets carried a full range of tubes, specialty transistors, and other electronic gadgets. Now, Radio Shack remains the only U.S. national electronics store chain. Radio Shack continues to support electronics experimenters and in recent years has improved the selection of parts available primarily through the Internet (you can buy the Parallax BASIC Stamp 2 along with some low-end Microchip PIC MCUs), but for the most part they stock only very common and basic components. If your needs extend beyond resistors, capacitors, and a few integrated circuits, you must turn to other sources. Locally, you can check the Yellow Pages under Electronics—Retail for a list of electronic parts shops near you.
4.5 Electronics Wholesalers and Distributors Most electronic stores carry a limited selection, especially if they serve the consumer or hobby market. Most larger cities across the United States—and in other countries throughout the world, for that matter—host one or more electronics wholesalers or distributors. These companies specialize in providing parts for industry. Wholesalers and distributors are two different kinds of businesses, and it’s worthwhile to know how they differ so you can approach them effectively. Wholesalers are accustomed to providing parts in quantity; they offer attractive discounts because they can make up for them with higher volume. Unless you are planning to buy components in the hundreds of thousands, a wholesaler is likely not your best choice. Distributors may also sell in bulk, but many of them are also set up to sell parts in “onesies and twosies.” Cost per item is understandably higher, and not all distributors are willing to sell to the general public. Rather, they prefer to establish relationships with companies and organizations that may purchase thousands of dollars’ worth of parts over the course of a year. Still, some electronics parts distributors, particularly those with catalogs on the Internet (see “Finding Parts on the Internet” later in this chapter) are more than happy to work with individuals, though minimum-order requirements may apply. Check with the companies near you and ask for their terms of service. When buying through a distributor, keep in mind that you are seldom able to browse the warehouse to look for goodies. Most distributors provide a listing of the parts they carry. Some only list the lines they offer. You are required to know the make, model, and part number of what you want to order. Fortunately, virtually all electronics manufacturers provide free information about their products on the Internet. Many such Internet sites offer a search tool that allows you to look up parts
42
BUYING PARTS
by function. Once you find a part you want, jot down its number and use it to order from the local distributor. If you belong to a local robotics club or user’s group, you may find it advantageous to establish a relationship with a local electronics parts distributor through the club. Assuming the club has enough members to justify the quantities of each part you’ll need to buy, the same approach can work with electronics wholesalers. You may find that the buying power of the group gets you better service and lower prices.
4.6 Samples from Electronics Manufacturers Only a few electronics manufacturers are willing to send samples of their products to qualified customers. A qualified customer is typically an engineer in the industry and will have potential business for the manufacturer—all others will be given the contact information for a recommended distributor. Ten years ago, this was not the case, and many chip manufacturers were willing to send samples based on simple requests from individuals. Over the years, the cost of providing this service, along with contracts with wholesalers and distributors that prohibit manufacturers from dealing directly with individuals, has made this service obsolete. If you belong to a school or a robotics club, you may still be able to get some sample parts, development tools, and part documentation from chip manufacturers. To find out what is possible from a specific vendor, contact the local sales or support office (which can be found on the company’s web site) either by phone or email. When you are making your request, it is a good idea to have a list of requirements for the application along with the part number you believe best meets these requirements; the customer support representative may be able to help you find a part that is cheaper, better meets your requirements, or is easier to work with. Finally, it should go without saying that when you make the request, it should be reasonable. It can be incredibly infuriating for manufacturers to get demands for large sample quantities of parts from individuals that just seem to be trying to avoid having to pay for them legitimately. One manufacturer has stated that it got out of the parts sampling business because of the number of requests received for specially programmed parts (the part’s unprogrammed retail cost is $1.00) that would allow illegally copied software to be played on home video game machines.
4.7 Specialty Stores Specialty stores are outlets open to the general public that sell items you won’t find in a regular hardware or electronic parts store. They don’t include surplus outlets, which are discussed in the next section. What specialty stores are of use to robot builders? Consider these:
•
Sewing machine repair shops. Ideal for finding small gears, cams, levers, and other precision parts. Some shops will sell broken machines to you. Tear the machine to shreds and use the parts for your robot.
4.8 SHOPPING THE SURPLUS STORE
• • •
• • •
43
Auto parts stores. The independent stores tend to stock more goodies than the national chains, but both kinds offer surprises on every aisle. Keep an eye out for things like hoses, pumps, and automotive gadgets. Used battery depots. These are usually a business run out of the home of someone who buys old car and motorcycle batteries and refurbishes them. Selling prices are usually between $15 and $25, or 50 to 75 percent less than a new battery. Junkyards. Old cars are good sources for powerful DC motors, which are used to drive windshield wipers, electric windows, and automatic adjustable seats (though take note: such motors tend to be terribly inefficient for battery-based ’bots). Or how about the hydraulic brake system on a junked 1969 Ford Falcon? Bring tools to salvage the parts you want. And maybe bring the Falcon home with you, too. Lawn mower sales–service shops. Lawn mowers use all sorts of nifty control cables, wheel bearings, and assorted odds and ends. Pick up new or used parts for a current project or for your own stock at these shops. Bicycle sales–service shops. Not the department store that sells bikes, but a real professional bicycle shop. Items of interest: control cables, chains, brake calipers, wheels, sprockets, brake linings, and more. Industrial parts outlets. Some places sell gears, bearings, shafts, motors, and other industrial hardware on a one-piece-at-a-time basis. The penalty: fairly high prices and often the requirement that you buy a higher quantity of an item than you really need.
4.8 Shopping the Surplus Store Surplus is a wonderful thing, but most people shy away from it. Why? If it’s surplus, the reasoning goes, it must be worthless junk. That’s simply not true. Surplus is exactly what its name implies: extra stock. Because the stock is extra, it’s generally priced accordingly—to move it out the door. Surplus stores that specialize in new and used mechanical and electronic parts or military surplus (not to be confused with surplus clothing and camping) are a pleasure to find. Most urban areas have at least one such surplus store; some as many as three or four. Get to know each and compare their prices. Bear in mind that surplus stores don’t have massmarket appeal, so finding them is not always easy. Start by looking in the phone company’s Yellow Pages under Electronics and also under Surplus. While surplus is a great way to stock up on DC motors, gears, roller chain, sprockets, and other odds and ends, you must shop wisely. Just because the company calls the stuff surplus doesn’t mean that it’s cheap or even reasonably priced. A popular item in a catalog or advertised on the Internet may sell for top dollar. Always compare the prices of similar items offered by several surplus outlets before buying. Consider all the variables, such as the added cost of insurance, postage and handling, and COD fees if the part is going to be shipped to you. Remember that most surplus stores sell as-is (often contracted into the single word asis) and do not allow returns of any kind. As-is means just that, the parts are sold as they are sitting there; this does not mean they work nor does it mean that they are free from scratches, cracks, leaks, or other problems that may limit their usefulness and appeal. Try-
44
BUYING PARTS
ing to return something to a surplus store is often simply an invitation to be abused. If the item costs more than you are comfortable with losing if it doesn’t work properly, then you shouldn’t buy it.
4.8.1 WHAT YOU CAN GET SURPLUS Shopping surplus can be a tough proposition because it’s hard to know what you’ll need before you need it. And when you need it, there’s only a slight chance that the store will have what you want. Still, certain items are almost always in demand by the robotics experimenter. If the price is right (especially on assortments or sets), stock up on the following.
•
•
•
• •
•
Gears. Small gears between 1⁄2 and 3 in are extremely useful. Stick with standard tooth pitches of 24, 32, and 48. Try to get an assortment of sizes with similar pitches. Avoid grab bag collections of gears because you’ll find no mates. Plastic and nylon gears are fine for most jobs, but you should use larger metal gears for the main drive systems of your robots. Roller chain and sprockets. Robotics applications generally call for 1⁄4-in (#25) roller chain, which is smaller and lighter than bicycle chain. When you see this stuff, snatch it up, but make sure you have the master links if the chain isn’t permanently riveted together. Sprockets come in various sizes, which are expressed as the number of teeth on the outside of the sprocket. Buy a selection. Plastic and nylon roller chain and sprockets are fine for general use; steel is preferred for main drives. Bushings. You can use bushings as a kind of ball bearing or to reduce the hub size of gears and sprockets so they fit smaller shafts. Common motor shaft sizes are 1⁄8 in for small motors and 1⁄4 in for larger motors. Gears and sprockets generally have 3⁄8-in, 1⁄2-in, and 5⁄8-in hubs. Oil-impregnated Oilite bushings are among the best, but they cost more than regular bushings. Spacers. These are made of aluminum, brass, or stainless steel. The best kind to get have an inside diameter that accepts 10⁄32 and 1⁄4-in shafts. Motors. Particularly useful are the 6-V and 12-V DC variety. Most motors turn too fast for robotics applications but you can often luck out and find some geared motors. Final speeds of 20 to 100 r/min at the output of the gear reduction train are ideal. If gear motors aren’t available, be on the lookout for gearboxes that you can attach to your motors. Stepper motors are handy, too, but make sure you know what you are buying. Rechargeable batteries. The sealed lead-acid and gel-cell varieties are common in surplus outlets. Test the battery immediately to make sure it takes a charge and delivers its full capacity (test it under a load, like a heavy-duty motor). These batteries come in 6-V and 12-V capacities, both of which are ideal for robotics. Surplus nickel-cadmium and nickel-metal hydride batteries are available, too, in either single 1.2-V cells or in combination battery packs. Be sure to check these batteries thoroughly.
4.9 Finding Parts on the Internet The Internet has given a tremendous boost to the art and science of robot building. Through the Internet—and more specifically the World Wide Web—you can now search for and find
4.10 FROM HERE
45
the most elusive part for your robot. Most of the major surplus and electronics mail-order companies provide online electronic catalogs. You can visit the retailer at their web site and either browse their offerings by category or use a search feature to quickly locate exactly what you want. Moreover, with the help of web search engines such as Google (www.google.com), you can search for items of interest from among the millions of web sites throughout the world. Search engines provide you with a list of web pages that may match your search query. You can then visit the web pages to see if they offer what you’re looking for. Of course, don’t limit your use of the Internet and the World Wide Web to just finding parts. You can also use them to find a plethora of useful information on robot building. See Appendix B, “Sources,” and Appendix C, “Robot Information on the Internet,” for categorized lists of useful robotics destinations on the Internet. These lists are periodically updated at www.robotoid.com. A number of web sites offer individuals the ability to buy and sell merchandise. Most of these sites are set up as auctions: someone posts an item to sell and then waits for people to make bids on it. Robotics toys, books, kits, and other products are common finds on web auction sites like Ebay (www.ebay.com) and Amazon (www.amazon.com). If your design requires you to pull the guts out of a certain toy that’s no longer made, try finding a used one at a web auction site. The price should be reasonable as long as the toy is not a collector’s item. Keep in mind that the World Wide Web is indeed worldwide. Some of the sites you find may not be located in your country. Though many web businesses ship internationally, not all will. Check the web site’s fine print to determine if the company will ship to your country, and note any specific payment requirements. If they accept checks or money orders, the denomination of each must be in the company’s native currency.
4.10 From Here To learn more about . . .
Read
Tools for robot building
Chapter 6, “Tools”
Description of electronic components
Chapter 5, “Electronic Components”
Details on batteries and battery types
Chapter 17, “Batteries and Robot Power Supplies”
Common motor types used in robotics
Chapter 19, “Choosing the Right Motor”
This page intentionally left blank
CHAPTER
5
ELECTRONIC COMPONENTS
E
lectronics are the central nervous system of your robot and will be responsible for passing information to and from peripheral functions as well as processing inputs and turning them into the output functions the robot performs. Any given hobby robot project might contain a dozen or more electronic components of varying types, including resistors, capacitors, integrated circuits, and light-emitting diodes. In this chapter, you’ll read about the components commonly found in hobby robot projects and their many specific varieties. You’ll also learn their functions and how they are used.
5.1 Cram Course in Electrical Theory Understanding basic electronics is a keystone to being able to design and build your own robots. The knowledge required is not all that difficult—in fact the basic theories with diagrams can fit on two sheets of paper (following) which you are encouraged to photocopy and hang up as a quick reference. Electricity always travels in a circle, or circuit, like the one in Fig. 5-1. If the circuit is broken, or opened, then the electricity flow stops and the circuit stops working. Electricity consists of electrons, which are easily moved from the atoms of metal conductors. There are two components of electricity that can be measured. Voltage is the pressure applied to the electrons to force them to move through the metal wires as well as the
47 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
ELECTRONIC COMPONENTS
Electricity Flow
Electricity Flow
Switch
+
Resistor with Brown, Black, and Red Bands
9 Volt Battery Bar Indicating Polarity
LED
Electricity Flow FIGURE 5-1 Electricity flows in a circle, or circuit, from positive (+) to negative. If the circuit is broken (as when the switch is open), electricity stops flowing and the circuit stops working.
DMM Set to Read Voltage Positive
9.00
1k
48
+
9 Volt Battery
DCV 20
Neg
ativ
e
ti Posi
9
ve
e
Negativ
DMM Set to Read Current DCV 20
DCA 200m
FIGURE 5-2 A digital multimeter can be used to measure the voltage across a component as well as the current through it.
Find: i = ?
V
From Ohm's Law Triangle: Result: i =
V R
i
R
FIGURE 5-3 Using the Ohm’s law triangle, voltage, current, or resistance can be calculated when the other two values are known.
DCA 200m
5.2 WIRE GAUGE
49
R T = R1 + R2 + R3
V R1
VR1=
V x R1 R1 + R2 + R3
R2
VR2=
V x R2 R1 + R2 + R3
R3
VR3=
V x R3 R1 + R2 + R3
FIGURE 5-4 When resistors are wired in series, the total resistance of the circuit is proportional to the sum of the resistances.
+
Vin
Vout =
R1 Vout
Vin x R2 R1 + R2
R2
FIGURE 5-5 Two resistors can be used to change an input voltage to another, lower value.
R1
R2
Rn
R=
1 1 1 + R1 R2
FIGURE 5-6 Placing resistors in parallel will reduce the total resistance of the circuit.
+
1 Rn
50 ELECTRONIC COMPONENTS
different components in the circuit. As the electrons pass through a component they lose some of the pressure, just as water loses pressure due to friction when it moves through a pipe. The initial voltage applied to the electrons is measured with a volt meter or a multimeter set to measure voltage and is equal to the voltage drops through components in the circuit. The label given to voltage is V. The second measurement that can be applied to electricity is current, which is the number of electrons passing by a point in a given time. There are literally several billion, billion, billion, billion, billion, billion electrons flowing past a point at a given time. For convenience, the unit Coulomb (C) was specified, which is 6.25 × 1018 electrons and is the basis for the ampere (A), which is the number of electrons moving past a point every second. The label given to current is the nonintuitive i. The voltage across a component and the current through it can be measured using a digital multimeter as shown in Fig. 5-2. It is important to remember that voltage is the pressure change across a component, so to measure it you have to put a test lead on either side of the component. Current is the volume of electrons moving past a certain point every second, and to measure it, the circuit must be broken and the tester put in line, or in series, with the component being measured. The current flowing through a component can be calculated if the voltage change, or drop, is known along with the resistance of the component using Ohm’s law. This law states that the voltage drop across a resistance is equal to the product of the resistance value and the current flowing through it. Put mathematically, Ohm’s law is: V=i×R Where V is voltage across the component measured in volts, i is the current through the component measured in amperes or amps, and R is the resistance measured in ohms, which has the symbol Ω. Using algebra, when any two of the three values are known, the third can be calculated. If you are not comfortable using algebra to find the missing value, you can use Ohm’s law triangle (Fig. 5-3). This tool is quite simple to use. Just place your finger over the value you want to find, and the remaining two values along with how they are located relative to one another shows you the calculation that you must do to find the missing value. For the example in Fig. 5-3, to find the formula to calculate current, put your finger over i and the resulting two values V over R is the formula for finding i (divide the voltage drop by the resistance of the component). Resistances can be combined, which changes the electrical parameters of the entire circuit. For example, in Fig. 5-4 resistances are shown placed in line or in series and the total resistance is the sum of the resistances. Along with this, the voltage drop across each resistor is proportional to the value of the individual resistors relative to the total resistance of the circuit. The ratio of voltages in a series circuit can be used to produce a fractional value of the total voltage applied to a circuit. Fig. 5-5 shows a voltage divider, which is built from two series resistors and outputs a lower voltage than was input into the circuit. It is important to remember that this circuit cannot source (provide) any current—any current draw will increase the voltage drop through the top resistor and lower the voltage of the output. Finally, resistances can be wired parallel to one another as in Fig. 5-6. In this case, the total resistance drops and the voltage stays constant across each resistor (increasing the total
5.2 WIRE GAUGE
51
amount of current flowing through the circuit). It is important to remember that the equivalent resistance will always be less than the value of the lowest resistance. The general case formula given in Fig. 5-6 probably seems very cumbersome but is quite elegant when applied to two resistors in parallel. The equivalent resistance is calculated using: Requivalent = (R1 × R2) / (R1 + R2) Whew! This is all there is to it with regards to basic electronics. The diagrams have all been placed in the following to allow you to photocopy them, study while you have a free moment, and pin up over your workbench so you always have them handy.
5.2 Wire Gauge The most basic component that you will be working with is the wire. There are essentially two types that you should be aware of: solid core and multi-stranded. Solid core wire is exactly what is implied: there is a single conductor within the insulation. Multi-strand wire consists of many small strands of wire, each carrying a fraction of the total current passed through the wire. Solid core wire is best for high current applications, while multi-stranded wire is best for situations where the wire will change shape because the thin strands bend more easily than one large one. It should not surprise you that the thicker the conductor within the wire, the more current it can carry. Wires must not be overloaded or their internal resistance will cause the wire to overheat, potentially melting the insulation and causing a fire. Table 5-1 lists different American wire gauge (AWG) wire sizes and their specified current-carrying capacity. As a rule of thumb you should halve the amount of current you pass through these different size wires—the current specified in Table 5-1 is the maximum amount of current with a 20 C increase in temperature. By carrying half this amount, there will be minimal heating and power loss within the wires. TABLE 5-1
Single Conductor Wire Current-Carrying Capacity
CONDUCTOR SIZE
MAXIMUM CURRENT-CARRYING CAPACITY
TYPICAL APPLICATION
12 AWG
36 Amps
Large Motor Power/Robot Battery
14 AWG
27 Amps
Large Motor Power
16 AWG
19 Amps
Medium Motor Power
18 AWG
15 Amps
Medium Motor Power
20 AWG
10 Amps
Logic Power, Small Motor Power
22 AWG
8 Amps
Logic Power, Small Motor Power
30 AWG
2 Amps
Wire Wrapping/Small Signals
52 ELECTRONIC COMPONENTS
Along with the size of the conductor and the amount of current it can carry, a plethora of different options are available when choosing wire for a specific application. There are a variety of ways of providing multiple conductors (each one separated from each other to allow multiple signals or voltage to pass through them) in a single wire; there are different insulations for different applications and different methods of molding the wires so they can be attached to different connectors easily. Many books this size and larger detail the options regarding wiring for different applications. As you start out with your robot applications, try to use 20 AWG single conductor, multi-stranded wiring for everything (buy it in several colors, including black and red so you can easily determine what is the wire’s function). As you build larger robots and understand the electrical requirements of the different parts, you can start experimenting with wire sizes and connecting systems.
5.3 Fixed Resistors A fixed resistor supplies a predetermined resistance to a circuit. The standard unit of value of a resistor is the ohm (with units in volts per ampere, according to Ohm’s law), represented by the symbol Ω. The higher the ohm value, the more resistance the component provides to the circuit. The value on most fixed resistors is identified by color coding, as shown in Fig. 5-7. The color coding starts near the edge of the resistor and comprises four, five, and sometimes six bands of different colors. Most off-the-shelf resistors for hobby projects use standard four-band color coding. The values of each band are listed in Table 5-2, and the formula for determining the resistance from the bands is: Resistance = ((Band 1 Color Value × 10) + (Band 2 Color Value)) × 10Band 3 Color Value ohms If you are not sure what the resistance is for a particular resistor, use a digital multimeter to check it. Position the test leads on either end of the resistor. If the meter is not autorang-
FIGURE 5-7 Resistors use color coding to denote their value. Start from the color band nearest the end. Most resistors have four bands: three for the value and one for the tolerance.
5.4 VARIABLE RESISTORS
TABLE 5-2
53
Resistor Band Values
COLOR
BAND COLOR VALUE
TOLERANCE
Black
0
N/A
Brown
1
1%
Red
2
2%
Orange
3
N/A
Yellow
4
N/A
Green
5
0.5%
Blue
6
0.25%
Violet
7
0.1%
Gray
8
0.05%
White
9
N/A
Gold
N/A
5%
Silver
N/A
10%
ing, start at a high range and work down. Be sure you don’t touch the test leads or the leads of the resistor; if you do, you’ll add the natural resistance of your own body to the reading. Resistors are also rated by their wattage. The wattage of a resistor indicates the amount of power it can safely dissipate. Resistors used in high-load applications, like motor control, require higher wattages than those used in low-current applications. The majority of resistors you’ll use for hobby electronics will be rated at 1⁄4 or even 1⁄8 of a watt. The wattage of a resistor is not marked on the body of the component; instead, you must infer it from the size of the resistor.
5.4 Variable Resistors Variable resistors let you dial in a specific resistance. The actual range of resistance is determined by the upward value of the potentiometer. Potentiometers are thus marked with this upward value, such as 10K, 50K, 100K, 1M, and so forth. For example, a 50K potentiometer will let you dial in any resistance from 0 to 50,000 ohms. Note that the range is approximate only. Potentiometers are of either the dial or slide type, as shown in Fig. 5-8. The dial type is the most familiar and is used in such applications as television volume controls and electric blanket thermostat controls. The rotation of the dial is nearly 360°, depending on which potentiometer you use. In one extreme, the resistance through the potentiometer (or pot) is zero; in the other extreme, the resistance is the maximum value of the component.
54 ELECTRONIC COMPONENTS
Rotary (dial) Slide
Solder Terminals
Solder Terminals
FIGURE 5-8 Potentiometers are variable resistors. You’ll find them in rotary or slide versions; rotary potentiometers are the easiest to use in hobby circuits.
Some projects require precision potentiometers. These are referred to as multiturn pots or trimmers. Instead of turning the dial one complete rotation to change the resistance from, say, 0 to 10,000 ohms, a multiturn pot requires you to rotate the knob 3, 5, 10, even 15 times to span the same range. Most are designed to be mounted directly on the printed circuit board. If you have to adjust them, you will need a screwdriver or plastic tool.
5.5 Capacitors After resistors, capacitors are the second most common component found in the average electronic project. Capacitors serve many purposes. They can be used to remove traces of transient (changing) current ripple in a power supply, to delay the action of some portion of the circuit, or to perform an integration or differentiation of a repeating signal. All these applications depend on the ability of the capacitor to hold an electrical charge for a predetermined time. Capacitors come in many more sizes, shapes, and varieties than resistors, though only a small handful are truly common. However, most capacitors are made of the same basic stuff: a pair of conductive elements separated by an insulating dielectric (see Fig. 5-9). This dielectric can be composed of many materials, including air (in the case of a variable capacitor, as detailed in the next section), paper, epoxy, plastic, and even oil. Most capacitors
Electrical Charge between Plates Capacitor Plates
Schematic Symbol for a Capacitor
FIGURE 5-9 Capacitors store an electrical charge for a limited time. Along with the resistor, they are critical to the proper functioning of many electronic circuits.
5.5 CAPACITORS
+
Positive Lead (Anode)
Electrolytic (Polarized) Capacitor Value/Rating
Capacitor Value Stamp (See Text)
Tantalum (Polarized) Capacitor Value/Rating
Unpolarized (Ceramic Disk or Polyester)
55
Negative Lead (Cathode)
FIGURE 5-10 Different capacitor appearance and markings. Note that in some packages, the positive lead (anode) is indicated while in others it is the negative lead (cathode).
actually have many layers of conducting elements and dielectric. When you select a capacitor for a particular job, you must generally also indicate the type, such as ceramic, mica, or Mylar. Capacitors are rated by their capacitance, in farads, and by the breakdown voltage of their dielectric. The farad is a rather large unit of measurement, so the bulk of capacitors available today are rated in microfarads, or a millionth of a farad. An even smaller rating is the picofarad, or a millionth of a millionth of a farad. The micro in the term microfarad is most often represented by the Greek mu (µ) character, as in 10 µF. The picofarad is simply shortened to pF. The voltage rating is the highest voltage the capacitor can withstand before the dielectric layers in the component are damaged. For the most part, capacitors are classified by the dielectric material they use. The most common dielectric materials are aluminum electrolytic, tantalum electrolytic, ceramic, mica, polypropylene, polyester (or Mylar), paper, and polystyrene. The dielectric material used in a capacitor partly determines which applications it should be used for. The larger electrolytic capacitors, which use an aluminum electrolyte, are suited for such chores as power supply filtering, where large values are needed. The values for many capacitors are printed directly on the component. This is especially true with the larger aluminum electrolytic, where the large size of the capacitor provides ample room for printing the capacitance and voltage. Smaller capacitors, such as 0.1 or 0.01 µF mica disc capacitors, use a common three-digit marking system to denote capacitance and tolerance. The numbering system is easy to use, if you remember it’s based on picofarads, not microfarads. A number such as 104 means 10, followed by four zeros, as in 100,000
56 ELECTRONIC COMPONENTS
or 100,000 picofarads. Values over 1000 picofarads are most often stated in microfarads. To make the conversion, move the decimal point to the left six spaces: 0.1 µF. Note that values under 1000 picofarads do not use this numbering system. Instead, the actual value, in picofarads, is listed, such as 10 (for 10 pF). One mark you will find almost exclusively on larger tantalum and aluminum electrolytic is a polarity symbol, most often a minus (−) sign. The polarity symbol indicates the positive and/or negative lead of a capacitor. If a capacitor is polarized, it is extremely important that you follow the proper orientation when you install the capacitor in the circuit. If you reverse the leads to the capacitor—connecting the positive lead (called the anode) to the ground rail instead of the negative lead (called the cathode), for example—the capacitor may be ruined. Other components in the circuit could also be damaged. Fig. 5-10 shows some different capacitor packages along with their polarity markings.
5.6 Diodes The diode is the simplest form of semiconductor. It is available in two basic flavors, germanium and silicon, which indicates the material used to manufacture the active junction within the diode. Diodes are used in a variety of applications, and there are numerous subtypes. Here is a list of the most common.
• • • • •
Rectifier. The average diode, it rectifies AC current to provide DC only. Zener. It limits voltage to a predetermined level. Zeners are used for low-cost voltage regulation. Light-emitting. These diodes emit infrared of visible light when current is applied. Silicon-controlled rectifier (SCR). This is a type of high-power switch used to control AC or DC currents. Bridge rectifier. This is a collection of four diodes strung together in sequence; it is used to rectify an incoming AC current.
Diodes carry two important ratings: peak inverse voltage (PIV) and current. The PIV rating roughly indicates the maximum working voltage for the diode. Similarly, the current rating is the maximum amount of current the diode can withstand. Assuming a diode is rated for 3 amps, it cannot safely conduct more than 3 amps without overheating and failing. All diodes have positive and negative terminals (polarity). The positive terminal is the anode, and the negative terminal is the cathode. You can readily identify the cathode end of a diode by looking for a colored stripe near one of the leads. Fig. 5-11 shows a diode that has a stripe at the cathode end. Note how the stripe corresponds with the heavy line in the schematic symbol for the diode. All diodes emit light when current passes through them. This light is generally only in the infrared region of the electromagnetic spectrum. The light-emitting diode (LED) is a special type of semiconductor that is expressly designed to emit light in human visible wavelengths. LEDs are available to produce any of the basic colors (red, yellow, green, blue, or white) of light as well as infrared. The infrared LEDs are especially useful in robots for a variety of different applications.
5.7 TRANSISTORS
57
Diode
Cathode Band Schematic Symbol for a Diode
FIGURE 5-11 The polarity of diodes is marked with a stripe. The stripe denotes the cathode (negative) lead.
LEDs carry the same specifications as any other diode. The LED has a PIV rating of about 100 to 150 V, with a maximum current rating of under 40 mA (usually only 5 to 10 mA is applied to the LED). Most LEDs are used in low-power DC circuits and are powered with 12 V or less. Even though this voltage is far below the PIV rating of the LED, the component can still be ruthlessly damaged if you expose it to currents exceeding 40 or 50 mA. A resistor is used to limit the current to the LED.
5.7 Transistors Transistors were designed as an alternative to the old vacuum tube, and they are used in similar applications, either to amplify a signal by providing a current control or to switch a signal on and off. There are several thousand different transistors available. Besides amplifying or switching a current, transistors are divided into two broad categories:
• •
Signal. These transistors are used with relatively low-current circuits, like radios, telephones, and most other hobby electronics projects. Power. These transistors are used with high-current circuits, like motor drivers and power supplies.
You can usually tell the difference between the two merely by size. The signal transistor is rarely larger than a pea and uses slender wire leads. The power transistor uses a large metal case to help dissipate heat, and heavy spokelike leads. Transistors are identified by a unique code, such as 2N2222 or MPS6519. Refer to a data book to ascertain the characteristics and ratings of the particular transistor you are interested in. Transistors are rated by a number of criteria, which are far too extensive for the scope of this book. These ratings include collector-to-base voltage, collector-toe-mitter voltage, maximum collector current, maximum device dissipation, and maximum operating frequency. None of these ratings are printed directly on the transistor. Signal transistors are available in either plastic or metal cases. The plastic kind is suitable for most uses, but some precision applications require the metal variety. Transistors that use metal cases (or cans) are less susceptible to stray radio frequency interference and they also dissipate heat more readily.
58 ELECTRONIC COMPONENTS
You will probably be using NPN (Fig. 5-12) and PNP (Fig. 5-13) bipolar transistors. These transistors are turned on and off by a control current passing through the base. The current that can pass through the collector is the product of the base current and the constant hFE, which is unique to each transistor. Bipolar transistors can control the operation and direction of DC motors using fairly simple circuits. Fig. 5-14 shows a simple circuit that will turn a motor on and off using a single NPN bipolar transistor and a diode. When the current passing through coils of a magnetic device changes, the voltage across the device also changes, often in the form of a large spike called kickback. These spikes can be a hundred volts or so and can very easily damage the electronic devices they are connected to. By placing a diode across the motor as shown in Fig. 5-15, the spikes produced when the motor is shut off will be shunted through the diode and will not pass along high voltages to the rest of the electronics in the circuit. The circuit shown in Fig. 5-15 is known as an H-bridge because without the shunt diodes the circuit looks like the letter H. This circuit allows current to pass in either direction through a motor, allowing it to turn in either direction. The motor turns when one of the two connections is made to +V. Both connections can never be connected to +V as this will turn on all the transistors, providing a very low resistance path for current from +V, potentially burning out the driver transistors. Along with bipolar transistors, which are controlled by current, there are a number of other transistors, some of which are controlled by voltage. For example, the MOSFET (for metal-oxide semiconductor field-effect transistor) is often used in circuits that demand high
Collector ic = ib x hFE
ib
Lettering Part Number
TO-92 Package
E B C
Base
ie = ib + i c Emitter Schematic Symbol FIGURE 5-12 The NPN bipolar transistor collector current is controlled by current injected into the base.
5.7 TRANSISTORS
59
Emitter ie = ib + i c ib
Lettering Part Number
TO-92 Package
E B C
Base
ic = ib x hFE Collector Schematic Symbol FIGURE 5-13 The PNP bipolar transistor collector current is controlled by current drawn from the base.
+V
Motor
1N4148 470 NPN
To Turn On the Motor, Connect the NPN Bipolar Transistor’s Base to +V FIGURE 5-14 The complete transistor circuit needed to turn on and off a DC electric motor.
60
ELECTRONIC COMPONENTS
+V
+V
PNP
PNP Motor
NPN
NPN
NPN
Forwards Control Connect to +V to Turn Motor Forwards
Backwards Control Connect to +V to Turn Motor Backwards
NPN
FIGURE 5-15 The six transistor H-bridge motor driver allows a DC motor to be turned on and off and run in either direction. Do not connect both controls to +V.
current and high tolerance. MOSFET transistors don’t use the standard base-emitter collector connections. Instead, they call them gate, drain, and source. The operational differences among the different transistors will become clearer as you become more experienced in creating electronic circuits.
5.8 Grounding Circuitry When wiring electronic circuits, it is useful to have a large common negative voltage connection or ground built into the robot. This connection is normally thought of as being at earth ground and is the basic reference for all the components in the circuit. Having a common ground also simplifies the task of drawing schematics; instead of wiring all the negative connections to the negative power supply, all the negative connections are wired to the three bar symbol shown in Fig. 5-16. Positive voltages are normally indicated with an arrow pointing upward and the label of the positive voltage to be used. These conventions will be used throughout this book.
FIGURE 5-16 This symbol is used for the common negative voltage connection in an electronic circuit.
5.10 SCHEMATICS AND ELECTRONIC SYMBOLS
61
Part Number
Index Mark
74LS04 0582 Date Code
FIGURE 5-17 Integrated circuits (ICs) are common in most any electronic system, including robotics.
5.9 Integrated Circuits The integrated circuit forms the backbone of the electronics revolution. The typical integrated circuit comprises many transistors, diodes, resistors, and even capacitors. As its name implies, the integrated circuit, or IC, is a discrete and wholly functioning circuit in its own right. ICs are the building blocks of larger circuits. By merely stringing them together you can form just about any project you envision. Integrated circuits are most often enclosed in dual in-line packages (DIPs), like the one shown in Fig. 5-17. This type of component has a number of pins that can be inserted into holes of a printed circuit board and is also known as a pin through hole (PTH) component. There are numerous types of packages and methods of attaching chips to PCBs but beginners should be working with just PTH DIPs. As with transistors, ICs are identified by a unique code, such as 7400 or 4017. This code indicates the type of device. You can use this code to look up the specifications and parameters of the IC in a reference book. Many ICs also contain other written information, including manufacturer catalog number and date code. Do not confuse the date code or catalog number with the code used to identify the device.
5.10 Schematics and Electronic Symbols Electronics use a specialized road map to indicate what components are in a device and how they are connected together. This pictorial road map is the schematic, a kind of blueprint of everything you need to know to build an electronic circuit. Schematics are composed of special symbols that are connected with intersecting lines. The symbols represent individual components, and the lines represent the wires that connect these components together. The language of schematics, while far from universal, is intended to enable most anyone to duplicate the construction of a circuit with little more information than a picture. The experienced electronics experimenter knows how to read a schematic. This entails recognizing and understanding the symbols used to represent electronic components and how these components are connected. All in all, learning to read a schematic is not difficult. Fig. 5-18 shows many of the most common symbols.
62
ELECTRONIC COMPONENTS
FIGURE 5-18 These symbols are used on schematics to represent different electronic devices.
5.11 From Here To learn about . . .
Read
Finding electronic components
Chapter 4, “Buying Parts”
Working with electronic components
Chapter 6, “Electronic Construction Techniques”
Using electronic components with robot control computers
Chapter 12, “An Overview of Robot ‘Brains’ ”
CHAPTER
6
TOOLS
T
ake a look at the tools in your garage or workshop. You probably already have all the implements required to build your own robot. Unless your robot designs require a great deal of precision (and most hobby robots don’t), a common assortment of hand tools is all that’s really needed to construct robot bodies, arms, drive systems, and more. Most of the hardware, parts, and supplies you need are also things you probably already have, left over from old projects around the house. You can readily purchase the pieces you don’t have at a hardware store, a few specialty stores around town, or through the mail. This chapter discusses the basic tools for hobby robot building and how you might use them. You should consider this chapter only as a guide; suggestions for tools are just that— suggestions. By no means should you feel that you must own each tool or have on hand all the parts and supplies mentioned in this chapter. You may have tools that you like to use that aren’t listed in this chapter. Once again, the concept behind this book is to provide you with the know-how to build robots from discrete modules. In keeping with that open-ended design, you are free to exchange parts in the modules as you see fit. Some supplies and parts may not be readily available to you, so it’s up to you to consider alternatives and how to work them into your design. Ultimately, it will be your task to take a trip to the hardware store, collect the items you need, and hammer out a unique creation that’s all your own.
63 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
64
TOOLS
6.1 Safety When building a robot, there should be one overriding concern and that is the safety of you and the other people building the robot. A momentary distraction or a few seconds of carelessness can lead to you or somebody else being seriously hurt. There are a few simple rules to follow when building robots to make sure that everyone is safe and, even if accidents happen, to minimize the chances for injuries. 1. Always wear safety glasses. There are a variety of different safety glasses available.
2.
3.
4.
5.
6. 7.
8.
Make sure you get ones that have shatterproof glass and side protection. If you wear glasses, use safety glasses that fit over your regular glasses or have a pair made with impact-resistant lenses and side shields. Never disable or take off tool safety devices. This apparatus may seem to make the work more difficult and harder to observe, but they are there for a purpose. If doing the work seems to be particularly onerous due to the safety devices, then chances are you are not using the tool correctly. Always work in a well-ventilated area. Some tools or building processes output gases that are not normally toxic, but in a closed environment can be dangerous. If you are working in a garage, it is a good idea to install a bathroom exhaust fan. Never work without somebody nearby. There will be times when you work on your own, but make sure there is somebody you can call out to if there is a problem—never work alone in a house. If something goes wrong, take a few minutes to figure out what was its root cause and how to either fix it or prevent it from happening again later. Try to avoid getting frustrated or angry at the work and instead go back and fix the reasons for the problem. Practical jokes have no place in a workshop. Things that seem funny at the spur of the moment can unleash a catastrophic chain of events. Keep a fire extinguisher in the work area. Cutting tools can throw off sparks or raise the temperature of materials to the flashpoint of wood and paper. Soldering irons, by definition, are very hot. Short-circuited batteries can become extremely hot and their casings catch fire. Make sure there is a telephone close by. Ideally “911” should be programmed into it.
The most important rule is to never use a tool unless you are trained in its operation and understand all the safety issues. The same goes for chemicals; even apparently benign compounds can become dangerous with the right set of circumstances. Make sure you read and are familiar with all manuals, material safety sheets, and any plan notes before starting work. Following these simple rules and properly preparing to do the work will greatly minimize the chances of somebody getting hurt.
6.2 Setting Up Shop You’ll need a worktable to construct the mechanisms and electronic circuits of your robots. The garage is an ideal location because it affords you the freedom to cut and drill wood,
6.3 BASIC TOOLS
65
metal, and plastic without worrying about getting pieces in the carpet or tracking filings and sanding dust throughout the house. The garage is also good because it will minimize any trapped paint or chemical smells, and on those occasions when you burn out an electrical or electronic device, the house won’t take on the smell of a store having a fire sale. Your new hobby will be better tolerated and even encouraged if it does not result in extra work or inconvenience for anyone you live with. In whatever space you choose to set up your robot lab, make sure all your tools are within easy reach. You can keep special tools and supplies in an inexpensive fishing tackle box. It provides lots of small compartments for screws and other parts. For best results, your work space should be an area where the robot-in-progress will not be disturbed if you have to leave it for several hours or several days, as will usually be the case. It should go without saying that the worktable and any power tools should also be off limits or inaccessible to young children. Good lighting is a must. Both mechanical and electronic assembly requires detail work, and you will need good lighting to see everything properly. Supplement overhead lights with a 60-W desk lamp. You’ll be crouched over the worktable for hours at a time, so a comfortable chair or stool is a must. Be sure you adjust the seat for the height of the worktable. It’s not a bad idea to set up your workshop with a networked PC and a phone to be electronically connected to the outside world as well as the systems within your house. Being able to talk to other people (either by phone or the Internet) will be useful, especially if you are having a problem and have the material and tools right in front of you. A PC networked to other PCs in the house could be used for displaying design drawings produced on another computer or allowing you to perform a quick web search for information. Remember to protect the PC and phone from dust and filings that could become airborne when material is being cut.
6.3 Basic Tools Construction tools are what you use to fashion the frame and other mechanical parts (or structure) of the robot. We will look at the tools needed to assemble the electronics later in this chapter. The basic tools for creating a robot include:
• • •
•
Claw hammer. These can be used for just about any purpose. Rubber mallet. For gently bashing together pieces that resist being joined, nothing beats a rubber mallet; it is also useful for forming sheet metal. Measurement tools. You should have a variety of metal scales, wood and plastic rulers all of varying lengths, as well as a cheap analog dial or digital calipers. You may also want to keep a drill diameter gauge handy along with tools for measuring screw diameters and pitches. Finally, kitchen and fishing scales are useful tools for keeping track of how much the robot is going to weigh. Screwdriver assortment. Have several sizes of flat-head and Phillips-head screwdrivers. It’s also handy to have a few long-blade screwdrivers, as well as a ratchet driver. Get a screwdriver magnetizer/demagnetizer; it lets you magnetize the blade so it attracts and holds screws for easier assembly.
66
TOOLS
• • • • • • •
• • •
Hacksaw. To cut anything, the hacksaw is the staple of the robot builder. Buy an assortment of blades. Coarse-tooth blades are good for wood and PVC pipe plastic; fine-tooth blades are good for copper, aluminum, and light-gauge steel. Miter box. To cut straight lines, buy a good miter box and attach it to your worktable (avoid wood miter boxes; they don’t last). You’ll also use the box to cut stock at nearperfect 45° angles, which is helpful when building robot frames. Wrenches, all types. Adjustable wrenches are helpful additions to the shop but careless use can strip nuts. The same goes for long-nosed pliers, which are useful for getting at hard-to-reach places. One or two pairs of Vise-Grips will help you hold pieces for cutting and sanding. A set of nut drivers will make it easy to attach nuts to bolts. Measuring tape. A 6- or 8-ft steel measuring tape is a good length to choose. Also get a cloth measuring tape at a fabric store so you can measure things like chain and cable lengths. Square. You’ll need one to make sure that pieces you cut and assemble from wood, plastic, and metal are square. File assortment. Files will enable you to smooth the rough edges of cut wood, metal, and plastic (particularly important when you are working with metal because the sharp, unfinished edges can cut you). Motor drill. Get one that has a variable speed control (reversing is nice but not absolutely necessary). If the drill you have isn’t variable speed, buy a variable speed control for it. You need to slow the drill when working with metal and plastic. A fast drill motor is good for wood only. The size of the chuck is not important since most of the drill bits you’ll be using will fit a standard 1⁄4-in chuck. Drill bit assortment. Use good sharp ones only. If yours are dull, have them sharpened (or do it yourself with a drill bit sharpening device), or buy a new set. Vise. A vise is essential for holding parts while you drill, nail, and otherwise torment them. An extra large vise isn’t required, but you should get one that’s big enough to handle the size of the pieces you’ll be working with. A rule of thumb: a vice that can’t close around a 2-in block of metal or wood is too small. Safety goggles. Wear them when hammering, cutting, and drilling as well as any other time when flying debris could get in your eyes. Be sure you use the goggles. A shred of aluminum sprayed from a drill bit while drilling a hole can rip through your eye, permanently blinding you. No robot project is worth that.
If you plan to build your robots from wood, you may want to consider adding rasps, wood files, coping saws, and other woodworking tools to your toolbox. Working with plastic requires a few extra tools as well, including a burnishing wheel to smooth the edges of the cut plastic (the flame from a cigarette lighter also works but is harder to control), a stripheater for bending, and special plastic drill bits. These bits have a modified tip that isn’t as likely to rip through the plastic material. Small plastic parts can be cut and scored using a sharp razor knife or razor saw, both of which are available at hobby stores.
6.3.1 OPTIONAL TOOLS There are a number of other tools you can use to make your time in the robot shop more productive and less time consuming. Note that many of these tools are powerful and cause
6.3 BASIC TOOLS
67
a lot of injury or damage if you are not careful or are inexperienced in their use. If you are unfamiliar with any of the tools, do not buy or use them until you have received training in them!
•
• • • •
•
• •
• •
A drill press helps you drill better holes because you have more control over the angle and depth of each hole. Be sure to use a drill press vise to hold the pieces. Never use your hands! Along with the drill press, if you are working with metal, it is a good idea to get a spring-loaded center punch, which places an indentation in the material when you press down on it. This indentation will help guide the drill bit to the correct location and is a lot easier to see than a scratch. A table saw or circular saw makes it easier to cut through large pieces of wood and plastic. To ensure a straight cut, use a guide fence or fashion one out of wood and clamps. Be sure to use a fine-tooth saw blade if you are cutting through plastic. Using a saw designed for general woodcutting will cause the plastic to shatter. A miter saw is a useful tool for precisely cutting wood and plastic parts (making sure that the correct blade for the material is being used). Many of the more recent miter saws have laser guides that will help you precisely line up the cut to marks that you have made in the material. An abrasive cutter is a useful tool to have around if you have to cut steel and thick aluminum channel. The cutter looks like a miter saw, but has a silicon carbide cutting disk that chews through the material being cut. The abrasive cutter is reasonably precise, very fast, but will leave a burr that will have to be trimmed off with a file. A motorized hobby tool, such as the model shown in Fig. 6-1, is much like a handheld router. The bit spins very fast (25,000 r/min and up), and you can attach a variety of wood, plastic, and metal working bits to it. The better hobby tools, such as those made by Dremel and Weller, have adjustable speed controls. Use the right bit for the job. For example, don’t use a wood rasp bit with metal or plastic because the flutes of the rasp will too easily fill with metal and plastic debris. A RotoZip tool (that’s its trade name) is a larger, more powerful version of a hobby tool. It spins at 30,000 r/min and uses a special cutting bit—it looks like a drill bit, but works like a saw. The RotoZip is commonly used by drywall installers, but it can be used to cut through most any material you’d use for a robot (exception: heavy-gauge steel). A Pop Rivet Gun will allow you to quickly fasten two pieces of metal (or metal and plastic) together permanently in just a few seconds. An inexpensive tool (less than $10) can be used. Hot-melt glue guns are available at most hardware and hobby stores and come in a variety of sizes. The gun heats up glue from a stick; press the trigger and the glue oozes out the tip. The benefit of hot-melt glue is that it sets very fast—usually under a minute. You can buy glue sticks for normal- or low-temperature guns. Exercise caution when using a hot-melt glue gun: the glue is hot, after all! A nibbling tool is a fairly inexpensive accessory (under $20) that lets you “nibble” small chunks from metal and plastic pieces. The maximum thickness depends on the bite of the tool, but it’s generally about 1⁄16 in. Use the tool to cut channels and enlarge holes. A tap and die set lets you thread holes and shafts to accept standard-sized nuts and bolts. Buy a good set. A cheap assortment is more trouble than it’s worth.
68
TOOLS
FIGURE 6-1 A motorized hobby tool is ideal for drilling, sanding, and shaping small parts.
• •
A thread-size gauge, made of stainless steel, may be expensive, but it helps you determine the size of any standard SAE or metric bolt. It’s a great accessory for tapping and dieing. A brazing tool or small welder lets you spot-weld two metal pieces together. These tools are designed for small pieces only. They don’t provide enough heat to adequately weld pieces larger than a few inches in size. Be sure that extra fuel and oxygen cylinders or pellets are readily available for the brazer or welder you buy. There’s nothing worse than spending $30 to $40 for a home welding set, only to discover that supplies are not available for it. Be sure to read the instructions that accompany the welder and observe all precautions.
6.4 Electronic Tools Constructing electronic circuit boards or wiring the power system of your robot requires only a few standard tools. A soldering iron leads the list. For maximum flexibility, invest in a modular soldering pencil, the kind that lets you change the heating element. For routine electronic work, you should get a 25- to 30-W heating element. Anything higher may damage electronic components. You can use a 40- or 50-W element for wiring switches, relays, and power transistors. Stay away from instant-on soldering irons. For any application other than soldering large-gauge wires they put out far too much heat.
6.4 ELECTRONIC TOOLS
69
As obvious as it seems to most people, do not use soldering iron, solder, or flux that is designed for plumbing applications. These tools and materials are not appropriate for any robot applications and could potentially damage the components being connected together.
• • • • • • • • • •
Soldering stand. Mandatory for keeping the soldering pencil in a safe, upright position. Soldering tip assortment. Get one or two small tips for intricate printed circuit board work and a few larger sizes for routine soldering chores. Solder. Buy resin or flux core type that is designed for electronics. Acid core and silver solder should never be used on electronic components. Solder sponge. Sponges are useful for cleaning the soldering tip as you use it. Keep the sponge damp, and wipe the tip clean every few joints. Desoldering vacuum tool. This is useful for soaking up molten solder. Use it to get rid of excess solder, remove components, or redo a wiring job. Solder braid. Performs a similar function to the desoldering vacuum tool by wicking excess molten solder away from a joint or a component. Dental picks. These are ideal for probing and separating wires and component leads. Resin cleaner. Apply the cleaner after soldering is complete to remove excess resin. An ultrasonic jewelry cleaner used with the resin cleaner (or isopropyl alcohol) will get the components very clean with very little work on your part. Solder vise. This vise serves as a third hand, holding together pieces to be soldered so you are free to work the iron and feed the solder. An illuminated magnifying glass. Often going by the trade name Dazer, this provides a two or three time magnification of the surface below. It is invaluable for inspecting work or soldering fine components.
6.4.1 STATIC CONTROL Running robots are terrible environments for electronics. The motors tend to produce large transients on the power lines that come back to the control electronics, running across different surfaces will build up static electrical charges, and different metal parts can produce unexpected voltages and currents that can upset electronics. Fortunately, most modern electronic devices are protected from static electrical discharges, but you should still make some basic concessions to protect them from being damaged during assembly and operation. Everybody is familiar with the sparks that you can produce by shuffling along a synthetic carpet and touching a metal doorknob. What will probably surprise you is the magnitude of the voltage needed to produce a spark: for you to feel and see the spark, a static charge of 2500 V or more is required. The minute amount of current flow (on the order of microamperes) is why you are not hurt. As you have probably heard, when somebody is electrocuted it is the current that kills, not the voltage. The amount of static electricity that can damage a silicon chip is significantly less— 125 V can ruin a diode’s PN junction or a MOSFET’s gate oxide layer. Note that 125 V is 20 times less than the 2500-V threshold needed to detect static electricity. This relatively low level is the reason for the concern about static electricity. The term electrostatic discharge (ESD) is used to describe the release of static electricity (either from you to the doorknob or into an electronic circuit). Virtually all modern electric devices have
70
TOOLS
built-in protections against ESD, but there are still a number of things that you must do to ensure that the components are not damaged by static electricity, either during assembly or use. You can buy basic ESD protection kits, which consist of a conducting mat, a wrist strap with cord, and a static bleed line that can be attached to the grounding screw (holding the faceplate on an electrical outlet), for about $20. Before buying this type of kit, there are a number of things that you should be aware of. First, the term conducting when applied to the mat, the wrist strap, and the static bleed line is very loosely applied; each of these components should have internal resistances in the mega-ohm range. Do not buy an ESD kit that does not have a mega-ohm resistor in the wrist strap cord or the static bleed line as there could be dangerous voltages passed along them into you. Finally, before attaching the static bleed line to the electrical outlet’s grounding screw make sure that the socket is wired properly using a socket tester (which costs around $5). All circuit assembly should take place on the conducting mat while you are wearing the wrist strap. When you buy electronic components, they will either be packaged in conducting plastic tubes or in anti-static bags. When you have completed the assembly operation, the components should be returned to their original packages and any assembled circuitry placed inside an anti-static bag. Operation of the circuitry can have potential problems as was noted at the start of this section. To minimize the chance of the robot’s electronics becoming damaged, there are a few precautions that can be taken:
• • • • • •
The metal parts of the robot should all be connected together and connected to the ground (negative) connection of the robot’s electronics. This will prevent static electricity from building up within the robot. Robot whiskers must be connected to the ground as they can generate static electricity when they run across an object. Castor mountings should be attached to the robot’s ground connection to avoid buildups of static electricity. You might want to let a small metal chain or wire braid run on the ground while the robot is moving to help dissipate static charges from the robot. The robot electronics should be within some kind of metal box to protect them from static electricity when the robot is picked up. Connectors to PCs (e.g., USB or RS-232) for programming or monitoring must have the outside shells connected to the robot’s metal frame and negative connection to make sure any static electricity buildup is not passed through either the robot’s or the PC’s electronics, damaging them.
6.4.2 DIGITAL MULTIMETER A digital multimeter (DMM and also known as a volt-ohm meter or multitester) is used to test voltage and current levels along with the resistance of different parts of circuits. Along with these basic functions, you can find DMMs that can test transistors and capacitors, and measure signal frequencies and temperature. They can be purchased from under $10 to several thousand, and if you don’t already own a volt-ohm meter you should seriously consider buying one immediately. The low cost of a simple unit is disproportionate to the usefulness of the instrument.
6.4 ELECTRONIC TOOLS
71
There are many DMMs on the market today. For robotics work, a meter of intermediate quality is sufficient and does the job admirably at a price between $30 and $75 (it tends to be on the low side of this range). Meters are available at Radio Shack and most electronics outlets. While analog (meters with needles) multimeters are still available, you should avoid them. Digital meters employ a numeric display not unlike a digital clock or watch. Analog meters use the older-fashioned mechanical movement with a needle that points to a set of graduated scales. When they first became available, DMMs (like the one shown in Fig. 6-2) used to cost a great deal more than the analog variety, but now they generally cost less than analog meters, are more easily read, and are usually more robust. In fact, it’s hard to find a decent analog meter these days. Most low-cost DMMs require you to select the range before it can make an accurate measurement. For example, if you are measuring the voltage of a 9-V transistor battery, you set the range to the setting closest to, but above, 9 V (with most meters it is the 0 to 20 or 0 to 50-V range). Auto-ranging meters (which cost more than the basic models) don’t require you to do this, so they are inherently easier to use. When you want to measure voltage, you set the meter to volts (either AC or DC) and take the measurement. The meter displays the results in the readout panel. Little of the work you’ll do with robot circuits will require a DMM that’s superaccurate; when working with electronics, being within a few percentage points of the desired value is normally good enough for a circuit to work properly. The accuracy of a meter is the mini-
FIGURE 6-2 A volt-ohm meter (or multitester) checks resistance, voltage, and current. This model is digital and has a 31⁄2-digit liquid crystal display (LCD) readout.
72
TOOLS
mum amount of error that can occur when taking a specific measurement. For example, the meter may be accurate to 2000 V, plus or minus 0.8 percent. A 0.8 percent error at the kinds of voltages used in robots—typically, 5 to 12 V DC—is only 0.096 V. The number of digits in the DMM display determines the maximum resolution of the measurements. Most DMMs have three and a half digits, so they can display a value as small as 0.001 (the half digit is a 1 on the left side of the display). Anything less than that is not accurately represented and there’s little need for accuracy better than this. DMMs vary greatly in the number and type of functions they provide. At the very least, all standard meters let you measure AC volts, DC volts, milliamps, and ohms. Some also test capacitance and opens or shorts in discrete components like diodes and transistors. These additional functions are not absolutely necessary for building general-purpose robot circuits, but they are handy when troubleshooting a circuit that refuses to work. The maximum ratings of the meter when measuring volts, milliamps, and resistance also vary. Before buying a specific DMM, make sure you understand what the maximum values are that the meter can handle. Most DMMs have maximum values ratings in the ranges of: DC voltages to 1000 V AC voltages to 500 V DC currents to 200 mA with up to 10 A using a fused input Resistance 2 MΩ One exception to this is when you are testing current draw for the entire robot versus just for motors. Many DC motors draw an excess of 200 mA, and the entire robot is likely to draw 2 or more amps. Obviously, this is far out of the range of most digital meters, but there are ways to do it as is shown in Chapter 19. DMMs come with a pair of test leads, one black and one red. Each is equipped with a needlelike metal probe. Standard leads are fine for most routine testing, but some measurements may require that you use a clip lead. These attach to the end of the regular test leads and have a spring-loaded clip on the end. You can clip the lead in place so your hands are free to do other things. The clips are insulated to prevent short circuits. Most applications of the DMM involve testing low voltages and resistance, both of which are relatively harmless to humans. Sometimes, however, you may need to test high voltages—like the input to a power supply—and careless use of the meter can cause serious bodily harm. Even when you’re not actively testing a high-voltage circuit, dangerous currents can still be exposed. The proper procedure for using a meter is to set it beside the unit under test, making sure it is close enough so the leads reach the circuit. Plug in the leads, and test the meter operation by first selecting the resistance function setting (use the smallest scale if the meter is not auto-ranging). Touch the leads together: the meter should read 0 Ω or something very close (a half ohm or so). If the meter does not respond, check the leads and internal battery and try again. Analog multimeters often have a “zero adjust,” which provides a basic calibration capability for the meter. Once the meter has checked out, select the desired function and range and apply the leads to the circuit under test. Usually, the black lead will be connected to the ground, and the red lead will be connected to the various test points in the circuit.
6.4 ELECTRONIC TOOLS
73
6.4.3 LOGIC PROBES Meters are typically used for measuring analog signals. Logic probes test for the presence or absence of low-voltage digital data signals. The 0s and 1s are usually electrically defined as 0 and 5 V, respectively, when used with TTL integrated circuits (ICs). In practice, the actual voltages of the 0 and 1 bits depend entirely on the circuit and the parts used to make it up. You can use a meter to test a logic circuit, but the results aren’t always predictable. Further, many logic circuits change states (pulse) quickly, and meters cannot track the voltage switches quickly enough. Logic probes, such as the model in Fig. 6-3, are designed to give a visual and (usually) audible signal of the logic state of a particular circuit line. One LED (light-emitting diode) on the probe lights up if the logic is 0 (or low); another LED lights up if the logic is 1 (or high). You should only work with a probe that has a built-in buzzer with different tones for the two logic levels. This feature will allow you to look at the circuitry you are probing rather than having to glance at the probe to see the logic level. A third LED or tone may indicate a pulsing signal. A good logic probe can detect that a circuit line is pulsing at speeds of up to 10 MHz, which is more than fast enough for robotic applications, even when using computer control. The minimum detectable pulse width (the time the pulse remains at one level) is 50 nanoseconds, which again is more than sufficient. Another feature that you should be aware of is the ability of the probe to work with different logic families and logic voltage levels. Different CMOS logic families can work at
FIGURE 6-3 The logic probe in use. Note that in the photograph the probe derives its power from the circuit under test.
74
TOOLS
power supply voltages ranging from 3 to 15 V with a logic level transition voltage of onehalf the power supply voltage (1.5 to 7.5 V). TTL logic’s transition voltage is usually regarded as 1.4 V and is independent of the input power supply (which ranges from 4.75 to 5.25 V). The logic technology that the probe works with is switch selectable. Most probes are not battery operated; rather, they obtain operating voltage from the circuit under test. This feature allows you to start simply probing your circuit without providing a separate power supply (with a matching ground to the test circuit) for the logic probe and determining the appropriate CMOS logic test level. Although logic probes may sound complex, they are really simple devices, and their cost reflects this. You can buy a reasonably good logic probe for under $20. The logic probe available from Radio Shack, which has most of the features listed here, can be purchased at this price point. You can also make a logic probe if you wish; it is not recommended as you will be hard pressed for buying the necessary parts for less than the cost of an inexpensive unit. To use the logic probe successfully you really must have a circuit schematic to refer to. Keep it handy when troubleshooting your projects. It’s nearly impossible to blindly use the logic probe on a circuit without knowing what you are testing. And since the probe receives its power from the circuit under test, you need to know where to pick off suitable power. To use the probe, connect the probe’s power leads to a voltage source on the board, clip the black ground wire to circuit ground, and touch the tip of the probe against a pin on an integrated circuit or the lead of some other component. For more information on using your probe, consult the manufacturer’s instruction sheet. When designing your robot, it is a good idea to keep your digital logic separate from power supplies and other high-voltage/high-current circuits. When working on an awkward circuit, such as one mounted in a robot, it is not unusual for the metal probe tip to slip and short out other circuits. If the board is all digital logic, then this isn’t a problem—but if there are other circuits on the board, you could end up damaging them, your logic probe, and any number of miscellaneous circuits.
6.4.4 OSCILLOSCOPE An oscilloscope is a pricey tool, but for performing serious work or understanding how the circuitry behaves in your robot, it is invaluable and will save you hours of frustration. Other test equipment will do some of the things you can do with a scope, but oscilloscopes do it all in one box and generally with greater precision. Among the many applications of an oscilloscope, you can do the following:
• • • • •
Test DC or AC voltage levels Analyze the waveforms of digital and analog circuits Determine the operating frequency of digital, analog, and RF circuits Test logic levels Visually check the timing of a circuit to see if things are happening in the correct order and at the prescribed time intervals.
The most common application used to demonstrate the operation of an oscilloscope is converting sound waves into a visual display by passing the output of a microphone into
6.4 ELECTRONIC TOOLS
75
an oscilloscope. This application, while very appealing, does not demonstrate any of the important features of an oscilloscope nor is it representative of the kind of signals that you will probe with it. When you are looking at buying an oscilloscope, you should consider the different features and functions listed in the following. The resolution of the scope reveals its sensitivity and accuracy. On an oscilloscope, the X (horizontal) axis displays time, and the Y (vertical) axis displays voltage. These values can be measured by the marks, or graticules, on the oscilloscope display. To change the sensitivity, there is usually a knob on the oscilloscope that will make the time between each set of markings larger or smaller. The value between the graticule markings is either displayed on the screen itself electronically or marked on the oscilloscope by the adjustment knob (Fig. 6-4). There are two different types of oscilloscopes. The analog oscilloscope passes the incoming signal directly from the input probes to the CRT display without any processing. Rather than displaying the signal as it comes in, there is normally a trigger circuit, which starts the display process when the input voltage reaches a specific point. Analog oscilloscopes are best suited for repeating waveforms; they can be used to measure their peak to peak voltages, periods, and timing differences relative to other signals. The digital storage oscilloscope (DSO) converts the analog voltage to a digital value and then displays it on a computer-like screen. By converting the analog input to digital, the waveform can be saved and displayed after a specific event (also known as the trigger, as in the analog oscilloscope) or processed in some way. Whereas the peak to peak voltage and the waveform’s period is measured from the screen in an analog oscilloscope, most digital storage oscilloscopes have the ability to calculate these (and other) values for you. Digital storage oscilloscopes can be very small and flexible; there are a number of products available that connect directly to a PC and avoid the bulk and cost of a display all together. It
Clock Active for 14 us
Clock
Data Data Valid 32 us Data AFTER Clock Valid 14 us BEFORE Clock FIGURE 6-4 Digital storage oscilloscope display showing the changing voltage level on the two pins used in the BS2’s shiftout statement.
76
TOOLS
should be noted that the digital storage oscilloscope is capable of displaying the same repeating waveforms as an analog oscilloscope. One of the most important specifications of an oscilloscope is its bandwidth, which is the maximum frequency signal that can be observed accurately. For example, a 20 MHz oscilloscope can accurately display and measure a 20 MHz sine wave. The problem with most signals is that they are not perfect sine waves; they usually consist of much higher frequency harmonics, which make up the signal. To accurately display an arbitrary waveform at a specific frequency, the bandwidth must be significantly higher than the frequency itself; five times the required bandwidth is the minimum that you should settle for, with 10 times being a better value. So, if in your circuit, you have a 20 MHz clock, to accurately observe the signal the oscilloscope’s bandwidth should be 100 MHz or more. Along with the bandwidth measurement in a digital storage oscilloscope, there is also the sampling rate of the incoming analog signal. The bandwidth measurement of a digital storage oscilloscope is still relevant; like the analog oscilloscope it specifies the maximum signal frequency that can be input without the internal electronics of the digital storage oscilloscope distorting it. The sampling rate is the number of times per second that the oscilloscope converts the analog signal to a digital value. Most digital storage oscilloscopes will sample at 10 to 50 times the bandwidth and the sampling measurement is in units of samples per second. Finally, the oscilloscope’s trigger is an important feature that many people do not understand how to use properly. As previously noted, the trigger is set to a specific voltage to start displaying (or recording in the case of a digital storage oscilloscope) the incoming analog voltage signal. The trigger allows signals to be displayed without jitter so that the incoming waveform will be displayed as a steady waveform, instead of one that jumps back and forth or appears as a steady blur without any defined start point. The trigger on most oscilloscopes can start the oscilloscope when the signal goes from high to low at a specific voltage level, or from low to high. Over the years, oscilloscopes have improved dramatically, with many added features and capabilities. Among the most useful features is a delayed sweep, which is helpful when you are analyzing a small portion of a long, complex signal. This feature is not something that you will be comfortable using initially, but as you gain experience with the oscilloscope and debugging you will find that it is an invaluable feature for finding specific problems or observing how the circuitry works after a specific trigger has been executed. The probes used with oscilloscopes are not just wires with clips on the end of them. To be effective, the better scope probes use low-capacitance/low-resistance shielded wire and a capacitive-compensated tip. These ensure better accuracy. Most scope probes are passive, meaning they employ a simple circuit of capacitors and resistors to compensate for the effects of capacitive and resistive loading. Many passive probes can be switched between 1X and 10X. At the 1X setting, the probe passes the signal without attenuation (weakening). At the 10X setting, the probe reduces the signal strength by 10 times. This allows you to test a signal that might otherwise overload the scope’s circuits. Active probes use operational amplifiers or other powered circuitry to correct for the effects of capacitive and resistive loading as well as to vary the attenuation of the signal. Table 6-1 shows the typical specifications of passive and active oscilloscope probes.
6.4 ELECTRONIC TOOLS
TABLE 6-1
77
Specifications For Typical Oscilloscope Probe
PROBE TYPE
FREQUENCY RANGE
RESISTIVE LOAD
CAPACITIVE LOAD
Passive 1X
DC–5 MHz
1 megohm
30 pF
Passive 10X
DC–50 MHz
10 megohms
5 pF
Active
20–500 MHz
10 megohms
2 pF
As an alternative to a stand-alone oscilloscope you may wish to consider a PC-based oscilloscope solution. Such oscilloscopes not only cost less but may provide additional features, such as long-term data storage. A PC-based oscilloscope uses your computer and the software running on it as the active testing component. Most PC-based oscilloscopes are comprised of an interface card or adapter. The adapter connects to your PC via an expansion board or a serial, parallel, or USB port (different models connect to the PC in different ways). A test probe then connects to the interface. Software running on your PC interprets the data coming through the interface and displays the results on the monitor. Some oscilloscope adapters are designed as probes with simple displays, giving you the capability of the DMM, logic probe, and oscilloscope in a package that you can hold in your hand. Prices for low-end PC-based oscilloscopes start at about $100. The price goes up the more features and bandwidth you seek. For most robotics work, you don’t need the most fancy-dancy model. PC-based oscilloscopes that connect to the parallel, serial, or USB port—rather than internally through an expansion card—can be readily used with a portable computer. This allows you to take your oscilloscope anywhere you happen to be working on your robot. The designs provided in this book don’t absolutely require that you use an oscilloscope, but you’ll probably want one if you design your own circuits or want to develop your electronic skills. A basic, no-nonsense model is enough, but don’t settle for the cheap, singletrace analog units. A dual-trace (two-channel) digital storage oscilloscope with a 20- to 25-MHz maximum input frequency (with 250,000 samples per second) should do the job nicely. The two channels let you monitor two lines at once (and reference it to a third trigger line), so you can easily compare the input and output signals at the same time. The digital storage features will allow you to capture events and study them at your leisure, allowing you to track the execution progress of the software and its response to different inputs. Oscilloscopes are not particularly easy to use for the beginner; they have lots of dials and controls for setting operation. Thoroughly familiarize yourself with the operation of your oscilloscope before using it for any construction project or for troubleshooting. Knowing how to set the time per-division knob is as important as knowing how to turn the oscilloscope on and you won’t be very efficient at finding problems until you understand exactly how the oscilloscopes trigger. As usual, exercise caution when using the scope with or near high voltages.
78
TOOLS
6.5 From Here To learn more about . . .
Read
Electronic components
Chapter 5, “Electronic Components”
How to solder
Chapter 6, “Electronic Construction Techniques”
Building electronic circuits
Chapter 6, “Electronic Construction Techniques”
Building mechanical apparatuses
Part 2, “Robot Platform Construction”
CHAPTER
7
ELECTRONIC CONSTRUCTION TECHNIQUES
T
o operate all but the simplest robots requires an electronic circuit of one type or another. The way you construct these circuits will largely determine how well your robot functions and how long it will last. Poor performance and limited life inevitably result when hobbyists use so-called rat’s nest construction techniques such as soldering together the loose leads of components. Using proper construction techniques will ensure that your robot circuits work well and last as long as you have a use for them. This chapter covers the basics of several types of construction techniques, starting with the basics of soldering, wire-wrapping, and some circuit prototyping techniques. While only the fundamentals are being presented, these methods, techniques, and tools are useful for even very sophisticated circuitry. For more details, consult a book on electronic construction techniques. Appendix A contains a list of suggested sources.
7.1 Soldering Tips and Techniques Soldering is the process of heating up two pieces of metal together and electrically joining them using a (relatively) low melting temperature metal (normally a lead-tin alloy). Discrete components, chips, printed circuit boards, and wires can all be joined by soldering them together. Soldering is not a construction technique and will not provide a robust mechanical connection that can be used in robot structures. Soldering sounds and looks simple 79 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
80
ELECTRONIC CONSTRUCTION TECHNIQUES
enough, but there is a lot of science behind it and care must be taken to get strong, reliable connections (called joints) without damaging any of the components being soldered. Fig. 7-1 shows the important aspects of a solder joint. The two pieces of metal to be connected (which is almost always copper) are joined by another metal (the solder) melted to them. When the solder is melted to the copper, it should wet smoothly over the entire copper surface. Even though the solder melts at a lower temperature than the copper, there are very thin interfaces produced that consist of a copper/solder alloy. These interfaces are called the intermetallic regions of the solder joints and one of the goals of soldering is to make sure these regions are as thin as possible to avoid alloying of the copper and solder (which raises the melting point of the solder and makes the joint brittle). The following sections provide an overview of soldering. If you solder sporadically with months in between turning on your soldering iron, it is a good idea to review this material to ensure that the work is carried out efficiently and safely.
7.1.1 SOLDER SAFETY Keep the following points in mind when soldering:
• • • • • •
Keep your fingers away from the tip of the soldering pencil. A hot soldering iron can seriously burn you. Never touch a solder joint until after it has cooled. While using the soldering iron, always place it in a properly designed iron stand. To avoid inhaling the fumes for any length of time, work only in a well-ventilated area. While the fumes produced during soldering are not particularly offensive, they can be surprisingly toxic. Always wear eye protection such as safety glasses or optically clear goggles when clipping leads. Keep a fire extinguisher handy, just in case.
Solder “Fillet”
Copper
Solder
“Intermetallic” Regions FIGURE 7-1 Solder joint cross-section.
Copper
7.1 SOLDERING TIPS AND TECHNIQUES
81
7.1.2 TOOLS AND EQUIPMENT 7.1.2.1 Soldering iron and tip When you are looking for a soldering iron, choose one that is designed for electronics, like the one in Fig. 7-2. The iron should have a fairly low wattage rating (not higher than 30 W). Most soldering irons or pencils are designed so you can change the tips as easily as changing a lightbulb. Make sure that you have the smallest pointed tip available for your iron as it will be required for small electronics assembly. It is a good idea to buy a soldering iron that is grounded to keep from running the risk of damaging sensitive electronic components by subjecting them to electrostatic discharge. Do not use the instant-on type soldering guns favored in the old tube days, and definitely do not use an iron that was designed for plumbing. These types of irons produce far too much unregulated heat and can easily damage the components being soldered. If your soldering iron has a temperature control and readout, dial it to between 665 and 680°F. This is the typical melting point for solder and will pose the minimum danger of damage to the electronic components. If your iron has just the control and lacks a heat readout, set it to low initially. Wait a few minutes for the iron to heat up, then try one or two test connections. Adjust the heat control so that solder flows onto the connection in under 5 s. Remember that when you are not using your soldering iron, keep it in an insulated stand.
FIGURE 7-2 Use a low-wattage (25 to 30 W) soldering pencil for all electronics work.
82
ELECTRONIC CONSTRUCTION TECHNIQUES
Which soldering tip you choose is important. For best results, use a fine tip designed specifically for printed circuit board use (unless you are soldering larger wires; in that case, use a larger tip). Tips are made to fit certain types and brands of soldering irons, so make sure you get ones that are made for your iron. 7.1.2.2 Sponge Keep a damp sponge (just about any type of kitchen sponge will do) by the soldering station and use it to wipe off extra solder. Do not allow globs of solder to remain on the tip. The glob may come off while you’re soldering and ruin the connection. The excess solder can also draw away heat from the tip of the pencil, causing a poor soldering job. You’ll have to rewet the sponge now and then if you are doing lots of soldering. Never wipe solder off onto a dry sponge, as the sponge could melt or catch on fire. 7.1.2.3 Solder and flux You should use only 63% lead/37% tin rosin core solder. It comes in different thicknesses; for best results, use the thin type (0.050 in) for most electronics work, especially if you’re working with printed circuit boards. Never use acid core or silver solder on electronic equipment. (Note: certain silver-bearing solders are available for specialty electronics work, and they are acceptable to use although a lot more expensive than tin–lead solders.) You have probably heard about lead-free solders, which, not surprisingly, do not contain any lead in an effort to protect the environment. Unless you are well versed in soldering and are certain that all the components that are going to be soldered have had their leads prepared for lead-free solders, then it is highly recommended that you stay away from them. Lead-free solders melt at a higher temperature than tin–lead solders and lead contamination can cause even higher temperature melting points, which will make it very difficult to remove the components. Flux is a weak heat-activated acid that cleans the metal surfaces of the components being soldered of oxides and some contaminants. In some cases, such as soldering large wires, you may find it advantageous to apply liquid flux to the surfaces to ensure the larger areas are cleaned during the solder process. To avoid getting into trouble with liquid flux, only buy flux at the store where you bought your solder and make sure that it is the same formulation as the flux in the solder. There are very aggressive fluxes designed for specialized applications that will literally dissolve your components and solder iron tip. If you aren’t sure, then refrain from buying any flux and rub the connections with steel wool before soldering to clean off the surfaces to be soldered. Solder should be kept clean and dry. Avoid tossing your spool of solder into your electronics junk bin. It can collect dust, grime, oil, grease, and other contaminants. Dirty solder requires more heat to melt. In addition, the grime fuses with the solder and melds into the connection. If your solder becomes dirty, wipe it off with a damp paper towel soaked in alcohol, and let it dry. 7.1.2.4 Soldering tools Basic soldering tools include a good pair of small needlenose pliers, wire strippers, and wire cutters (sometimes called side or diagonal cutters). The stripper should have a dial that lets you select the gauge of wire you are using. A pair of nippy cutters, which cuts wire leads flush to the surface of the board, is also handy. A heat sink should be avoided during soldering—some people may say that it is necessary to avoid heat damage to components, but a heat sink will raise the length of time the
7.1 SOLDERING TIPS AND TECHNIQUES
83
iron will have to be applied to the joint in order to melt the solder and could result in poor solder joints as well as an increased amount of heat being passed to the component. As discussed in the following, the iron should only be in contact with the component’s leads for a few seconds, much less than the amount of time required to damage the component. 7.1.2.5 Cleaning supplies It is often necessary to clean up before and after you solder. Isopropyl alcohol makes a good, all-around cleaner to remove flux after soldering. After the board has cooled, flux can form a hard surface that is difficult to remove. The best way to clean a circuit board is to use isopropyl alcohol in an ultrasonic cleaner, but you can also use a denture brush (which has much stiffer bristles than an ordinary toothbrush) with isopropyl alcohol as well. 7.1.2.6 Solder vacuum and solder braid These tools are used for removing excess solder and removing components after they have been soldered. Desoldering (removing components that have been soldered to a board) is a tricky process that even with a lot of skill can result in a damaged circuit board and components. To minimize the need for desoldering, you should take care to ensure the correct components are being soldered in the correct orientation and use sockets instead of soldering wherever possible.
7.1.3 HOW TO SOLDER The basis of successful soldering is to use the soldering iron to heat up the work, whether it is a component lead, a wire, or whatever. You then apply the solder to the work. If the solder doesn’t flow onto the joint, then check the iron’s temperature, add a bit more rosin core solder or even add a bit of liquid flux. Once the solder flows around the joint (and some will flow to the tip), remove the iron and let the joint cool. The joint should look smooth and shiny. If the solder appears dull and crinkly, then you have a cold joint. To fix the joint, apply the soldering iron again to remelt the solder. Avoid disturbing the solder as it cools; a cold joint might be the result. Do not apply heat any longer than necessary. Prolonged heat can permanently ruin electronic components. A good rule of thumb is that if the iron is on any one spot for more than 5 s, it’s too long. If at all possible, you should keep the iron at a 30° to 40° angle for best results. Most tips are beveled for this purpose. Apply only as much solder to the joint as is required to coat the lead and circuit board pad. A heavy-handed soldering job may lead to soldering bridges, which is when one joint melds with joints around it. At best, solder bridges cause the circuit to cease working; at worst, they cause short circuits that can burn out the entire board. When soldering on printed circuit boards, you’ll need to clip off the excess leads that protrude beyond the solder joint. Use a pair of diagonal or nippy cutters for this task. Be sure to protect your eyes when cutting the lead.
7.1.4 SOLDER TIP MAINTENANCE AND CLEANUP After soldering, wipe the hot tip on the solder sponge to remove any excess solder, flux, and contaminants. Then let the iron cool. After many hours of use, the soldering tip will become old, pitted, and deformed. This is a good time to replace the tip. Old or damaged tips impair
84
ELECTRONIC CONSTRUCTION TECHNIQUES
the transfer of heat from the iron to the connection, which can lead to poor soldering joints. Be sure to replace the tip with one made specifically for your soldering iron. Tips are generally not interchangeable between brands.
7.2 Breadboards The term breadboard is used for a variety of experimenter wired circuit products. In this book, the term will be used to describe the temporary prototyping circuit platform shown in Fig. 7-3 in which the holes are connected to adjacent ones by a spring-loaded connector. The typical arrangement is to have the interior holes connected outward while the outside rows of holes are connected together to provide a bus structure for power and common signals. Wire (typically 22 gauge) and most electronic components can be pushed into the circuit to make connections and, when the application is finished, to pull out for reuse. Breadboards are engineered to enable you to experiment with a circuit, without the trouble of soldering. When you are assured that the circuit works, you may use one of the other four construction techniques described in this chapter to make the design permanent. A typical solderless breadboard mounted on a metal carrier is shown in Fig. 7-4. Breadboards are available in many different sizes and styles, but most provide rows of common tie points that are suitable for testing ICs, resistors, capacitors, and most other components that have standard lead diameters. It is a good idea to first test all the circuits you build on a solderless breadboard. It is important to note that the resistance between adjacent pins is on the order of 5 Ω and the
Interior Connections
Exterior
FIGURE 7-3 Breadboard with interior connections shown.
7.3 PROTOTYPING PCBs
85
FIGURE 7-4 Use solderless breadboards to test out new circuit ideas. When they work, you can construct a permanent circuit.
capacitance between connectors can be as high as 2 pF. These parasitic impedances mean that your circuit may not perform properly in all cases (especially for currents over 100 mA or signals switching at a few MHz) and you may have to resort to one of the other prototyping methodologies described in the following. It should also be noted that breadboard component connections can come loose when under vibration—such as in a mobile robot.
7.3 Prototyping PCBs There are many different commercial products that allow you to solder together a custom circuit reasonably quickly and easily. These products may have generic names like breadboard circuit boards, universal solder boards, or experimenters’ PC boards. The Vector line of products is commonly used by many robot experimenters. These boards consist of a series of copper strips (which can be cut) to allow you to create custom circuits surprisingly
86
ELECTRONIC CONSTRUCTION TECHNIQUES
easily using standard PCB soldering techniques. Other prototyping PCBs have sockets and commonly used circuits already etched into the PCBs to further simplify the assembly and wiring of the circuit. The main disadvantage of universal solder boards is that they don’t provide for extremely efficient use of space. It can be difficult to cram the components onto a small space on the board, and you will find that it takes some experience to properly plan your circuits. For this reason, only use prototyping PCBs when wiring a fairly small and simple circuit. Remember to drill mounting holes to secure the board in whatever enclosure or structure you are using.
7.4 Point-to-Point Prototyping Wiring Point-to-point wiring refers to the practice of mounting electronic components to a prototyping PCB and connecting the leads together directly with solder. This technique was used extensively in the pre-IC days and was often found on commercial products. An example of a circuit built on a prototyping PCB and connected together using point-to-point wiring is shown in Fig. 7-5. When building point-to-point wired circuits, you must be careful to use insulated wire as point-to-point construction invites short circuits and burnouts. Point-to-point wiring is the most difficult method of creating circuitry discussed in this chapter, but often it is the only
FIGURE 7-5 Circuit created on a prototyping PCB and wired together using point-topoint wiring techniques.
7.6 QUICK TURN PROTOTYPE PRINTED CIRCUIT BOARDS
87
method that allows you to get a robust circuit built quickly. Remember to start small and don’t be afraid to experiment with different techniques in order to get the most efficient circuitry.
7.5 Wire-Wrapping An older method used to wire complex circuitry together is known as wire-wrapping: a bared wire is literally wrapped around a long post, which is connected to the pin of an IC or some other component. Wire-wrapping can be used to create very complex circuits, and it is surprisingly robust. However, there are a number of downsides to this wiring method that you should be aware of. Wire-wrapping requires specialized tools, component sockets (with long, square leads), and prototyping PCBs—each of which can be substantially more expensive than standard parts. It also takes a surprisingly long time. Professional wire-wrappers with automated equipment plan on each wire connection taking 30 s; starting out with hobbyist tools you will be hard pressed to perform (on average) one wire every 3 minutes. It should also be noted that a complex wire-wrapped board quickly becomes a rat’s nest and wiring errors are extremely difficult to find. Finally, wiring power and analog components into a wire-wrapped circuit is difficult and can be extremely time consuming.
7.6 Quick Turn Prototype Printed Circuit Boards Probably the most efficient method of prototyping circuits is to design a simple printed circuit board and have a small number of samples built by a quick turn manufacturer. Depending on your location, you could conceivably have your PCBs within a business day. Quick turn PCBs (like the one shown in Fig. 7-6) are also surprisingly cost efficient—you should plan on the PCBs costing $5 per square inch, approximately the same as what you would pay for PCBs, sockets, and wiring for a wire-wrapped circuit. For a beginner, the time spent designing the PCB is similar to that of wire-wrapping a PCB. The big advantage of using quick turn PCBs is the ability to change and replicate the circuit very quickly. Using any of the other prototyping techniques previously discussed, the effort in wiring is only applied to one circuit; the time increases linearly with each additional circuit built. A PCB design can be replicated without any additional investment in time and certainly adds to the professionalism of a robot. An understandable concern about designing printed circuit boards is the time required to learn how to use the design tools, their cost, and learning how to efficiently lay out circuits on a PCB. Currently there are a number of open source software projects and commercial products that allow hobbyists to design PCBs and produce Gerber files (which are the design files used to manufacture the PCBs) for free. There are quite a few books devoted to explaining how PCB layout is accomplished and lists many of the tricks that you should be
88
ELECTRONIC CONSTRUCTION TECHNIQUES
FIGURE 7-6 PCBs, like this one, can be created quickly as well as inexpensively and can be replicated with very little effort.
aware of. Learning how to design PCBs is a marketable skill and one that will certainly pay off in the future.
7.7 Headers and Connectors Robots are often constructed from subsystems that may not be located on the same circuit board. You must therefore know how to connect subsystems on different circuit boards. Avoid the temptation to directly solder wires between boards. This makes it much harder to work with your robot, including testing variations of your designs with different subsystems. Instead, use connectors whenever possible, as shown in Fig. 7-7. In this approach you connect the various subsystems of your robot using short lengths of wire. You terminate each wire with a connector of some type or another. The connectors attach to mating pins on each circuit board. You don’t need fancy cables and cable connectors for your robots. In fact, these can add significant weight to your ’bot. Instead, use ordinary 20- to 26-gauge wire, terminated with single- or double-row plastic connectors. You can use ribbon cable for the wire or individual insulated strips of wire. Use plastic ties to bundle the wires together. The plastic connectors are made to mate with single- and double-row headers soldered directly on the circuit board. You can buy connectors and headers that have different numbers of pins or you can salvage them from old parts (the typical VCR is chock-full of them!).
7.8 ELIMINATING STATIC ELECTRICITY
89
FIGURE 7-7 Using connectors makes for more manageable robots. Use connectors on all subsystems of your robot.
When making interconnecting cables, cut the wires to length so there is a modest amount of slack between subsystems. You don’t want, or need, gobs of excess wire. Nor do you want the wire lengths so short that the components are put under stress when you connect them together.
7.8 Eliminating Static Electricity The ancient Egyptians discovered static electricity when they rubbed animal fur against the smooth surface of amber. Once the materials were rubbed together, they tended to cling to one another. Similarly, two pieces of fur that were rubbed against the amber tended to separate when they were drawn together. While the Egyptians didn’t understand this mysterious unseen force—better known now as static electricity—they knew it existed. Today, you can encounter static electricity by doing nothing more than walking across a carpeted floor. As you walk, your feet rub against the carpet, and your body takes on a static charge. Touch a metal object, like a doorknob or a metal sink, and that static is quickly discharged from your body. You feel the discharge as a shock. Carpet shock has never been known to kill anyone. The amount of voltage and current is far too low to cause great bodily harm. But the same isn’t true of electronic circuits. Considering how your body can develop a 10,000- to 50,000-V charge when you walk across a carpet, try to imagine what that might do to electrical components rated at just 5 or 15 V. The sudden crash of electrical energy can burn holes right through a sensitive transistor or integrated circuit, rendering it completely useless.
90
ELECTRONIC CONSTRUCTION TECHNIQUES
Transistors and integrated circuits designed around a metal-oxide substrate can be particularly sensitive to high voltages, regardless of the current level. These components include MOSFET transistors, CMOS integrated circuits, and most computer microprocessors.
7.8.1 STORING STATIC-SENSITIVE COMPONENTS Plastic is one of the greatest sources of static electricity. Storage and shipping containers are often made of plastic, and it’s a great temptation to dump your static-sensitive devices into these containers. Don’t do it. Invariably, static electricity will develop, and the component could be damaged. Unfortunately, there’s no way to tell if a static-sensitive part has become damaged by electrostatic discharge just by looking at it, so you won’t know things are amiss until you actually try to use the component. At first, you’ll think the circuit has gone haywire or that your wiring is at fault. If you’re like most, you won’t blame the transistors and ICs until well after you’ve torn the rest of the circuit apart. It’s best to store static-sensitive components using one of the following methods. All work by grounding the leads of the IC or transistor together, which diminishes the effect of a strong jolt of static electricity. Note that none of these storage methods is 100 percent foolproof.
•
•
•
Anti-static mat. This mat looks like a black sponge, but it’s really conductive foam. You can (and should) test this by placing the leads of a volt-ohm meter on either side of a length of the foam. Dial the meter to ohms. You should get a reading instead of an open circuit. The foam can easily be reused, and large sheets make convenient storage pads for many components. Anti-static pouch or bag. Anti-static pouches are made of a special plastic (which generates little static) and are coated on the inside with a conductive layer. The bags are available in a variety of forms. Many are a smoky black or gray; others are pink or jet black. As with mats, you should never assume a storage pouch is anti-static just from its color. Check the coating on the inside with a volt-ohm meter—its resistance should be in the 10k to 1 MΩ range. Anti-static tube. The vast majority of chips are shipped and stored in convenient plastic tubes. These tubes help protect the leads of the IC and are well suited to automatic manufacturing techniques. The construction of the tube is similar to the anti-static pouch: plastic on the outside, a thin layer of conductive material on the inside. You can often get tubes from electronic supply stores by just asking for leftover tubes that would normally be thrown away. It is a good idea to only put one type of chip in each tube, label the tube, and keep the same family of chips together. This will make finding specific components much easier.
7.8.2 TIPS TO REDUCE STATIC Consider using any and all of the following simple techniques to reduce and eliminate the risk of electrostatic discharge.
•
Wear low-static clothing and shoes. Your choice of clothing can affect the amount of static buildup in your body. Whenever possible, wear natural fabrics such as cotton or
7.9 GOOD DESIGN PRINCIPLES
• • •
91
wool. Avoid wearing polyester and acetate clothing, as these tend to develop large amounts of static. Use an anti-static wrist strap. The wrist strap grounds you at all times and prevents static buildup. The strap is one of the most effective means for eliminating electrostatic discharge, and it’s one of the least expensive. Ground your soldering iron. If your soldering pencil operates from AC current, it should be grounded. A grounded iron not only helps prevent damage from electrostatic discharge; it also lessens the chance of receiving a bad shock should you accidentally touch a live wire. Use component sockets. When you build projects that use ICs, install sockets first. When the entire circuit has been completely wired, you can check your work, then add the chips. Note that some sockets are polarized so the component will fit into them one way only. Be sure to observe this polarity when wiring the socket.
7.9 Good Design Principles While building circuits for your robots, observe the good design principles described in the following sections, even if the schematic diagrams you are working from don’t include them.
7.9.1 PULL-UP RESISTORS When a digital electronic chip input is left unconnected or floating, the value presented at the input is indeterminate. This is especially true for CMOS chips, which use the gates of MOSFET chips as inputs (TTL inputs are automatically high when inputs are left floating). To ensure that the inputs values are a known value, a pull up should be used or, if the input must be low during operation, then an inverted pull up (shown in Fig. 7-8) should be used. Pull-down resistors on logic inputs should be avoided because of the low resistance (less than 150 Ω) required to ensure TTL inputs are at a low value. To raise the input to a high value, a high-current source must be applied to the input pin to overcome the pull-down resistor. The pull-up resistor can be a relatively high value (10k or more) to minimize any possible power drain and allow simple changes to logic without large current flows.
7.9.2 USE BYPASS CAPACITORS Some electronic components, especially fast-acting logic chips, generate a lot of noise in the power supply lines. You can reduce or eliminate this noise by putting bypass (so-called decoupling) capacitors between the +V and ground rails of all chips as close to the power supply pins as possible, as shown in Fig. 7-9. Suggested values are 0.01 µF to 0.1 µF. If you are using polarized parts, be sure to properly orient the capacitor.
7.9.3 KEEP LEAD LENGTHS SHORT Long leads on components can introduce noise in other parts of a circuit. The long leads also act as a virtual antenna, picking up stray signals from the circuit, from overhead light-
92
ELECTRONIC CONSTRUCTION TECHNIQUES
Output of Inverter is Low due to Pull Up Resistor
10k Optional Switch Tying to Ground
Logic Output FIGURE 7-8 When an input has to be held low, use an inverted pull up as shown here. This will allow easy logic level changing for circuit test.
ing, and even from your own body. When designing and building circuits, strive for the shortest lead lengths on all components. This means soldering the components close to the board and clipping off any excess lead length, and if you are breaking any connections cut the wires or PCB traces as close to the chip pin as possible.
7.9.4 AVOID GROUND LOOPS A ground loop is when the ground wire of a circuit comes back and meets itself. The +V and ground of your circuits should always have dead ends to them. Ground loops can cause erratic behavior due to excessive noise in the circuit, which can be very difficult to track down to a root cause.
+V
Bypass or decoupling capacitor
IC
Ground
FIGURE 7-9 Add decoupling capacitors near the power and ground pins of integrated circuits.
7.10 FROM HERE
7.10 From Here To learn more about . . .
Read
Tools for circuit construction
Chapter 6, “Tools”
Where to find electronic components
Chapter 4, “Buying Parts”
Where to find mechanical parts
Chapter 4, “Buying Parts”
Understanding components used in electronic circuitry
Chapter 5, “Electronic Components”
93
This page intentionally left blank
PA R T
ROBOT PLATFORM CONSTRUCTION
Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
2
This page intentionally left blank
CHAPTER
8
PLASTIC PLATFORMS
I
t all started with billiard balls. A couple of hundred years ago, billiard balls were made from elephant tusks. By the 1850s, the supply of tusk ivory was drying up and its cost had skyrocketed. So, in 1863 Phelan & Collender, a major manufacturer of billiard balls, offered a $10,000 prize for anyone who could come up with a suitable substitute for ivory. A New York printer named John Wesley Hyatt was among several folks who took up the challenge. Hyatt didn’t get the $10,000. His innovation, celluloid, was too brittle to be used for billiard balls. But while Hyatt’s name won’t go down in the billiard parlor hall of fame, he will be remembered as the man who started the plastics revolution. Hyatt’s celluloid was perfect for such things as gentlemen’s collars, ladies’ combs, containers, and eventually even motion picture film. In the more than 100 years since the introduction of celluloid, plastics have taken over our lives. Plastic is sometimes the object of ridicule—from plastic money to plastic furniture—yet even its critics are quick to point out its many advantages.
• • •
Plastic is cheaper per square inch than wood, metal, and most other construction materials. Certain plastics are extremely strong, approaching the tensile strength of such light metals as copper and aluminum. Some plastic is unbreakable.
Plastic is an ideal material for use in hobby robotics. Its properties are well suited for numerous robot designs, from simple frame structures to complete assemblies. Read this chapter 97 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
98
PLASTIC PLATFORMS
to learn more about plastic and how to work with it. At the end of the chapter, we’ll show you how to construct an easy-to-build differentially driven robot—the Minibot—from inexpensive and readily available plastic parts. Included in the robot design is a simple wired (or tethered) remote control that can be used in the other example robots in this section.
8.1 Types of Plastics Plastics represent a large family of products. Plastics often carry a fancy trade name, like Plexiglas, Lexan, Acrylite, Sintra, or any of a dozen other identifiers. Some plastics are better suited for certain jobs, so it will benefit you to have a basic understanding of the various types of plastics. Here’s a short rundown of the plastics you may encounter.
•
•
• • • •
• •
ABS. Short for acrylonitrile butadiene styrene, ABS is most often used in sewer and wastewater plumbing systems. The large black pipes and fittings you see in the hardware store are made of ABS. It is a glossy, translucent plastic that can take on just about any color and texture. It is tough, hard, and yet relatively easy to cut and drill. Besides plumbing fittings, ABS also comes in rods, sheets, and pipes—and as LEGO plastic pieces! Acrylic. Acrylic is clear and strong, the mainstay of the decorative plastics industry. It can be easily scratched, but if the scratches aren’t too deep they can be rubbed out. Acrylic is somewhat tough to cut because it tends to crack, and it must be drilled carefully. The material comes mostly in sheets, but it is also available in extruded tubing, in rods, and in the coating in pour-on plastic laminate. Cellulosics. Lightweight and flimsy but surprisingly resilient, cellulosic plastics are often used as a sheet covering. Their uses in robotics are minor. One useful application, however, stems from the fact that cellulosics soften at low heat, and thus they can be slowly formed around an object. These plastics come in sheet or film form. Epoxies. Very durable, clear plastic, epoxies are often used as the binder in fiberglass. Epoxies most often come in liquid form, so they can be poured over something or onto a fiberglass base. The dried material can be cut, drilled, and sanded. Nylon. Nylon is tough, slippery, self-lubricating stuff that is most often used as a substitute for twine. Plastics distributors also supply nylon in rods and sheets. Nylon is flexible, which makes it moderately hard to cut. Phenolics. An original plastic, phenolics are usually black or brown, easy to cut and drill, and smell terrible when heated. The material is usually reinforced with wood or cotton bits or laminated with paper or cloth. Even with these additives, phenolic plastics are not unbreakable. They come in rods and sheets and as pour-on coatings. The only application of phenolics in robotics is as circuit board material. Polycarbonate. Polycarbonate plastic is a close cousin of acrylic but more durable and resistant to breakage. Polycarbonate plastics are slightly cloudy and are easy to mar and scratch. They come in rods, sheets, and tube form. A common, inexpensive windowglazing material, polycarbonates are hard to cut and drill without breakage. Polyethylene. Polyethylene is lightweight and translucent and is often used to make flexible tubing. It also comes in rod, film, sheet, and pipe form. You can reform the material by applying low heat, and when the material is in tube form you can cut it with a knife.
8.1 TYPES OF PLASTICS
• •
• •
•
99
Polypropylene. Like polyethylene, polypropylene is harder and more resistant to heat. Polystyrene. Polystyrene is a mainstay of the toy industry. This plastic is hard, clear (though it can be colored with dyes), and cheap. Although often labeled high-impact plastic, polystyrene is brittle and can be damaged by low heat and sunlight. Available in rods, sheets, and foamboard, polystyrene is moderately hard to cut and drill without cracking and breaking. Polyurethane. These days, polyurethane is most often used as insulation material, but it’s also available in rod and sheet form. The plastic is durable, flexible, and relatively easy to cut and drill. PVC. Short for polyvinyl chloride, PVC is an extremely versatile plastic best known as the material used in freshwater plumbing and in outdoor plastic patio furniture. Usually processed with white pigment, PVC is actually clear and softens in relatively low heat. PVC is extremely easy to cut and drill and almost impervious to breakage. PVC is supplied in film, sheet, rod, tubing, even nut-and-bolt form in addition to being shaped into plumbing fixtures and pipes. Silicone. Silicone is a large family of plastics in its own right. Because of their elasticity, silicone plastics are most often used in molding compounds. Silicone is slippery and comes in resin form for pouring.
Table 8-1 lists the different types of plastics used for different household applications.
TABLE 8-1
Plastics in Everyday Household Articles
HOUSEHOLD ARTICLE
TYPE OF PLASTIC
Bottles, containers • Clear • Translucent or opaque
• Polyester, PVC • Polyethylene, polypropylene
Buckets, washtubs
Polyethylene, polypropylene
Foam cushions
Polyurethane foam, PVC foam
Electrical circuit boards
Laminated epoxies, phenolics
Fillers • Caulking compounds • Grouts • Patching compounds • Putties
• Polyurethane, silicone, PVC • Silicone, PVC • Polyester, fiberglass • Epoxies, polyester, PVC
Films • Art film • Audio tape • Food wrap • Photographs
• Cellulosics • Polyester • Polyethylene, polypropylene • Cellulosics (continued)
100
PLASTIC PLATFORMS
TABLE 8-1
Plastics in Everyday Household Articles (Continued )
HOUSEHOLD ARTICLE
TYPE OF PLASTIC
Glasses (drinking) • Clear, hard • Flexible • Insulated cups
• Polystyrene • Polyethylene • Styrofoam (polystyrene foam)
Hoses, garden
PVC
Insulation foam
Polystyrene, polyurethane
Lubricants
Silicones
Plumbing pipes • Fresh water • Gray water
• PVC, polyethylene, ABS • ABS
Siding and paneling
PVC
Toys • Flexible • Rigid
• Polyethylene, polypropylene • Polystyrene, ABS
Tubing (clear or translucent)
Polyethylene, PVC
8.2 Working with Plastics The actions of cutting, drilling, painting, choosing, etc. plastics can be overwhelming if you don’t have the basic information. Different plastics have different characteristics that will affect how they are handled and formed and whether or not they are appropriate for an application. In the following, common plastics used in robots are discussed along with information regarding how to work with them.
8.2.1 HOW TO CUT PLASTIC Soft plastics may be cut with a sharp utility knife. When cutting, place a sheet of cardboard or artboard on the table. This helps keep the knife from cutting into the table, which could ruin the tabletop and dull the knife. Use a carpenter’s square or metal rule when you need to cut a straight line. Prolong the blade’s life by using the rule against the knife holder, not the blade. Most sheet plastic comes with a protective peel-off plastic on both sides. Keep it on when cutting—not only will it protect the surface from scratches and dings but it can also be marked with a pencil or pen when you are planning your cuts. Harder plastics can be cut in a variety of ways. When cutting sheet plastic less than 1⁄8-in thick, use a utility knife and metal carpenter’s square to score a cutting line. If necessary, use clamps to hold down the square. Carefully repeat the scoring two or three times to deepen the cut. Place a 1⁄2- or 1-in
8.2 WORKING WITH PLASTICS
101
dowel under the plastic so the score line is on the top of the dowel. With your fingers or the palms of your hands, carefully push down on both sides of the score line. If the sheet is wide, use a piece of 1-by-2 or 2-by-4 lumber to exert even pressure. Breakage and cracking is most likely to occur on the edges, so press on the edges first, then work your way toward the center. Don’t force the break. If you can’t get the plastic to break off cleanly, deepen the score line with the utility knife. Thicker sheet plastic, as well as extruded tubes, pipes, and bars, must be cut with a saw. If you have a table saw, outfit it with a plywoodpaneling blade. Among other applications, this blade can be used to cut plastics. You cut through plastic just as you do with wood, but the feed rate (the speed at which the material is sawed in two) must be slower. Forcing the plastic or using a dull blade heats the plastic, causing it to deform and melt. A band saw is ideal for cutting plastics less than 1⁄2-in thick, especially if you need to cut corners. When working with a power saw, use fences or pieces of wood held in place by C-clamps to ensure a straight cut. You can use a handsaw to cut smaller pieces of plastic. A hacksaw with a medium- or fine-tooth blade (24 or 32 teeth per inch) is a good choice. You can also use a coping saw (with a fine-tooth blade) or a razor saw. These are good choices when cutting angles and corners as well as when doing detail work. A motorized scroll (or saber) saw can be used to cut plastic, but you must take care to ensure a straight cut. If possible, use a piece of plywood held in place by C-clamps as a guide fence. Routers can be used to cut and score plastic, but unless you are an experienced router user you should not attempt this method.
8.2.2 HOW TO DRILL PLASTIC Wood drill bits can be used to cut plastics, but bits designed for glass drilling yield better, safer results. If you use wood bits, you should modify them by blunting the tip slightly (otherwise the tip may crack the plastic when it exits the other side). Continue the flute from the cutting lip all the way to the end of the bit (see Fig. 8-1). Blunting the tip of the bit isn’t hard
Cutting lip Standard bit
Modified bit
FIGURE 8-1 Suggested modifications for drill bits used with plastic. The end is blunted and the flutes are extended to the end of the cutting tip.
102
PLASTIC PLATFORMS
to do, but grinding the flute is a difficult proposition. The best idea is to invest in a few glass or plastic bits, which are already engineered for drilling plastic. Drilling with a power drill provides the best results. The drill should have a variable speed control. Reduce the speed of the drill to about 500 to 1000 r/min when using twist bits, and to about 1000 to 2000 r/min when using spade bits. When drilling, always back the plastic with a wooden block. Without the block, the plastic is almost guaranteed to crack. When using spade bits or brad-point bits, drill partially through from one side, then complete the hole by drilling from the other side. As with cutting, don’t force the hole and always use sharp bits. Too much friction causes the plastic to melt. To make holes larger than 1⁄4 in you should first drill a smaller, pilot hole. If the hole is large, over 1⁄4 in in diameter, start with a small drill and work your way up several steps. You should practice drilling on a piece of scrap material until you get the technique right.
8.2.3 HOW TO BEND AND FORM PLASTIC Most rigid and semirigid plastics can be formed by applying low localized heat. A sure way to bend sheet plastic is to use a strip heater. These are available ready-made at some hardware and plastics supply houses, or you can build your own. A narrow element in the heater applies a regulated amount of heat to the plastic. When the plastic is soft enough, you can bend it into just about any angle you want. There are two important points to remember when using a strip heater. First, be sure that the plastic is pliable before you try to bend it. Otherwise, you may break it or cause excessive stress at the joint (a stressed joint will look cracked or crazed). Second, bend the plastic past the angle that you want. The plastic will relax a bit when it cools off, so you must anticipate this. Knowing how much to overbend will come with experience, and it will vary depending on the type of plastic and the size of the piece you’re working with. You can mold thinner sheet plastic around shapes by first heating it up with a hair dryer or heat gun, then using your fingers to form the plastic. Be careful that you don’t heat up the plastic too much. You don’t want it to melt, just conform to the underlying shape. You can soften an entire sheet or piece by placing it into an oven for 10 or so minutes (remove the protective plastic before baking). Set the thermostat to 300°F and be sure to leave the door slightly ajar so any fumes released during the heating can escape. Ventilate the kitchen and avoid breathing the fumes, as they can be noxious. All plastics release gases when they heat up, but the fumes can be downright toxic when the plastic actually ignites. Therefore, avoid heating the plastic so much that it burns. Dripping, molten plastic can also seriously burn you if it drops on your skin.
8.2.4 HOW TO POLISH THE EDGES OF PLASTIC Plastic that has been cut or scored usually has rough edges. You can file the edges of cut PVC and ABS using a wood or metal file. You should polish the edges of higher-density plastics like acrylics and polycarbonates by sanding, buffing, or burnishing. Try a fine-grit (200 to 300), wet–dry sandpaper and use it wet. Buy an assortment of sandpapers and try several until you find the coarseness that works best with the plastic you’re using. You can apply jeweler’s rouge, available at many hardware stores in large blocks, by using a polishing wheel. The wheel can be attached to a grinder or drill motor.
8.2 WORKING WITH PLASTICS
103
Burnishing involves using a very low temperature flame (a match or lighter will do) to melt the plastic slightly. You can also use a propane torch kept some distance from the plastic. Be extremely careful when using a flame to burnish plastic. Don’t let the plastic ignite, or you’ll end up with an ugly blob that will ruin your project, not to mention filling the room with poisonous gas.
8.2.5 HOW TO GLUE PLASTIC Most plastics aren’t really glued together; they are melted using a solvent that is often called cement. The pieces are fused together—that is, made one. Household adhesives can be used for this, of course, but you get better results when you use specially formulated cements. Herein lies a problem. The various plastics we have described rarely use the same solvent formulations, so you’ve got to choose the right adhesive. That means you have to know the type of plastic used in the material you are working with (see Table 8-1). Using Table 8-2, you can select the recommended adhesives for attaching plastics. When using solvent for PVC or ABS plumbing fixtures, apply the cement in the recommended manner by spreading a thin coat on the pieces to be joined. A cotton applicator is included in the can of cement. Plastic sheet, bars, and other items require more careful cementing, especially if you want the end result to look nice. With the exception of PVC solvent, the cement for plastics is watery thin and can be applied in a variety of ways. One method is to use a small painter’s brush, with a #0 or #1 tip. Joint the pieces to be fused together and paint the cement onto the joint with the brush. Capillary action will draw the cement into the joint, where it will spread out. Another method is to fill a special syringe applicator with cement. With the pieces butted together, squirt a small amount of cement into the joint line. In all cases, you must be sure that the surfaces at the joint of the two pieces are perfectly flat and that there are no voids where the cement may not make ample contact. If you are
TABLE 8-2
Plastic Bonding Guide
PLASTIC TYPE
CEMENT TO ITSELF, USE
CEMENT TO OTHER PLASTIC, USE
CEMENT TO METAL, USE
ABS
ABS–ABS solvent
Rubber adhesive
Epoxy
Acrylic
Acrylic solvent
Epoxy
Contact cement
Cellulosics
White glue
Rubber adhesive
Contact cement
Polystyrene
Model glue
Epoxy
CA glue*
Polystyrene foam
White glue
Contact cement
Contact cement
Polyurethane
Rubber adhesive
Epoxy, contact cement
Contact cement
PVC
PVC–PVC solvent
PVC–ABS (to ABS)
Contact cement
(*CA stands for cyanoacrylate ester, sometimes known as Super Glue, after a popular brand name.)
104
PLASTIC PLATFORMS
joining pieces whose edges you cannot make flush, apply a thicker type of glue, such as contact cement or white household glue. You may find that you can achieve a better bond by first roughing up the joints to be mated. You can use coarse sandpaper or a file for this purpose. After applying the cement, wait at least 15 minutes for the plastic to fuse and the joint to harden. Disturbing the joint before it has time to set will permanently weaken it. Remember that you cannot apply cement to plastics that have been painted. If you paint the pieces before cementing them, scrape off the paint and refinish the edges so they’re smooth again.
8.2.6 USING HOT GLUE WITH PLASTICS Perhaps the fastest way to glue plastic pieces together is to use hot glue. You heat the glue to a viscous state in a glue gun, then spread it over the area to be bonded. Hot-melt glue and glue guns are available at most hardware, craft, and hobby stores in several different sizes. The glue is available in a normal and a low-temperature form. Low-temperature glue is generally better with most plastics because it avoids the sagging or softening of the plastic sometimes caused by the heat of the glue. One caveat when working with hot-melt glue and guns (other than the obvious safety warnings) is that you should always rough up the plastic surfaces before trying to bond them. Plastics with a smooth surface will not adhere well when using hot-melt glue, and the joint will be brittle and perhaps break off with only minor pressure. By roughing up the plastic, the glue has more surface area to bond to, resulting in a strong joint. Roughing up plastic before you join pieces is an important step when using any glue or cement (with the exception of CA), but it is particularly important when using hot-melt glue.
8.2.7 HOW TO PAINT PLASTICS Sheet plastic is available in transparent or opaque colors, and this is the best way to add color to your robot projects. The colors are impregnated in the plastic and can’t be scraped or sanded off. However, you can also add a coat of paint to the plastic to add color or to make it opaque. Most plastics accept brush or spray painting. Spray painting is the preferred method for jobs that don’t require extra-fine detail. Carefully select the paint before you use it, and always apply a small amount to a scrap piece of plastic before painting the entire project. Some paints contain solvents that may soften the plastic. One of the best all-around paints for plastics is the model and hobby spray cans made by Testor. These are specially formulated for styrene model plastic, but the paint adheres well without softening on most plastics. You can purchase this paint in a variety of colors, in either gloss or flat finish. The same colors are available in bottles with self-contained brush applicators. If the plastic is clear, you have the option of painting on the front or back side (or both for that matter). Painting on the front side will produce the paint’s standard finish: gloss colors come out gloss; flat colors come out flat. Flat-finish paints tend to scrape off easier, however, so exercise care. Painting on the back side with gloss or flat paint will only produce a glossy appearance because you look through the clear plastic to the paint on the back side. Moreover, painting imperfections will more or less be hidden, and external scratches won’t mar the paint job.
8.3 BUILD THE MINIBOT
105
8.2.8 BUYING PLASTIC Some hardware stores carry plastic, but you’ll be sorely frustrated at their selection. The best place to look for plastic—in all its styles, shapes, and chemical compositions—is a plastics specialty store, a sign-making shop, or a hobby shop. Most larger cities have at least one plastic supply store or sign-making shop that’s open to the public. Look in the Yellow Pages under Plastics—Retail. Another useful source is the plastics fabricator. There are actually more of these than retail plastic stores. They are in business to build merchandise, display racks, and other plastic items. Although they don’t usually advertise to the general public, most will sell to you. If the fabricator doesn’t sell new material, ask to buy the leftover scrap.
8.2.9 PLASTICS AROUND THE HOUSE You need not purchase plastic for all your robot needs at a hardware or specialty store. You may find all the plastic you really need right in your own home. Here are a few good places to look:
•
•
• • •
Used compact discs (CDs). CDs, made from polycarbonate plastics, are usually just thrown away and not recycled. With careful drilling and cutting, you can adapt them to serve as body parts and even wheels for your robots. Exercise caution when working with CDs: they can shatter when you drill and cut them, and the pieces are very sharp and dangerous. Old phonograph records. Found in the local thrift store, records—particularly the thicker 78-r/min variety—can be used in much the same way as CDs and laser discs. The older records made from the 1930s through 1950s used a thicker plastic that is very heavy and durable. Thrift stores are your best bet for old records no one wants anymore (who is that Montovani guy, anyway?). Note that some old records, like the V-Discs made during World War II, are collector’s items, so don’t wantonly destroy a record unless you’re sure it has no value. Salad bowls, serving bowls, and plastic knickknacks. They can all be revived as robot parts. I regularly prowl garage sales and thrift stores looking for such plastic material. PVC irrigation pipe. This can be used to construct the frame of a robot. Use the short lengths of pipe left over from a weekend project. You can secure the pieces with glue or hardware or use PVC connector pieces (Ts, Ls, etc.). Old toys. Not only for structural materials but you can often find a selection of motors, gears, and driver circuitry that can be salvaged and used in your robot projects.
8.3 Build the Minibot You can use a small piece of scrap sheet acrylic to build the foundation and frame of the Minibot differentially driven robot. The robot is about 6 in2 and scoots around the floor or table on two small rubber tires. The basic version is meant to be wire-controlled, although in upcoming chapters you’ll see how to adapt the Minibot to automatic electronic control,
106
PLASTIC PLATFORMS
TABLE 8-3
Minibot Parts List
1
6-in-by-6-in acrylic plastic (1⁄16- or 1⁄8-in thick)
2
Small hobby motors with gear reduction
2
Model airplane wheels
1
31⁄2-in (approx.) 10⁄24 all-thread rod
1
6-in-diameter (approx.) clear plastic dome
1
Four-cell AA battery holder
Misc.
1
⁄2-in-by-8⁄32 bolts, 8⁄32 nuts, lock washers, 1⁄2-in-by-10⁄24 bolts, 10⁄24 nuts, lock washers, cap nuts
even remote control. The power source is a set of four AA flashlight batteries because they are small, lightweight, and provide more driving power than 9-V transistor batteries. The parts list for the Minibot can be found in Tables 8-3 and 8-4.
8.3.1 FOUNDATION OR BASE The foundation is clear or colored Plexiglas or some similar acrylic sheet plastic. The thickness should be at least 1⁄8 in, but avoid very thick plastic because of its heavy weight. The prototype Minibot used 1⁄8-in-thick acrylic, so there was minimum stress caused by bending or flexing. Cut the plastic as shown in Fig. 8-2. Remember to keep the protective paper cover on the plastic while you cut. File or sand the edges to smooth the cutting and scoring marks. The corners are sharp and can cause injury if the robot is handled by small children. You can easily fix this by rounding off the corners with a file. Find the center and drill a hole with a #10 bit. Fig. 8-2 also shows the holes for mounting the drive motors. These holes are spaced for a simple clamp mechanism that secures hobby motors commonly available on the market.
8.3.2 MOTOR MOUNT The small DC motors used in the prototype Minibot were surplus gear motors with an output speed of about 30 r/min. The motors for your Minibot should have a similar speed
TABLE 8-4
Minibot Remote Control Switch
1
Small electronic project enclosure
2
Double-pole, double-throw (DPDT) momentary switches, with center-off return
Misc.
Hookup wire (see text)
8.3 BUILD THE MINIBOT
107
1"
1" (approx.)
1" (approx.)
Drill (#10 Bit)
In center 1" (approx.)
1" (approx.) Drill (#10 Bit)
Hole Drill #19 Bit
Hole Drill #19 Bit Drill (#10 Bit)
1"
2" 6"
FIGURE 8-2 The cutting guide for the base of the plastic Minibot. The sets of two holes on either side are for the motor mount, and they should be spaced according to the specific mount you are using. Motors of different sizes and types will require different mounting holes.
because even with fairly large wheels, 30 r/min makes the robot scoot around the floor or a table at about 4 to 6 in/s. Choose motors small enough so they don’t crowd the base of the robot and add unnecessary weight. Remember that you have other items to add, such as batteries and control electronics. Use 3⁄8-in-wide metal mending braces to secure the motor (the prototype used plastic pieces from an old Fastech toy construction kit; you can use these or something similar). You may need to add spacers or extra nuts to balance the motor in the brace. Drill holes for 8 ⁄32 bolts (#19 bit), spaced to match the holes in the mending plate. Another method is to use small U-bolts, available at any hardware store. Drill the holes for the U-bolts and secure them with a double set of nuts. Attach the tires to the motor shafts. Tires designed for a radio-controlled airplane or race car are good choices. The tires are well made, and the hubs are threaded in standard screw sizes (the threads may be metric, so watch out!). On the prototype, the motor shaft was threaded and had a 4-40 nut attached on each side of the wheel. Fig. 8-3 shows a mounted motor with a tire attached. Installing the counterbalances completes the foundation-base plate. These keep the robot from tipping backward and forward along its drive axis. You can use small ball bearings, tiny
108
PLASTIC PLATFORMS
FIGURE 8-3 How the drive motors of the Minibot look when mounted. In the prototype Minibot the wheels were threaded directly onto the motor shaft. Note the gear-reduction system built onto the hobby motor.
casters, or—as was used on the prototype—the head of a 10⁄24 locknut. The locknut is smooth enough to act as a kind of ball bearing and is about the right size for the job. Attach the locknut with a 10⁄24-by-1⁄2-in bolt (if the bolt you have is too long to fit in the locknut, add washers or a 10⁄24 nut as a spacer).
8.3.3 TOP SHELL The top shell is optional, and you can leave it off if you choose. The prototype used a round display bowl 6 in in diameter that I purchased from a plastics specialty store. Alternatively, you can use any suitable half sphere for your robot, such as an inverted salad bowl. Feel free to use colored plastic. Attach the top by measuring the distance from the foundation to the top of the shell, taking into consideration the gap that must be present for the motors and other bulky internal components. Cut a length of 10⁄24 all-thread rod to size. The length of the prototype shaft was 31⁄2 in. Secure the center shaft to the base using a pair of 10⁄24 nuts and a tooth lock washer. Secure the center shaft to the top shell with a 10⁄24 nut and a 10⁄24 locknut. Use a tooth lock washer on the inside or outside of the shell to keep the shell from spinning loose.
8.3.4 BATTERY HOLDER You can buy battery holders that hold from one to six dry cells in any of the popular battery sizes. The Minibot motors, like almost all small hobby motors, run off 1.5 to 6 V. A four-
8.3 BUILD THE MINIBOT
109
cell, AA battery holder does the job nicely. The wiring in the holder connects the batteries in series, so the output is 6 V. Secure the battery holder to the base with 8⁄32 nuts and bolts. Drill holes to accommodate the hardware. Be sure the nuts and bolts don’t extend too far below the base or they may drag when the robot moves. Likewise, be sure the hardware doesn’t interfere with the batteries.
8.3.5 WIRING DIAGRAM The wiring diagram in Fig. 8-4 allows you to control the movement of the Minibot in all directions. This simple two-switch system, which will be used in many other projects in this book, uses double-pole, double-throw (DPDT) switches. The switches called for in the circuit are spring-loaded so they return to a center-off position when you let go of them. By using the dual pole double-throw switches, the electrical current passed to the motors changes direction as the switches are thrown from one extreme to the other. The actual connections are the same as what is used in an electrical H-bridge, which is discussed elsewhere in the book. For the hook-up wire used to connect the robot to the remote control box, you might want to try a 6-ft length of Cat-5 network cable; at least four wires must connect the robot to the remote control box (two for power and two for each motor). The color-coded and combined wires are ideal for an application like this.
V+ S1 DPDT Switch
(Bottom View)
Right Motor
Forward Reverse Off Switch Side View
S2 DPDT Switch
(Bottom View)
Left Motor
V-
Movement of contacts
FIGURE 8-4 Use this schematic for wiring the motor control switches for the Minibot. Note that the switches are double-pole, double-throw (DTDP), with a spring return to center-off.
110
PLASTIC PLATFORMS
8.4 From Here To learn more about . . .
Read
Wooden robots
Chapter 9, “Wooden Platforms”
Metal robots
Chapter 10, “Metal Platforms”
Using batteries
Chapter 17, “All About Batteries and Robot Power Supplies”
Selecting the right motor
Chapter 19, “Choosing the Right Motor for the Job”
Using a computer or microcontroller
Chapter 12, “An Overview of Robot ‘Brains’ ”
CHAPTER
9
WOODEN PLATFORMS
W
ood may not be high-tech, but it’s an ideal building material for hobby robots. Wood is available just about everywhere. It’s relatively inexpensive, easy to work with, and mistakes can be readily covered up, filled in, or painted over. In this chapter, using wood for robot structures will be presented and how you can apply simple woodworking skills to construct a basic wooden robot platform. This platform can then serve as the foundation for a number of robot designs you may want to explore.
9.1 Choosing the Right Wood There is good wood and there is bad wood. Obviously, you want the good stuff, but you have to be willing to pay for it. For reasons you’ll soon discover, you should buy only the best stock you can get your hands on. The better woods are available at specialty wood stores, particularly the ones that sell mostly hardwoods and exotic woods. Your local lumber and hardware store may have great buys on rough-hewn redwood planking, but it’s hardly the stuff of robots.
9.1.1 PLYWOOD The best overall wood for robotics use, especially for foundation platforms, is plywood. In case you are unfamiliar with plywood (Fig. 9-1), this common building material comes in 111 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
112
WOODEN PLATFORMS
Top View
Side View
Top Layer
Top Layer Middle Layer
Middle Layer
Bottom Layer Bottom Layer
Wood Grain Direction Indicator
FIGURE 9-1 Plywood is manufactured by laminating (gluing together) thin sheets of wood (called veneer). By changing the angle of the wood’s grain, the final plywood is stronger than a single piece of veneer three times thicker than the ones used.
many grades and is made by laminating thin sheets of wood together. The cheapest plywood is called shop grade, and it is the kind often used for flooring and projects where looks aren’t too important. The board is full of knots and knotholes, and there may be considerable voids inside the board, all of which detract from its strength. The remaining grades specify the quality of both sides of the plywood. Grade N is the best and signifies natural finish veneer. The surface quality of grade N really isn’t important to us, so we can settle for grade A. Since we want both sides of the board to be in good shape, a plywood with a grade of A-A (grade A on both sides) is desired. Grades B and C are acceptable, but only if better plywoods aren’t around. Depending on the availability of these higher grades, you may have to settle for A-C grade plywood (grade A on one side, grade C on the other). Most plywoods you purchase at the lumber stores are made of softwoods—usually fir and pine. You can get hardwood plywood as well through a specialty wood supplier or from hobby stores (ask for aircraft-quality plywood). Hardwood-based plywood is more desirable because it is more dense and less likely to chip. Don’t confuse hardwood plywood with hardboard. The latter is made of sawdust epoxied together under high pressure. Hardboard has a smooth finish; its close cousin, particleboard, does not. Both types are unsuitable for robotics because they are too heavy and brittle. Plywood comes in various thicknesses starting at about 5⁄16 in and going up to over 1 in. Thinner sheets are acceptable for use in a robotics platform if the plywood is made from hardwoods. When using construction-grade plywoods (the stuff you get at the home improvement store), a thickness in the middle of the range—1⁄2 or 3⁄8 in—is ideal.
9.1 CHOOSING THE RIGHT WOOD
113
Construction plywood generally comes in 4-by-8-ft panels. Hardwood plywoods, particularly material for model building, come in smaller sizes, such as 2 ft by 2 ft. You don’t need a large piece of plywood; the smaller the board, the easier it will be to cut to the exact size you need. Remember that most home improvement stores will cut wood for you—saving you the cost of buying power saws and doing it yourself. The professional-grade saws available at home improvement stores will make a straight, even cut and the staff is usually trained in making the cuts very accurately. Along with cutting the wood to the size you want, they may have leftover pieces for just a dollar or two that can be further cut down to the exact size you want.
9.1.2 PLANKING An alternative to working with plywood is planking. Use ash, birch, or some other solid hardwood. Stay away from the less meaty softwoods such as fir, pine, and hemlock. Most hardwood planks are available in widths of no more than 12 or 15 in, so you must take this into consideration when designing the platform. You can butt two smaller widths together if absolutely necessary. Use a router to fashion a secure joint, or attach metal mending plates to mate the two pieces together. (This latter option is not recommended; it adds a lot of unnecessary weight to the robot.) When choosing planked wood, be especially wary of warpage and moisture content. If you have a planer, which cuts down planks of wood into absolutely flat and square pieces and the unit you have can handle the relatively thin and small pieces to be used in robots, then you can select the wood based on its grain and quality. If you don’t have a planer, take along a carpenter’s square, and check the squareness and levelness of the lumber in every possible direction. Reject any piece that isn’t perfectly square; you’ll regret it otherwise. Defects in premilled wood go by a variety of colorful names, such as crook, bow, cup, twist, wane, split, shake, and check, but they all mean headache to you. Wood with excessive moisture may bow and bend as it dries, causing cracks and warpage. These can be devastating in a robot you’ve just completed and perfected. Buy only seasoned lumber stored inside the lumberyard, not outside. Watch for green specks or grains—these indicate trapped moisture. If the wood is marked, look for an MC specification. An MC-15 rating means that the moisture content doesn’t exceed 15 percent, which is acceptable. Good plywoods and hardwood planks meet or exceed this requirement. Don’t get anything marked MC-20 or higher or marked S-GREEN—bad stuff for robots.
9.1.3 BALSA Yes, you’ve read correctly, balsa wood can be useful as part of a robot structure. Balsa is very light (and strong for its density), easily shaped, and readily available in different sizes in virtually all hobby shops throughout the world. It has a number of other properties that make it well suited for robot applications, not only for prototyping complex parts due to the ease in which it can be cut and formed and glued together in other pieces. You might think that it’s understated to say that balsa is a softwood; you have probably pressed your thumbnail into a piece at some time and been amazed how easy it is to put an
114
WOODEN PLATFORMS
imprint into the wood. This property along with its ability to absorb vibration make it ideal as a lining for fragile parts mounts. By buying a thick enough piece of balsa, chances are that you can replace the entire hold down with a piece having similar strength, as well as being much lighter. The major consumer of balsa is not the model airplane industry, as you might have thought, but the liquid natural gas (LNG) industry as an insulator for large LNG tanks. There may be cases where parts of your robot are hot and placed in close proximity to other parts that are temperature sensitive. Before trying to come up with a fan or redesign solution, why don’t you try a small piece of balsa, cut to size. You will probably discover that the balsa will help separate the different temperature areas effectively for a small amount of work and cost. Note that an insulator is not a heat sink or a heat removal device like a fan. If you are using balsa to separate a device that has to stay cool beside one that becomes very hot, make sure that there is a way for the heat from the hot device to leave the robot. Encasing the part in a balsa box to keep heat from affecting other parts will result in the part becoming very hot and eventually burning out or catching fire.
9.1.4 DOWELS Wood dowels come in every conceivable diameter, from about 1⁄16 to over 11.2 in. Wood dowels are 3 or 4 ft in length. Most dowels are made of high-quality hardwood, such as birch or ash. The dowel is always cut lengthwise with the grain to increase strength. Other than choosing the proper dimension, there are few considerations to keep in mind when buying dowels. You should, however, inspect the dowel to make sure it is straight. At the store, roll the dowel on the floor. It should lie flat and roll easily. Warpage is easy to spot. Dowels can be used either to make the frame of the robot or as supports and uprights.
9.2 The Woodcutter’s Art You’ve cut a piece of wood in two before, haven’t you? Sure you have; everyone has. You don’t need any special tools or techniques to cut wood for a robot platform. The basic shop cutting tools will suffice: a handsaw, a backsaw, a circular saw, a jigsaw (if the wood is thin enough for the blade), a table saw, a radial arm saw, or—you name it. Whatever cutting tool you use, make sure the blade is the right one for the wood. For example, the combination blade that probably came with your power saw isn’t the right choice for plywood and hardwood. Outfit the saw with a cutoff blade or a plywoodpaneling blade. Both have many more teeth per inch. Handsaws generally come in two versions: crosscut and ripsaw. You need the crosscut kind. If you are unfamiliar with the proper use of the tools that you are planning on using, you should go to your local library to look up books on woodworking, or find out when your local home improvement center is having classes on tool usage. Using the right tools and blades along with learning a few tips will make the work go much smoother and faster and result in a better finished product.
9.4 FINISHING
115
9.3 Cutting and Drilling You can use a hand or motor tools to cut and drill through wood. The choice isn’t important and is really a personal one. The most critical parameter, however, is to make sure that you only use sharp cutting tools and drill bits. If your bits or saw teeth are dull, replace them or have them sharpened. Unless otherwise required, all cuts into wood are perpendicular (90 degrees) to its surface and, in most cases, the edges are also perpendicular to one another. To ensure that the cuts are at the proper angle, you should use either a miter box with your handsaw or a powered miter saw. These tools will help ensure that the cuts you make are at the correct angles and are as accurate as possible. It’s important that you drill straight holes, or your robot will not assemble properly. If your drill press is large enough, you can use it to drill perfectly straight holes in plywood and other large stock. Otherwise, use a portable drill stand. These attach to the drill or work in a number of other ways to guarantee a hole perpendicular to the surface of the material. Before cutting or drilling, remember the carpenter’s adage: “Measure twice and cut once.”
9.4 Finishing You can easily shape wood using rasps and files. If the shaping you need to do is extensive— like creating a circle in the middle of a large plank—you may want to consider getting a handheld rotary cutter. Be careful if you are thinking about buying a simple rotary rasp for your drill; the bearings within a drill are designed for vertical loads, not side-to-side loads and by using a cutter with your drill, you may end up ruining it. After cutting the wood down into the desired shape, use increasingly finer grades of sandpaper followed by the painting process outlined in the following. The process outlined here will require just a few minutes to accomplish (over a few days, allowing for the paint to dry) and will allow you to create finished pieces of material (wood, metal, and plastic) that will have the functional benefits of: 1. Eliminating the dust on the surface of the material, allowing for effective two-sided tape
attachment to (and removal from). Eliminating the fibers in wood also will allow for more effective glue bonds. 2. Smoothing the surface and reducing the lifted fibers that appear when wood gets moist or wet over time. 3. Eliminating splinters and sharp edges when handling the robot and minimizing surface splintering when drilling into wood. 4. Allowing for pencil and ink markings of the surface to be easily wiped off for corrections. This is not possible with bare wood, metal, or plastic. I tend to just use aerosol paint—when properly used there is very little mess and no brushes to clean up. From an auto-body supply house, you should buy an aerosol can of primer
116
WOODEN PLATFORMS
(gray is always the first choice) and from a hardware store buy an aerosol can of indoor/ outdoor (or marine) acrylic paint in your favorite color. Red catches the eye, isn’t overwhelming, and will hide any blemishes in the wood or your work. Set up a painting area in a garage or some other well-ventilated area by laying down newspaper both on a flat surface as well as a vertical surface. Next, lay down bottle caps to be used as supports for the materials that you are going to be painting. You don’t have to use bottle caps—scraps of wood or other detritus can be just as effective—just make sure that when you are painting something you care about that the supports are smaller than the perimeter of the object being finished. You will want to finish the ends of the plywood and don’t want to end up with paint flowing between the plywood and the support. Lightly sand the surfaces of the material you are going to paint. You may want to sand the edges of the strips more aggressively to take off any loose wood that could become splinters. Once you have finished, moisten a rag and wipe it over the surface you have sanded to pick up any loose dust. Shake the can of primer using the instructions printed on the can. Usually there is a small metal ball inside the can and you will be instructed to shake it until the ball rattles easily inside. Start with the two plywood strips that have been left over. Place one end on the bottle caps, supporting the surface to be painted and spray about 6 in of the strip, starting at the supported end. Most primers take 30 minutes or so to dry. Check the instructions on the can before going on to the next step of sanding and putting on new coats of paint or primer. After the first application of primer, you will probably find that the surface of the wood is very rough. This is due to the cut fibers in the wood standing on end after being moistened from the primer. Repeat the sanding step (along with sanding the ends of the wood and wiping down with the damp rag) before applying another coat of primer. After the second coat is put down, let it dry, sand very lightly, and wipe down again. Now you are ready to apply the paint. Shake according to instructions on the can and spray the plywood strips, putting on a thin, even coat. You will probably find that the paint will seem to be sucked into the wood and the surface will not be that shiny. This is normal. Once the paint has dried, lightly sand again, wipe down with a wet cloth, and apply a thicker coat of paint. When this coat has dried, you’ll find that the surface of the plywood is very smooth and shiny. You do not have to sand the paint again. The plywood is now ready to be used in a robot.
9.5 Building a Wooden Motorized Platform Figs. 9.2 and 9.3 show approaches for constructing a basic square and round motorized wooden platform, respectively. See Table 9-1 for a list of the parts you’ll need. To make the square plywood platform shown in Fig. 9-2, cut a piece of 3⁄8- or 1⁄2-in plywood to 10 by 10 in (the thinner 3⁄8-in material is acceptable if the plywood is the heavy-duty hardwood variety, such as aircraft-quality plywood). Make sure the cut is square. Notch the wood as shown to make room for the robot’s wheels. The notch should be large enough to
9.5 BUILDING A WOODEN MOTORIZED PLATFORM
117
Plywood
10"
2"
6" 6"
FIGURE 9-2 Cutting plan for a square plywood base.
accommodate the width and diameter of the wheels, with a little breathing room to spare. For example, if the wheels are 6 in diameter and 1.5 in wide, the notch should be about 6.5 by 1.75 in. To make a motor control switch for this platform, see the parts list in Table 8-4 in Chapter 8.
Cut Circle
Center Hole
FIGURE 9-3 Cutting plan for a round plywood base.
10"
118
WOODEN PLATFORMS
TABLE 9-1
Parts List For Wood Base
Base
10″ by 10″ 3⁄8″ to 1⁄2″ thick plywood
2
DC gear motors
2
5″ to 7″ rubber wheels
1
11⁄4″ caster wheel
2
2″ by 4″ lumber (see text)
1
4× “D” cell battery holder
Misc.
1″ by 10⁄24 stove bolts, 3″ by 10⁄24 stove bolts, 10⁄24 nuts and flat washers, 11⁄4″ by 8⁄32 stove bolts, 8⁄32 nuts, flat washers, and lock washers
Fig. 9-3 shows the same 10-in-square piece of 3⁄8- or 1⁄2-in plywood cut into a circle. Use a scroll saw and circle attachment for cutting. As you did for the square platform, make a notch in the center beam of the circle to allow room for the wheels—the larger the wheel, the larger the notch.
9.5.1 ATTACHING THE MOTORS The wooden platform you have constructed so far is perfect for a fairly sturdy robot, so the motor you choose can be powerful. Use heavy-duty motors, geared down to a top speed of no more than about 75 r/min; 30 to 40 r/min is even better. Anything faster than 75 r/min will cause the robot to dash about at speeds exceeding a few miles per hour, which is unacceptable unless you plan on entering your creation in the sprint category of the Robot Olympics. Note: you can use electronic controls to reduce the speed of the gear motor by 15 or 20 percent without losing much torque, but you should not slow the motor too much or you’ll lose power. The closer the motor operates at its rated speed, the better results you’ll have. Throttling motors will be discussed later in the book. If the motors have mounting flanges and holes on them, attach them using corner brackets. Some motors do not have mounting holes or hardware, so you must fashion a holddown plate for them. You can make an effective hold-down plate, as shown in Fig. 9-4, out of 2 by 4 lumber. Round out the plate to match the cylindrical body of the motor casing. Then secure the plate to the platform. Last, attach the wheels to the motor shafts. You may need to thread the shafts with a die so you can secure the wheels. Use the proper size nuts and washers on either side of the hub to keep the wheel in place. You’ll make your life much easier if you install wheels that have a setscrew. Once they are attached to the shaft, tighten the setscrew to screw the wheels in place.
9.5.2 STABILIZING CASTER Two motors and a centered caster, attached to the robot’s base as depicted in Fig. 9-5, allows you to have full control over the direction your robot travels. You can make the robot
9.5 BUILDING A WOODEN MOTORIZED PLATFORM
119
8/32 Nut (Length determined by thickness of wood block)
A
Flat Washer Tooth Lockwasher Nut
Side View
B
Motor
Top View FIGURE 9-4 One way to secure the motors to the base is to use a wood block hollowed out to match the shape of the motor casing. a. Side view; b. Top view.
turn by stopping or reversing one motor while the other continues turning. Attach the caster using four 8⁄32-by-1-in bolts. Secure the caster with tooth lock washers and 8⁄32 nuts. The caster should be mounted so that the robot base is level and it can swivel with a minimum of resistance. You may, if necessary, use spacers to increase the distance from the base plate of the caster to the bottom of the platform. If the caster end of the robot is much higher than the wheels, then the motor mounting bolts or the rear of the robot might rub on the ground. If this is the case, you should be looking at using a smaller caster, larger wheels, or mounting the motors on the bottom of the robot base.
9.5.3 BATTERY HOLDER You can purchase battery holders that contain from one to six dry cells in any of the popular battery sizes. When using 6-V motors, you can use a four-cell D battery holder. You can
120
WOODEN PLATFORMS
Motors and DriveWheels
A
Caster
Top
Bottom
1" x 8/32 Bolt
Platform
B
Tooth Lockwasher Nut Caster
FIGURE 9-5 Attaching the caster to the platform. a. Top and bottom view; b. caster hardware assembly detail.
also use a single 6-V lantern or rechargeable battery. Motors that require 12 V will need two battery holders, two 6-V batteries, or one 12-V battery (motorcycle batteries are often excellent power sources for robots, which require 12 V and a fair amount of current). For the prototype, 6-V motors and a four-cell D battery holder were used. Secure the battery holder(s) to the base with 8⁄32 nuts and bolts. Drill holes to accommodate the hardware. Be sure the nuts and bolts don’t extend too far below the base or they may drag when the robot moves. Likewise, be sure the hardware doesn’t interfere with the batteries. Wire the batteries and wheels to the DPDT through control switches, as shown in the Minibot project described at the end of Chapter 8, “Plastic Platforms.” One switch controls the left motor; the other switch controls the right motor.
9.6 FROM HERE
121
9.6 From Here To learn more about . . .
Read
Plastic robots
Chapter 8, “Plastic Platforms”
Metal robots
Chapter 10, “Metal Platforms”
Using batteries
Chapter 17, “All about Batteries and Robot Power Supplies”
Selecting the right motor
Chapter 19, “Choosing the Right Motor for the Job”
Using a computer or microcontroller
Chapter 12, “An Overview of Robot ‘Brains’ ”
This page intentionally left blank
CHAPTER
10
METAL PLATFORMS
FIGURE 10-1 The completed Buggybot.
M
etal is perhaps the best all-around material for building robots because it offers better strength than other materials. If you’ve never worked with metal before, you shouldn’t worry; there is really nothing to it. The designs outlined in this chapter and the chapters that follow will show you how to construct robots both large and small out of readily available metal stock, without resorting to welding or custom machining.
123 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
124
METAL PLATFORMS
10.1 Working with Metal If you have the right tools, working with metal is only slightly harder than working with wood or plastic. You’ll have better-than-average results if you always use sharpened, wellmade tools. Dull, bargain-basement tools can’t effectively cut through aluminum or steel stock. Instead of the tool doing most of the work, you do.
10.1.1 MARKING CUT LINES AND DRILL HOLE CENTERS Marking metal for cutting and drilling is more difficult than other materials due to its increased hardness and resistance to being permanently marked by inks. Professional metal workers scratch marking lines in metal using a tool called a scratch awl; it can be purchased at hardware stores for just a few dollars. You’ll find that when you drill metal the bit will skate all over the surface until the hole is started. You can eliminate or reduce this skating by using a punch prior to drilling. There are spring-loaded punches that simply require you to press down on them before they snap and pop a small indentation in the material. You can also buy punches that require a hammer to make the indentation, but the spring-loaded ones are easier to work with and do not cost a lot more.
10.1.2 CUTTING To cut metal, use a hacksaw outfitted with a fine-tooth blade, one with 24 or 32 teeth per inch. Coping saws, keyhole saws, and other handsaws are generally engineered for cutting wood, and their blades aren’t fine enough for metal work. You can use a power saw, like a table saw or reciprocating saw, but, again, make sure that you use the right blade. For large aluminum or steel angle stock, an abrasive cutter is invaluable and will make short work of any cuts—remember that the cut ends will be hot for quite a while after the cutting process! You’ll probably do most of your cutting by hand. You can help guarantee straight cuts by using an inexpensive miter box. You don’t need anything fancy, but try to stay away from the wooden boxes. They wear out too fast. The hardened plastic and metal boxes are the best buys. Be sure to get a miter box that lets you cut at 45 degrees both vertically and horizontally. Firmly attach the miter box to your workbench using hardware or a large clamp.
10.1.3 DRILLING Metal requires a slower drilling speed than wood, and you need a power drill that either runs at a low speed or lets you adjust the speed to match the work. Variable speed power drills are available for under $30 these days, and they’re a good investment. Be sure to use only sharp drill bits. If your bits are dull, replace them or have them sharpened. Quite often, buying a new set is cheaper than professional sharpening. When it comes to working with metal, particularly channel and pipe stock, you’ll find a drill press is a godsend. It improves accuracy, and you’ll find the work goes much faster. Always use a proper vise when working with a drill press. Never hold the work with your
10.2 BUILD THE BUGGYBOT
125
hands. Especially with metal, the bit can snag as it’s cutting and yank the piece out of your hands. If you can’t place the work in the vise, clamp it to the cutting table.
10.1.4 BENDING One of the biggest challenges you will have when working with metal parts in your robots will be bending them accurately and evenly. When you go to your first robot competitions, you will no doubt see a few robots that look like they were run over by an eighteen-wheeler and hammered back into shape; hopefully you weren’t critical; working metal into the desired shape is a challenge. So much so that when you first start working with metal on your own, you probably will want to avoid building robots that require any bent metal. It should not be surprising that different types of metals require different methods for bending. Steel bar stock, for example, can have a sharp angle bent into it by placing it in a vise at the point of the bend and then hitting it with a hammer to force the bend to the desired angle. Gentle bends in steel require more sophisticated tools; but you could use the equipment designed to bend steel for wrought iron fencing. Aluminum stock, on the other hand, is just about impossible to bend in a home workshop. Using the techniques described for bending aluminum will result in it cracking or even breaking off. If you must use aluminum, then you should either use bar stock cut and fastened together or have a piece of stock milled to the desired shape. Different forms of metal also are treated differently. The techniques previously discussed are not appropriate for sheet metal. Bending sheet metal is best accomplished using a sheet metal brake, which will bend the sheet metal (steel, aluminum, or copper) to any desired angle. Modest brakes can be purchased for about $100 from better machine shop supply houses (which you can find in the Yellow Pages).
10.1.5 FINISHING Cutting and drilling often leave rough edges, called flashing, in the metal. These edges must be filed down using a medium- or fine-pitch metal file, or else the pieces won’t fit together properly. A rotary tool with a carbide wheel will make short work of the flashing. Aluminum flash comes off quickly and easily; you need to work a little harder when removing the flash in steel or zinc stock.
10.2 Building the Buggybot The Buggybot is a small robot built from a single 6-by-12-in sheet of 1⁄16-in-thick aluminum, nuts, and bolts, and a few other odds and ends. You can use the Buggybot as the foundation and running gear for a very sophisticated petlike robot. As with the robots built with plastic and wood we discussed in the previous two chapters, the basic design of the all-metal Buggybot can be enhanced just about any way you see fit. This chapter details the construction of the framework, locomotion, and power systems for a wired remote control robot. Future chapters will focus on adding more sophisticated features, such as wireless remote control, automatic navigation, and collision avoidance and detection. Refer to Table 10-1 for a list of the parts needed to build the Buggybot.
126
METAL PLATFORMS
TABLE 10-1 Parts List for Buggybot (see parts list in Table 8-4 of Chapter 8 for motor control switch) 1
6-by-12-in sheet of 1⁄16-in-thick aluminum for the frame
2
Tamiya high-power gearbox motors (from kit—see text)
2
3-in-diameter Lite Flight foam wheels
2
5
2
3
1
Two-cell D battery holder
1
11⁄2-in swivel caster misc
Misc.
1-in-by-6⁄32 stove bolts, nuts, flat washers, 1⁄2-in-by-6⁄32 stove bolts, nuts, tooth lock washers, flat washers (as spacers)
⁄56 nuts (should be included with the motors) ⁄16-in collars with setscrews
10.2.1 FRAMEWORK Build the frame of the Buggybot from a single sheet of 1⁄16-in-thick aluminum sheet. This sheet, measuring 6 by 12 in, is commonly found at hobby stores. As this is a standard size, there’s no need to cut it. Follow the drill-cutting template shown in Fig. 10-2. After drilling, use a large shop vise or woodblock to bend the aluminum sheet as shown in Fig. 10-3. Accuracy is not all that important. The angled bends are provided to give the Buggybot its unique appearance.
10.2.2 MOTORS AND MOTOR MOUNT The prototype Buggybot uses two high-power gearbox motor kits from Tamiya, which are available at many hobby stores (as well as Internet sites, such as TowerHobbies.com). These motors come with their own gearbox; choose the 1:64.8 gear ratio. An assembled motor is shown in Fig. 10-4. Note that the output shaft of the motor can be made to protrude a variable distance from the body of the motor. Secure the shaft (using the Allen setscrew that is included) so that only a small portion of the opposite end of the shaft sticks out of the gearbox on the other side, as shown in Fig. 10-4. You should secure the gearboxes and motors to the aluminum frame of the Buggybot as depicted in Fig. 10-5. Use 6⁄32 bolts, flat washers, and nuts. Be sure that the motors are aligned as shown in the drawing. Note that the shaft of each motor protrudes from the side of the Buggybot. Fig. 10-6 illustrates how to attach the wheels to the shafts of the motors. The wheels used in the prototype were 3-in-diameter foam Lite Flight tires, commonly available at hobby stores. Secure the wheels in place by first threading a 3⁄16-in collar (available at hobby stores) over the shaft of the motor. Tighten the collar in place using its Allen setscrew. Then cinch the wheel onto the shaft by tightening a 5⁄56 threaded nut to the end of the motor shaft (the nut should be included with the gearbox motor kit). Be sure to tighten down on the nut so the wheel won’t slip.
10.2 BUILD THE BUGGYBOT
127
Drill Holes for Caster Plate 6" by 12" Aluminum Sheet 5 1/2"
3/8" 1 7/8"
(Same)
1 1/2"
FIGURE 10-2 Drilling diagram for the Buggybot frame.
10.2.3 SUPPORT CASTER The Buggybot uses the two-wheel-drive tripod arrangement. You need a caster on the other end of the frame to balance the robot and provide a steering swivel. The 11⁄2-in swivel caster is not driven and doesn’t do the actual steering. Driving and steering are taken care of by the drive motors. Referring to Fig. 10-7, attach the caster using two 6⁄32 by 1⁄2-in bolts and nuts. Note that the mechanical style of the caster, and indeed the diameter of the caster wheel, is dependent on the diameter of the drive wheels. Larger drive wheels will require either a different mounting or a larger caster. Small drive wheels will likewise require you to adjust the caster mounting and possibly use a smaller-diameter caster wheel.
128
METAL PLATFORMS
1 1/2"
4 1/2"
6"
FIGURE 10-3 Bend the aluminum sheet at the approximate angles shown here.
10.2.4 BATTERY HOLDER The motors require an appreciable amount of current, so the Buggybot really should be powered by heavy-duty C- or D-size cells. The prototype Buggybot used a two-cell D battery holder. The holder fits nicely toward the front end of the robot and acts as a good coun-
Tire
Nut
Motor and Gearbox
Motor Shaft
Coupler (with Setscrew) Output Gear (with Setscrew) FIGURE 10-4 Secure the output shaft of the motor so that almost all of the shaft sticks out on one side of the motor.
10.2 BUILD THE BUGGYBOT
129
1/2" x 6/32 Bolt Base Mounting Flange Nut
Motor Gearbox FIGURE 10-5 The gearboxes and motors are attached to the frame of the Buggybot using ordinary hardware.
terweight. You can secure the battery holder to the robot using double-sided tape or hookand-loop (Velcro) fabric.
10.2.5 WIRING DIAGRAM The basic Buggybot uses a manual wired switch control. The control is the same one used in the plastic Minibot detailed in Chapter 8, “Plastic Platforms.” Refer to the wiring diagram in Fig. 8-4 of that chapter for information on powering the Buggybot.
FIGURE 10-6 Attach the foam wheels (with plastic hubs) for the Buggybot onto the shafts of the motors.
130
METAL PLATFORMS
1/2" x 6/32 Bolt Base Tooth Lockwasher Nut Caster
FIGURE 10-7 Mounting the caster to the Buggybot.
To prevent the control wire from interfering with the robot’s operation, attach a piece of heavy wire (the bottom rail of a coat hanger will do) to the caster plate and lead the wire up it. Use nylon wire ties to secure the wire. The completed Buggybot is shown in Fig. 10-1.
10.3 Test Run You’ll find that the Buggybot is an amazingly agile robot. The distance it needs to turn is only a little longer than its length, and it has plenty of power to spare. There is room on the robot’s front and back to mount additional control circuitry. You can also add control circuits and other enhancements over the battery holder. Just be sure that you can remove the circuit(s) when it comes time to change or recharge the batteries.
10.4 From Here To learn more about . . .
Read
Plastic robots
Chapter 8, “Plastic Platforms”
Metal robots
Chapter 9, “Wooden Platforms”
Using batteries
Chapter 17, “All about Batteries and Robot Power Supplies”
Selecting the right motor
Chapter 19, “Choosing the Right Motor for the Job”
Using a computer or microcontroller
Chapter 12, “An Overview of Robot ‘Brains’ ”
CHAPTER
11
HACKING TOYS
R
eady-made toys can be used as the basis for more complex home-brew hobby robots. The toy industry is robot crazy, and you can buy a basic motorized or unmotorized robot for parts, building on it and adding sophistication and features. Snap or screwtogether kits, such as the venerable Erector set, let you use premachined parts for your own creations. And some kits, like LEGO and Robotix, are even designed to create futuristic motorized robots and vehicles. You can use the parts in the kits as-is or cannibalize them, modifying them in any way you see fit. Because the parts already come in the exact or approximate shape you need, the construction of your own robots is greatly simplified. About the only disadvantage to using toys as the basis for more advanced robots is that the plastic and lightweight metal used in the kits and finished products are not suitable for a homemade robot of any significant size or strength. You are pretty much confined to building small minibot or scooterbot-type robots from toy parts. Even so, you can sometimes apply toy parts to robot subsystems, such as a light-duty arm-gripper mechanism installed on a larger automaton. In the following sections, a number of different toys and building sets are discussed and their appropriateness for use as robots. Let’s take a closer look at using toys in your robot designs in this chapter, and examine several simple, cost-effective designs using readily available toy construction kits.
131 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
132
HACKING TOYS
11.1 A Variety of Construction Sets Toy stores are full of plastic put-together kits and ready-made robot toys that seem to beg you to use them in your own robot designs. Here are some toys you may want to consider for your next project.
11.1.1 ERECTOR SET The Erector set, now sold by Meccano, has been around since the dawn of time—or so it seems. The kits, once made entirely of metal but now commonly including many plastic pieces, come in various sizes and are generally designed to build a number of different projects. Many kits are engineered for a specific design with perhaps provisions for moderate variations. Among the useful components of the kits are prepunched metal girders, plastic and metal plates, tires, wheels, shafts, and plastic mounting panels. You can use any as you see fit, assembling your robots with the hardware supplied with the kit or with 6⁄32 or 8⁄32 nuts and bolts. Several Erector sets, such as those in the action troopers collection, come with wheels, construction beams, and other assorted parts that you can use to construct a robot base. Motors are typically not included in these kits, but you can readily supply your own. Because Erector set packages regularly come and go, what follows is a general guide to building a robot base. You’ll need to adapt and reconfigure based on the Erector set parts you have on hand. The prepunched metal girders included in the typical Erector set make excellent motor mounts. They are lightweight enough that they can be bent, using a vise, into a U-shaped motor holder. Bend the girder at the ends to create tabs for the bolts, or use the angle stock provided in an Erector set kit. The basic platform is designed for four or more wheels, but the wheel arrangement makes it difficult to steer the robot. The design presented in Fig. 11-1 uses only two wheels. The platform is stabilized using a miniature swivel caster at one end. You’ll need to purchase the caster at the hardware store. Note that the shafts of the motors are not directly linked to the wheels. The shaft of the wheels connects to the base plate as originally designed in the kit. The drive motors are equipped with rollers, which engage against the top of the wheels for traction. You can use a metal or rubber roller, but rubber is better. The pinch roller from a discarded cassette tape player is a good choice, as is a 3⁄8-in beveled bibb washer, which can be found in the plumbing section of the hardware store. You can easily mount a battery holder on the top of the platform. Position the battery holder in the center of the platform, toward the caster end. This will help distribute the weight of the robot. The basic platform is now complete. You can attach a dual-switch remote control, as described earlier in the book, or automatic control circuitry as will be outlined in later chapters. Do note that over the years the Erector set brand has gone through many owners. Parts from old Erector sets are unlikely to fit well with new parts. This includes but is not limited to differences in the threads used for the nuts and bolts. If you have a very old Erector set (such as those made and sold by Gilbert), you’re probably better off keeping them as collector’s items rather than raiding them for robotic parts. The very old Erector sets of the 1930s through 1950s fetch top dollar on the collector’s market (when the sets are in good, complete condition, of course).
11.1 A VARIETY OF CONSTRUCTION SETS
A
Drive Motor Rubber Roller
133
Motor Clamp
Base
Wheel Swivel Side View
B
Drive Wheels
Caster
FIGURE 11-1 Constructing the motorized base for a robot using Erector set (Meccano) parts. a. Attaching the motor and drive roller over the wheel; b. Drive wheel-caster arrangement.
Similarly, today’s Meccano sets are only passably compatible with the English-made Meccano sets sold decades ago. Hole spacing and sizes have varied over the years, and mixing and matching is neither practical nor desirable.
11.1.2 ROBOTIX The Robotix kits, originally manufactured by Milton-Bradley and now sold by Learning Curve, are specially designed to make snap-together walking and rolling robots. Various kits are available, and many of them include at least one motor (additional motors are available separately). You control the motors using a central switch pad. Pushing the switch forward turns the motor in one direction; pushing the switch back turns the motor in the other direc-
134
HACKING TOYS
tion. The output speed of the motors is about 6 r/min, which makes them a bit slow for moving a robot across the room but perfect for arm-gripper designs. The structural components in the Robotix kits are molded from high-impact plastic. You can connect pieces together to form just about anything. One useful project is to build a robotic arm using several of the motors and structural components. The arm can be used by itself as a robotic trainer or attached to a larger robot. It can lift a reasonable 8 oz or so, and its pincher claw is strong enough to firmly grasp most small objects. While the Robotix kit allows you to snap the pieces apart when you’re experimenting, the design presented here is meant to be permanent. Glue the pieces together using plastic model cement or contact cement. Cementing is optional, of course, and you’re free to try other, less permanent methods to secure the parts together, such as small nuts and bolts, screws, or Allen setscrews. When cemented, the pieces hold together much better, and the arm is considerably stronger. Remember that, once cemented, the parts cannot be easily disassembled, so make sure that your design works properly before you commit to it. When used as a stand-alone arm, you can plug the shoulder motor into the battery holder or base. You don’t need to cement this joint. Refer to Fig. 11-2 as you build the arm. Temporarily attach a motor (call it motor 1) to the Robotix battery holder–base plate. Position the motor so that the drive spindle points straight up. Attach a double plug to the drive spindle and the end connector of another motor (motor 2). Position this motor so that the drive spindle is on one side. Next, attach another double plug and an elbow to the drive spindle of motor 2. Attach the other end of the elbow connector to a beam arm.
FIGURE 11-2 The robot arm constructed with parts from a Robotix construction kit.
11.1 A VARIETY OF CONSTRUCTION SETS
135
Connect a third motor (motor 3) to the large connector on the opposite end of the beam arm. Position this motor so the drive spindle is on the other end of the beam arm. Attach a double plug and an elbow between the drive spindle of motor 3 and the connector opposite the drive spindle of the fourth motor (motor 4). The two claw levers directly attach to the drive spindle of motor 4. Motorize the joints by plugging in the yellow power cables between the power switch box and the motor connectors. Try each joint, and note the various degrees of freedom. Experiment with picking up various objects with the claw. Make changes now before disassembling the arm and cementing the pieces together. After the arm is assembled, route the wires around the components, making sure there is sufficient slack to permit free movement. Attach the wires to the arm using nylon wire ties.
11.1.3 LEGO LEGO has become the premier construction toy, for both children and adults. The LEGO Company, parent company of the LEGO brand, has expanded the line as educational resources, making the ubiquitous LEGO bricks as well as parts suitable for small engineering projects (the Technic line) common in schools across the country and around the world. Along with buying kits, you can buy specific parts directly from LEGO or from a variety of sites on the Internet. LEGO also makes the Mindstorms, a series of sophisticated computerized robots that can be programmed in a variety of different ways. Along with Mindstorms, LEGO makes the Spytech set of robots, which can be used to learn more about behavior-based programming. These tools are excellent for the beginner and can be enhanced with more sophisticated programming environments when you become more comfortable with programming and electronics. LEGO bricks and parts are excellent for prototyping robot systems, but there are some issues that you should be aware of when you are planning to build a robot from them. First, the bricks do not hold together well in any kind of vibration. You can try gluing them together, but this largely defeats the purpose of having a reconfigurable assembly system. The final issue that you should be aware of is that LEGO bricks and parts are quite heavy for their size, which can cause a problem with some robot designs.
11.1.4 CAPSULA Capsula is a popular snap-together motorized parts kit that uses unusual tube and sphere shapes. Capsula kits come in different sizes and have one or more gear motors that can be attached to various components. The kits contain unique parts that other put-together toys don’t, such as a plastic chain and chain sprockets or gears. Advanced kits come with remote control and computer circuits. All the parts from these kits are interchangeable. The links of the chain snap apart, so you can make any length of chain that you want. Combine the links from many kits and you can make an impressive drive system for an experimental lightweight robot.
11.1.5 FISCHERTECHNIK The Fischertechnik kits, made in Germany and imported into North America by a few educational companies, are the Rolls-Royces of construction toys. Actually, toy isn’t the proper
136
HACKING TOYS
term because the Fischertechnik kits are not just designed for use by small children. In fact, many of the kits are meant for high school and college industrial engineering students, and they offer a snap-together approach to making working electromagnetic, hydraulic, pneumatic, static, and robotic mechanisms. All the Fischertechnik parts are interchangeable and attach to a common plastic base plate. You can extend the lengths of the base plate to just about any size you want, and the base plate can serve as the foundation for your robot, as shown in Fig. 11-3. You can use the motors supplied with the kits or use your own motors with the parts provided. Because of the cost of the Fischertechnik kits, you may not want to cannibalize them for robot components. But if you are interested in learning more about mechanical theory and design, the Fischertechnik kits, used as-is, provide a thorough and programmed method for jumping in with both feet.
11.1.6 K’NEX K’Nex uses unusual half-round plastic spokes and connector rods (see Fig. 11-4) to build everything from bridges to Ferris wheels to robots. You can build a robot with just K’Nex parts or use the parts in a larger, mixed-component robot. For example, the base of a walking robot may be made from a thin sheet of aluminum, but the legs might be constructed from various K’Nex pieces.
FIGURE 11-3 A sampling of Fischertechnik parts.
11.1 A VARIETY OF CONSTRUCTION SETS
137
FIGURE 11-4 K’Nex sets let you create physically large robots that weigh very little. The plastic pieces form very sturdy structures when properly connected.
A number of K’Nex kits are available, from simple starter sets to rather massive specialpurpose collections (many of which are designed to build robots, dinosaurs, or robot dinosaurs). Several of the kits come with small gear motors so you can motorize your creation. Motors that interface to K’Nex parts are also available separately.
11.1.7 ZOOB Zoob (made by Primordial) is a truly unique form of construction toy. A Zoob piece consists of a stem with a ball or socket on either end. You can create a wide variety of construction projects by linking the balls and sockets together. The balls are dimpled so they connect securely within their sockets. One practical application of Zoob is to create armatures for human- or animal-like robots. The Zoob pieces work in a way similar to bone joints.
11.1.8 CHAOS Chaos sets are designed for structural construction projects: bridges, buildings, working elevator lifts, and the like. The basic Chaos set provides beams and connectors, along with chutes, pulleys, winches, and other construction pieces. Add-on sets are available that contain parts to build elevators, vortex tubes, and additional beams and connectors.
138
HACKING TOYS
11.1.9 OTHER CONSTRUCTION TOYS There are many other construction toys that you may find handy. Check the nearest wellstocked toy store or a toy retailer on the Internet for the following:
• • • • • •
Expandagon Construction System (Hoberman) Fiddlestix Gearworks (Toys-N-Things) Gears! Gears! Gears! (Learning Resources) PowerRings (Fun Source) Zome System (Zome System) Construx (no longer made, but sets may still be available for sale)
Perhaps the most frequently imitated construction set has been the Meccano/Erector set line. Try finding these imitators, either in new, used, or thrift stores:
• • •
Exacto Mek-Struct Steel Tec
11.2 Specialty Toys for Robot Hacking Some toys and kits are just made for hacking (retrofitting, remodeling) into robots. Some are already robots, but you may design them to be controlled manually instead of interfacing to control electronics. The following sections describe some specialty toys you may wish to experiment with.
11.2.1 ROBOSAPIEN Robosapien is a humanoid robot created by Mark Tilden, the inventor of BEAM robotics. The robot itself is controlled by an infrared remote control and can either perform individual actions (move a leg or an arm, grunt, or grasp) or they can be programmed into a sequence of instructions that the robot will follow. Along with this rudimentary sequenced programming ability, the Robosapien also has a number of sensors (including collision sensors in its feet) that can be used to cause the robot to respond to its environment (again in a very simple manner). Since its introduction in late 2003, the Robosapien has been the target of many different hacks, including coming up with ways to create sequences on a computer rather than through the remote control and replacing the central processor in the robot with either a programmable microcontroller or even a PDA, which provides a much higher level of control. These hacks are well documented on a variety of different web sites, and there are a number of books detailing how the Robosapien is constructed and what can be done to modify it.
11.2.2 TAMIYA Tamiya is a manufacturer of a wide range of radio-controlled models. It also sells a small selection of gearboxes in kit form that you can use for your robot creations. One of the most
11.2 SPECIALTY TOYS FOR ROBOT HACKING
139
useful is a dual-gear motor, which consists of two small motors and independent drive trains. You can connect the long output shafts to wheels, legs, or tracks. Tamiya also sells a dual-motor, tracked tractor-shovel kit (see Fig. 11-5) that you control via a switch panel. You can readily substitute the switch panel with computerized control circuitry that will provide for full forward and backward movement of the tank treads as well as the up and down movement of the shovel.
11.2.3 OWIKITS AND MOVITS The OWIKITS and MOVITS robots are precision-made miniature robots in kit form. A variety of models are available, including manual (switch) and microprocessor-based versions. The robots can be used as-is, or they can be modified for use with your own electronic systems. For example, the OWIKIT Robot Arm Trainer (model OWI007) is normally operated by pressing switches on a wired control pad. With just a bit of work, you can connect the wires from the arm to a computer interface (with relays, for example) and operate the arm via software control. For the most part, the kits can be fairly easily hacked but you will have to design your own motor drivers (which is an important point as will be discussed later in the chapter). The kit comes with an interesting dual motor that operates the left and right treads. Most of the OWIKITS and MOVITS robots come with preassembled circuit boards; you are expected to assemble the mechanical parts. Some of the robots use extremely small parts and require a keen eye and steady hand. The kits are available in three skill levels: beginner, intermediate, and advanced. If you’re just starting out, try one or two kits in the beginner level.
FIGURE 11-5 The Tamiya Bulldozer kit can be used as a lightweight robot platform.
140
HACKING TOYS
11.2.4 ROKENBOK Rokenbok toys are radio-controlled construction vehicles that take the form of both wheeled and tracked versions. Despite the European-sounding name, Rokenbok toys are made in the United States and have recently become available through mass-market retailers (the beginner’s kit costs around $80). Each vehicle is controlled by a game controller; all the game controllers are connected to a centralized radio transmitter station. The Sony PlayStation-style controllers can be hacked and connected directly to the input/output (I/O) of a computer or microcontroller (similar to what is shown in Chapter 16). The transmitter station also has a connector for computer control, but as of this writing Rokenbok has not released the specifications or an interface for this port.
11.3 Robots from Converted Vehicles Motorized toy cars, trucks, and tractors can make ideal robot platforms—with an afternoon’s or evening’s work they can be modified to run under switch remote control or computer control, as will be shown in this section. The least expensive radio-controlled cars have a single drive motor and a separate steering servo or solenoid mechanism. Despite what many people think, they can be fairly easily modified into robots although the car-type steering gives them less agility (i.e., the ability to literally turn on a dime) than a tracked vehicle. When hacking these vehicles, care must be taken to ensure you understand how steering is accomplished and you will have to go through the circuitry to ensure that your computer control can drive it. Most radio- and wire-controlled tractor vehicles or simple toys with differential drives are well suited for conversion into a robot. You will have to strip off the vehicle’s body and probably modify the electronics that come with the robot as well as add some of your own. Turning a robot by changing the direction of wheels or tracks does produce a lot of drag; when modifying these toys into robots it is important to keep the weight of the modifications as low as possible. When considering a vehicle for hacking into a robot, look at how it is powered and consider whether or not it is appropriate—small remote controlled cars that run off a single 1.2 V NiMH battery can be modified into a microcontroller controlled robot, but some work will be required to add a boost power supply for the microcontroller as well as a fairly comprehensive review of the drive electronics to ensure that the correct current is passed to the motor drivers. When you are doing this for the first time, it is easier to select a toy that is powered by three or four AA cells. Another option is to use two small motorized vehicles (mini four-wheel-drive trucks are perfect), remove the wheels on opposite sides, and mount them on a robot platform. Your robot uses the remaining wheels for traction. Each of the vehicles is driven by a single motor, but since you have two vehicles (see Fig. 11-6), you still gain independent control of both wheel sides. The trick is to make sure that, whatever vehicles you use, they are the same exact type. Variations in design (motor, wheel, etc.) will cause your robot to crab to one side as it attempts to travel a straight line. The reason: the motor in one vehicle will undoubtedly run a little slower or faster than the other, and the speed differential will cause your robot to veer off course.
11.3 ROBOTS FROM CONVERTED VEHICLES
Modified Motor
141
Removed Wheel
Base
FIGURE 11-6 You can build a motorized robot platform by cannibalizing two small motorized toys and using each “half” of them.
11.3.1 HACKING A TOY INTO A ROBOT The toy chosen for hacking into a robot was the differentially driven, radio remote control robot shown in Fig. 11-7. The toy was purchased as part of a set of two at a local hardware store for less than $10. This may seem like an incredibly lucky find (a remote control vehicle for only $5), but by keeping your eyes open you will discover that there are many endof-life toys that can be modified into a robot quite easily. The body of the toy car was held on by four bolts and was easily removed (Fig. 11-8). The screws holding down the PCB were removed, giving access to the circuitry side of the PCB (Fig. 11-9) as well as the motors, allowing the the snubber circuit built into them to be observed. When hacking a remote control toy, you are well advised to use as much of the existing circuitry as possible. At one end of the PCB, you will see a number of transistors (at the top of Fig. 11-9) that are wired to the drive motors. These transistors and the resistors associated with them should be used as the motor drivers for your robot. What you should look for are four resistors connected between the transistors and the radio receiver. You could trace out the circuit used for the motor drivers and compare it to the ones shown in Chapter 20, but it is much easier to find the four resistors leading between the two parts of the PCB and cut the PCB at this point as shown in Fig. 11-10. Before cutting, if you are unsure about the purpose of these transistors, desolder one of the resistors at the receiver side and connect it to the positive power of the toy; one set of wheels should start turning. If it doesn’t, then you have either not selected the correct resistors or power is not getting to all the necessary parts of the circuit for the wheels to turn. Once the PCB is cut, you can attach longer wires to the resistors (which will be used by the robot controller) and put heat shrink tubing over the joints. At this time, the toy’s power wiring and the four motor driver leads can be wired to a connector that will be attached to the controller board (Fig. 11-11). This may seem premature, but you have finished the electrical modifications to the toy to turn it into a robot!
142
HACKING TOYS
FIGURE 11-7 This remote control robot was purchased as a set of two for less than $10. The remote controls work at 27 and 49 MHz and the toys are powered by three AA alkaline batteries.
FIGURE 11-8 The body removed from the remote control car. Note that the component side of the PCB is facing downwards into the vehicle’s plastic chassis.
11.3 ROBOTS FROM CONVERTED VEHICLES
143
FIGURE 11-9 The remote control receiver PCB with motor drive transistors at the top.
Now, control electronics can be added to the toy to turn it into a robot. For the example toy in this section, a BASIC Stamp 2 (BS2) was added using the circuit shown in Fig. 11-12. The BS2 has a communications/programming interface built in and four I/O pins are used to control the operation of the toy’s motors. This circuit was built onto a prototyping PCB along with a mating connector for the toy’s motor drivers. Note that the BS2 is powered from the toy’s three AA batteries. Don’t worry if you don’t understand how the BASIC Stamp 2 works and how it can control the robot’s motors; the operation of the microcontroller and how it can be used as a robot controller is described in later chapters. Once the BS2 prototype PCB circuit was assembled, it was mounted to the robot by cutting down some pieces of phenolic PCB material, mounting 6-32 screws on them and epoxying them down to the robot/toy’s plastic chassis (Fig. 11-13). The BS2 prototype PCB was screwed down to the chassis using 6-32 acorn nuts, which, along with the six-pin connector to the chassis power supply and motors, allows the PCB to be removed for repair or modification. The completed robot (Fig. 11-14) is ready for action! To test the operation of the robot, the following program was used: ' ' ' '
BS2 Robot Move This Program Moves the Toy Based Robot Randomly
144
HACKING TOYS
FIGURE 11-10 The PCB is cut underneath the current limiting resistors, which pass the receiver’s control signals to the toy’s motor drivers.
FIGURE 11-11 Add extension wires to the motor driver resistors and bring them out to a connector.
11.3 ROBOTS FROM CONVERTED VEHICLES
145
1
0.1 uF
C2
Right Forward Right Reverse Left Forward Left Reverse
SOUT
VIN
24
2
SIN
VSS
23
3
ATN
_RES
22
4
VSS
VDD
21
5
P0
P15
20
6
P1
P14
19
7
P2
P13
18
8
P3
P12
17
9
P4
P11
16
10
P5
P10
15
11
P6
P9
14
12
P7
P8
13
BASIC Stamp 2
C1
1
Connector to Toy
FIGURE 11-12 The BASIC Stamp 2 control circuit for providing computer control of the hacked toy. More information about the BS2 and its operation can be found in Chapter 15.
FIGURE 11-13 Pieces of phenolic PCB material were cut down, drilled for 6-32 nylon bolts, and epoxyed into the toy’s plastic chassis to provide mounting for the BS2 PCB.
146
HACKING TOYS
' myke predko ' ' 05.09.19 ' '{&STAMP BS2} '{&PBASIC 2.5} ' I/O Ports RightForward RightReverse LeftForward LeftReverse ' Variables i VAR Byte '
PIN PIN PIN PIN
4 5 6 7
Mainline LOW LOW LOW LOW DO
RightForward RightReverse LeftForward LeftReverse
'
Make all the Motor Drives Output
'
Loop Forever
FIGURE 11-14 Ready to roll! The modifications to the toy are complete and the BS2 has been added and is ready for programming.
11.4 FROM HERE
HIGH RightForward HIGH LeftForward PAUSE 1500
'
Move Forward for 1.5 Seconds
LOW LeftForward PAUSE 750
'
Turn Left for 0.75 Seconds
147
LOOP
This program simply moves the robot forward for a second and a half and then turns left before repeating. The BS2 PCB and mounting hardware weigh quite a bit less than the original toy’s chassis, and the toy, which was already quite fast, is extremely fast with the lighter modifications in place. To be able to effectively use the robot, a PWM will have to be put in place to throttle down the motors to get a more realistic and controllable operating speed for the robot. It should be noted that you will find figuring out the wiring of a hacked toy will rarely be as straightforward as the prototype shown here. Often, toys will use surface mount technology (SMT) components, which are much smaller and harder to trace than the oldfashioned pin through hole (PTH) components found in this toy. Remember that the radio circuitry is always separate from the motor driver circuitry on the PCB and the regular nature of the motor driver circuitry (consisting of multiple transistors and resistors) makes it quite easy to identify. Once you have identified the motor driver circuitry, you should be able to find the current limiting resistors for the motor driver transistors; from here it should be quite easy to work through the robot modification.
11.4 From Here To learn more about . . .
Read
Brains you can add to robots made from toys
Chapter 12, “An Overview of Robot ‘Brains’ ”
Using the BS2 Microcontroller
Chapter 15, “The BASIC Stamp 2 Microcontroller”
Overview of DC Motors
Chapter 20, “Working with DC Motors”
This page intentionally left blank
PA R T
3
COMPUTERS AND ELECTRONIC CONTROL
Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
This page intentionally left blank
CHAPTER
12
AN OVERVIEW OF ROBOT “BRAINS”
B
“
rain, brain, what is brain?” If you’re a Trekker, you know this is a line from one of the original Star Trek episodes entitled “Spock’s Brain.” The quality of the story notwithstanding (it is universally regarded as one of the worst, yet paradoxically one of the most popular), the episode was about how Spock’s brain was surgically removed by a race of temporarily hyperintelligent women who needed it to run their underground environmental control system. Dr. McCoy was able to create a control mechanism that would allow somebody to operate Spock’s brainless body in order for it to be present when the brain was found. Without its brain, Spock’s body was not much more than a remotely controlled model car; capable of performing some operations under direct human control, but not able to operate autonomously. The brains of a person or robot process information from the environment; then based on the programming or logic they determine the proper course of action. Without a brain of some type and the ability to respond to different environmental information, a robot is really nothing more than just a motorized toy. A computer of one type or another is the most common brain found in a robot. A robot control computer is seldom like a PC on your desk, though robots can certainly be operated by most any personal computer. And of course not all robot brains are computerized. A simple assortment of electronic components—a few transistors, resistors, and capacitors—is all that is really needed to make a rather intelligent robot. Endowing your robot with electronic smarts is a huge topic, so additional material is provided in the following chapters to help you understand how electronic sensors and actuators are interfaced to computers and how decisions are made on which actions to take.
151 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
152
AN OVERVIEW OF ROBOT “BRAINS”
12.1 Brains from Discrete Components You can use the wiring from discrete components (transistors, resistors, etc.) to control a robot. This book contains numerous examples of this type of brain, such as the line-tracing robot circuits in Chapter 33, “Navigation.” The line-tracing functionality is provided by just a few common integrated logic circuits and a small assortment of transistors and resistors. Light falling on either or both of two photodetectors causes motor relays to turn on or off. The light is reflected from a piece of tape placed on the ground. Fig. 12-1 shows another common form of robot brain made from discrete component parts. This brain makes the robot reverse direction when it sees a bright light. The circuit is simple, as is the functionality of the robot: light shining on the photodetector turns on a relay. Variations of this circuit could make the robot stop when it sees a bright light. By using two sensors, each connected to separate motors (much like the line-tracers of Chapter 33), you could make the robot follow a bright light source as it moves. By simply reversing the sensor connections to the motors, you can make the robot behave in the opposite manner as shown in Fig. 12-1, such as steering away from the light source, instead of driving toward it. See Fig. 12-2 for an example.
+V
M1
Ground +5V
D1 1N4003
R1 10K
R2 1K
c Q1 2N2222
b Q1
RL1
e
FIGURE 12-1 Only a few electronic components are needed to control a robot using the stimulus of a sensor.
12.1 BRAINS FROM DISCRETE COMPONENTS
153
FIGURE 12-2 By connecting the sensors and control electronics differently, a robot can be made to “behave” in different ways.
You could add additional simple circuitry to extend the functionality of robots that use discrete components for brains. For instance, you could use a 555 timer as a time delay: trigger the timer and it runs for 5 or 6 s, then stops. You could wire the 555 to a relay so it applies juice only for a specific amount of time. In a two-motor robot, using two 555 timers with different time delays could make the thing steer around walls and other obstacles.
12.1.1 BEAM TECHNOLOGY Over the past 15 years, robotics expert Mark Tilden has been designing and testing a class of unique robots that fall into their own classification, which he calls BEAM. These small robots, which can generally be built in an afternoon using mostly reclaimed parts from various electronics devices found around the house, are an excellent way to learn about different robot motors and actuators as well as to see electronic devices working in ways that their designers definitely never intended. Along with the learning aspects of BEAM technology and robots, there are a number of competitive events that have been designed around different basic BEAM operations that are fun and inexpensive to compete in.
154
AN OVERVIEW OF ROBOT “BRAINS”
BEAM is an acronym for:
•
• • •
Biology. These robots often not only mimic the different structures and behaviors of living organisms, but with their simple construction BEAM robots are meant to evolve through humans continually improving them. It must also be pointed out that an important feature of BEAM technology is the use of renewable energy sources (primarily photocells) for power, which the robots feed from. This need for feeding is often part of the overall operation of the robots. Electronics. The control and motor drivers used in the robots. As previously noted, many example BEAM robots bend the operation of different components to perform actions that are suited to controlling the operation of the robots. Aesthetics. Unlike most robots, BEAM robots are designed and constructed with thought applied to what the robot will look like when it is completed. The desire is to have the function of the robot to be immediately obvious from its form. Mechanics. Instead of the traditional robot shapes, BEAM robots are very efficiently designed, both with an eye toward the aesthetics of the design and making the operation of the robot as efficient as possible by using simple electronic parts that do not have to be tailored to specific motors and sensors.
Normally when you are in a surplus store or pulling apart an old VCR, you are looking at the motors and drive electronics as parts that will be built into a much larger robot. A BEAM roboticist will be looking at the subassembly the motor is built into and how to use that as the basis for an entire robot. This difference in approach is what makes BEAM technology so special. BEAM robots are a fascinating branch of robots, but the lack of computer control and their typically small size makes them quite difficult to adapt to more than one application or multiple environments. In the appendices, different BEAM resources are listed and it is recommended that you look through them for the technical information and to marvel at the elegance of their designs.
12.2 Brains from Computers and Microcontrollers The biggest downside of making robot controls from discrete components is the work required to change the hardwired brains to change the behavior of the robot. You either need to change the wires around or add and remove components. Using an experimenter’s breadboard makes it easier to try out different designs simply by plugging components and wiring into the board. But this soon becomes tiresome and can lead to errors because parts can work loose from the board. You can rewire a robot controlled by a computer simply by changing the software running on the computer. For example, if your robot has two light sensors and two motors, you don’t need to do much more than change a few lines of programming code to make the robot come toward a light source, rather than move away from it. No changes in hardware
12.3 TYPES OF COMPUTERS FOR ROBOTS
155
are required. This type of programming functionality is demonstrated in Chapter 15 with a Parallax BASIC Stamp 2 and some of the example applications that it can run.
12.3 Types of Computers for Robots An almost endless variety of computers can be used as a robot’s brain. The most common types that are used are:
• • • •
Microcontroller. These are programmed either in assembly language or a high-level language such as BASIC or C. There are literally hundreds of different microcontrollers with a plethora of different interfacing capabilities that you can choose from to control your robot. Personal Digital Assistant. An old Palm Pilot provides a lot of processing power in a fairly small space with a number of features that make it very attractive for use as a robot controller. It can be difficult to interface with. Single-board computer. A few years ago, complete computer systems built on a PCB were the preferred method of controlling robots. These systems are still used but are much less popular due to the availability of low-cost PC motherboards and more powerful, easy to use microcontrollers. Personal computer motherboards and laptops. Very small form factor PC motherboards and laptops are common controllers for larger robots. These controllers can be programmed using standard development tools and commercial, digital I/O add-ons for the interfaces needed for the different robot functions.
12.3.1 MICROCONTROLLERS Microcontrollers are the preferred method for endowing a robot with smarts. The reasons for this include their low costs, simple power requirements (usually 2.5 to 5 V), and ability of most to be programmed using software and a simple hardware interface on your PC. Once programmed, the microcontroller is disconnected from the PC and operates on its own. Microcontrollers can either be downloaded with a program that provides all the functions required of it or execute a tokenized program, which provides a set of basic functions for the application and the software already built into the microcontroller handling the various interfaces. Virtually all microcontrollers can be used as either device; the reason for choosing one over the other really comes down to cost, your experience and skills, available features, and ease of use. You shouldn’t be scared at the idea of having to come up with all the code that executes within a microcontroller. If you are familiar with a PC, you know that there are several megabytes of code for the BIOS (basic input/output system) as well as several hundred megabytes of code devoted to the operating system. Going by this standard, it will seem like developing a complete application for a microcontroller is a daunting task. In reality, the operation of the code within the microcontroller is quite simple, and other than requiring a few configuration commands, the software is quite straightforward. The advantage of using a microcontroller that requires a complete application is cost; a microcontroller suitable for
156
AN OVERVIEW OF ROBOT “BRAINS”
use in robots can cost as little as $1.00. A potential drawback to this type of microcontroller is the cost of a programmer, which can be very substantial for some chips. When source code is tokenized, it is passed through a compiler, just like regular application code, but instead of producing a series of instructions, the compiler produces a set of commands that are executed within the microcontroller. This type of microcontroller can have a series of very complex commands programmed into it, which makes them available to new application developers instead of having to puzzle out how to implement them. To further simplify the operation of this type of microcontroller, a bootloader program is typically already burned into them, allowing a simple programming operation that does not require any additional hardware. The Parallax BASIC Stamp 2 discussed later in this book is a bootloader-equipped microcontroller, which has a simple RS-232 programming (and console) interface. Both kinds of microcontroller are fully programmable, but bootloader-equipped microcontrollers, like the BASIC Stamp 2, are programmed in a high-level language such as BASIC. Stand-alone microcontrollers can usually be programmed in a variety of different high-level languages (BASIC, Java, C) as well as assembly language, giving a lot more flexibility to the application developer. Microcontrollers are available with 8, 16, or 32-bit processors. While PCs have long since graduated to 32-bit and higher architectures with protect mode and virtual memory operating systems, most applications for microcontrollers do not require more than eight bits. The exact format and contents of an assembly-language microcontroller program vary between manufacturers. The popular PIC microcontrollers from Microchip follow one language convention. Microcontrollers from Intel, Atmel, Motorola, NEC, Texas Instruments, Philips, Hitachi, Holtek, and other companies all follow their own conventions. While the basic functionality of microcontrollers from these different companies is similar, learning to use each one involves a learning curve. As a result, robot developers tend to fixate on one brand, and even one model, since learning a new assembly language and processor architecture can require a lot of extra work. Table 12-1 lists a number of different microcontrollers available on the market. 12.3.1.1 The Complete Computer System on a Chip A key benefit of microcontrollers is that they combine a microprocessor component with various inputs/outputs (I/O) that are typically needed to interface with the real world. For example, the 8051 controller sports the following features, many of which are fairly standard among microcontrollers:
• • • • • •
Central processing unit (CPU) CPU reset and clocking support circuitry Hardware interrupts Built-in timer or counter Programmable full-duplex serial port 32 I/O lines (four eight-bit ports) configurable as an eight-bit RAM and ROM/EPROM bus
Some microcontrollers will have greater or fewer I/O lines, and not all have hardware interrupt inputs. Some will have special-purpose I/O for such things as voltage comparison or analog-to-digital conversion. Just as there is no one car that’s perfect for everyone, each microcontroller’s design will make it more suitable for certain applications than for others.
12.3 TYPES OF COMPUTERS FOR ROBOTS
TABLE 12-1
157
Different Microcontrollers
MICROCONTROLLER NAME
MANUFACTURER
COMMENTS
PIC
Microchip
Many different part numbers that are very popular with roboticists. The PIC16F84 has been a traditional favorite, but new microcontrollers are better suited to robot applications. Lots of free development software and example applications available. The BASIC Stamp 2 uses a PIC MCU as its preprogrammed controller.
68HC11
Freescale
Historically a very popular microcontroller for use in robots. Can be somewhat difficult and expensive to work with due to lack of tools available on the Internet. Note: freescale products used to be known as Motorola.
8051
Intel (originally)
Many different varieties and part numbers available from a plethora of manufacturers. The original parts are very simple but different manufacturers have MCUs with sophisticated interfaces. Lots of tools and example applications available on the Internet.
AVR
Atmel
Increasingly popular part for robot applications. Good free tools available for standard and MegaAVR parts.
H8
Hitachi
Used in many commercial robots. Tools available on the Internet but fewer example applications than available for other devices.
8018x
Intel
Microcontroller version of the 8088 used in the original IBM PC. Can be somewhat difficult to find today and requires a BIOS chip for proper operation making it the most difficult to work with of the devices listed here.
It must be pointed out that one of the important features of the microcontroller is the built-in hardware providing reset control and processor clock support. Many modern microcontrollers only require power supplied to them along with a decoupling capacitor and nothing more to run. This makes them an attractive alternative to traditional TTL or CMOS logic chips. 12.3.1.2 Program and Data Storage The typical low-cost microcontroller will only have a few thousand bytes of program storage, which will seem somewhat confining (especially when your PC probably has 512MB or more of main board memory and 40GB or more of disk storage). Despite seeming very small, this amount of memory is usually more than adequate for loading in a robot application; many initial robot programs do not require more than a few dozen lines of program code. If a human-readable display is used, it’s typically limited to a small 2-by-16 character LCD, not entire screens of color graphics and text. By using external addressing, advanced microcontrollers may handle more storage:
158
AN OVERVIEW OF ROBOT “BRAINS”
megabytes of data are not uncommon. For most robot programs, only a few hundred bytes of storage will be required in a microcontroller. Some microcontrollers—and computers for that matter—stuff programs and data into one lump area and have a single data bus for fetching both program instructions and data. These are said to use the Princeton, or more commonly Von Neumann, architecture. This is the architecture common to the IBM PC compatible and many desktop computers, but is only found in older microcontroller architectures. Rather, most modern microcontrollers use the Harvard architecture, where programs are stored in one place and data in another. Two buses are used: one for program instructions and one for data. The difference is not trivial. A microprocessor using the Harvard architecture can run faster because it can fetch the next instructions while accessing data. When using the Von Neumann architecture, the processor must constantly switch between going to a data location and a program location on the same bus. The Von Neumann architecture is superior for microcontrollers used in a bootloader configuration and in applications that use realtime operating systems—applications that are beyond the scope of this book. Because of the clear delineation in program and data space in the Harvard architecture, such microcontrollers have two separate memory areas: EEPROM (electrically erasable programmable read-only memory) for program space and RAM (random access memory) for holding data used while the program runs. A version of EEPROM used in many microcontrollers is known as Flash. You will often see two data storage specifications for microcontrollers. There are some differences in how the two processor architectures are programmed but learning between the two is not terribly difficult; with the use of high-level languages, the differences become transparent and should not be used to select a microcontroller for a robot. Of much greater importance is the availability of the device itself, the resource materials, development tools, and example applications as well as the ease in which programs can be loaded into the chip. 12.3.1.3 Chip Programming Microcontrollers used in robots are meant to be programmed and erased many times over. A few years ago, finding parts with EEPROM or Flash program memory was not an easy task, and a few microcontrollers (such as the PIC16F84) became very popular devices for robot developers because they could be reprogrammed easily without undergoing any special steps. Older PROM and EEPROM-based microcontrollers were more difficult to work with and required additional tools to erase them before a new program could be burned into them. With the wide availability of EEPROM- and Flash-based microcontrollers, the focus now turns to the cost and overhead of programming applications into microcontrollers. All microcontroller manufacturers have programmers available for their microcontroller chips and there are third-party tools that can program a wide variety of different chips. The cost for these programmers ranges from $25 to several thousand dollars. Another option for programming microcontroller chips is to build your own programmer, which can cost as little as $2 to $3, depending on the state of your parts drawer. Another consideration is application debugging. Many microcontrollers are becoming available on the market with built-in debugging features, eliminating the need for an incircuit emulator and allowing you to debug your applications for just a few hundred dollars. To perform this debugging, several I/O pins of the microcontroller must be dedicated to the
12.3 TYPES OF COMPUTERS FOR ROBOTS
159
debugger hardware connection and cannot be used for application input and output pins. In theory, the ability to debug the program running in a robot seems like an outstanding idea, but in practice, it can be very difficult to implement on a mobile robot. It may sound ironic, but you should seriously consider a microcontroller that has a debugger interface built in as this could be used as a programming interface, eliminating the need to pull out the chip every time the program is updated. By being able to plug a cable into the robot for programming, the time required to update the program in the microcontroller as well as the opportunity for damaging the microcontroller chip will be greatly reduced. The ability and cost of a microcontroller programmer are probably the most important considerations that you should make when choosing a microcontroller to work with. While a chip may be ideally suited to the robot application you want to create, if you cannot get a reasonably priced programmer, then you will find that you are spending a disproportionate amount of money on something that does not affect the operation of the robot. A less capable microcontroller with a cheap and simple programming interface will be a lot more useful to you in the long run.
12.3.2 PERSONAL DIGITAL ASSISTANTS Palm Pilots and other small personal digital assistants (PDAs) can be used as a small robot controller that combines many of the advantages of microcontrollers, larger single-board computers, and PC motherboards and laptops. The built-in power supply and graphic LCD display (with Graffiti stylus input) are further advantages, eliminating the need for supplying power to the PDA and providing a method of entering in parameter data or even modifying the application code without a separate computer. The most significant issue that you will encounter using a PDA as a robot controller is deciding how to interface it to the robot’s electronics. PDAs are becoming increasingly popular as robot controllers and there are a variety of products and resources that will make the effort easier for you. There are two primary types of PDAs to consider based on the operating system used. The Palm O/S was the original, and there are a number of programming languages and native programming environments to consider. One notable product that is very popular with robot developers is the HotPaw (www.hotpaw.com/hotpaw) BASIC programming environment lets you develop, compile, and run BASIC applications on your PDA with a less than $20 license fee. Windows CE is the other type of operating system used by PDAs and offers essentially the same features as the Palm-based devices. At the time of this writing, Microsoft offers a number of eMbedded Visual Tools from their Dveloper’s web site (www.microsoft.com) for Windows CE devices including eMbedded Visual BASIC, which can be written and tested on a PC before being downloaded into the PDA. Once you have decided on the device and the programming environment, you have to decide what is going to be the methodology for connecting the PDA into the robot. You have two choices: the serial port that is built into the robot or the IRDA infrared data port. The serial port is similar to a PC’s RS-232 port, but typically only implements two handshaking lines and generally does not produce valid RS-232 voltage levels—neither of which is a significant issue, but things that you should be aware of. The IRDA port is a fairly high speed (from 9.600 to 115.2 kbps) infrared serial port that implements a reasonably complex data protocol. There are a number of IR transceivers and stack protocol chips (such as the Microchip MPC2150) that you can use to implement the interface—the total cost for
160
AN OVERVIEW OF ROBOT “BRAINS”
the stack protocol chip, IR transceiver, and miscellaneous electronics will cost you about $20). It must be pointed out that the IRDA interface will only communicate reliably if the distance between the PDA and other devices is less than 3 ft (1 m). In either case, an intelligent device will have to be connected to the serial connections and used to interface with the robot’s motor drivers and sensors. The advantage of using the serial port is lower parts cost while the IRDA port avoids a direct electrical connection between the robot and the PDA, which eliminates any potential upsets of the PDA due to electrical noise coming from the robot. You can use a prepackaged serial interface chip or you can program a small microcontroller, like a BS2, to provide the serial interface to the robot peripherals.
12.3.3 SINGLE-BOARD COMPUTERS If you look through older robotics books and magazines, you will see a number of robots that are controlled by single-board computers or SBCs. Like microcontrollers, an SBC can be programmed in either assembly language or in a high-level language such as BASIC or C and contain the processor and memory but also the I/O interfaces necessary to control a robot. SBCs avoid the programming issues of microcontrollers due to the built-in RS-232 or Ethernet interfaces, which allow simple application transfers. Older SBCs used with robots were generally based on the Motorola 68HC11 microcontroller because of the large amount of software and tools available for them. Another type of SBC that has been popular with roboticists in the past is the PC/104 form factor in which a processor card could be plugged directly into stacking memory, I/O, or video output cards. Despite the apparent bias in its name, many processor cards are available for the PC/104 form factor, providing the ability to use a PC processor, a Motorola 68000, MIPs, or Sparc processor with standard hardware. Applications for PC/104 systems were usually downloaded into on-board EPROM or Flash memory chips. This approach offered tremendous flexibility although at a fairly high cost. Most modern single-board computers are full PCs with complete systems built on a small circuit board. A very popular form factor is the mini-ITX, which provides a complete PC in a 6.7 in square. These systems can support many hundreds of megabytes of memory and can run Microsoft Windows or Linux operating systems, allowing standard PC development tools to be used for program development. There are three downsides to using SBCs in robots, especially if you are starting out and are designing your own robot:
•
•
Power required by SBCs is usually more than a single supply and they do not have on-board voltage regulators. A Mini-ITX motherboard requires, +3.3, +5, +12, −5 and −12 V provided to it for proper operation. High-capacity batteries and DC–DC converters can provide appropriate voltages, but their weight and size results in the SBC only being used in large robots. Installing an operating system and running an application can be very challenging. Disk drives are very unreliable in a robot environment where the robot vibrates as it moves, and also require a great deal of power. A USB Flash memory thumb drive could be used, but this device would have to be loaded with an image of the operating system along with
12.3 TYPES OF COMPUTERS FOR ROBOTS
•
161
application code. Versions of Linux can be found on the Internet that are suitable for loading in and booting from a thumb drive, but this is not a trivial exercise. Adding I/O ports would most likely be through the SBC’s USB ports. There are a number of suppliers that have digital I/O as well as different advanced function I/O cards available that connect to a PC via USB. Depending on the interface cards, the software interfaces to the I/O functions can be quick, sophisticated, and difficult to program.
Despite the drawbacks, the use of single-board computers, especially those that are PC based, offer some intriguing possibilities. As previously discussed, it would be nice to be able to debug a robot application while it is working in a mobile robot. This is extremely difficult with microcontrollers, but it could be quite easy to do in an SBC-controlled robot; if it were equipped with an 802.11 (or any other wireless) network card, the SBC could run the debugger and make its display available to other PCs on the wireless network via X-Windows. Another possible application would be to use the network interface to stream video from the robot to a base station that was controlling the robot. The code required for these applications is readily available over the Internet and could be added to a robot with very little extra work. 12.3.3.1 Single-Board Computer Kits To handle different kinds of jobs, SBCs are available in larger or smaller sizes than the 4-by-4-in PC/104. And while most SBCs are available in ready-made form, they are also popular as kits. For example, the BotBoard series of single-board computers, designed by robot enthusiast Marvin Green, combine a Motorola 68HC11 microcontroller with outboard interfacing electronics. The Miniboard and HandyBoard, designed by instructors at MIT, are other single-board computers based on the HC11; both are provided in kit and ready-made form from various sources.
12.3.4 PERSONAL COMPUTERS Having your personal computer control your robot is a good use of available resources because you already have the computer to do the job. Of course it probably also means that your automaton is constantly tethered to your PC, with either a wire or a radio frequency or infrared link. Just because the average PC is deskbound doesn’t mean you can’t mount it on your robot and use it in a portable environment. Whether you’d want to is another matter. Certain PCs are more suited for conversion to mobile robot use than others. Here are the qualities to look for if you plan on using your PC as the brains in an untethered robot:
• •
Small size. In this case, small means that the computer can fit in or on your robot. A computer small enough for one robot may be a King Kong to another. Generally speaking, however, a computer larger than about 12 by 12 in is too big for any reasonably sized ’bot. Standard power supply requirements. A PC will require +5, +12, −5 and −12 V, and many PCs will also require +3.3 V. Depending on the motherboard that you use, you may discover that the +3.3, +5, or +12 V supply is the one that requires the most current as it is used to power most of the components on the PC. A few will function if the
162
AN OVERVIEW OF ROBOT “BRAINS”
•
• •
•
−12 and −5 voltages are absent. It may take a lot of work to figure out which power supplies are required and how much current must be available to each one. Accessibility to the microprocessor system bus or an input/output port. The computer won’t do you much good if you can’t access the data, address, and control lines. The IBM PC architecture provides for ready expansion using daughter cards that connect to the motherboard. Standard motherboards also support a variety of standard I/O ports, including parallel (printer), serial, and Universal Serial Bus (USB). There are a number of I/O cards designed for the USB so this may be the most promising avenue. Programmability. You must be able to program the computer using either assembly language or a higher-level language such as BASIC, C, or Java. The open source community has a number of open source compiler projects available for you to choose from. Mass storage capability. You need a way to store the programs you write for your robot, or every time the power is removed from the computer you’ll have to rekey the program back in. Floppy disks or small, low-power hard disk drives are possible contenders here although the low-cost USB Flash thumb drives are probably your best option. Being solid state, they will be much more reliable in the vibration-filled environment of a robot and they use very little power. Even modest sized (64 MB and less) thumb drives can be loaded with an operating system and application code, eliminating the need for operating systems all together. If these drives are to be used, you will have to make sure that your motherboard can boot from the thumb drive. Availability of technical information. You can’t tinker with a computer unless you have a full technical reference manual. While manufacturers no longer publish these manuals, there are a number of references available for PCs that you can choose from and many of these will discuss alternative applications for PCs (such as building them into robots).
The PC may seem an unlikely computer for robot control, but it offers many worthwhile advantages: expansion slots, large software base, and readily available technical information. Another advantage is that these machines are plentiful on the used market—$20 at some thrift stores. As software for PCs has become more and more sophisticated, older models have to be junked to make room for faster processors and larger memories. You don’t want to put the entire PC on your mobile robot; it would be too heavy. Instead, remove the motherboard from inside the PC, and install that on your ’bot. How successful you are doing this will depend on the design of the motherboard you are using. The supply requirements of older PC-compatible motherboards are rather hefty: you need one or more large batteries to provide power and tight voltage regulation. Later models of motherboards (those made after about 1990) used large-scale integration chips that dramatically cut down on the number of individual integrated circuits. This reduces the power consumption of the motherboard as well. Favor these “newer” motherboards (sometimes referred to as green motherboards, for their energy-saving qualities), as they will save you the pain and expense of providing extra battery power. The keyboard is separate and connects to the motherboard by way of a small connector. The BIOS in some motherboards will allow you to run the PC without a keyboard detected. You will want this capability—without it, the motherboard won’t boot the operating system, and you’ll need to either keep a keyboard connected to the motherboard or rig up some kind of dummy keyboard adapter. The same goes for the video display. Make sure you can operate the motherboard without the display.
12.3 TYPES OF COMPUTERS FOR ROBOTS
163
12.3.4.1 IBM PC-Compatible Laptops Motherboards from desktop IBM PCcompatible computers can be a pain to use because of the power supply requirements. A laptop on the other hand is an ideal robot-control computer. The built-in battery and display avoid the need for a number of custom power supplies and a display device for the robot. Check online auction sites such as Ebay, a used computer store, or your local classified ads for used units. You should use the laptop as-is, without removing its parts and mounting them on the robot. That way, you can still access the keyboard and display. Use the parallel, serial, and USB ports on the laptop to connect to the robot. You should not use the laptop’s batteries for powering the robot. While they are quite sophisticated and provide a great deal of power, they are designed for the load of the laptop, adding a significant load will cause them to run down faster and be potentially damaged by the extra drain of the robot’s motors. You may find that it is impossible to run the robot from the laptop’s batteries—protection and monitoring circuitry built into the laptop and the battery packs may detect the additional load and shut down the system fearing that the additional load is a short circuit or a problem with the battery pack itself. 12.3.4.2 Operating Systems If you make the decision to use a PC motherboard (or even a complete PC) in your robot, you will have to make the nontrivial decision on what type of operating system you are going to run and what features you are going to have on it. Fortunately, there are a lot of web sites, books, and other resources that will help you set up the operating system, support libraries, and application code, but you will have to spend some time thinking about how everything should work and what features you want to have available. The first question you should ask yourself is, what features do you want to have available in the operating system running on your robot’s PC? The obvious answer is as few as possible to minimize the amount of space that will be used for the operating system. The reason behind this answer is correct; but the decision point isn’t—the operating system that is loaded onto the robot’s PC should be as small as possible, but it should have as many features built into it as possible. The reason for wanting as many features as possible is to give you as many options as possible for how the PC will run. While you should avoid running the PC motherboard from a hard disk or CD-ROM, you still want to have the drivers loaded and active in the system in case you want to use them later. Similarly, network interface card (NIC) drivers should be installed along with USB, serial, parallel, and other motherboard interfaces. You should not restrict any flexibility in the PC motherboard’s operation until you have finished and perfected the robot (which will probably never happen). The question you should now be asking is, what else is there to take out? If everything is being left in, there isn’t that much space left to save. Actually there is one big piece that you can take out and that is the graphical user interface—the Windows interface that you work with is at least half the total size of the operating system on disk and in memory. With it taken out, you should have an operating system that will only require 60 MB or so of storage—small enough to fit on a USB Flash thumb or key drive with the application code included. Loading applications or other files is as simple as plugging the USB thumb drive into your PC and copying the files into it, just as you would copy files between folders. If you were not to use a USB thumb drive, you
164
AN OVERVIEW OF ROBOT “BRAINS”
would have to either disconnect the disk drive or eject the CD and update its contents—it’s a bit more work but still very doable. Storing the operating system and application on a USB thumb drive will eliminate the extra power required by a spinning hard disk or CD/DVD drive, as well as avoid the potential reliability issues of rotating devices running on an electrically noisy and vibrating robot. There are numerous web sites devoted to providing information required to set up a thumb drive as a bootable device along with installing an operating system onto it. Once you have decided where to put the operating system and application code you can decide which operating system you are most comfortable with. All major operating systems can be used (Microsoft Windows (all flavors), MS-DOS, and Linux) after the graphical user interface has been removed from it. There are no significant reasons for choosing one operating system over another; the important points will be which ones you are most comfortable with and which ones have the software development tools that you have and are proficient working with. Regardless of the operating system used, there are a variety of open source tools that you can download for application development. These can be found using a quick Google search or by looking at www.cygwin.com, which is an X-Windows-based environment for Microsoft Windows that will allow you to simulate the Linux environment and develop and debug applications for any of the three major operating systems. Even if you are unfamiliar with Linux or Unix operating environments and do not consider yourself very technical, it is surprisingly easy to download and work with these tools.
12.4 Inputs and Outputs The architecture of robots requires inputs, for such things as mode setting or sensors, as well as outputs, for things like motor control or speech. The basic input and output of a computer or microcontroller is a two-state binary voltage level (off and on), usually 0 and 5 V. For example, to place an output of a computer or microcontroller to high, the voltage on that output is brought, under software control, to +5 V. In addition to standard low/high inputs and outputs, there are several other forms of I/O found on single-board computers and microcontrollers. The more common are listed in the following sections, organized by type. Several of these are discussed in more detail later in the book.
12.4.1 SERIAL COMMUNICATIONS The most common type of computer interfacing is known as serial, in which multiple bits are sent as a series of bits over time on a single wire. There are a number of different types of serial communications protocols as shown in Fig. 12-3, with asynchronous, synchronous, and Manchester encoding. Each methodology is optimized for different situations. The two most likely communications methods that you will have to work with when interfacing a robot controller to I/O devices is synchronous serial communications, which consists of a data line and a clock line as shown in Fig. 12-4. There are several different protocols used for synchronous serial communications, but they all have one characteristic in
12.4 INPUTS AND OUTPUTS
Start Bit
Asynchronous
Synchronous
B0
“Idle”, No Data Being Sent
B1
Stop Bit B2
B3
B4
B5
B6
B7
Optional Error Detection Bit
Data Bits
Data
B0
165
B1
B2
B3
B4
B5
B6
B7
Clock Data Saved on “Rising Edge” of Clock Signal “Leader”
Manchester Encoding
B0
B1
“1”
“0”
B2
B3
B4
Bit Timing Synch Pulse
FIGURE 12-3 The different serial interfaces used in robots.
common: the bit on the data line is saved in the receiver when the clock transitions from high to low or low to high. The timing of the clock line does not have to be consistent and in some synchronous serial protocols, there can be multiple devices on the clock and data lines and part of the protocol is used to determine which device is active at any given time. The three most common types of synchronous serial communication methodologies are:
•
• •
I2C (inter-integrated circuit). This is a two-wire serial network protocol created by Philips to allow integrated circuits to communicate with one another. With I2C you can install two or more microcontrollers in a robot and have them communicate with one another. One I2C-equipped microcontroller may be the master, while the others are slaves and used for special tasks, such as interrogating sensors or operating the motors. Microwire. This is a serial synchronous communications protocol developed by National Semiconductor products. Most Microwire-compatible components are used for interfacing with microcontroller or microprocessor support electronics, such as memory and analog-to-digital converters. SPI (serial peripheral interface). This is a standard used by Motorola and others to communicate between devices. Like Microwire, SPI is most often used to interface with
“Glitch” Ignored by Receiver
Sent Data Clock Received Data B0
B1
B2
B3
B4
B5
B6
B7
FIGURE 12-4 Close-up detail showing how synchronous serial data is only picked up on the clock edge.
166
AN OVERVIEW OF ROBOT “BRAINS”
microcontroller or microprocessor support electronics, especially outboard EEPROM memory.
12.4.2 ASYNCHRONOUS SERIAL COMMUNICATIONS (FROM SERIAL COMMUNICATIONS) Asynchronous serial communications uses a single wire to send a packet that consists of a number of bits, each the same length. The most popular data protocol for asynchronous serial communications is known as non-return to zero (NRZ) and consists of the first bit, the Start Bit is low and is used by the receiver to identify the middle of each bit of the incoming data stream for the most accurate reading as shown in Fig. 12-5. There can be any number of data bits, but for most communications, eight bits, allowing the transmission of a byte, are used. The following data bits have the same period and are read as they are received. The stop bit is a high value (the non-return to zero that resets the data line to a high value so the next start bit will be detected by the receiver) that provides a set amount of time for the sender and receiver to prepare for the next data packet. An error detection bit can be placed at the end of the data bits, but this is rarely done in modern asynchronous serial communications. The most popular form of asynchronous serial communications and one that you have probably heard of is commonly referred to as RS-232 (although more accurately known as EIA-232) and changes the normal TTL voltage levels of the serial data from 0 to +5 V to +12 (0) and −12 (1) V. There are a number of chips available that will make this voltage conversion simpler, most notably the Maxim MAX232, which generates the positive and negative voltages on the chip from the +5 V supply. Along with RS-232, RS-422, and RS-485
Start Bit
Glitch Check
Bit Read
Bit Read
Bit Read
Bit Read
Bit Read
Parity Read
Data Process
Overspeed Clock FIGURE 12-5 The asynchronous serial data stream consists of a start bit, which goes low, followed by a number of data bits. The receiver finds the center of the low start bit and then uses this point to read the values of subsequent bits.
12.4 INPUTS AND OUTPUTS
167
are commonly used forms of asynchronous serial communications, and like RS-232, these standards can be implemented using commonly available chips. Sending and receiving RS-232 data in a computer system may seem like a chore, but it is actually simplified by the universal asynchronous receiver/transmitter (known by its acronym UART) that will send and receive NRZ asynchronous data automatically with the computer system writing to it to start a data send or polling the UART to determine if the last written data byte has been sent or if data has been received. Along with the send and receive data bits, there are a number of other lines that can be used with RS-232 for handshaking (system-to-system communications to indicate that data can be sent or received) but these lines are largely ignored in most modern communications. The UART generally will provide an interface to these bits as well.
12.4.3 DIGITAL-TO-ANALOG CONVERSION There are two principle types of data conversion:
• • •
Analog-to-digital conversion (ADC) transforms analog (linear) voltage changes to binary (digital). ADCs can be outboard, contained in a single integrated circuit, or included as part of a microcontroller. Multiple inputs on an ADC chip allow a single IC to be used with several inputs (4-, 8-, and 16-input ADCs are common). Digital-to-analog conversion (DAC) transforms binary (digital) signals to analog (linear) voltage levels. DACs are not as commonly employed in robots; rather, they are commonly found on such devices as compact disc players. Comparator. This is an input that can compare a voltage level against a reference. The value of the input is then lower (0) or higher (1) than the reference. Comparators are most often used as simple analog-to-digital converters where high and low are represented by something other than the normal voltage levels (which can vary, depending on the kind of logic circuit used). For example, a comparator may trigger high at 2.7 v.
12.4.4 PULSE AND FREQUENCY MANAGEMENT The three major types of pulse and frequency management are the following: Input capture is an input to a timer that determines the frequency of an incoming digital signal. With this information, for example, a robot could differentiate between inputs, such as two different locator beacons in a room. Input capture is similar in concept to a tunable radio. Pulse width modulation (PWM) is a digital output that has a square wave of varying duty cycle (e.g., the “on” time for the waveform is longer or shorter than the “off” time). PMW is often used with a simple resistor and capacitor to approximate digital-to-analog conversion, to create sound output, and to control the speed of a DC motor. Pulse accumulator is an automatic counter that counts the number of pulses received on an input over X period of time. The pulse accumulator is part of the architecture of the microprocessor or microcontroller and can be programmed autonomously. That is, the accumulator can be collecting data even when the rest of the microprocessor or microcontroller is busy running some other program.
168
AN OVERVIEW OF ROBOT “BRAINS”
12.4.5 SPECIAL FUNCTIONS There are a variety of other features available in different microcontrollers and computer systems. From a high level they will make your application much more elegant and probably simpler, but they can require specialized knowledge that will take you a while to develop.
• • • •
Hardware interrupts. Interrupts are special input that provides a means to get the attention of a microprocessor or microcontroller. When the interrupt is triggered, the microprocessor can temporarily suspend normal program execution and run a special subprogram. External reset. This is an input that resets the computer or microcontroller so it clears any data in RAM and restarts its program (the program stored in EEPROM or elsewhere is not erased). Switch debouncer. This cleans up the signal transition when a mechanical switch (push button, mercury, magnetic reed, etc.) opens or closes. Without a debouncer, the control electronics may see numerous signal transitions and could interpret each one as a separate switch state. With the debouncer, the control electronics sees just a single transition. Input pull-up. Pull-up resistors (5 to 10K) are required for many kinds of inputs to control electronics. If the source of the input is not actively generating a signal, the input could float and therefore confuse the robot’s brain. These resistors, which can be built into a microcontroller and activated via software, prevent this floating from occurring.
12.5 From Here To learn more about . . .
Read
Connecting computers and other circuits to the outside world
Chapter 14, “Computer Peripherals”
Using the BASIC Stamp microcontroller
Chapter 15, “The BASIC Stamp 2 Microcontroller”
CHAPTER
13
PROGRAMMING FUNDAMENTALS
I
f you were to watch old movies, you would get the idea that all you needed to build a robot were a couple of motors, a switch or relay, a battery, and some wire. In actuality, most robots, including the hobby variety, are equipped with a computational brain of one type or another that is told what to do through programming. The brain and programming are typically easier and less expensive to implement than are discrete circuitry, which is one reason why it’s so popular to use a computer to power a robot. The nature of the programming depends on what the robot does. If the robot is meant to play tennis, then its programming is designed to help it recognize tennis balls, move in all lateral directions, perform a classic backhand, and maybe jump over the net when it wins. But no matter what the robot is supposed to do all of the robot’s actions come down to a relatively small set of instructions in whatever programming language you are using. If you’re new to programming or haven’t practiced it in several years, read through this chapter on the basics of programming for controlling your robots. This chapter discusses rudimentary stuff so you can better understand the more technical material in the chapters that follow. Even if you are familiar with programming, please take a few minutes and read through the chapter. Important concepts needed for programming robots are presented along with some of the fundamental program templates used for programming robots. If you were to skip this chapter, you may become confused at some of the code examples and programming discussions presented later in the book.
169 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
170
PROGRAMMING FUNDAMENTALS
13.1 Important Programming Concepts There are eight critical concepts to understanding programming, whether for robots or otherwise. In this chapter, we’ll talk about each of the following in greater detail:
• • • • • • • •
Linear program execution Variables and I/O ports Assignment statements Mathematical expressions Arrays and character strings Decision structures Macros, subroutines, and functions Console I/O
13.1.1 LINEAR PROGRAM EXECUTION Modern computer systems, regardless of their sophistication, are really nothing more than electronic circuits that read instructions from their memory in order and execute them as they are received. This may fly in the face of your perception of how a computer program works; especially when you are familiar with working on a PC in which different dialog boxes can be brought up at different times and different buttons or controls can be accessed randomly and not in any predefined sequence. By saying that a computer program is a sequence of instructions that are read and executed may seem to belittle the amount of work that goes into them along with the sophistication of the operations they perform, but this is really all they are. A sequence of instructions to latch data from a storage location into an external register using two I/O registers (one for data and one for the register clock line) could be: Address 1 2 3 4 5 6 7
Instruction I/O Port 1 = All Output I/O Port 2 = 1 Clock Output Bit I/O Port 2 Clock Output Bit = Low Holding Register = Storage Location "A" I/O Port 1 = Holding Register I/O Port 2 Clock Output Bit = High I/O Port 2 Clock Output Bit = Low
In this sequence of instructions, the address each instruction is stored in has been included to show that each incrementing address holds the next instruction in sequence for the program. The first computers could only execute the sequence of instructions as-is and not modify the execution in any way. Modern computers have been given the ability to change which section of instruction sequence is to be executed, either always or conditionally. The following sequence of instructions will latch the values of one to five into the external register by conditionally changing the section of the instruction sequence to be executed, based on the current value.
13.1 IMPORTANT PROGRAMMING CONCEPTS
Address 1 2 3 4 5 6 7 8 9 10 11 12 13 14
171
Instruction Holding Register = 1 Storage Location "A" = Holding Register I/O Port 1 = All Output I/O Port 2 = 1 Clock Output Bit I/O Port 2 Clock Output Bit = Low Holding Register = Storage Location "A" I/O Port 1 = Holding Register I/O Port 2 Clock Output Bit = High I/O Port 2 Clock Output Bit = Low Holding Register = Storage Location "A" Holding Register = Holding Register + 1 Storage Location "A" = Holding Register Holding Register = Holding Register - 5 If Holding Register Does Not Equal 0, Next Execution Step is 6
In the second program, after the contents of ‘Holding Register “A” ’ have 1 added to them, the value has 5 subtracted from it and if the result is not equal to zero, execution continues at address 6 rather than ending after address 14. Note that data from a “Storage Location” cannot pass directly to an output port nor can mathematical operations be performed on it without storing the contents in the “Holding Register” first. In this simple program, you can see many of the programming concepts listed in operation, and while they will seem unfamiliar to you, the operation of the program should be reasonably easy to understand. The sequential execution of different instructions is known as linear program execution and is the basis for program execution in computers. To simplify the creation of instruction sequences, you will be writing your software in what is known as a high-level language or, more colloquially, a programming language. The programming language is designed for you to write your software (or code) in a format similar to the English language, and a computer program known as a compiler will convert it into the sequence of instructions needed to carry out the program.
13.1.2 FLOWCHARTS If you were given instruction in programming before reading this book, you may have been presented with the concept of flowcharts—diagrams that show the flow of the application code graphically as passing through different boxes that either perform some function or control the direction the path of execution takes. Fig. 13-1 shows an example flowchart for a robot program in which a robot will go forward until it encounters an object and then reverse and turn left for a half second. The advantage of using flowcharts in teaching programming is how well they describe simple applications graphically and show the operation of high-level programming concepts in a form that is easy to understand. Flowcharts have four serious drawbacks that limit their usefulness. First, they do not work well for low-level programming concepts. A simple arithmetic statement that multiplies two values together and stores the product in different locations is written as: A = B × C
In most programming languages this is easily understood by everyone by virtue that this is a simple equation taught in grade school. The flowcharting standard does not easily handle this operation.
172
PROGRAMMING FUNDAMENTALS
Begin
Read Infrared Proximity Sensor
Go Forward
No
Object Detected?
Yes
Reverse and Turn Left for 1/2 Second
FIGURE 13-1 A flowchart will display high-level program execution.
At the other end of the spectrum, flowcharts cannot easily describe complex programming concepts like the select statement in PBASIC (described in Chapter 15) or sequences of operations. The third issue with flowcharting is that they are hard to change when a new feature is added to a program or mistakes in the program are corrected. This program is alleviated somewhat with computer-aided graphical programs, but it is still a chore to update a flowchart. Finally, flowcharts do not show what programs are doing very effectively. Computer programming languages are literally that; a language used by a human to communicate with a computer that is similar in format as a spoken or written language used to communicate ideas and concepts to other humans. While programs may seem difficult to read, their function can usually be determined by applying the same rules of logic used when communicating with other people. This is not true with flowcharting, where the function of the program is difficult to find in a moderately complex diagram. Flowcharts are effective in explaining certain types of programming operations, but their inability to represent multiple statement types as well as not being very efficient in describing complex programs with different types of statements has pushed them away from the forefront of computer programming education. There are some applications that use a flowcharting format (the programming interface for Lego Mindstorms and
13.1 IMPORTANT PROGRAMMING CONCEPTS
173
National Instruments’ LabView are the most popular), but for the most part computer (and robot) programming is carried out using traditional text-based linear execution programming languages. The use of these programming languages for robotics is discussed in the following.
13.1.3 VARIABLES AND I/O PORTS The term variable comes from the notion that the data is not constant and has to be stored somewhere for later use. Even if you knew what the data value was at some time, it may have changed since the last time it was checked; variable data isn’t static. To be able to store and find data in a changeable place is a keystone to programming. Memory in a computer can be thought of as a series of mailboxes, like the ones shown in Fig. 13-2. Each variable is given a name or a label to allow a program to access it. When data is accessed, this name is used by the computer to retrieve or change the value stored in it. Using the variable names in the mailboxes of Fig. 13-2, an arithmetic assignment statement can be created: i = 7
In this statement, the variable i will store the value 7; this is an example of storing a constant value in a variable. Variables can be read and their value can be stored in another variable like j = k
in which the contents of k are stored in j. While the statement is described as storing the contents of one variable into another, the original (value source) variable’s contents don’t change or are taken away—the value is copied from k and the same value put into j. At the end of the statement, both j and k store the same value. Finally, in i = (j ∗ k) + Src
i
j
k
Date Src
FIGURE 13-2 Variables can be thought of as a series of boxes, each of which is given a name to allow the data to be easily found.
174
PROGRAMMING FUNDAMENTALS
the computer will retrieve the contents of j, k and Src, find the product of j and k, add it to Src, and then save the computed value into i. This is an example of a complex assignment statement, which will be discussed later in the chapter. I/O ports and hardware special function registers usually use the variable format for reading and writing values into the computer’s hardware. So, to output 123 from a computer system I/O port, a statement like this is used: IOPort = 123
When you are new to programming, this can be confusing. Hardware that is treated like registers can be difficult to visualize (especially when you retrieve the value of a register and find that it has changed due to a changing input or a counter value). The data stored in variables come in many forms, and how you choose to store and display data can make your programming much easier to work through or much harder due to many difficult to find errors. There are three different aspects of data, including the amount of space used to store individual values, the format the data is displayed in, and whether relevant pieces of data can be stored together. These three aspects are discussed in the following two sections. 13.1.3.1 Data Types Several different data types are available to all types of programming for storing data in variables and I/O ports. Which one you choose will depend on the data being stored in them. The values might represent a number like 1 or 127, the numeric equivalent of a text character (65 is “A” using the ASCII standard), or a binary value like 00010001, which could mean “run both motors forward” in your robot. No matter what form the data type is in, most programming languages expect to see data follow predefined types. This is necessary so the data can be properly stored in memory. The most common data type is the eight-bit integer, so-called because the value stores an integer (a whole number) using eight bits. With eight bits, the program can work with a number from 0 to 255 (or −128 to +127, depending on how it uses the eighth bit). The basic data types that you can expect in a programming language are as follows:
• • • • • •
one-bit value, which can hold a 1/0, true/false or high/low value eight-bit integer, or byte (can hold a number or a string value) eight-bit ASCII character 16-bit integer, or word 32-bit integer, or long or double word (dword) 32-bit floating point, or single (floating point means a number with a decimal point)
In many cases, the language provides for either or both signed and unsigned values. The first bit (called the most significant bit, or MSB) is either 0 or 1, which means a positive or negative value. With a 16-bit unsigned integer, for example, the program can store values from 0 to 65535. With a 16-bit signed integer, the program can store values from −32768 to +32767.
13.1 IMPORTANT PROGRAMMING CONCEPTS
175
13.1.3.2 Number Bases In school you learned that when every number is written out, it is done as part of a base or radix. This is the number of different characters a single digit can have. We are most familiar with the base 10 (known as decimal) due to the number of fingers we have, allowing our ancestors to easily count and add without the need for a pencil and paper. Values larger than the maximum number of characters allowed in a single digit caused additional, higher value digits to be used. These digits are multiplied by the next power of the number base. To illustrate what this means, consider the number 123. The value is larger than what a single digit can be so digits multiplied by different powers of the base are used. The single digits are multiplied by the base to the power 0. “Tens” are the base to the power 1 and “hundreds” are the base to the power 2. The number can be written out mathematically as: 3 × 100 = 3 × 1 2 × 101 = 2 × 10 1 × 102 = 1 × 100 Total
= 3 = 20 = 100 = 123
Decimal is the most convenient base for humans to work with, but it isn’t for computers. Computer circuitry is built from digital logic, which can be either a one (1) or zero (0). Rather than develop circuitry that only works with base 10 numbers, computer designers instead have chosen to have them work in terms of base 2, or binary. The operation of binary is identical to that of decimal, except each digit is a power of 2, not a power of 10. Using this information, Table 13-1 was developed to show the values for each digit of an eight-bit binary number. Note that the bit number is actually the power of 2 for the digit.
TABLE 13-1 Binary number values. The “%” in front of the binary number is used to indicate the value is binary and not decimal or hexadecimal. BIT
BINARY VALUE
DECIMAL VALUE
0
%00000001
1 = 20
1
%00000010
2 = 21
2
%00000100
4 = 22
3
%00001000
8 = 23
4
%00010000
16 = 24
5
%00100000
32 = 25
6
%01000000
64 = 26
7
%10000000
128 = 27
176
PROGRAMMING FUNDAMENTALS
Knowing the decimal values for each bit, a decimal number can be converted to a binary number by taking away the highest possible value. The decimal number 123 can be converted to binary as: Bit Bit Bit Bit Bit Bit Bit Bit
7 6 5 4 3 2 1 0
= 128 cannot be taken away from 123 = 64 can be taken away from 123 = 32 can be taken away from 59 = 16 can be taken away from 27 = 8 can be taken away from 11 = 4 cannot be taken away from 3 = 2 can be taken away from 3 = 1 can be taken away from 1
– – – – – – – –
%0xxxxxxx %01xxxxxx %011xxxxx %0111xxxx %01111xxx %011110xx %0111101x %01111011
So, the binary number 01111011 is equivalent to the decimal number 123. When binary numbers are written in this book, they are proceeded by a percent (%) character, which is used in BASIC to indicate that a number is binary and not decimal. Binary numbers can be cumbersome to work with—it should be obvious that trying to remember, say, and record “zero-one-one-one-one-zero-one-one” is tedious at best. To help make working with large binary numbers easier, hexadecimal, or base 16, numbers (which can be represented by four bits) is commonly used. Hexadecimal numbers consist of the first 10 decimal digits followed by the first six letters of the alphabet (A through F) as shown in Table 13-2. The same methodology is used for converting decimal values to hexadecimal as was used for binary, except that each digit is 16 times the previous digit. The “123” decimal works out to $7B where the “$” character is used in BASIC to indicates it’s a hexadecimal number. When programming, it is recommended that binary values are used for single bits, hexadecimal is used for register values, and decimal for everything else. This will make your program reasonably easy to read and understand and imply what the data is representing in the program without the need for explaining it explicitly.
13.1.4 ASSIGNMENT STATEMENTS To move data between variables in a computer system, you will have to use what is known as an assignment statement; some value is stored in a specific variable and uses the format DestinationVariable = SourceValue
where the SourceValue can be an explicit number (known as a constant, literal, or immediate value) or a variable. If SourceValue is a variable, its contents are copied from SourceValue and the copy of the value is placed into DestinationVariable. Going back to the previous section, the SourceValue could also be a structure or union element. The most correct way of saying this is “The contents of SourceValue are stored in DestinationValue,” but this implies that the number is physically taken from SourceValue (leaving nothing behind) and storing it in DestinationValue. It has to be remembered that the value stored in SourceValue does not change in an assignment statement. 13.1.4.1 Mathematical Expressions A computer wouldn’t be very useful if all it could do is load variables with constants or the value of other variables. They must also
13.1 IMPORTANT PROGRAMMING CONCEPTS
177
TABLE 13-2 Hexadecimal values with binary and decimal equivalents. Note the “$” in front of the hexadecimal number is used as an indicator like “%” for binary numbers. HEXADECIMAL NUMBER
BINARY EQUIVALENT
DECIMAL EQUIVALENT
$0
%0000
0
$1
%0001
1
$2
%0010
2
$3
%0011
3
$4
%0100
4
$5
%0101
5
$6
%0110
6
$7
%0111
7
$8
%1000
8
$9
%1001
9
$A
%1010
10
$B
%1011
11
$C
%1100
12
$D
%1101
13
$E
%1110
14
$F
%1111
15
be able to perform some kind of arithmetic manipulation on the values (or data) before storing them into another variable (or even back into the same variable). To do this, a number of different mathematical operations are available in all high-level programming languages to allow you to modify the assignment statement with mathematical functions in the format DestinationVariable = SourceValue1 + SourceValue2
in which DestinationVariable is loaded with the sum of SourceValue1 and SourceValue2. DestinationVariable must be a variable, but SourceValue1 and SourceValue2 can be either constants or variables. Their values are read by the computer, stored in a temporary area within the processor, added together, and the result (sum) is stored into the destination variable. Along with being able to add two values together, programming languages provide a number of different mathematical (addition, subtraction, multiplication, and division) operations that can be performed on variables as well as bitwise (AND, OR, XOR) and compari-
178
PROGRAMMING FUNDAMENTALS
son (equals, less than, greater than, etc.). Table 13-3 lists the commonly used mathematical operations in computer programming. The characters used to represent the different operations may have some differences between languages, but for the most part they are quite consistent for the basic mathematical operations. Multiple operations can be performed from a single expression, resulting in a very complex mathematical process being carried out within the computer from a string of characters that were quite easy for you to input into the computer program. 13.1.4.2 Order of Operations All but the oldest or very simple programming languages can handle more than one operator in an expression. This allows you to combine three or more numbers, strings, or variables together to make complex expressions, such as 5 + 10 / 2 ∗ 7
This feature of multiple operators comes with a penalty, however. You must be careful of the order of precedence or operation, that is, the order in which the program evaluates an expression. Some languages evaluate expressions using a strict left-to-right process (the Parallax BASIC Stamp 2 PBASIC language is one), while others follow a specified pattern where certain operators are dealt with first, then others. This is known as the order of operations and ensures that the higher priority operations execute first. The common order of operations for most programming languages is listed in Table 13-3. The programming language usually does not distinguish between operators that are on the same level or precedence. If it encounters a _ for addition and a - for subtraction, it will evaluate the expression by using the first operator it encounters, going from left to right. You can often specify another calculation order by using parentheses. Values and operators inside the parentheses are evaluated first. Keeping the order of operations straight for a specific programming language can be difficult, but there is a way of forcing your expressions to execute in a specific order and that
TABLE 13-3 or Priority
Different Mathematical Operators and Their Order of Operations
PRIORITY
ORDER
OPERATORS
Lowest
1
− (negation), ∼(bitwise not), !(logical not)
2
+ (addition), −(subtraction)
3
* (multiplication), /(division)
4
&(bitwise AND), |(bitwise OR), ^(bitwise XOR)
5
(shift right)
6
=(greater than or equals)
Highest
7
&&(logical AND), 储(logical OR)
13.1 IMPORTANT PROGRAMMING CONCEPTS
179
is to place parentheses around the most important parts of the expression. For example, if you wanted to find the product of 4 and the sum of 5 and 3 and store it in a variable, you could write it as A = 4 ∗ (5 + 3)
in your program to ensure that the sum of 5 and 3 is found before it is multiplied by 4. If the parentheses were not in place, you would probably have to use a temporary variable to save the sum before calculating the product, like temp = 5 + 3 A = 4 ∗ temp
to ensure the calculation would be performed correctly. 13.1.4.3 Using Bitwise Operators Bitwise mathematical operations can be somewhat confusing to new robot programmers primarily because they are not taught in introductory programming courses or explained in introductory programming texts. This is unfortunate because understanding how to manipulate bits in the programming language is critical for robotics programming. Some languages simplify the task of accessing bits by the use of a single bit data type, while others do not provide you with any data types smaller than a byte (eight bits). The reason why manipulating bits in robots is so important is due to the organization of control bits in the controlling computer systems. Each I/O port register variable address will consist of eight bits, with each bit being effectively a different numeric value (listed in Table 13-4). To look at the contents of an individual bit, you will have to isolate it from all the others using the bitwise AND operator: Bit4 = Register & 16 ' Isolate Bit 4 from the rest of register’s bits
Looking at this for the first time, it doesn’t make a lot of sense although when you consult with Table 13-4, by looking at the binary value you can see that the value of 16 just has one bit of the byte set to 1 and when this is ANDed with the contents of the register, just this one bit’s value will be accurate—all the others will be zero. The set bit value that isolates the single bit of the byte is known as a mask. You can either keep a table of mask values in your pocket at all times, or you can use the arithmetic value at the right of Table 13-4. The shift left (> 12 X = X & mask X = X + 1 X = X // 8 X = X >
Shift Right n Bits
2
A = B >> n
'
ATN
Get arcTangent
2
A = XCord ATN YCord
HYP
Get Hypotenuse
2
A = XCord HYP YCord
MIN
Return Minimum Value
2
A = Value1 MIN Value2
MAX
Return Maximum Value
2
A = Value1 MAX Value2
DIG
Return Specified Digit
2
A = Value DIG Digit
REV
Reverse Set # of Bites
2
A = Value1 REV Value2
ABS
Return Absolute Value
1
A = ABS B
COS
Return Cosine of Value
1
A = COS B
SIN
Return Sine of Value
1
A = SIN(B)
~
Bitwise Invert
1
A = ~B
SQR
Return Square Root
1
A = SQR B
DCD
Set Specified Bit
1
A = DCD 4
' Same as A = 1 B
Return true if the first argument is greater than the second
A = B
Return true if the first argument is greater than or equal to the second
A < B
A < B
Return true if the first argument is less than the second
A >= B
A B
Note that the code statements inside the DO/LOOP are indented a number of spaces. This optional indentation makes it easier for people to see which code is part of a loop and what is outside it. This convention is used by most programmers and is one that you should follow to make it easier for both yourself and others to read the source code. In this example code, the code inside the loop executes seven times before execution flows out of the loop and on to the rest of the program. The DO WHILE/LOOP statement can be used for this purpose, but it is more traditional to use the FOR/NEXT statements: FOR VarName = StartValue TO EndValue [STEP StepValue] ... ' Code Executing inside the "FOR/NEXT" Loop NEXT
The FOR statement initializes a variable with an initial value and then executes until the variable is equal to the final (end) value with the variable being incremented during each loop. If no StepValue is specified, then the incrementing value is one. Using the FOR/NEXT, the seven times loop code shown previously could be reduced to: FOR i = 1 TO 7 ... NEXT
' Code that executes 7×
While the program space gains seem to be marginal over the DO/LOOP, the major advantage of using the FOR/NEXT in this case is how obvious it is to somebody reading the code. Rather than decoding the DO/LOOP statements, the FOR/NEXT is known to be a counting loop. Before going on, it should be pointed out that the comparison expressions of the DO/LOOP statements can be expanded beyond the simple examples shown so far. First, the comparison values can have arithmetic operators, causing them to calculate values in the DO/LOOP statement as shown below:
15.4 UNDERSTANDING AND USING PBASIC
DO WHILE (A ∗ 4) > 32 ... A = A - 4 LOOP
229
' Repeated code (uses "A" in calculations) ' Reduce value of "A" ' Repeat the Loop
Like the complex arithmetic expressions described in the previous section, remember that the evaluation of the expressions takes place left to right with priority given to values and operators in parentheses. When you are starting out, it is probably a good idea to avoid performing calculations in your comparison expressions until you are very comfortable with programming. The second enhancement to the comparison operators is the ability to AND as well as OR the results of multiple comparison operators together: DO WHILE ((A ∗ 4) > 32) AND (STOPFlag = 0) ... ' Repeated code (uses "A" in calculations) A = A - 4 ' Reduce value of "A" LOOP ' Repeat the loop
To make reading the program easier, remember to place each comparison expression inside parentheses (and this is actually a pretty good idea anyway). Along with looping a program or sections of the program for a set number of times, it is also possible to execute blocks of code conditionally. The traditional way of doing this is to use the IF/ELSE/ENDIF statement which evaluates a conditional expression and if the result is true executes specific code. As shown in the following example code, the condition expression of the IF/ELSE/ENDIF statements is exactly the same as the one used with the DO/LOOP: IF (A = B) THEN ... ELSE ... ENDIF
' Code Executes if A = B ' Code Executes if A B
The code after the ELSE statement executes if the comparison expression evaluates to false. Another way of saying this (refer back to Table 15-4), is that the ELSE code executes if the complement comparison expression is true. The ELSE code is optional and no part of it will execute if the comparison is true. Along with the IF/ELSE/ENDIF statements, if there are multiple constant values for a variable that each result in a different execution path, then the SELECT/CASE/SELECTEND statements can be used to specify blocks of code that execute when the variable is compared to any of these values. SELECT(VarName) CASE Constant1 ... CASE Constant2 ... : CASE ELSE ... ENDSELECT
' Code Executes if VarName = Constant1 ' Code Executes if VarName = Constant2
' Code Executes if VarName ANY Constants
230
THE BASIC STAMP 2 MICROCONTROLLER
The SELECT/CASE/ENDSELECT statements could be modeled using IF/ELSE/ENDIF statements arranged as: IF (Varname = Constant1) ... ' Code Executes if VarName = Constant1 ELSE IF (Varname = Constant1) ... ' Code Executes if VarName = Constant2 ELSE ... ' Code Executes if VarName ANY Constants ENDIF ENDIF
Note that when the multiple IF/ELSE/ENDIF statements are used together, each line is indented to indicate what previous statement it executes under. The DO WHILE/LOOP, DO UNTIL/LOOP, DO /LOOP WHILE, DO /LOOP UNTIL, IF/ELSE/ENDIF, and SELECT/CASE/ENDSELECT statements and the code associated with them are known as decision structures because they are well-defined blocks of code that execute based on the result of a test (or decision). They also go under other names such as flow control or conditional execution statements. Regardless of their name, they are common to most programming languages that you will be working with. If you are already familiar with PBASIC or are referencing other books about BS2, you will probably see that a whole class of decision structures, the IF/THEN and BRANCH, statements is not mentioned. Along with this, if you look on the Internet for sample applications, you probably won’t see the decision structures listed here at all in the code. With the introduction of PBASIC 2.5, Parallax introduced these decision structures to allow the application developer to write code using structured programming methodologies. Structured programming eschews the use of GOTO statements as they make a program difficult to read and certain operations, like rewriting the previous IF/ELSE/ENDIF example code. IF (A B) THEN NotEquals ... ' Code Executes if A = B GOTO Finished NotEquals: ... ' Code Executes if A B Finished:
difficult to implement correctly. (The character strings ending in a colon (:) are labels and indicate specific points in the code execution should jump to.) It is considered good programming form to only use structured programming statements, such as the ones presented in this section, and avoid the use of GOTOs or statements that execute GOTOs all together. Finally, it was implied at the start of the section that all programs should use the program template provided previously as a basis for application programs, which required the use of a DO/LOOP implemented as an infinite loop. There are cases where you will want to execute a simple program that executes a number of statements and stops. This type of program is good for experimenting with the BS2 and learning about different PBASIC statements and functions. When implementing this type of program, always remember to place an END statement at the bottom of the code. The END statement stops the BS2’s interpreter and leaves the
15.4 UNDERSTANDING AND USING PBASIC
231
I/O pins in their current state until power or the reset pin is cycled or a new program is loaded into it. Depending on the function of the example program, either a DO/LOOP is used or an END statement.
15.4.4 BUILT-IN FUNCTIONS The PBASIC language supports several dozen built-in functions that are used to control some activity of the chip, including sounding tones through an I/O pin or waiting for a change of state on an input. The following functions are among the most useful for robotics. You’ll want to study these statements more fully in the BASIC Stamp manual, and more information regarding many of them are discussed elsewhere in this book.
•
•
•
• •
• •
Button. The button function momentarily checks the value of an input and then branches to another part of the program if the button is in a low (0) or high (1) state. This function lets you choose which I/O pin to examine, the target state you are looking for (either 0 or 1), and the delay and rate parameters that can be used for such things as switch debouncing. The button function doesn’t stop program execution, which allows you to monitor a number of I/O pins at once. This function’s operation is somewhat difficult to understand and will be explained in detail later in the book. Debug and debugin. The BASIC Stamp Editor has a built-in terminal that passes data, in different formats, to and from the BASIC Stamp with the programming PC. These functions are highly useful during testing; for example, you can have the debug function display the parameters that were used to calculate the current output state of an I/O pin, so you can determine whether the program is working properly. Freqout. The freqout function is used to generate tones primarily intended for audio reproduction. You can set the I/O pin, duration, and frequency (in hertz) using this function. An interesting feature of freqout is that you can apply a second frequency, which intermixes with the first. For example, you can combine a straight middle A (440 Hz) with a middle C (523 Hz) to create a kind of chord. Don’t expect a symphonic sound, but it works for simple tunes. When freqout is used to drive a speaker you should connect capacitors (and resistors, as required) to build a filter. Pause. The pause function is used to delay execution by a set amount of time. To use pause you specify the number of milliseconds (thousandths of a second) to wait. For example, pause 1000 pauses for 1 s. Pulsin. The pulsin function measures the width of a single pulse with a resolution of two microseconds (2 µs). You can specify which I/O pin to use, whether you’re looking for a 0-to-1 or 1-to-0 transition, as well as the variable you want to store the result in. Pulsin is handy for measuring time delays in circuits, such as the return ping of an ultrasonic sonar. Pulsout. Pulsout is the inverse of pulsin; with pulsout you can create a finely measured pulse with a duration of between 2 µs and 131 milliseconds (ms). The pulsout statement is ideal when you need to provide highly accurate waveforms. Rctime. The rctime statement measures the time it takes for an RC (resistor/capacitor) network to discharge to an opposite logical state. The rctime statement is often used to indirectly measure the capacitance or resistance of a circuit, or simply as a kind of simplified analog-to-digital circuit. Fig. 15-6 shows a sample circuit.
232
THE BASIC STAMP 2 MICROCONTROLLER
FIGURE 15-6 The rctime statement is used to measure the time it takes for a capacitor to discharge (the timing is accurate to 2 µs intervals). With this information you can indirectly measure capacitance or resistance.
• •
Serin and serout. Serin and serout are used to send and receive asynchronous serial communications. They are typically used for RS-232 interfaces, but have a number of formatting options that make them appropriate for a variety of different applications— even communicating between multiple BASIC Stamps. Shiftin and shiftout. The shiftin and shiftout functions are used in two- or three-wire synchronous serial communications. With shiftin/shiftout a separate pin is used for clocking the data between the source and destination. If you’re only sending or receiving data, you can use just two pins: one for data and one for clock. If you’re both sending and receiving, your best bet is to use three pins: data in, data out, and clock.
These statements are useful when communicating with a variety of external hardware, including serial-to-parallel shift registers and serial analog-to-digital converters.
15.5 Sample Interface Applications Before going on to interfacing the BS2 (or any other microcontroller) into robots or a final application, you should spend some time learning how to program, create electrical interfaces, and debug applications. In the following sections, some simple applications are presented along with basic wiring information for the BS2 that will come in handy when you are creating your own applications. A quick Internet search will also yield many different sites with information on robots and microcontrollers. For instance, as this edition of the book was written, a Google search of BS2 and Robots yielded over 10,000 sites. Even if only 1 out of 10 sites had a BS2 application on it, there are over 1000 projects that you can choose from or use as a reference for your robot. Along with links to web pages, you should also consider joining one of the Yahoo! list servers (some listed in the appendices) to share your ideas and ask questions of others. Please do not consider this book as the ultimate resource on the BS2 and how it is used in robot applications. Go through the appendices for additional introductory how-to reference books on the BS2 and how microcontrollers can be used with robots. The more time spent learning about a specific microcontroller, building your own circuits, and trying different programs as well as seeing a variety of different people’s perspectives will minimize the problems that you will have later when you are wiring up and programming your robot.
15.5 SAMPLE INTERFACE APPLICATIONS
233
15.5.1 BASIC BS2 SETUP At the start of this chapter, it was noted that the BS2 could be programmed cheaply and easily. Unlike other microcontrollers, you can create a breadboard-based development circuit like the one shown in Fig. 15-7 for about $10 (if you use new parts). The circuit consists of a serial interface to your PC along with a small breadboard, a box of precut wires, a breadboard-mountable DPST switch (an EG-1903 is used in Fig. 15-7), and a three AA battery clip attached to the breadboard’s backside two-sided tape. The entire package can be built in about 20 minutes and once the BASIC Stamp Editor software has been downloaded into your PC you are ready to go! The biggest piece of work is soldering five wires and a jumper to a nine-pin female D-shell connector to make the serial communications/programmer interface as shown in Fig. 15-8 (a photograph of an assembled prototype is shown in Fig. 15-9). The BS2 is programmed via RS-232. If your PC does not have a serial port, you can buy a USB to RS-232 adapter. The parts needed to put the interface connector together are listed in Table 15-5. You might be tempted to put the two 0.1 µF capacitors onto the breadboard, but you will find that by spending a few extra minutes soldering them to the nine-pin female D-shell, the effort of having to come up with the most efficient breadboard wiring will be avoided each time the BS2 is used in an application. Also note that the four wires (each a different color to aid in keeping track of them) were cut to the same length with a 1⁄2 in (1 cm) or so of bared copper and bent in the same direction to allow them to be pressed into the breadboard.
FIGURE 15-7 BS2 on a breadboard with the communications/programmer interface and a three AA battery pack stuck to the back side of the breadboard and providing power to the BS2.
234
THE BASIC STAMP 2 MICROCONTROLLER
FIGURE 15-8 The BS2’s serial communications/programmer interface is quite simple.
FIGURE 15-9 All the parts of the final BS2’s serial communications/programmer interface can be soldered as one assembly. Notice that the wires all bend together to provide an easy and direct interface to the BS2.
15.5 SAMPLE INTERFACE APPLICATIONS
TABLE 15-5
235
Serial Communications/Programming Interface Parts List
Connector
Female nine-pin D-shell connector
Capacitors
0.1 µF capacitors (any type)
Misc.
24 gauge wire, different colors
When you’ve assembled the serial communications/programming interface, cut a strip of the two-sided tape off the back of a small breadboard and stick on a three or four AA battery clip. For the BS2 to work properly, 4.5 to 6 V must be applied to it. If you are going to use alkaline cells (which produce 1.5 to 1.8 V each), only three batteries are required. If you are going to use NiMH rechargeable batteries (which produce 1.2 V), then four batteries will be required. You might also want to put a power switch in line with the positive voltage from the battery pack. The positive and negative voltage should be connected to the common strips on the breadboard and connected to VDD (pin 21) and VSS (pin 23), respectively. VIN and the on-board voltage regulator is bypassed as is the _RES (Reset) pin. The BS2 will power up any time power is applied to it. With the hardware together, you can download the BASIC Software Editor (from www.parallax.com, “Downloads”) and install it on your PC. Along with Windows software, there are also Linux and Mac editors available. The editor should install like any other application and once you have connected the serial port to a straight-through nine-pin male to nine-pin female cable, you are ready to try out your first application! The typical first application of any computer system is the Hello World, which follows. This program will simply print out the welcome phrase to indicate that it is up and running. Key in the program to the BASIC Stamp Editor, save it on your PC’s desktop, and then either click on the right-pointing triangle on the toolbar or press Ctrl-R. This will compile, download, and then run the application. ' Hello World ' ' This Program Prints the String "Hello World!" ' ' ' Author: Myke Predko ' ' Date: 05.06.23 ' ' '{$STAMP BS2} '{$PBASIC 2.5} ' Variables ' Mainline DEBUG "Hello World!", CR
'
Print the String
END
'
Stop Program
236
THE BASIC STAMP 2 MICROCONTROLLER
If the program was keyed in correctly and the wiring is correct, a terminal Window should appear with the message “Hello World.” If there is an error message indicating there is a problem with the program, check what you’ve keyed in to make sure the program has been entered correctly. If the PC cannot find a BS2 connected to it, check the wiring of the nine-pin D-shell connector and that at least 4.5 (but not more than 6.0) V is going into the BS2’s pin 21 and 23. Additional debugging information can be found in the BASIC Stamp Syntax and Reference manual downloadable from the Parallax web site.
15.5.2 LED OUTPUTS With the software loaded on your PC and a simple programming/communications interface built and tested for your BS2, you can now start experimenting with the input/output capabilities of the microcontroller. The most fundamental output device that is used with a microcontroller is the light-emitting diode (LED) and with it you can learn a lot about programming and how the BS2 works. To demonstrate LED interfacing in this and the next section, you should wire the circuit shown in Fig. 15-10, consisting of the BS2, the programming/communications interface, and eight LEDs, wired to the low eight bits of the BS2’s I/O port. The parts required for this circuit are listed in Table 15-6. To simplify the wiring in the prototype, eight 5 × 2 mm rectangular LEDs were used instead of square LEDs (Fig. 15-11). The first task you might want to perform is to flash a single LED (we’ll get to the other LEDs later in this section) by performing a delay, turning the LED on, waiting the same delay, and turning the LED off. This process is repeated using the DO/LOOP statements. The first program, listed here, writes directly to the P0 I/O pin to turn the LED on and off with delays in between, as described in this paragraph. ' LED Flash Demonstration 1 - Flash LED on P0 2× per second '{$STAMP BS2} '{$PBASIC 2.5} '
Mainline DIR0 = 1 DO OUT0 = 0 PAUSE 250 OUT0 = 1 PAUSE 250 LOOP
' P0 is an output ' LED On ' Delay 1/4 second ' LED off ' Repeat
When doing any kind of programming for the first time, or if you encounter a problem, it is recommended that you try to come up with three different ways of performing a task. The first way, while it works, might not be the most efficient or easily understood method of performing the task. Writing directly to the I/O ports using assignment statements may be confusing to some people. A second way of flashing the LED on and off could be to use the built-in HIGH and LOW PBASIC functions rather than writing to the I/O ports directly. These functions avoid the need for writing to the bits directly:
15.5 SAMPLE INTERFACE APPLICATIONS
237
1 SOUT
VIN
24
2
SIN
VSS
23
3
ATN
_RES
22
4
VSS
VDD
21
5
P0
P15
20
6
P1
P14
19
7
P2
P13
18
P12
27
P11
26
BASIC Stamp 2
0.1 uF
1
8
P3
9
P4
10
P5
P10
15
11
P6
P9
14
12
P7
P8
13
+ 3x AA Batteries
8x5x2mm LEDs FIGURE 15-10 BS2 with serial communications/programmer interface and eight LEDs.
FIGURE 15-11 The circuit is very simple when 5 × 2 mm LEDs are bent into shape as shown here.
238
THE BASIC STAMP 2 MICROCONTROLLER
TABLE 15-6
BS2 LED Experimentation Circuit Parts List
BS2
Parallax BASIC Stamp 2
LEDs
5 × 2 mm Red LEDs
Programmer
BS2 Programmer/Communications Interface
Misc.
Breadboard, 3x AA Alkaline Battery Clip, Breadboard Wires, Power Switch
' LED Flash Demonstration 2 - Flash LED on P0 2× per second '{$STAMP BS2} '{$PBASIC 2.5} '
Mainline DO LOW 0 PAUSE 250 HIGH 0 PAUSE 250 LOOP
' LED On ' Delay 1/4 second ' LED off ' Repeat
Finally, when looking up the HIGH and LOW functions, you might have discovered the TOGGLE function, which changes the output state of an I/O pin. This feature makes the program even simpler: ' LED Flash Demonstration 3 - Flash LED on P0 2× per second '{$STAMP BS2} '{$PBASIC 2.5} '
Mainline OUTPUT 0 DO TOGGLE 0 PAUSE 250 LOOP
' LED = LED ^ 1 ' Delay 1/4 second ' Repeat
It is recommended that you play around with the LEDs and try to come up with different applications to demonstrate how the various functions work. For example, you might want to create a Cylon Eye using the eight LEDs using the code: ' LED Flash Demonstration 4 - Cylon Eye '{$STAMP BS2} '{$PBASIC 2.5} Direction VAR Bit ' Up/Down Direction '
Mainline DIRL = $FF OUTL = 1
' '
P7:P0 Outputs P0 is On
Direction = 0
'
Go Up
15.5 SAMPLE INTERFACE APPLICATIONS
239
DO PAUSE 100 ' Delay 1/10 second IF (Direction = 0) THEN ' Select Direction OUTL = OUTL > 1 IF (OUT0 = 1) THEN Direction = 0 ENDIF LOOP ' Repeat
Don’t be afraid to try new ideas and if they don’t work, spend some time trying to understand what the problem is and fix it. A good rule of thumb is that your first real program will take two weeks to get running properly, your second program a week, the third two days, the fourth four hours, and so on until you are very familiar with programming the BS2 and looking at different ways of approaching the problems. The Cylon Eye program probably seems very impressive and most likely very difficult to implement on your own, but if you work at the problem, try out different things, and always keep in the back of your mind that you want to think of three different ways of approaching a problem, you will become a competent programmer very quickly.
15.5.3 ADDING SWITCHES AND OTHER DIGITAL INPUTS LEDs, as well as being useful devices for learning how to program, are excellent status indicators for the current state of the program of different inputs. The most basic input device is the momentary on button, which closes the circuit when pressed. This device can be used along with LEDs to demonstrate how digital inputs are passed to the BS2. The circuit used to test button inputs is shown in Fig. 15-12 and the parts required are listed in Table 15-7. The circuitry was chosen to match that of the previous section to avoid 1 SOUT
2
VIN
24
3
SIN
VSS
23
ATN
_RES
4
VSS
22
VDD
5
21
P0
6
P15
20
P1
P14
19
7
P2
P13
18
8
P3
9
P4
P12
17
P11
10
P5
16
P10
11
15
P6
P9
14
12
P7
P8
13
BASIC Stamp 2
0.1 uF
1
10k
+
Momentary On Button
8x5x2mm LEDs
FIGURE 15-12 Momentary on button added to the BS2 eight-LED circuit.
3x AA Batteries
240
THE BASIC STAMP 2 MICROCONTROLLER
TABLE 15-7
BS2 Button Experimentation Circuit Parts List
BS2
Parallax BASIC Stamp 2
LEDs
5 × 2 mm Red LEDs
10k
10k Resistor
Button
Momentary On Button—with wires soldered on to interface with the breadboard
Programmer
BS2 Programmer/Communications Interface
Misc.
Breadboard, 3x AA Alkaline Battery Clip, Breadboard Wires, Power Switch
the need to tear down and build up a new circuit as you are learning about the BS2. You may be able to find a momentary on button that can be plugged directly into the breadboard, but chances are you will have to solder some wires to a switch and push them into the breadboard to add the switch to the circuit. The BS2 is built from CMOS technology. As discussed earlier in the book, it does not have its own internal voltage or current source so you must make sure that the input pins are driven either high or low. In this circuit, the 10k resistor pulls up the input pin until the button is pressed and the pin is connected to ground (pulled down). The 10k resistor limits the amount of current that passes through the momentary on switch to ground to about 50 µA. A pull-up circuit, such as this, should always be used with BS2 inputs to ensure that the voltage always transitions from high to low and a very small amount of current passes between them. To test the circuit, the following program will turn on the LED at P0 any time the input at P15 is low (which is the pulled up momentary on button). Notice that the value at P15 cannot be passed directly to P0—when the button is pressed, the input is low, but to turn on the LED, the output must be high. The XOR (^ operator) with 1 will invert the signal from P15 so it can be used with P0. ' Button Demonstration 1 - Control LED on P0 by Button on P15 '{$STAMP BS2} '{$PBASIC 2.5} '
Mainline DIR0 = 1 DO OUT0 = IN15 ^ 1 LOOP
' P0 is an output ' Toggle Button Input ' Repeat
When you pushed down the button, you may have noticed that the LED flickered on and off. This was due to button bounce, dirty contacts, or your finger getting tired. To try and show this action more clearly, the second button demonstration turns off all eight LEDs
15.5 SAMPLE INTERFACE APPLICATIONS
241
and then starts to turn them on (by shifting bits up) when the button is pressed. If the button is lifted, then the program stops until the button is pressed again. ' Button Demonstration 2 - Button Bounce Demonstration '{$STAMP BS2} '{$PBASIC 2.5} '
Mainline DIRL = $FF ' LEDs on P0-P7 OUTL = 0 DO DO WHILE (IN15 = 1) ' Wait for Button Press LOOP OUTL = 0 ' Turn off LEDs DO WHILE (IN15 = 0) ' Shift Up while Pressed OUTL = (OUTL = "A") AND (InputString(j) = "0") AND (InputString(j) = "0") AND (InputString(j) = 24) AND ((Temp & $1F) O DIR0, 1
which puts I/O pin 0 into output mode. To read the state of a pin variable, use the “I(nput)” command > I OUT0
and the program will display the data. To demonstrate the operation of the program, wire an LED with its cathode at the BS2’s pin 0 and its anode at pin 3. To turn on the LED, enter the following command sequence. The comments following are to explain what each command is doing. > > > >
O I O I
DIRA, %1001 DIRS OUT3, 1 INL
' ' ' '
Make Read Turn Read
BS2 Pins 0 & 3 Outputs Back ALL the Mode Bits to See Changes on the LED in the lower 8 Bits of the Input Bits
TABLE 15-11 Different Labels to Access the Different BS2 “OUT” Register Bit Combinations REGISTER BITS
“OUT” LABEL
COMMENTS
0–15
OUTS
All 15 Output Bits
0–7
OUTL
Lower 8 Output Bits
8–15
OUTH
Upper 8 Output Bits
0–3
OUTA
Lowest 4 Output Bits
4–7
OUTB
Second Lowest 4 Output Bits
8–11
OUTC
Second Highest 4 Output Bits
12–15
OUTD
Highest 4 Output Bits
2
OUT2
Bit 2
13
OUT13
Bit 13
252
THE BASIC STAMP 2 MICROCONTROLLER
Ironically, even though this application was written for beginners, it is really quite advanced. A large part of this is due to the string parsing that the program performs but a large part is due to trying to shoehorn the application into a BS2 (use Ctrl-M in the BASIC Stamp Editor to see what I mean). The program took a bit of work in figuring out which register was being specified and then what was the value to be written to it.
15.6 BS2 Application Design Suggestions The BS2 will most likely be the easiest microcontroller or computer system that you will work with. It is easy to program, and the built-in functions allow you to do more with the I/O pins than what you would normally expect to be able to do with a simple microcontroller. Electrically, while the BS2 is very robust, there are a few things that you can do to ensure that it will work reliably and safely in your robot application. The first thing is to provide an externally regulated 5V to the BS2’s VDD pin rather than some higher voltage on VIN. The on-board regulator’s maximum current output of 100 mA is the reason for suggesting the alternative power input. The voltage regulator has been known to burn out when excessive current is being drawn through the on-board PIC’s I/O pins (for turning on LEDs, for example). The regulator can be replaced, but it is a lot easier to plan for providing 5 V directly to the BS2. The voltage of three AA (or even AAA) alkaline batteries in series is sufficient to power the BS2 along with any external peripherals safely. In some instances, especially when high voltages are involved, the I/O pins of the BS2 can be damaged. The recommended prevention to this problem is to always put a 220 Ω resistor in series with the I/O pin and whatever devices they are connected to. A 220 Ω resistor will limit the maximum current passing through the I/O pins but still provide enough current to light LEDs. The example circuits in this chapter do not have 220 Ω resistors built into them to simplify the wiring of the sample applications, but when you are installing a BS2 into a robot you should always make sure that you have a resistor on every I/O pin. There is no need for an external reset control. The BS2’s “_RES” pin is pulled up, so that if you want to add a momentary on button that can tie the pin to ground and reset the BS2 you can. For the most part, this isn’t necessary. Finally, it is always a good idea to build the BS2’s programming interface into your robot. The circuit is simple and will eliminate the need to pull out the BS2 every time the program is changed. This will reduce the wear and tear on the I/O pins as well as the socket connectors and minimize the chance that you will damage your BS2. Many of these suggestions are applicable to other microcontrollers and computer interfaces. A few extra parts and a few extra minutes can mean that your competitive robot always will be ready for action, not on the bench waiting for its “brains” to be replaced.
15.7 FROM HERE
253
15.7 From Here To learn more about . . .
Read
Using DC motors for robot locomotion
Chapter 20, “Working with DC Motors”
Using servo motors for robot control and locomotion
Chapter 22, “Working with Servo Motors”
Choices and alternatives for robot computers and microcontrollers
Chapter 12, “An Overview of Robot ‘Brains’ ”
Attaching real-world hardware computers and microcontrollers
Chapter 14, “Computer Peripherals”
This page intentionally left blank
CHAPTER
16
REMOTE CONTROL SYSTEMS
T
he most basic robot designs—just a step up from motorized toys—use a wired control box on which you flip switches to move the robot around the room or activate the motors in the robotic arm and hand. The wire link can be a nuisance and acts as a tether preventing your robot from freely navigating through the room. You can cut this physical umbilical cord and replace it with a fully electronic one by using a remote control receiver and transmitter. This chapter details several popular ways to achieve links between you and your robot. You can use the remote controller to activate all of the robot’s functions, or, with a suitable on-board computer working as an electronic recorder, you can use the controller as a teaching pendant. You manually program the robot through a series of steps and routines, then play it back under the direction of the computer. Some remote control systems even let you connect your personal computer to your robot. You type on the keyboard, or use a joystick for control, and the invisible link does the rest.
16.1 Controlling Your Robot with a PC Joystick or Control Pad In previous editions of this book, a joystick taken from an old Atari video game was used as a build-your-own teaching pendant. Over the years, it has become very difficult to find sur255 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
256
REMOTE CONTROL SYSTEMS
plus or used Atari video game joysticks and even the ones that are available are generally in poor shape because the plastic boot often cracked or pulled out of the plastic base, making the joystick difficult to use. What should be readily available are PC joysticks or gamepads, which can be easily adapted into wired controllers for robots. The PC joystick connects to a PC via a 15 pin D-shell connector and is wired according to Fig. 16-1. The pinout of the PC port is given in Table 16-1 and it can accommodate up to two joysticks. For robot applications in which the joystick will be used to control the motion of the robot, only Joystick A along with its two fire buttons are used. For more complex robots, two joysticks could be wired into the port. The joystick isn’t a terrible interface, although it can be difficult to work precisely. Despite the added capability of proportional joysticks, games quickly standardized on a gamepad similar to that used by Nintendo with a cross joystick that was digital (indicates Up, Down, Left, or Right). To interface the gamepad digital joystick with the standard PC game port, the circuit shown in Fig. 16-2 was developed. When the joystick is centered, current flows through one 50k resistor, which is the same resistance as when the analog joystick is centered. If the Right or Down button is pressed, the PNP transistor is turned off and current flows through a second 50k resistor, providing the full 100k resistance of the standard joystick. Finally, if the Left or Up button is pressed, the resistance drops to zero. This circuit works quite well and gives the PC the same interface as a basic game machine. To demonstrate the operation of a gamepad (or an old PC joystick) and turn on an LED according to whether the joystick is moved to an extreme, the circuit in Fig. 16-3 (and parts
Vcc 1
15 Pin Male D-Shell Connector
100k
100k
FIGURE 16-1 Internal wiring of PC joystick. Note that the analog outputs are part of a voltage divider tied to Vcc with a resistance of 0 to 100k.
16.1 CONTROL YOUR ROBOT WITH A PC JOYSTICK OR CONTROL PAD
TABLE 16-1
PC Joystick Port Pinout
PIN
FUNCTION
1
+5 V DC
2
B1A—button 1, joystick A
3
XA—x axis resistance, joystick A
4
Ground
5
Ground
6
YA—y axis resistance, joystick A
7
B2A—button 2, joystick A
8
+5 V DC
9
+5 V DC
10
B1B—button 1, joystick B
11
XB—x axis resistance, joystick B
12
GND/MIDI out
13
YB—y axis resistance, joystick B
14
B2B—button 2, joystick B
15
+5 V DC/MIDI In
Vcc
Vcc
Vcc
50k PNP 50k Right/ Down
Left/ Up Output Resistance
50k
FIGURE 16-2 Internal circuitry for a PC gamepad to provide 100k when the Right/Down button is pressed, 50k when no button is pressed, and 0 Ω when the Left/Up button is pressed.
257
258
REMOTE CONTROL SYSTEMS
TABLE 16-2
Parts List for PC Gamepad Interface
15 pin female D-shell
15 pin female D-shell connector
LM339
LM339 quad open-collector output comparator chip
LED1–LED4
Visible light LEDs
R1–R2
10k resistors
R3, R4, R7
100k resistors
R5
22k resistor
R6
47k resistor
R8–R11
470 Ω resistors
Misc.
Breadboard, breadboard wiring, 4x AA battery clip, 4x AA batteries, breadboard mountable switch
list in Table 16-2) was developed. Wires will have to be soldered to the 15 pin female D-shell connector to allow it to be wired to a breadboard. The circuit uses the two voltages produced by the voltage divider built from R5 through R7 to compare to the voltages produced by the voltage divider, which uses the gamepad/joystick internal resistances along with a 100k resistor to find out if any of the axes have gone to the extreme. The comparator will allow current to flow through the appropriate LED when the gamepad/joystick resistance is at an extreme. This circuit will be used as the basis for a robot motion teaching tool in the next section.
Vcc Vcc
Vcc
Vcc
Vcc
Vcc
R5 22k LED1
LED2
LED3
LED4
R9 470
R10 470
R11 470
R6 47k
LM339 +
R7 100k
Vcc Vcc Vcc 4x AA Batteries 1
R1, R2 10k
15 Pin Female D-Shell Connector R3, R4 100k
Vcc
R8 470
+ 3 7 – 1 6 + 5 – 4
2
+ 11 – 10
13
+ 9 – 12 14 8
Right Left Up Down
FIGURE 16-3 PC gamepad interface. When a gamepad or joystick control is moved to an extreme, one or two LEDs will light.
16.2 BUILD A JOYSTICK TEACHING PENDANT
259
16.2 Building a Joystick Teaching Pendant With the circuit that will convert the position of a PC-compatible gamepad or joystick into four digital signals, you can add a microcontroller that will convert the data bits into motor control values as well as give you the ability to record a set of movements for playback later. This application is often called a teaching pendant. In this section, the gamepad/joystick interface circuit will be enhanced to do just that, as well as provide you with a method of saving the recorded positions for use in other applications. Fig. 16-4 shows how a BS2 can be added to the gamepad/joystick interface along with two LEDs and four motor control bits used to control the motion of a differentially driven robot. Along with the connections for the gamepad/joystick position, the pulled-up A and B buttons are used as control signals to the recording and playback of the teaching pendant application. The BS2 can be connected to either TTL/CMOS compatible motor drivers or to four LEDs, which will simulate the operation of the motors. For the prototype, the circuit was added to a simple DC driven mobile robot to observe the performance of the robot. After you’ve built the circuit, you can load the following program into the BS2 to demonstrate the operation of the teaching pendant control. ' ' ' ' ' '
BS2 Teaching Pendant - Use BS2 and PC Gamepad for Robot Training Along with using the PC Gamepad/Joystick for Tethered Robot Remote Control; it can also be used to record and play back movements
Vcc
1
Left Forward Vcc
BS2
Left Reverse
Vcc R5 22k R6 47k
+
LED2 Dump
R7 100k
Vcc Vcc Vcc 4x AA Batteries 1
Rec LED1
Vcc + 3 7 – 1 6
Right
+ 5 – 4
2
Left
+ 11 – 10
13
R1, R2 10k
15 Pin Female D-Shell Connector
+ 9 – 14 12 8
R3, R4 100k
Up
Right Forward Right Reverse
Down
LM339 FIGURE 16-4 The teaching pendant circuitry. The BS2 communications/programming interface will be used for saving a series of commands for the robot.
260
REMOTE CONTROL SYSTEMS ' Author: Myke Predko ' ' Date: 05.09.07 ' ' '{$STAMP BS2} '{$PBASIC 2.5}
' Pin Declarations RecLED PIN 2 DumpLED PIN 3 ButtonA PIN 5 ButtonB PIN 4
' ' ' '
Indicate Recording Indicate Sending Data to PC Motion Record Record Stop/Play back
JoyLeft JoyRight JoyUp JoyDown
PIN PIN PIN PIN
9 8 7 6
' '
Joystick Outputs from LM339 - Active Low
LeftFor LeftRev RightFor RightRev
PIN PIN PIN PIN
0 1 15 14
' ' ' '
Motor Control Pins - Active High - For Dual H-Bridge Differentially Driven Robot
' Variable Declarations i VAR Byte JValue VAR Byte ' ECount VAR Word ' DBounce VAR Word ' BState VAR Byte '
Joystick Read in Value EEPROM Address Counter Wait 20ms for debounce
Mainline LOW RecLED LOW DumpLED LOW LeftFor ' Initialize Motor Outputs to Low LOW LeftRev LOW RightFor LOW RightRev WRITE 0, 0 ' Nothing to Start Executing DEBUG "PC Gamepad/Joystick Teaching Pendant", CR DO GOSUB ButtonOff
'
Wait for Both Buttons Raised
DBounce = 0 ' Wait for Button/2 Button Pressed BState = 0 DO WHILE (DBounce < 50) IF (ButtonA = 0) THEN IF (ButtonB = 0) THEN ' Two Buttons Pressed IF (BState = 3) THEN DBounce = DBounce + 1 ELSE BState = 3 DBounce = 0
16.2 BUILD A JOYSTICK TEACHING PENDANT
261
ENDIF ' Single Button Pressed IF (BState = 1) THEN DBounce = DBounce + 1 ELSE BState = 1 DBounce = 0 ENDIF ENDIF ELSE IF (ButtonB = 0) THEN IF (BState = 2) THEN DBounce = DBounce + 1 ELSE BState = 2 DBounce = 0 ENDIF ELSE ' Nothing Pressed BState = 0 DBounce = 0 ENDIF ENDIF LOOP ELSE
SELECT (BState) CASE 1 ' Start Recording ECount = 0 GOSUB ButtonOff DEBUG "Start Recording..." HIGH RecLED DO WHILE (ButtonB = 1) AND (ECount < 1000) PAUSE 95 ' Want Roughly 100 ms between Samples JValue = (INS >> 6) & $F ' Get Value to Save WRITE ECount, JValue ECount = ECount + 1 GOSUB RobotMove LOOP WRITE ECount, 0 ' Indicate Recording is Finished DEBUG "Finished Recording.", CR LOW RecLED CASE 2 ECount = 0 GOSUB ButtonOff DEBUG "Playing Back Recorded..." HIGH DumpLED JValue = 1 DO WHILE (ButtonB = 1) AND (ECount < 1000) AND (JValue 0) PAUSE 95 ' Want Roughly 100 ms between Samples READ ECount, JValue ECount = ECount + 1 GOSUB RobotMove LOOP WRITE ECount, 0 ' Indicate Recording is Finished DEBUG "Finished Playing Back.", CR LOW DumpLED CASE 3 DEBUG "Dump the Program", CR i = 8 ECount = 0 ' Dump the Program READ ECount, JValue
262
REMOTE CONTROL SYSTEMS
DO WHILE (JValue 0) IF (i = 8) THEN DEBUG CR, "data ", DEC4 ECount i = 0 ENDIF DEBUG ", %", BIN4 JValue ECount = ECount + 1 READ ECount, JValue i = i + 1 LOOP DEBUG CR ENDSELECT LOOP ' Loop Forever ButtonOff: ' Wait for Buttons to be Released DBounce = 0 DO WHILE (DBounce < 100) IF (ButtonA = 1) AND (ButtonB = 1) THEN DBounce = DBounce + 1 ELSE DBounce = 0 ENDIF LOOP RETURN RobotMove: ' Using "JValue", Specify Robot Movement SELECT (JValue & %1111) CASE %1101 ' Moving Forwards HIGH LeftFor LOW LeftRev HIGH RightFor LOW RightRev CASE %1001 ' Moving Forwards and to Left LOW LeftFor LOW LeftRev HIGH RightFor LOW RightRev CASE %0101 ' Moving Forwards and to Right HIGH LeftFor LOW LeftRev LOW RightFor LOW RightRev CASE %1110 ' Moving in Reverse LOW LeftFor HIGH LeftRev LOW RightFor HIGH RightRev CASE %1010 ' Moving in Reverse and to Left LOW LeftFor LOW LeftRev LOW RightFor HIGH RightRev CASE %0110 ' Moving in Reverse and to Right LOW LeftFor HIGH LeftRev LOW RightFor LOW RightRev CASE %1011 ' Turning to the Left LOW LeftFor HIGH LeftRev HIGH RightFor LOW RightRev
16.2 BUILD A JOYSTICK TEACHING PENDANT
263
CASE %0111 ' Turning to the Right HIGH LeftFor LOW LeftRev LOW RightFor HIGH RightRev CASE %1111 ' Stopped LOW LeftFor LOW LeftRev LOW RightFor LOW RightRev ENDSELECT RETURN
To operate the pendant, press the A button on the gamepad/joystick to start the recording operation. Samples of the joystick position are taken every 100 ms and recorded in the BS2’s built-in EPROM for up to 100 s (1000 samples). To stop the recording, press the B button. Using the Memory Map function of the BASIC Stamp Editor software, the program was found to take up EEPROM memory locations $474 to $7FF or 2956 bytes, leaving a maximum 1140 bytes available for recording. A total of 1000 samples and bytes was chosen to allow for some expansion of the application later. To play back the application, press the B button and the robot will perform the actions in the EEPROM memory, exactly as they were recorded. It’s actually a lot of fun recording a series of motions and then watching a robot repeat them. Finally, to dump out the contents of the EEPROM, make sure the robot and BS2 are connected to a PC with the BASIC Stamp Editor software active. Start up a Debug Terminal window and press the A and B buttons simultaneously. When this is done, a series of PBASIC DATA statements are generated, which can be cut and pasted from the Debug Terminal window into an application or another program editor. These statements can be put directly into another application (and you might want to put in the RobotMove subroutine from the previous program as well) for use in it.
16.2.1 POSSIBLE ENHANCEMENTS There are a number of things that can be done to enhance the teaching pendant; some have tried the program as shown here while others are just being thrown out for your experimentation:
• • •
Double the memory usage. One hundred seconds of recorded robot motion is probably more than you will ever need, but in the rare case that you will need more samples, you could double up the memory by placing two four-bit samples into each EEPROM byte rather than the one used in the basic program. Allow control without recording. Right now, the robot motion is only allowed after the button A is pressed. You might want to modify the program to allow the robot to be controlled at any time with the two buttons controlling recording and playback. Don’t erase recorded data on start up. When the application first powers up, it writes a zero to the first EEPROM location. A zero is interpreted as a data stop. If you would like to save the data from one execution instance to the next, delete the “write 0, 0” statement at the start of the program.
264
REMOTE CONTROL SYSTEMS
• • • •
Add a second joystick for robot arm control. This will allow you to control a gripper on the front of a mobile robot or a multi-axis robot arm. Along with this, many gamepads have more than just two buttons—they can have up to four (the second two are used by a second controller) that can be used to enhance the application. Use data as escape maneuvers in combat robots. One thing you will find difficult to program a robot for is a series of predefined movements that behave exactly as you would like. You will probably find it easier to record the desired sequence and just play it back when required. Use multiple movement recordings in an application. There’s no reason why you wouldn’t want to have multiple recordings in an application. If the robot was a combat robot, you might want to randomize your escape maneuvers to make it more difficult for your opponents. Put a B button on a robot to allow playback without the pendant. It is worth the few seconds to add a button wired to the ground in parallel with the gamepad/joystick’s B button to allow the robot to perform the recorded operation without having the pendant attached. Keeping the pendant’s wires away from the movement of the robot can be a pain sometimes, especially when you have a sequence preprogrammed in that you like.
16.3 Commanding a Robot with Infrared Remote Control In the 1960s, the first television remote controls appeared, which had two or three basic functions: on/off, channel change, and sound mute. To change the channel you had to keep depressing the channel button until the desired channel appeared (the channels changed up, from 2 through 13, then started over again). What was more amazing than the remote control itself was how it worked: by ultrasonic sound. Depressing one of the control buttons struck a hammer against a metal bar cut to a specific length and produced a specific high-frequency tone. A microphone in the TV picked up the high-pitched ping and responded accordingly—although it wasn’t unusual for women’s jewelry and other metal items to produce the same frequencies and cause the channel to change (or worse, the TV to go off) periodically. These days, remote control of TVs, VCRs, and other electronic devices is taken for granted. Instead of just two functions, the average remote handles dozens—more than the knobs and buttons on the TV or VCR itself. Except for some specialty remotes that use UHF radio signals, today’s remote controls operate with infrared (IR) light. Pressing a button on the remote sends a specific signal pattern; the distinctive pattern is deciphered by the unit under control. You can use the same remote controls to operate a mobile robot. A computer or microcontroller is used to decipher the signal patterns received from the remote via an infrared receiver. Because infrared receiver units are common finds in electronic and surplus stores (they’re used heavily in TVs, VCRs, etc.), adapting a remote control for robotics use is actu-
16.3 COMMANDING A ROBOT WITH INFRARED REMOTE CONTROL
265
ally fairly straightforward. It’s mostly a matter of connecting the pieces together. With your infrared remote control you’ll be able to command your robot in just about any way you wish—to start, stop, turn, whatever. Here are the major components of the robot infrared remote control system:
•
•
•
Infrared remote. Most any modern infrared remote control will work, but . . . the signal patterns they use vary considerably. You’ll find it most convenient to use a universal remote control (about $10 at a department store). These remote controls can work with just about any make and model of TV set, DVD player, VCR, cable/satellite receiver/ decoder available on the market. Infrared receiver module. The receiver module contains an infrared light detector, along with various electronics to clean up, amplify, and demodulate the signal from the remote control. The remote sends a signal built from a pattern of on/off flashes of infrared light. These flashes are modulated at about 38–40 kHz to differentiate them from other infrared sources in the receiver’s environment. The receiver strips out the modulation and provides just the on/off flashing patterns (which will be referred to as the signal or packet in this chapter). Computer or microcontroller. You need some hardware to decode the light patterns, and a computer or microcontroller, running appropriate software, makes the job straightforward.
Previous editions of the book described the Sharp remote control standard or protocol for the infrared signal, but in this edition, the Sony format will be used. The reason for changing to the Sony standard is the fewer number of bits that are used in the data transmission, the more definite difference between a 1 or 0 of the data, and the greater number of projects available on the Internet and in books that use it. Receiving the modulated signal is quite simple; there are a number of different remote control receivers available on the market, like the Sharp GP1U57X shown in Fig. 16-5. The receivers are very sensitive to electrical noise, so it is important to provide the 56 Ω resistor, 47 µF, and 0.1 µF filter capacitors to the circuit as shown. Some older receivers are built into metal cans, which may require external grounding as shown in the diagram. The outputs are usually open collector, so a pull-up resistor, like the 10k one shown in Fig. 16-5 is required. When it comes right down to it, it really doesn’t matter which protocol is used; they are all built around a similar data packet using the parts that are shown in Fig. 16-6. The first part is the leader and is used to indicate the start of the packet—for Sony remote controls, this is 2.2 ms in length. The packet’s data bits (12 in the case of the Sony protocol) start with a synchronizing pulse with the length of the low pulse being the bit value. The Sony data bits are either 0.55 ms (550 µs) or 1.1 ms in length.
16.3.1 A TYPICAL MICROCONTROLLER INTERFACE It might be intimidating at first to think about trying to receive and process remote control codes. In this and the next section, three different methods will be demonstrated and there are a number of ways that can be considered for use in a robot. The important
266
REMOTE CONTROL SYSTEMS
+5 vdc R2 56W
C2 47µF
+
C1 0.1
+V Sharp GP1U57X (or Equivalent)
R1 10K Signal Output
Out
Gnd Ground Strap Soldered to Case
FIGURE 16-5 The infrared receiver-demodulator requires relatively few external components that are primarily used to filter any noise out of the unit’s power source.
aspects of the differences are the ability to differentiate between a 1 and a 0 and to determine when an invalid packet (part of it is lost or has been garbled) is received and then reject it. The first method is a brute force approach of timing the signals coming in. ' '
Sony Remote Control Receiver Operation Method 1 Read the Timing for Each Bit DO DO WHILE (InputPin = 1) : LOOP ' Wait for Signal to go Low i = 0: DO WHILE (InputPin = 0) : i = i + 1: LOOP ' Get Leader IF ((i > 2.0ms) AND (i < 2.4ms) THEN ' Look for Valid Leader j = 0 ' Use "j" to Count the Number of Bits RemoteCode = 0 ' Reset the Returned Value DO WHILE (j < 12) DO WHILE (InputPin = 1) : LOOP ' Wait for Synch to Finish i = 0: DO WHILE (InputPin = 0) : i = i + 1: LOOP ' Time Bit IF ((i < 0.45ms) AND (i > 1.3ms) THEN j = 100 ' Indicate Invalid Bit ELSE
1 Bit
Packet Start (4T)
Synch (1T)
1 (1T)
0 Bit
0 (2T)
FIGURE 16-6 Sony remote control packet start leader and data bit specification.
16.3 COMMANDING A ROBOT WITH INFRARED REMOTE CONTROL
'
267
IF (i < 0.75ms) THEN ' "1" RemoteCode = (RemoteCode 1.3ms)) THEN j = 0 ' Invalid Bit ELSE IF (Timer < 0.75ms) THEN TempCode = (TempCode 20) then ButtonDown = 20 endif '
Execute Robot Functions Dlay(1ms - ExecutionTime) endwhile
' '
Find Robot Outputs to Inputs Ensure Loop Executes in 1 ms
Note that the button “state” variables are limited to a maximum value of 20. This is done to ensure that the variables do not overflow and become zero, which indicates the buttons are not pressed. While the code in the listing seems complex, you should remember that multiple buttons could be added to the robot application by simply copying this code for each additional button (new counter variables will be required as well). You will discover that the execution time penalty of the button debounce software is negligible, and using this code, you should be able to add a number of buttons to your robot application relatively easily.
29.3 OPTICAL SENSORS
507
29.3 Optical Sensors Optical sensors use a narrow beam of light to detect when an object is within the grasping area of a gripper. Optical sensors provide the most rudimentary form of touch sensitivity and are often used with other touch sensors, such as mechanical switches. Building an optical sensor into a gripper is easy. Mount an infrared LED in one finger or pincher; mount an infrared-sensitive phototransistor in another finger or pincher (see Fig. 29-6). Where you place the LED and transistor along the length of the finger or pincher determines the grasping area. Mounting the infrared pair on the tips of the fingers or pinchers provides little grasping area because the robot is told that an object is within range when only a small portion of it can be grasped. In most gripper designs, two or more LEDs and phototransistors are placed along the length of the grippers or fingers to provide more positive control. Alternatively, you may wish to detect when an object is closest to the palm of the gripper. You’d mount the LED and phototransistor accordingly. Fig. 29-7 shows the schematic diagram for a single LED-transistor pair. Adjust the value of R2 to increase or decrease the sensitivity of the phototransistor. You may need to place an infrared filter over the phototransistor to prevent it from triggering as a result of ambient light sources (some phototransistors have the filter built into them already). Use an LEDtransistor pair equipped with a lens to provide additional rejection of ambient light and to increase sensitivity. During normal operation, the transistor is on because it is receiving light from the LED. When an object breaks the light path, the transistor switches off. A control circuit connected to the conditioned transistor output detects the change and closes the gripper. In a practical application, using a computer as a controller, you’d write a short software program to control the actuation of the gripper.
Phototransistor LED
FIGURE 29-6 An infrared LED and phototransistor pair can be added to the fingers of a gripper to provide go/no-go grasp information.
508
THE SENSE OF TOUCH
+5V
R1 270Ω
LED1
R2 10K To Comparator, Amplifier, A/D Converter, etc.
Q1
Infrared Filter
FIGURE 29-7 The basic electronic circuit for an infrared touch sensor. Note the infrared filter; it helps prevent the phototransistor from being activated by ambient light.
29.4 Mechanical Pressure Sensors An optical sensor is a go/no-go device that can detect only the presence of an object, not the amount of pressure on it. A pressure sensor detects the force exerted by the gripper on the object. The sensor is connected to a converter circuit, or in some cases a servo circuit, to control the amount of pressure applied to the object. Pressure sensors are best used on grippers where you have incremental control over the position of the fingers or pinchers. A pressure sensor would be of little value when used with a gripper that’s actuated by a solenoid. The solenoid is either pulled in or it isn’t; there are no in-between states. Grippers actuated by motors are the best choices when you must regulate the amount of pressure exerted on the object.
29.4.1 CONDUCTIVE FOAM You can make your own pressure sensor (or transducer) out of a piece of discarded conductive foam—the stuff used to package CMOS ICs. The foam is like a resistor. Attach two pieces of wire to either end of a 1-in square hunk and you get a resistance reading on your volt-ohm meter. Press down on the foam, and the resistance lowers. The foam comes in many thicknesses and densities. Look for semi-stiff foam that regains its shape quickly after it’s squeezed. Very dense foams are not useful because they don’t quickly spring back to shape. Save the foam from the various ICs you buy and test other types until you find the right stuff for you. You can make a pressure sensor by sandwiching several pieces of material together, as shown in Fig. 29-8. The conductive foam is placed between two thin sheets of copper or aluminum foil. A short piece of 30 AWG wire-wrapping wire is lightly soldered onto the foil
29.4 MECHANICAL PRESSURE SENSORS
509
Mylar Sheet
Foil
Conductive Foam
Outputs Foil
Mylar Sheet
FIGURE 29-8 Construction detail for a pressure sensor using conductive foam. The leads are soldered or attached to foil (copper works best). Choose a foam that has a good “spring” to it.
(when using aluminum foil, the wire is wound around one end). Mylar plastic, like the kind used to make heavy-duty garbage bags, is glued on the outside of the sensor to provide electrical insulation. If the sensor is small and the sense of touch does not need to be too great, you can encase the foam and foil in heat-shrink tubing. There are many sizes and thicknesses of tubing; experiment with a few types until you find one that meets your requirements. The resistance of the conductive foam pressure transducers changes abruptly when they are compressed. The output may not return to its original resistance value (see Fig. 29-9). So in the control software, you should always reset the transducer just prior to grasping an object. For example, the transducer may first register an output of 30K Ω (the exact value depends on the foam, the dimensions of the piece, and the distance between wire terminals). The software reads this value and uses it as the set point for a normal (nongrasping) level to 30K. When an object is grasped, the output drops to 5K. The difference—25K—is the amount of pressure. Keep in mind that the resistance value is relative, and you must experiment to find out how much pressure is represented by each 1K of resistance change. The transducer may not go back to 30K when the object is released. It may spring up to 40K or go only as far as 25K. The software uses this new value as the new set point for the next occasion when the gripper grasps an object.
510
THE SENSE OF TOUCH
30 25 20 Resistance 15 (k ohms) 10 5 0
Press Release 0
1
2
3
4 5 6 Pressure (ounces)
7
8
9
FIGURE 29-9 The response curve for the conductive foam pressure sensor. Note that the resistance varies depending on whether the foam is being pressed or released.
29.4.2 STRAIN GAUGES Obviously, the home-built pressure sensors described so far leave a lot to be desired in terms of accuracy. If you need greater accuracy, you should consider commercially available strain gauges. These work by registering the amount of strain (the same as pressure) exerted on various points along the surface of the gauge. Strain gauges are somewhat pricey—about $10 and over in quantities of 5 or 10. The cost may be offset by the increased accuracy the gauges offer. You want a gauge that’s as small as possible, and preferably one mounted on a flexible membrane. See Appendix B, “Sources,” for a list of companies offering such gauges.
29.4.3 CONVERTING PRESSURE DATA TO COMPUTER DATA The output of both the homemade conductive foam pressure transducers and the strain gauges is analog—a resistance or voltage. Neither can be directly used by a computer, so the output of these devices must be converted into digital form first. Both types of sensors are perfect for use with an analog-to-digital converter. You can use one ADC0808 chip (under $5) with up to eight sensors. You select which sensor output you want to convert into digital form. The converted output of the ADC0808 chip is an eightbit word, which can be fed directly to a microprocessor or computer port. Fig. 29-10a shows the basic wiring diagram for the ADC0808 chip, which can be used with conductive foam transducer; Fig. 29-10b shows how to connect a conductive foam transducer to one of the analog inputs of the ADC0808. Notice the 10K resistor in Fig. 29-10, placed in series between the pressure sensor and ground. This converts the output of the sensor from resistance to voltage. You can change the value of this resistor to alter the sensitivity of the circuit. For more information on ADCs, see Chapter 14, “Computer Peripherals.”
29.5 EXPERIMENTING WITH PIEZOELECTRIC TOUCH SENSORS
511
FIGURE 29-10 a. The basic wiring diagram for converting pressure data into digital data, using an ADC0808 analog-to-digital converter (ADC) IC. You can connect up to eight pressure sensors to the one chip. b. How to interface a conductive foam sensor to the ADC0808 chip.
29.5 Experimenting with Piezoelectric Touch Sensors A new form of electricity was discovered just a little more than a century ago when the two scientists Pierre and Jacques Curie placed a weight on a certain crystal. The strain on the crystal produced an odd form of electricity—significant amounts of it, in fact. The Curie brothers coined this new electricity piezoelectricity; piezo is derived from the Greek word meaning press. Later, the Curies discovered that the piezoelectric crystals used in their experiments underwent a physical transformation when voltage was applied to them. They also found that the piezoelectric phenomenon is a two-way street. Press the crystals and out comes a voltage; apply a voltage to the crystals and they respond by flexing and contracting.
512
THE SENSE OF TOUCH
All piezoelectric materials share a common molecular structure, in which all the movable electric dipoles (positive and negative ions) are oriented in one specific direction. Piezoelectricity occurs naturally in crystals that are highly symmetrical—quartz, Rochelle salt crystals, and tourmaline, for example. The alignment of electric dipoles in a crystal structure is similar to the alignment of magnetic dipoles in a magnetic material. When an electrical voltage is applied to the piezoelectric material, the physical distances between the molecular dipoles change. This causes the material to contract in one dimension (or axis) and expand in the other. Conversely, placing the piezoelectric material under pressure (in a vise, for example) compresses the dipoles in one more axis. This causes the material to produce a voltage. While natural crystals were the first piezoelectric materials used, synthetic materials have been developed that greatly demonstrate the piezo effect. A common human-made piezoelectric material is ferroelectric zirconium titanate ceramic, which is often found in piezo buzzers used in smoke alarms, wristwatches, and security systems. The zirconium titanate is evenly deposited on a metal disc. Electrical signals, applied through wires bonded to the surfaces of the disc and ceramic, cause the piezo material to vibrate at high frequencies (usually 4 kHz and above). Piezo activity is not confined to brittle ceramics. PVDF, or polyvinylidene fluoride (used to make high-temperature PVDF plastic water pipes), is a semicrystalline polymer that lends itself to unusual piezoelectric applications. The plastic is pressed into thin, clear sheets and is given precise piezo properties during manufacture by—among other things—stretching the sheets and exposing them to intense electrical fields. PVDF piezo film is currently used in many commercial products, including noninductive guitar pickups, microphones, even solid-state fans for computers and other electrical equipment. One PVDF film you can obtain and experiment with is Kynar, available directly from the manufacturer (see Measurement Specialists at www.msiusa.com for more information). Whether you are experimenting with ceramic or flexible PVDF film, it’s important to understand a few basic concepts about piezoelectric materials:
• • •
Piezoelectric materials are voltage sensitive. The higher the voltage is, the more the piezoelectric material changes. Apply 1 V to a ceramic disc and crystal movement will be slight. Apply 100 V and the movement will be much greater. Piezoelectric materials act as capacitors. Piezo materials develop and retain an electrical charge. Piezoelectric materials are bipolar. Apply a positive voltage and the material expands in one axis. Apply a negative voltage and the material contracts in that axis.
29.5.1 EXPERIMENTING WITH CERAMIC DISCS The ubiquitous ceramic disc is perhaps the easiest form of piezoelectric transducer to experiment with. A sample disc is shown in Fig. 29-11. The disc is made of nonferrous metal, and the ceramic-based piezo material is applied to one side. Most discs available for purchase have two leads already attached. The black lead is the ground of the disc and is directly attached to the metal itself.
29.5 EXPERIMENTING WITH PIEZOELECTRIC TOUCH SENSORS
513
FIGURE 29-11 Piezo ceramic discs are ideally suited to be contact and pressure sensors for robotics.
You can use a ceramic disc as an audio transducer by applying an audio signal to it. Most piezo discs will emit sound in the 1K to 10K region, with a resonant frequency of between 3K and 4K. At this resonant frequency, the output of the disc will be at its highest. When the piezo material of the disc is under pressure—even a slight amount—the disc outputs a voltage proportional to the amount of pressure. This voltage is short lived: shortly after the initial change in pressure, the voltage output of the disc will return to 0. A negative voltage is created when the pressure is released (see the discussion of the bipolar nature of piezo materials earlier in the chapter). You can easily interface piezo discs to a computer or microcontroller, either with or without an analog-to-digital converter. Chapter 30, “Object Detection,” discusses several interface approaches. See the section “Piezo Disc Touch Bar” in that chapter for more information.
29.5.2 EXPERIMENTING WITH KYNAR PIEZO FILM Samples of Kynar piezoelectric film are available in a variety of shapes and sizes. The wafers, which are about the same thickness as the paper in this book, have two connection points, as illustrated in Fig. 29-12. Like ceramic discs, these two connection points are used to activate the film with an electrical signal or to relay pressure on the film as an electrical impulse.
514
THE SENSE OF TOUCH
Kynar Film Substrate
Reverse-side Layer Front-side Conductive Layer FIGURE 29-12 A close-up look at Kynar piezo film and its electrical contacts.
You can perform basic experiments with the film using just an oscilloscope (preferred) or a high-impedance digital voltmeter. Connect the leads of the scope or meter to the tabs on the end of the film (the connection will be sloppy; there are some suggestions for other ways to attach leads to Kynar film in the next section). Place the film on a table and tap on it. You’ll see a fast voltage spike on the scope or an instantaneous rise in voltage on the meter. If the meter isn’t auto-ranging and you are using the meter at a low setting, chances are that the voltage spike will exceed the selected range.
29.5.3 ATTACHING LEADS TO KYNAR PIEZO FILM Unlike piezoelectric ceramic discs, Kynar film doesn’t usually come with pre-attached leads (although you can order samples with leads attached, but they are expensive). There are a variety of ways to attach leads to Kynar film. Obviously, soldering the leads onto the film contact areas is out of the question. Acceptable methods include applying conductive ink or paint, self-adhesive copper-foil tape, small metal hardware, and even miniature rivets. In all instances, use small-gauge wire—22 AWG or smaller. You can expect the best results using 28 AWG and 30 AWG solid wire-wrapping wire. The following are the best methods:
•
• • •
Conductive ink or paint. Conductive ink, such as GC Electronics’ Nickel-Print paint, bonds thin wire leads directly to the contact points on Kynar film. Apply a small globule of paint to the contact point, and then slide the end of the wire in place. Wait several minutes for the paint to set before handling. Apply a strip of electrical tape to provide physical strength. Self-adhesive copper-foil tape. You can use copper-foil tape designed for repairing printed circuit boards to attach wires to Kynar film. The tape uses a conductive adhesive and can be applied quickly and simply. As with conductive inks and paints, apply a strip of electrical tape to the joint to give it physical strength. Metal hardware. Use small 2/56 or 4/40 nuts, washers, and bolts (available at hobby stores) to mechanically attach leads to the Kynar. Poke a small hole in the film, slip the bolt through, add the washer, and wrap the end of a wire around the bolt. Tighten with the nut. Miniature rivets. Homemade jewelry often uses miniature brass or stainless steel rivets. You can obtain the rivets and the proper riveting tool from many hobby and jewelry-
29.6 OTHER TYPES OF TOUCH SENSORS
515
+V
1
14
13 R1 10M
2
Output
IC1 4066 Piezo Film 7
FIGURE 29-13 A strike/vibration indicator using Kynar piezo film.
making stores. To use them, pierce the film to make a small hole, wrap the end of the wire around the rivet post, and squeeze the riveting tool (you may need to use metal washers to keep the wire in place).
29.5.4 USING KYNAR PIEZO FILM AS A MECHANICAL TRANSDUCER Fig. 29-13 shows a simple demonstrator circuit you can build that indicates each time a piece of Kynar film is struck. Tapping the film produces a voltage output, which is visually
FIGURE 29-14 The prototype Kynar piezo bend sensor.
516
THE SENSE OF TOUCH
indicated when the LED flashes. The 4066 IC is an analog switch. When a voltage is applied to pin 3, the connection between pins 1 and 2 is completed and that finishes the electrical circuit to light the LED. For a robotic application, you can connect the output to a computer or microcontroller.
29.5.5 CONSTRUCTING A KYNAR PIEZO FILM BEND SENSOR You can easily create a workable touch sensor by attaching one or two small Kynar transducers to a thick piece of plastic. The finished prototype sensor is depicted in Fig. 29-14. The plastic membrane could be mounted on the front of a robot, to detect touch contact, or even in the palm of the robot’s hand. Any flexing of the membrane causes a voltage change at the output of one or both Kynar film pieces.
29.6 Other Types of Touch Sensors The human body has many kinds of touch receptors embedded within the skin. Some receptors are sensitive to physical pressure, while others are sensitive to heat. You may wish to endow your robot with some additional touch sensors like:
•
• • •
Heat sensors can detect changes in the heat of objects within grasp. Heat sensors are available in many forms, including thermisters (resistors that change their value depending on temperature) and solid-state diodes that are specifically made to be ultrasensitive to changes in temperature. Chapter 34, “Fire Detection Systems,” discusses using solidstate temperature sensors. Air pressure sensors can be used to detect physical contact. The sensor is connected to a flexible tube or bladder (like a balloon); pressure on the tube or bladder causes air to push into or out of the sensor, thereby triggering it. To be useful, the sensor should be sensitive to increases in air pressure to about 1 lb/in2, or less. Resistive bend sensors, originally designed for use with virtual reality gloves, vary their resistance depending on the degree of bending. Mount the sensor in a loop, and you can detect the change in resistance as the loop is deformed by the pressure of contact. Microphones and other sound transducers make effective touch sensors. You can use microphones, either standard or ultrasonic, to detect sounds that occur when objects touch. Mount the microphone element on the palm of the gripper or directly on one of the fingers or pinchers. Place a small piece of felt directly under the element, and cement it in place using a glue that sets hard. Run the leads of the microphone to the sound trigger circuit, which should be placed as close to the element as possible.
29.7 FROM HERE
29.7 From Here To learn more about . . .
Read
Designing and building robot hands
Chapter 28, “Experimenting with Gripper Designs”
Connecting sensors to computers and microcontrollers
Chapter 14, “Computer Peripherals”
Collision detection systems
Chapter 30, “Object Detection”
Building light sensors
Chapter 32, “Robot Vision”
Fire, heat, and smoke detection for robotics
Chapter 34, “Fire Detection Systems”
517
This page intentionally left blank
CHAPTER
30
OBJECT DETECTION
Y
ou’ve spent hundreds of hours designing and building your latest robot creation. It’s filled with complex little doodads and precision instrumentation. You bring it into your living room, fire it up, and step back. Promptly, the beautiful new robot smashes into the fireplace and scatters itself over the living room rug. You remembered things like motor speed controls, electronic eyes and ears, even a synthetic voice, but you forgot to provide your robot with the ability to look before it leaps. Object detection systems take many forms and work in many different ways requiring different interfaces and programming. This chapter presents a number of passive and active object detection systems that are easy to build and use. Some of the systems are designed to detect objects close to the robot (called near-object, or proximity, detection), and some are designed to detect objects at distances of 10 ft or more (called far-object detection). Depending on how the sensor works, your robot may change trajectory to avoid an object far away from it or it could turn hard away or stop to avoid something that was sensed immediately in its path. The material in this chapter may seem very similar to that of Chapter 29, “the Sense of Touch,” and there is some overlap in the material and programming differences. To clear up any confusion, Chapter 29 discusses different methods of detecting whether a gripper has detected an object to pick up, while in this chapter the sensors reviewed are for mobile robots to ensure that they are not damaged by nor do they damage objects they collide with as they are moving about.
519 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
520
OBJECT DETECTION
30.1 Design Overview Object detection can be further divided into collision avoidance and collision detection. With collision avoidance, the robot uses noncontact techniques to determine the proximity of objects around it. It then avoids any objects it detects. Collision detection concerns what happens when the robot has already gone too far, and contact has been made with whatever foreign object was unlucky enough to be in the machine’s path. Collision avoidance can be further broken down into two subtypes: near-object detection and far-object detection. By its nature, all cases of collision detection involve making contact with nearby objects. All of these concepts are discussed in this chapter. Additionally, robot builders commonly use certain object detection methods to navigate a robot from one spot to the next. Many of these techniques are introduced here because they are relevant to object detection, but we develop them more fully in Chapter 33, “Navigation.”
30.1.1 NEAR-OBJECT DETECTION Near-object detection does just what its name implies: it senses objects that are close by, from perhaps just a breath away to as much as 8 or 10 ft. These are objects that a robot can consider to be in its immediate environment—objects it may have to deal with, and soon. These objects may be people, animals, furniture, or other robots. By detecting them, your robot can take appropriate action, which is defined by the program you give it. Your robot may be programmed to come up to people and ask them their name. Or it might be programmed to run away whenever it sees movement. In either case, it won’t be able to accomplish either behavior unless it can detect objects in its immediate area. There are two ways to effect near-object detection: proximity and distance:
• •
Proximity sensors care only that some object is within a zone of relevance. That is, if an object is near enough in the physical scene the robot is looking at, the sensor detects it and triggers the appropriate circuit in the robot. Objects beyond the proximal range of a sensor are effectively ignored because they cannot be detected. Distance measurement sensors determine the distance between the sensor and to some object within range. Distance measurement techniques vary; almost all have notable minimum and maximum ranges. Few yield accurate data if an object is very close to the robot. Likewise, objects just outside the sensor’s effective range can yield inaccurate results. Large objects far away may appear closer than they really are; very close small objects may appear abnormally larger than they really are, and so on. If there are multiple objects within the sensor’s field of view, the robot may have difficulty sorting them out and figuring out which one is closest (and is the most likely danger).
Sensors have depth and breadth limitations: depth is the maximum distance an object can be from the robot and still be detected by the sensor. Breadth is the maximum height and width of the sensor detection area. Some sensors see in a relatively narrow zone, typ-
30.1 DESIGN OVERVIEW
521
ically in a conical pattern, like the beam of a flashlight. Light sensors are a good example. Adding a lens in front of the sensor narrows the pattern even more. Other sensors have specific breadth patterns. The typical passive infrared sensor (the kind used on motion alarms) uses a Fresnel lens that expands the field of coverage on the top but collapses it on the bottom. This makes the sensor better suited for detecting human motion instead of cats, dogs, and other furry creatures (humans being, on average, taller than furry creatures). The detector uses a pyroelectric element to sense changes in heat patterns in front of it.
30.1.2 FAR-OBJECT DETECTION Far-object detection focuses on objects that are outside the robot’s primary area of interest but still within a detection range. A wall 50 ft away is not of critical importance to a robot (conversely, the same wall when it’s 1 ft away is very important). Far-object detection is typically used for area and scene mapping to allow the robot to get a sense of its environment. Most hobby robots don’t employ far-object detection because it requires fairly sophisticated sensors, such as narrow-beam radar or pulsed lasers. The difference between near- and far-object detection is relative. As the designer, builder, and master of your robot, you get to decide the threshold between near and far objects. Perhaps your robot is small and travels fairly slowly. In that case, far objects are those 4 to 5 ft away; anything closer is considered “near.” With such a robot, you can employ ordinary sonar distance systems for far-object detection, including area mapping. This chapter will concentrate on near-object detection methods since traditional farobject detection is beyond the reach and riches of most hobby robot makers (with the exception of sonar systems, which have a maximum range of about 30 ft). You may, if you wish, employ near-object techniques to detect objects that are far away relative to the world your robot lives in.
30.1.3 REMEMBERING THE KISS PRINCIPLE Engineering texts like to tout the concept of KISS: “Keep It Simple, Stupid.” If the admonition is intentionally insulting it is to remind all of us that usually the simple techniques are the best. Of course, simplicity is relative. An ant is simple compared to a human being, but so far no scientist has ever created the equivalent of a living ant. KISS certainly applies to using robotic sensors for object detection. Your ultimate goal may be to put “eyes” on your robot to help it see the world the way that you do. In fact, such eyes already exist in the form of CCD and CMOS video imagers. They’re relatively cheap, too—less than $50 retail for camera modules or hackable webcams. What’s missing in the case of vision systems is the ability to process the incoming signal ways to use the wealth of information provided by the sensor. How do you make a robot differentiate between a can of Dr. Pepper and Mrs. Johnson’s slobbering two-year-old—both of which are very wet when tipped over? When you think about which object detection sensor or system to add to your robot, consider the system’s relative complexity in relation to the rest of the project. If all your small ’bot needs is a bumper switch, then avoid going overboard with a $100 sonar system. Con-
522
OBJECT DETECTION
versely, if the context of the robot merits it, skimp with inadequate sensors. Larger, heavier robots require more effective object-detection systems—if for no other reason than to prevent injuring you—if it happens to start to run amok.
30.1.4 REDUNDANCY Two heads are better than one? Maybe. One thing is for sure: two eyes are definitely better than one. The same goes for ears and many other kinds of sensors. This is sensor redundancy at work (having two eyes and ears also provides stereo vision or hearing, which aids in perception). Sensor redundancy—especially for object detection—is not intended primarily to compensate for system failure, the way NASA builds backups into its space projects in case some key system fails 25,000 miles up in space. Rather, sensor redundancy is meant to provide a more complete picture and better situational awareness for the robot by using multiple sensors with different characteristics. If a long-range sensor says an object is 10 ft away and a mid-range sensor that is 8 ft away says it’s a foot away, then the robot’s control computer has dual conformation that there is an object present and can be confident that it is about 8 ft away. With only one sensor the robot must blindly (excuse the pun) trust that the sensor data is reliable. This is not a good idea because even for the best sensors data is not 100 percent reliable. There are two kinds of redundancy:
•
•
Same-sensor redundancy relies on two or more sensors of an identical type. Each sensor more or less sees the same scene. You can use sensor data in either (or both) of two ways: through statistical analysis or interpolation. With statistical analysis, the robot’s control circuitry combines the input from the sensors and uses a statistical formula to whittle the data to a most likely result. For example, sensors with wildly disparate results may be rejected out of hand, and the values of the remaining sensors may be averaged out. With interpolation, the data of two or more sensors is combined and crosscorrelated to triangulate on the object, just like having two eyes and two ears adds depth and direction to our visual and aural senses. Complementary-sensor redundancy relies on two or more sensors of different types. Since the sensors are fundamentally different—for example, they use completely different collection methods—the data from the sensors are always interpolated. For instance, if a robot has both a sonar and an infrared distance-measuring system, it uses both because it understands that for some kinds of objects the data from the infrared system will be more reliable, and for other objects the data from the sonar system will be more reliable. The previous example of the object 8 ft away is an example of complementary sensor redundancy.
Budget and time constraints will likely be the limiting factors in whether you employ redundant sensor systems in your robots. So when combining sensors, do so logically: consider which sensors complement others well and if they can be reasonably added. For example, both sonar and infrared proximity sensors can use the same 40 kHz modulation system. If you have one, adding the other need not be difficult, expensive, or timeconsuming.
30.2 NONCONTACT NEAR-OBJECT DETECTION
523
30.2 Noncontact Near-Object Detection Avoiding a collision is better than detecting it after it has happened. Short of building some elaborate radar distance measurement system, the ways for providing proximity detection to avoid collisions fall into two categories: light and sound. The following sections will take a closer look at several light- and sound-based techniques.
30.2.1 SIMPLE INFRARED LIGHT PROXIMITY SENSOR Light may always travel in a straight line, but it bounces off nearly everything. You can use this to your advantage to build an infrared collision detection system. You can mount several infrared bumper sensors around the periphery of your robot. They can be linked together to tell the robot that something is out there, or they can provide specific details about the outside environment to a computer or control circuit. The basic infrared detector is shown in Fig. 30-1 (refer to the parts list in Table 30-1). It provides an output that can be polled by a robot’s controller comparator or ADC input. This uses an infrared LED and infrared phototransistor. Fig. 30-2 shows how the LED and phototransistor might be mounted around the base of the robot to detect an obstacle like a wall, chair, or person. Sensitivity can be adjusted by changing the value of R2; reduce the value to increase sensitivity. An increase in sensitivity means that the robot will be able to detect objects farther away. A decrease in sensitivity means that the robot must be fairly close to the object before it is detected. Bear in mind that all objects reflect light in different ways. You’ll probably want to adjust the sensitivity so the robot behaves itself best in a room with white walls. But that sensitivity may not be as great when the robot comes to a dark brown couch or the coal gray suit of your boss. The infrared phototransistor should be baffled—blocked—from both ambient room light as well as direct light from the LED. The positioning of the LED and phototransistor is very important, and you must take care to ensure that the two are properly aligned. You may wish to mount the LED–phototransistor pair in a small block of wood. Drill holes for the LED and phototransistor.
TABLE 30-1
Parts List for Infrared Proximity Switch
R1
270 Ω resistor
R2
10K resistor
Q1
Infrared sensitive phototransistor
LED1
Infrared light-emitting diode
Misc.
Infrared filter for phototransistor (if needed)
524
OBJECT DETECTION
+5 vdc
R1 270Ω
R2 10K Output
LED1
LED
Phototransistor
Q1 Baffle
FIGURE 30-1 The basic design of the infrared proximity sensor.
Or, if you prefer, you can buy the detector pair already made up and installed in a similar block. The component shown in Fig. 30-3 is a TIL139 (or equivalent) from Texas Instruments. This particular component was purchased at a surplus store for about $1.
30.2.2 BETTER IR PROXIMITY SENSOR In Chapter 16, the TV remote control, which receives a modulated infrared light signal, was introduced as a basic method of providing a remote control to robots. Along with receiving commands for robot movement, it can also be used to seek out and find the range to objects around a robot just as a submarine detects objects around it using sonar. The equipment required to provide this capability just costs a few dollars and is surprisingly easy to experiment with as will be shown in the following section. An IR LED can be used to generate a modulated IR signal using the hardware shown in Fig. 30-4. The modulated IR signal lasts for about 500 µs, which is enough time for the TV remote control receiver to recognize it. If there is no object from which the signal can reflect off of, the TV remote control receiver does not indicate that a signal is present. The modu-
FIGURE 30-2 How the sensor is used to test proximity to a nearby object.
30.2 NONCONTACT NEAR-OBJECT DETECTION
525
FIGURE 30-3 The Texas Instruments TIL139 infrared emitter/detector sensor unit. These types of units are often available on the surplus market.
TriState Driver
IR LED 0.5% Duty Cycle PWM Running at 20 kHz
Opaque Barrier
Signal 10k to Microcontroller
TV IR Remote Control Receiver
Reflected IR Signal
100
Surface IR Light Reflects from LED to Receiver
38 kHz Oscillator
47 uF
FIGURE 30-4 The circuitry used to detect objects using infrared LEDs and TV remote controls operates on the same theory as sonar; signals sent out from the LED reflect off of objects and are detected using the TV remote control.
526
OBJECT DETECTION
lated signal is only active for a few hundred milliseconds to prevent the receiver from treating the signal as part of the background noise that it must filter out—leaving the signal active for more than a few milliseconds will cause the receiver to filter out the signal and look for other more transient signals. The opaque barrier is to ensure there is not a direct path from the IR LED to the TV remote control. As with a simple IR LED and IR phototransistor, a block of wood drilled with two holes, one for the LED and one for the phototransistor, can be used for this purpose. Other materials such as electrical tape or sheet metal can also be used. Many materials that you would think are opaque to infrared light—such as cardboard—actually are not and you should test the different material you are planning on using in your robot. Probably the most common and easy to use opaque barrier is 5 mm black heat-shrink tubing, cut to 3⁄4 to 1 in long and slipped over the IR LED; this prevents a direct path for the IR light from the LED to the TV remote control receiver and directs the IR light into a fairly narrow beam, allowing you to control where objects can be detected. The attenuated signal can only be recognized by the TV remote control receiver when enough energy has been reflected into it as shown in Fig. 30-5. The receiver does not immediately respond to the received signal and remains active some time after the signal
IR LED
Reflected Signal Reception
IR Receiver Waveform
FIGURE 30-5 Oscilloscope waveform of the signal sent to an IR LED and the output of the TV remote control receiver when the signal is reflected from some object.
30.2 NONCONTACT NEAR-OBJECT DETECTION
527
has stopped. If the LED output was at full power, then the signal would reflect off of other objects around the robot, resulting in reflections coming into the TV remote control receiver at such power that it would be recognized as a reflection. The solution to this problem is to attenuate, or lessen the ability of the TV remote control receiver to receive the incoming signals. The obvious way to lessen the power of the signal is to dim the LED by allowing less current to pass through it, but a much better way of handling the signal is to shift the modulation frequency. If you were to look at a TV remote control receiver data sheet, you would discover that the ability to detect incoming signals changes as the frequency of the modulated signal changes. The closer to the design frequency of the receiver, the more sensitivity it has. By using a different frequency from the TV remote control receiver’s nominal frequency, its ability to detect modulated signals decreases. In Table 30-2, the distance a particular 38 kHz IR TV remote control receiver can receive signals reflected from other objects is given. These values are for a specific manufacturer’s part number receiver; you will find that other manufacturers’ products will respond differently. What is interesting to note about Table 30-2 is that as the modulation frequency changes, the object detection distance decreases. As will be shown in the next section, by changing the modulation frequency of the IR LED, you can estimate the range to an object from the IR LED and TV remote control, which allows you to decide whether to take immediate evasive action or slightly alter the course of the robot. BS2 Implementation of the Proximity Sensor The BS2 does not have the capability to produce 38 or 40 kHz signals, which are the most commonly used modulation frequencies for TV remote control receivers to drive an LED for detecting objects directly. Instead, the freqout function produces a digital signal that can be filtered into an analog sine wave of a specific frequency. The mathematics behind the operation of the freqout function are not important except to note that harmonics at the IR receiver’s frequency are produced which allows it to be used for detecting objects around the BS2 as well as providing a simple range estimate for them. To test the ability of the BS2 to detect objects around it the circuit shown in Fig. 30-6 was created (its parts list is Table 30-3). A modulated signal can be output on Pin 0 and after
TABLE 30-2 38 kHz TV Remote Control Receiver Object Detection Distance for Different Modulation Frequencies. Modulation Frequencies Generated by a Microchip PIC Microcontroller. MODULATION FREQUENCY
OBJECT DETECTION DISTANCE
38.5 kHz
30 ft (360 in)
35.7 kHz
2 ft (24 in)
33.3 kHz
10 in
31.3 kHz
6 in
528
OBJECT DETECTION
6
1
9
5 IC1
Vcc 1 2 3 4 5
C1 C2
BS2
6 7 8 9 10 11 12
24 23 22 21 20
Vcc
R1
100
R2
C1
10k
47 uF
+
19 18 17 16 15 14 13
Vcc
4x AA Battery Vcc R3
270
LED1
FIGURE 30-6 BS2 circuit that generates a modulated signal for an IR LED which should be detected by a TV remote.
the BS2 has finished sending it, the output of an IR receiver can be polled at Pin 1. The application that tests the operation of the IR receiver follows. Remember to slip a piece of 5 mm heat shrink tubing over the IR LED. ' ' ' ' '
BS2 Object Detection - Using BS2 "Freqout" Detect Objects myke predko 05.09.10
TABLE 30-3
Parts List for BS2 IR Object Detection/Range Finder
BS2
Parallax BASIC Stamp 2
IC1
38 kHz IR TV remote control receiver
LED1
5mm IR LED
R1
100 Ω resistor
R2
10k resistor
R3
270 Ω resistor
C1
47 µF electrolytic capacitor
Misc.
BS2 communications/programming interface, breadboard, breadboard wiring, 4× AA battery clip, 4× AA batteries, 3⁄4 in long piece of 5 mm heat shrink tubing
30.2 NONCONTACT NEAR-OBJECT DETECTION
529
'{$STAMP BS2} '{$PBASIC 2.5} ' I/O Pins IREmitter PIN 0 IRRxr PIN 1 ' Variables IRStatus VAR Bit '
Mainline DO FREQOUT IREmitter, 1, 36500 ' Output IR Signal IRStatus = (IRRxr ^ 1) ' High When Received
LOOP
DEBUG "Sensor Value = ", BIN1 IRStatus, CR PAUSE 250 ' Repeat
When the IR LED is arranged to fire perpendicularly from the face of the TV remote control receiver, you should find that the IR receiver will detect objects at about 18 in away. As noted in the previous section, this distance can be reduced by changing the frequency, but instead of changing a single frequency to detect objects at a specific distance from the robot, why not also determine the distance objects are from the robot? In the next program listed, the frequency is changed to give a three-bit value indicating the relative distance of the object away from the IR LED/TV remote control receiver. When the least significant bit of the return value is set, the object is approximately a foot away from the sensor. The next bit indicates if the object is within 6 in of the sensor, and the most significant bit indicates if the object is within 3 in of the IR LED/TV remote control receiver sensor. This amount of accuracy should be adequate for most robot applications. ' ' ' ' ' ' ' ' ' '
BS2 Object Ranging - Using BS2 "Freqout" Detect Objects Different IR Frequencies are used to Determine the (Rough) Distance to an Object. Frequency Values Specified by Author. myke predko 05.09.10
'{$STAMP BS2} '{$PBASIC 2.5} ' I/O Pins IREmitter PIN 0 IRRxr PIN 1 ' Variables IRStatus VAR i VAR IRDist VAR IRFreq VAR
Byte Byte Byte Word
530
OBJECT DETECTION
'
Mainline DO IRStatus = 0 FOR i = 0 TO 2 LOOKUP i,[48000, 44500, 42000], IRFreq FREQOUT IREmitter, 1, IRFreq ' Output IR Signal IRStatus = (IRStatus 72) THEN ' Between 20 and 10 cm Slope = ABS(72 - 123) ' Slope is divisor per 10 cm ZeroPoint = 10 + ((123 ∗ 10) / Slope) y = ZeroPoint - ((x ∗ 10) / Slope) DEBUG "Distance = ", DEC y, " cm", CR ELSE IF (x > 51) THEN ' Between 30 and 20 cm Slope = ABS(51 - 72) ' Slope is divisor per 10 cm ZeroPoint = 20 + ((72 ∗ 10) / Slope) y = ZeroPoint - ((x ∗ 10) / Slope) DEBUG "Distance = ", DEC y, " cm", CR ELSE IF (x > 38) THEN ' Between 40 and 30 cm Slope = ABS(38 - 51) ' Slope is divisor per 10 cm ZeroPoint = 30 + ((51 ∗ 10) / Slope) y = ZeroPoint - ((x ∗ 10) / Slope) DEBUG "Distance = ", DEC y, " cm", CR ELSE IF (x > 28) THEN ' Between 50 and 40 cm Slope = ABS(28 - 38) ZeroPoint = 40 + ((38 ∗ 10) / Slope) y = ZeroPoint - ((x ∗ 10) / Slope) DEBUG "Distance = ", DEC y, " cm", CR ELSE ' Further Away than 50 cm DEBUG "Nothing In front of GP2D12", CR ENDIF ENDIF ENDIF ENDIF PAUSE 250
'
Delay to 4x per second
LOOP END
The development of the slope and the line was not trivial (although it does not look very complex in the code above) and it is calculated from first principles you learned in high school math. The lines that are produced are actually counterintuitive because the x axis is
534
OBJECT DETECTION
voltage while the y axis is distance (most graphs will show this data in reverse). When you are developing a project like this one, make sure that you use lots of DEBUG statements to verify the software calculations against your own. Because the BS2 cannot perform floating point operations, you will find that you will have to do strange things, like make your slopes in units of 10s of mV per decameters. The distance output is surprisingly accurate although it quickly diminishes when the power supply voltage varies from 5 V. In the schematic (Fig. 30-8) and parts list (Table 30-4), four AA alkaline batteries are specified, which will produce approximately 6 V (20% higher than the nominal voltage). In the prototype circuit, a Parallax BASIC Stamp Homework Board was used, which produces 5 V from a regulator, and the distances output matched measured distances surprisingly well.
30.2.4 PASSIVE INFRARED DETECTION You can use commonly available passive infrared detection systems to detect the proximity of humans and animals. These systems, popular in both indoor and outdoor security systems, work by detecting the change in infrared thermal heat patterns in front of a sensor. This sensor uses a pair of pyroelectric elements that react to changes in temperature. Instantaneous differences in the output of the two elements are detected as movement, especially movement by a heat-bearing object, such as a human. You can purchase pyroelectric sensors—commonly referred to as PIR, for passive infrared—new or salvage them from an existing motion detector. When salvaging from an existing detector, you can opt to unsolder the sensor itself and construct an amplification circuit around the removed sensor, or you can attempt to tap into the existing circuit of the detector to locate a suitable signal. Both methods are described next.
30.2.5 USING A NEW OR REMOVED-FROM-CIRCUIT DETECTOR Using a new PIR sensor is by far the easiest approach since new PIR sensors will come with a data sheet from the manufacturer (or one will be readily available on the Internet). Some sensors—such as the Eltec 422—have built-in amplification, and you can connect them directly to a microcontroller or computer. Others require extra external circuitry, including amplification and signal filtering and conditioning. If you prefer, you can attempt to salvage a PIR sensor from a discarded motion detector. Disassemble the motion detector, and carefully unsolder the sensor from its circuit board. The sensor will likely be securely soldered to the board so as to reduce the effects of vibration. Therefore, the unsoldered sensor will have fairly short connection leads. You’ll want to resolder the sensor onto another board, being careful to avoid applying excessive heat. Fig. 30-9 shows a typical three-lead PIR device. The pinouts are not industry standard, but the arrangement shown is common. Pin 1 connects to +V (often 5 V); pin 2 is the output, and pin 3 is ground. Physically, PIR sensors look a lot like old-style transistors and come in metal cans with a dark rectangular window on top (see Fig. 30-10). Often, a tab or notch will be located near pin 1. As even unamplified PIR sensors include an internal FET transistor for signal conditioning, the power connect and output of the sensor are commonly referred to by their common FET pinout names of drain and source.
30.2 NONCONTACT NEAR-OBJECT DETECTION
535
+V 1 2
Amp
Output Comparator
Signal Output
3 PIR Detector Fresnel Lens
FIGURE 30-9 Most PIR sensors are large, transistorlike devices with a fairly common pinout arrangement. This is a block diagram of how the typical PIR sensor works.
If the sensor incorporates an internal output amplifier and signal conditioner, its output will be suitable for direct connection to a microcontroller or other logic input. A buffer circuit, like that shown in Fig. 30-11, is often recommended to increase input impedance. The circuit uses an op amp in unity gain configuration. If the sensor you are using lacks a preamplifier and signal condition, you can easily add your own with the basic circuit shown in Fig. 30-12. With both the circuits shown in Figs. 30-11 and 30-12, the ideal interface to a robot computer or microcontroller is via an analog-to-digital converter (ADC). Many microcon-
FIGURE 30-10 The PIR sensor has an infrared window on the top to let in infrared heat radiated by objects. Movement of those objects is what the sensor is made to detect, not just the heat from an object.
536
OBJECT DETECTION
+V
R1 1K
2 -
From PIR
7
IC1 LM741 3 + 4
R2 1M 6
Output
FIGURE 30-11 Use a buffer circuit between the output of the amplified PIR device and the microcontroller or other logic input.
trollers offer these on chip. If your control circuit lacks a built-in ADC, you can add one using one of the approaches outlined in Chapter 14, “Computer Peripherals.” The output of the PIR sensor will be a voltage between ground and +V. For example’s sake, assume the output will be the full 0 to 5 V, though in practice the actual voltage switch will be more restricted (e.g., 2.2 to 4.3 V, depending on the circuitry you use). Assuming a 0 to 5 vdc output, with no movement detected, the output of the sensor will be 2.5 V. As movement is detected, the output will swing first in one direction, then the other. It’s important to keep this action in mind; it is caused by the nature of the pyroelectric element inside the sensor. It is also important to keep in mind that a heat source, even directly in front of the sensor, will not be detected if it doesn’t move. For a PIR device to work, the heat source must be in motion. When programming your computer or microcontroller, you can look for variances in the voltage that will indicate a rise or fall in the output of the sensor.
+V
2 -
7 IC1 LM741 3 + 4
From PIR
6
Output
R1 1K
FIGURE 30-12 If the PIR sensor you are using lacks a built-in output amplifier, you can construct one using commonly available op amps.
30.2 NONCONTACT NEAR-OBJECT DETECTION
537
30.2.6 HACKING A MOTION DETECTOR BOARD Rather than unsolder the PIR sensor from a motion detector unit, you may be able to hack into the motion detector circuit board to find a suitable output signal. The advantage of this approach is that you don’t have to build a new amplifier for the sensor. The disadvantage is that this can be hard to do depending on the make and model of the motion control unit that you use. For best results, use a motion detector unit that is battery powered. This avoids any possibility that the circuit board in the unit also includes components for rectifying and reducing an incoming AC voltage. After disassembling the motion detector unit, connect +5 vdc power to the board. (Note: some PIR boards operate on higher voltages, usually 9 to 12 V. You may need to increase the supply voltage to properly operate the board.) Using a multitester or oscilloscope (the scope is the preferred method), carefully probe various points on the circuit board and observe the reading on the meter or scope. Wave your hand over the sensor and watch the meter or scope. If you’re lucky, you’ll find two kinds of useful signals:
• •
Digital (on/off) output. The output will normally be LOW and will go HIGH when movement is detected. After a brief period (less than 1 s), the output will go LOW again when movement is no longer detected. With this output you do not need to connect the sensor to an analog-to-digital converter. Analog output. The output, which will vary several volts, is the amplified output of the PIR sensor. With this output you will need to connect the sensor to an analog-to-digital converter (or an analog comparator).
You may also locate a timed output, where the output will stay HIGH for a period of time— up to several minutes—after movement is detected. This output is not as useful. Fig. 30-13 shows the innards of a hacked motion detector. If the PIR board you are using operates with a 5 vdc supply, you can connect the wire you added directly to a microprocessor or microcontroller input. If the PIR board operates from a higher voltage, use a logic level translation circuit, or connect the wire you added from the PIR board to the coil terminals of a 9 or 12 volt reed relay.
30.2.7 USING THE FOCUSING LENS PIR sensors work by detecting electromagnetic radiation in the infrared region, especially about 5 to 15 micrometers (5000 to 15,000 nanometers). Infrared radiation in this part of the spectrum can be focused using optics for visible light. While you can use a PIR device without focusing, you’ll find range and sensitivity are greatly enhanced when you use a lens. Most motion detectors use either a specially designed Fresnel lens to focus infrared radiation or a motion detection lens, which causes the amount of light falling on the detector to change with movement. The Fresnel lens is a piece of plastic with grooves, and is made to gather more light at the top than at the bottom. With this geometry, when the sensor is mounted high and pointing down the motion detector is more sensitive to movement farther away than right underneath. The motion detection lens consists of a series of flat sections, which focus light from different areas—when a person moves, the amount of light reaching the detector changes, resulting in a changing signal.
538
OBJECT DETECTION
FIGURE 30-13 A hacked PIR detector, showing the DC-operated circuit board.
If you’ve gotten your PIR sensor by hacking a motion detector, you can use the same lens for your robot. You may wish to invert the lens from its usual orientation (because your robot will likely be near the ground, looking up). Or, you can substitute an ordinary positive diopter lens and mount it in front of the PIR sensor. Chapter 32, “Robot Vision,” has more information on the use and proper mounting of lenses. Note that, oddly enough, plastic lenses are probably a better choice than glass lenses. Several kinds of glass actively absorb infrared radiation, as do optical coatings applied to finer quality lenses. You may need to experiment with the lens material you use or else obtain a specialty lens designed for use with PIR devices.
30.2.8 ULTRASONIC SOUND Like light, sound has a tendency to travel in straight lines and bounce off any object in its path. You can use sound waves for many of the same things that light can be used for, including detecting objects. High-frequency sound beyond human hearing (ultrasonic) can be used to detect both proximity to objects as well as distance. In operation, ultrasonic sound is transmitted from a transducer, reflected by a nearby object, then received by another transducer. The advantage of using sound is that it is not sensitive to objects of different color and light-reflective properties. Keep in mind, however, that some materials reflect sound better than others and that some even absorb sound completely.
30.2 NONCONTACT NEAR-OBJECT DETECTION
539
This system is adaptable for use with either a single transmitter/receiver pair or multiple pairs. Ultrasonic transmitter and receiver transducers are common finds in the surplus market and even when new cost under $5 each (depending on make and model). Ultrasonic transducers are available from a number of retail and surplus outlets; see Appendix B, “Sources,” for a more complete list of electronics suppliers. You can also mount a single pair of transducers on a scanning platform (also called a turret or carousel), as shown in Fig. 30-14. The scanner can be operated using a standard RC servo (see Chapter 22, “Working with Servo Motors,” for more information). Figs. 30-15 and 30-16 show a basic circuit you can build that provides ultrasonic proximity detection and has two parts: a transmitter and a receiver (refer to the parts list in Tables 36-2 and 36-3). The transmitter circuit works as follows: a stream of 40 kHz pulses are produced by a 555 timer wired up as an astable multivibrator. The receiving transducer is positioned two or more inches away from the transmitter transducer. For best results, you may wish to place a piece of foam between the two transducers to eliminate direct interference. The signal from the receiving transducer needs to be amplified; an op amp (such as an LM741, as shown in Fig. 30-16) is more than sufficient for the job. The amplified output of the receiver transducer is directly connected to another 741 op amp wired as a comparator. The ultrasonic receiver is sensitive only to sounds in about the 40 kHz range (⫾ about 4 kHz).
FIGURE 30-14 Ultrasonic sensors mounted on an RC servo scanner turret.
540
OBJECT DETECTION
+12V
4
8
R4 2.2K
R1 1K 7 R2 5K
IC1 555
2
R3 1.2K
3
c
About 40 kHz
Q1 2N2222
b e
6 C2 0.1
Ultrasonic Transducer
C1 0.0033
1
FIGURE 30-15 Schematic diagram for a basic ultrasonic proximity transmitter.
The closer the ultrasonic sensor is to an object, the stronger the reflected sound will be. (Note, too, that the strength of the reflected signal will also vary depending on the material bouncing the sound.) The output of the comparator will change between LOW and HIGH as the sensor is moved closer to or farther away from an object. Once you get the circuit debugged and working, adjust potentiometer R2, on the op amp, to vary the sensitivity of the circuit. You will find that, depending on the quality of the transducers you use, the range of this sensor is quite large. When the gain of the op amp is turned all the way up, the range may be as much as 6 to 8 ft. (The op amp may ring, or
+V
+V
C1 0.01
R2 100K +V
R1 330
2
+V -
7 IC1 741
3 R3 10K Ultrasonic Transducer
R4 10K
+
6
C2 0.01
R5 1K
3
7
+ IC2 741
4 R8 330
2 R6 10K
-
6 Output 4
R7 10K
FIGURE 30-16 Schematic diagram for a basic ultrasonic proximity sensor receiver.
30.3 CONTACT DETECTION
541
oscillate, at very high gain levels, so use your logic probe to choose a sensitivity setting just below the ringing threshold.)
30.3 Contact Detection A sure way to detect objects is to make physical contact with them. Contact is perhaps the most common form of object detection and is often accomplished by using simple switches. This section will review several contact methods, including soft-contact techniques where the robot can detect contact with an object using just a slight touch.
30.3.1 PHYSICAL CONTACT BUMPER SWITCH An ordinary switch can be used to detect physical contact with an object. So-called bumper switches are spring-loaded push-button switches mounted on the frame of the robot, as shown in Fig. 30-17. The plunger of the switch is pushed in whenever the robot collides with an object. Obviously, the plunger must extend farther than all other parts of the robot. You may need to mount the switch on a bracket to extend its reach. The surface area of most push-button switches tends to be very small. You can enlarge the contact area by attaching a metal or plastic plate or a length of wire to the switch plunger. A piece of rigid 1⁄16-in-thick plastic or aluminum is a good choice for bumper plates. Glue the plate onto the plunger. Low-cost push-button switches are not known for their sensitivity. The robot may have to crash into an object with a fair amount of force before the switch makes positive contact, and for most applications that’s obviously not desirable. Leaf switches require only a small touch before they trigger. The plunger in a leaf switch (often referred to as a Microswitch), is extra small and travels only a few fractions of an inch before its contacts close. A metal strip, or leaf attached to the strip, acts as a lever, further increasing sensitivity. You can mount a plastic or metal plate to the end of the leaf to increase surface area. If the leaf is wide enough, you can use miniature 4/40 or 3/38 hardware to mount the plate in place.
Plunger Switch
Frame FIGURE 30-17 An SPST spring-loaded plunger switch mounted in the frame or body of the robot, used as a contact sensor.
542
OBJECT DETECTION
30.3.2 WHISKER Many animal experts believe that a cat’s whiskers are used to measure space. If the whiskers touch when a cat is trying to get through a hole, it knows there is not enough space for its body. We can apply a similar technique to our robot designs—whether or not a cat actually uses whiskers for this purpose. You can use thin 20- to 25-gauge piano or stove wire for the whiskers of the robot. Attach the wires to the end of switches, or mount them in a receptacle so the wire is supported by a small rubber grommet. By bending the whiskers, you can extend their usefulness and application. The commercially made robot shown in Fig. 30-18, the Movit WAO, has two whiskers that can be rotated in their switch sockets. When the whiskers are positioned so the loop is vertical, they can detect changes in topography to watch for such things as the edge of a table, the corner of a rug, and so forth. A more complex whisker setup is shown in Fig. 30-19. Two different lengths of whiskers are used for the two sides of the robots. The longer-length whiskers represent a space a few inches wider than the robot. If these whiskers are actuated by rubbing against an object but the short whiskers are not, then the robot understands that the pathway is clear to travel but space is tight.
FIGURE 30-18 The Movit WAO robot (one of the older models, but the newer ones are similar). Its two tentacles, or whiskers, allow it to navigate a space.
30.3 CONTACT DETECTION
543
Right Whisker
Left Whisker
A
Grommet (for Holding Whisker) Leaf Switch Whisker
Mounting Bolt
B
Vibration or Movement Causes Switch Activation
FIGURE 30-19 Adding whiskers to a robot. a. Whiskers attached to the dome of the Minibot (see Chap. 8); b. construction detail of the whiskers and actuation switches.
The short whiskers are cut to represent the width of the robot. Should the short whiskers on only one side of the robot be triggered, then the robot will turn the opposite direction to avoid the obstacle. If both sides of short whiskers are activated, then the robot knows that it cannot fit through the passageway, and it either stops or turns around. Before building bumper switches or whiskers into your robot, be aware that most electronic circuits will misbehave when they are triggered by a mechanical switch contact. The contact has a tendency to bounce as it closes and opens, so it needs to be conditioned. See the debouncing circuits in Chapter 29 for ways to clean up the contact closure so switches can directly drive your robot circuits.
30.3.3 SPRING WHISKERS You can make a very inexpensive and simple whisker sensor for your robots using an old spring and a piece of thick solid core wire as shown in Fig. 30-20. The whisker consists of
544
OBJECT DETECTION
a spring that has been pulled apart and the two ends straightened with one end being several inches long and acting as the whisker. Instead of using the straightened spring wire for the whisker, a piece of narrow plastic tubing can be used. The other end of the spring is simply soldered to the mounting PCB. Running through the center of the spring is a piece of bared, solid core (20 gauge is good for this application) that does not touch the spring unless there is a force against the whisker (straightened spring end), in which case, the two pieces of metal form a contact. Ideally, the center contact wire should be a pulled up connection to the robot controller while the spring and its integral whisker is connected to the robot’s ground. This wiring arrangement minimizes the chance that static electricity can form on the whisker and cause damage to the robot’s controller when it comes into contact with the center wire.
30.3.4 PRESSURE PAD In Chapter 29 you learned how to give the sense of touch to robot fingers and grippers. One of the materials used as a touch sensor was conductive foam, which is packaged with most CMOS and microprocessor ICs. This foam is available in large sheets and is perfect for use as collision detection pressure pads. Radio Shack sells a nice 5-in square pad that’s ideal for the job. Attach wires to the pad as described in Chapter 29, and glue the pad to the frame or skin of your robot. Unlike fingertip touch, where the amount of pressure is important, the salient ingredient with a collision detector is that contact has been made with something. This makes the interface electronics that much easier to build. Fig. 30-21 shows a suitable interface for use with the pad (refer to the parts list in Table 30-5). The pad is placed in series with a 3.3K resistor between ground and the positive supply voltage to form a voltage divider. When the pad is pressed down, the voltage at the output of the sensor will vary. The output of the sensor, which is the point between the pad
Center Contact Wire
Pulled and Straightened Spring
Force on Spring
Spring Making Contact with Center Wire
FIGURE 30-20 Spring whisker shown soldered to a PCB with a 20-gauge solid core wire running up through the center. When the whisker has a force applied to it, the spring comes into contact with the center wire.
30.3 CONTACT DETECTION
545
+5V
Pressure Sensor
RA 5
+
IC1 339 (1/4)
R1 3.3K R3 10K
4
-
R3 10K
3 2
Output
12
FIGURE 30-21 Converting the output of a conductive foam pressure sensor to an on/off type switch output.
and resistor, is applied to the inverting pin of a 339 comparator. (There are four separate comparators in the 339 package, so one chip can service four pressure pads.) When the voltage from the pad exceeds the reference voltage supplied to the comparator, the comparator changes states, thus indicating a collision. The comparator output can be used to drive a motor direction control relay or can be tied directly to a microprocessor or computer port. Follow the interface guidelines provided in Chapter 14.
30.3.5 MULTIPLE BUMPER SWITCHES What happens when you have many switches or proximity devices scattered around the periphery of your robot? You could connect the output of each switch to the computer, but that’s a waste of interface ports. A better way is to use a priority encoder or multiplexer. Both schemes allow you to connect several switches to a common control circuit. The robot’s microprocessor or computer queries the control circuit instead of the individual switches or proximity devices. Using a Priority Encoder The circuit in Fig. 30-22 uses a 74148 priority encoder IC. Switches are shown at the inputs of the chip. When a switch is closed, its binary equivalent
TABLE 30-5
Parts List for Pressure Sensor Bumper Switch
IC1
LM339 quad comparator IC
R1
3.3K resistor
R2
10K potentiometer
R3
10K resistor
Misc.
Conductive foam pressure transducer (see text)
+5vdc
546
16
R1 thru R8 all 1K
9 A
S1 thru S8 4
74148
7 B
3 2
C
6
1 13 12
INPUTS 14 GROUP SIGNAL ENABLE OUTPUT
15
11 5 10
ENABLE INPUT
8
EI
SWITCH 1 2 3 4
5
6
7
8
OUTPUT A B C
1 0 0 0 0 0 0 0 0
X C 0 0 0 0 0 0 0
X C 0 0 0 C 0 0 0
X C 0 0 0 0 C 0 0
X C 0 0 0 0 0 C 0
X C 0 0 0 0 0 0 0
1 1 0 1 0 1 0 1 0
X O C 0 0 0 0 0 0
X 0 0 C 0 0 0 0 0
X C 0 0 C 0 0 0 0
1 1 1 0 0 1 1 0 0
1 1 1 1 1 0 0 0 0
Truth Table--74148 priority encoder
FIGURE 30-22 Multiple switch detection using the 74148 priority encoder IC.
Goes HIGH when a switch is closed Goes LOW when a switch is closed
30.3 CONTACT DETECTION
547
appears at the A-B-C output pins. With a priority encoder, only the highest value switch is indicated at the output. In other words, if switches 4 and 7 are both closed, the output will only reflect the closure of pin 4. Another method is shown in Fig. 30-23. Here, a 74150 multiplexer IC is used as a switch selector. To read whether a switch is or not, the computer or microprocessor applies a binary weighted number to the input select pins. The state of the desired input is shown in inverted form at the Out pin (pin 10). The advantage of the 74150 is that the state of any switch can be read at any time, even if several switches are closed. Using a Resistor Ladder If the computer or microcontroller used in your robot has an analog-to-digital converter (ADC) or you don’t mind adding one, you can use another technique for interfacing multiple switches: the resistor ladder. The concept is simple, as Fig. 30-24 shows. Each switch is connected to ground on one side and to positive voltage in series with a resistor on the other side. Multiple switches are connected in parallel to an ADC input, as depicted in the figure. The resistors form a voltage divider. Each resistor has a different value, so when a switch closes the voltage through that switch is uniquely different. Note that because the resistors are in parallel, you can close more than one switch at one time. An in-between voltage will result. Feel free to experiment with the values of the resistors connected to each switch to obtain maximum flexibility.
+5VDC
24
S1-S16 Bumper Switches
8 7
0
6 2 5 3 4 4 3 5 2 6 1 7 23 8 22 9 21 10 20 11 19 12 18 13 17 14 16 15
R1-R16 1.2K
OUT
10 Output
1
A B C D
15 14 13 11
IC1 74150
ENABLE GND 12
FIGURE 30-23 Multiple switch detection using a 74150 multiplexer IC.
9
Input select
548
OBJECT DETECTION
FIGURE 30-24 A resistor ladder provides a variable voltage; the voltage at the output of the ladder is dependent on the switch(es) that are closed.
30.4 Soft Touch and Compliant Collision Detection The last nickname you’d want for your robot is “Bull in a China Closet,” a not too flattering reference to your automaton’s habit of crashing into and breaking everything. Unfortunately, even the best behaved robots occasionally bump into obstacles, including walls, furniture, and the cat (your robot can probably survive a head-on collision with a solid wall, but the family feline . . . maybe not!). Since it’s impractical—not to mention darn near impossible—to always prevent your robot from colliding with objects, the next best thing is to make those collisions as “soft” as possible. This is done using so-called soft touch or compliant collision detection means. Several such approaches are outlined here. You can try some or all; mixing and matching sensors on one robot is not only encouraged, it’s a good idea. As long as the sensor redundancy does not unduly affect the size, weight, or cost of the robot, having backups can make your robot a better behaved houseguest.
30.4.1 LASER FIBER WHISKERS You know about fiber optics: they’re used to transmit hundreds of thousands of phone calls through a thin wire. They’re also used to connect together high-end home entertainment gear and even to make “light sculpture” art. On their own, optical fibers offer a wealth of technical solutions, and when combined with a laser, optical fibers can do even more. The unique whiskers project that follows makes use of a relatively underappreciated (and often undesirable) synergy between low-grade optical fibers and lasers. To fully understand what happens to laser light in an optical fiber, you should first consider how fiber optics work and then how the properties of laser light play a key role in making the fiber-optic robowhiskers function.
30.4 SOFT TOUCH AND COMPLIANT COLLISION DETECTION
549
Fiber Optics: An Introduction An optical fiber is to light what PVC pipe is to water. Though the fiber is a solid, it channels light from one end to the other. Even if the fiber is bent, the light follows the path, altering its course at the bend and traveling on. Because light acts as an information carrier, a strand of optical fiber no bigger than a human hair can carry the same amount of data as some 900 copper wires. The idea for optical fibers is over 100 years old. British physicist John Tyndall once demonstrated how a bright beam of light was internally reflected through a stream of water flowing out of a tank. Serious research into light transmission through solid material started in 1934, when Bell Labs was issued a patent for the light pipe. In the 1950s, the American Optical Corporation developed glass fibers that transmitted light over short distances (a few yards). The technology of fiber optics really took off around 1970 when scientists at Corning Glass Works developed long-distance optical fibers. Optical fibers are composed of two basic materials, as illustrated in Fig. 30-25: the core and the cladding. The core is a dense glass or plastic material that the light actually passes through as it travels the length of the fiber. The cladding is a less dense sheath, also of plastic or glass, that serves as a refracting medium. An optical fiber may or may not have an outer jacket, a plastic or rubber insulation used as protection. Optical fibers transmit light by total internal reflection (TIR), as shown in Fig. 30-26. Imagine a ray of light entering the end of an optical fiber strand. If the fiber is perfectly straight, the light will pass through the medium just as it passes through a plate of glass. But if the fiber is bent slightly, the light will eventually strike the outside edge of the fiber. If the angle of incidence is great (more than the so-called critical angle), the light will be reflected internally and will continue its path through the fiber. But if the bend is large and the angle of incidence is small (e.g., less than the critical angle), the light will pass through the fiber and be lost. Note the cone of acceptance, as shown in Fig. 30-26. The cone represents the degree to which the incoming light can be off axis and still make it into the fiber. The cone of acceptance (usually 30°) of an optical fiber determines how far the light source can be from the optical axis and still manage to make it into the fiber. Though the cone of acceptance may
Protective Sheath Cladding
Core
FIGURE 30-25 The physical makeup of an optical fiber, consisting of core and cladding.
550 OBJECT DETECTION
Lost Rays Outside Cone of Acceptance
Cone of Acceptance
Totally Reflected Ray
FIGURE 30-26 Light travels through optical fibers due to a process called total internal reflection (TIR).
be great, fiber optics perform best when the light source (and detector) are aligned to the optical axis. Types of Optical Fibers The classic optical fiber is made of glass, otherwise known as silica (which is plain ol’ sand). Glass fibers tend to be expensive and are more brittle than stranded copper wire, but they are excellent conductors of light, especially light in the infrared region between 850 and 1300 nanometers (nm). Less expensive optical fibers are made of plastic. Though light loss through plastic fibers is greater than through glass fibers, they are more durable. Plastic fibers are best used in communications experiments with near-infrared light sources—the 780 to 950 nm range. This nicely corresponds to the output wavelength and sensitivity of common infrared emitters and detectors. Optical fiber bundles may be coherent or incoherent. These terms relate to the arrangement of the individual strands in the bundle. If the strands are arranged so that the fibers can transmit an image from one end to the other, they are said to be coherent. The vast majority of optical fibers are incoherent: an image or particular pattern of light is lost when it reaches the other end of the fiber. The cladding used in optical fibers may be one of two types: step-index and gradedindex. Step-index fibers provide a discrete boundary between more dense and less dense regions of core and cladding. They are the easiest to manufacture, but their design causes a loss of ray coherency when laser light passes through the fiber: that is, coherent light in, largely incoherent light out. The loss of coherency, which is due to light rays traveling slightly different paths through the fiber, reduces the efficiency of the laser beam. Still, it offers some very practical benefits. There is no discrete refractive boundary in graded-index fibers. The core and cladding media slowly blend, like an exotic tropical drink. The grading acts to refract light evenly, at
30.4 SOFT TOUCH AND COMPLIANT COLLISION DETECTION
551
any angle of incidence. This preserves coherency and improves the efficiency of the fiber. As you might have guessed, graded-index optical fibers are the most expensive of the bunch. Working with Fiber Optics Optical fibers may be cut with wire cutters, nippers, or even a knife. But you must exercise care to avoid injuring yourself from shards of glass that may fly out when the fiber is cut (plastic fibers don’t shatter when cut). Wear heavy cotton gloves and eye protection when working with optical fibers. Avoid working with fibers around food-serving or -preparation areas (that means stay out of the kitchen!). The bits of glass may inadvertently settle on food, plates, or eating utensils and could cause bodily harm. One good way to cut glass fiber is to gently nick it with a sharp knife or razor, then snap it in two. Position the thumb and index finger of both hands as close to the nick as possible, then break the fiber with a swift downward motion (snapping upward increases the chance that glass shards will fly off in your direction). Building the Laser-Optic Whisker Consider the arrangement in Fig. 30-27. A laser is pointed at one end of a stepped-index optical fiber. The fiber forms one or more loops around the front, side, or back of the robot. At the opposite end of the fiber is an ordinary phototransistor or photodiode. When the laser is turned on, the photodetector registers a certain voltage level from the laser light, say 2.5 V. This is the quiescent level. When one or more of the loops of the fiber are deformed—the robot has touched a person or thing, for instance—the laser light passing through the fiber is diverted in its path, and this changes the interference patterns at the photodetector end. The change in light level received by the photodetector does not span a very wide range, perhaps 1 V total. But this 1 V is enough to not only determine when the robot has touched an object but the relative intensity of the collision. The more the robot has connected to some object, the more the fibers will deform and the greater the output change of the light as it reaches the photodetector. +5V
Power Supply Regulator (as Needed) Output Laser Diode
Optical Fiber
Phototransistor
FIGURE 30-27 The basic parts of a laser-optic whisker are a laser, a length of fiber optics, and a photodetector.
552 OBJECT DETECTION
The key benefit of the laser-optic whisker system is that a collision can be detected with just a feather touch. In fact, your robot may know when it’s bumped into you before you do! Since contact with the robot is through a tiny piece of plastic, there’s little chance the machine will damage or hurt anything it bumps into. The whiskers can protrude several inches from the body of the robot and omnidirectionally, if you desire. In this way it will sense contact from any direction. Fig. 30-28 shows a prototype of this technique that consists of a hacked visible light penlight laser, several strands of cheap (very cheap) stepped-index optical fibers, and a set of three phototransistors. The optical fibers are tied together in a bundle using a small brass collar, electrical tape, and tie-wrap. This bundle is then inserted into the opening of the penlight laser and held in place with a sticky-back tie-wrap connector (available at Radio Shack and many other places). On the opposite ends of the optical fibers are #18 crimp-type bullet connectors. These are designed to splice two #18 or #20 wires together, end to end. Carefully crimp them onto the ends of the fibers, so they act as plug-in connectors. As shown in Fig. 30-29, these ersatz connectors plug into makeshift optical jacks, which are nothing more than 1⁄4-indiameter by 3⁄8-in-aluminum tubing. The tubing is glued over the ends of the phototransistors and the phototransistors are soldered near the edge of the prototyping PCB. Refer to Fig. 30-30 for a schematic wiring diagram of a power regulator for the penlight laser. Note the zener diode voltage regulator. The laser I used was powered by two AAA batteries, or roughly 3 V. Diode lasers are sensitive to high input voltage, and many will burn
FIGURE 30-28 The prototype laser-optic sensor, showing the loose fibers (on the robot these fibers are neatly looped to create a kind of sensor antenna).
30.4 SOFT TOUCH AND COMPLIANT COLLISION DETECTION
553
Aluminum Tubing Fiber-Optic strand Phototransistor Bullet Connector FIGURE 30-29 Use short lengths of aluminum tubing, available at hobby stores, and a crimp-on bullet connector to create “optical jacks” for the laser-optic whisker system.
out if fed a higher voltage than they are designed for. The penlight laser consumes less than about 30 mA. An alternative is to use three signal diodes (e.g., 1N4148) in series between the +V and the input of the laser to drop the 5 vdc voltage to about 2.7 to 3.0 V. The diodes you use should be rated for 1⁄4-W or higher. Interfacing the Photodetectors The output of a phototransistor is close to the full 0 to 5 V range of the circuit’s supply range. You’ll want your robot to be able to determine the intensity changes as the whiskers bump against objects. If you’re using a computer or microcontroller to operate your robot, this means you’ll need to convert the analog signal produced by the detectors into a digital signal suitable for the brains on your ’bot. Most popular microcontroller families have analog-to-digital converter (ADC) ports built in. If your computer or controller doesn’t have ADC inputs, you can add an outboard ADC using an ADC0809 or similar chips. See Chapter 14 for more information on interfacing an analog signal to a digital input by way of an analog-to-digital converter.
R1=47 ohms (typical; drives 30 mA) R1=27 ohms (drives 60 mA) Use 1/4-watt Resistors and Zener Diodes
FIGURE 30-30 Most penlight lasers are designed to operate with 3 vdc; use a zener diode or voltage regulator to provide the proper voltage.
554 OBJECT DETECTION
Creating the Whisker Loops Okay, so the laser-optic whisker system may not use cat-type whiskers with ends that stick out. Still, the word whisker aptly describes the way the system works. If something even so much as brushes lightly against the whisker, the light reaching the photodetector will change, and your robot can react accordingly. The prototype system for this book used three whiskers, all of which were formed into three small loops around the front and two sides of the test robot. The loops can be held in place with small screws, dabs of glue (don’t use hot-melt glue!), or even LEGO parts should your robot be constructed with them. When forming the loops don’t make them too tight. The more compliant the loops are, the more they will detect small amounts of pressure. If the loops are very tight, the fibers become rigid and not very compliant. This reduces the effectiveness of the whiskers. At the same time, the loops should not be so loose that they tend to wobble or flap while the robot is in motion. Should this occur, the natural vibration and movement of the fiber will cause false readings. A loop diameter of from 4 to 6 in should be sufficient given optical fiber pieces of average diameter and stiffness. Experiment with the optical fibers you obtain for the project. Your laser-optic whisker system does not need to use three separate fiber strands. One strand may be enough, especially if the robot is small. The prototype used three so the robot could independently determine in which direction (left, front, right) a collision or bump had occurred. Getting the Right Kind of Optical Fiber Perhaps the hardest part of constructing this project is finding the right kind of optical fiber. You want to avoid any kind of graded-index fiber (described earlier) because these will not produce the internal interference patterns that the project depends on. In essence, what you want is the cheapest, lousiest fiber-optic strands you can find. The kind designed for “light fountain art” (popular in the early 1970s) is ideal. You do not want to use data communications-grade optical fiber. Before you buy miles of optical fiber, test a 2-ft strand with a suitable diode laser and phototransistor. Loop the fiber and tape it snugly to your desk or workbench. Connect the phototransistor to a sensitive volt-ohm meter or, better yet, an oscilloscope. Gently touch the fiber loops to deform them. You should observe a definite change of output in the phototransistor. If you do not, examine your setup to rule out a wiring error, and try again. Turn the laser off momentarily and observe the change in output. Working with Laser Diodes Penlight lasers can be easily hacked for a wide variety of interesting robot projects—the soft-touch fiber-optic whisker is just one of them. Penlight lasers use a semiconductor lasing element. While these elements are fairly hearty, they do require certain handling precautions. And even though they are small, they still emit laser light that can be potentially dangerous to your eyes. So keep the following points in mind:
• •
Always make sure the terminals of a laser diode are connected properly to the drive circuit. Never apply more than the rated voltage to the laser or it will burn up.
30.4 SOFT TOUCH AND COMPLIANT COLLISION DETECTION
• • • • • • • • •
555
Extend the same care to laser diodes that you do to any static-sensitive device. Wear an anti-static wrist strap while handling the bare laser element, and keep the device in a protective, anti-static bag until it’s ready for use. Use only a grounded soldering pencil when attaching wires to the laser diode terminals. Limit soldering duration to less than 5 s per terminal. Never connect the probes of a volt-ohm meter across the terminals of a laser diode. The current from the internal battery of the meter may damage the laser. Use only batteries or well-filtered AC power supplies. Laser diodes are susceptible to voltage transients and can be ruined when powered by poorly filtered line-operated supplies. Take care not to short the terminals of the laser during operation. Avoid looking into the window of the laser while it is operating, even if you can’t see any light coming out (is the diode the infrared type?). Unless otherwise specified by the manufacturer, clean the output window of the laser diode with a cotton swab dipped in technical-grade isopropyl alcohol (less than 20% water). Alternatively, you can use optics-grade lens cleaning fluid. If you are using a laser from a laser penlight, bear in mind that the penlight casing acts as a heat sink. If you remove the laser from the penlight casing, be sure to attach the laser to a suitable heat sink to avoid possible damage. If you keep the laser in the casing, there is usually no need to add the heat sink—the casing should be enough.
30.4.2 PIEZO DISC TOUCH BAR The laser-optic whisker system described earlier is a great way to detect even your robot’s minor collisions. But it may be overkill in some instances, providing too much sensitivity for a zippy little robot always on the go. The soft-touch collision sensor described in this section, which uses commonly available piezo ceramic discs, is a good alternative to the laseroptic whisker system for lower-sensitivity applications. This sensor is constructed with a half-round bar to increase the area of contact. Construction of the Piezo Disc Touch Bar The main sensing elements of the piezo disc touch bar are two 1-in-diameter bare piezo ceramic discs. These discs are available at Radio Shack and many surplus electronics stores; they typically cost under $1 or $2 each, and you can often find them for even less. You attach the discs to a 61⁄2-in long support bar, which you can make out of plastic, even a long LEGO Technic beam. As shown in Fig. 30-31, you glue the discs into place with 1 ⁄8-in foam (available at most arts and craft stores) so it sticks to the ceramic surface of the disc and acts as a cushion. You then bend a length of 1⁄8-in-diameter aluminum tubing (approximately 8 to 9 in) into a half-circle; thread through two small grommets, as shown in Fig. 30-32; and glue the grommets to the support bar. You flatten the ends of the tubing and bend them at right angles to create a foot; the foot rests on the foam-padded surface of the discs. The half-round tubing slopes downward slightly on the prototype. This is intentional, so the robot can adequately sense objects directly in front of it near the ground. To construct the piezo disc touch bar prototype, hot-melt glue was used to attach the discs and grommets to the support bar. You can use most any other adhesive or glue you
556 OBJECT DETECTION
Piezo Disc Foam
Bar
FIGURE 30-31 Glue the piezo discs to a piece of plastic; the plastic is a support bar for the discs that also makes it easier to mount the touch bar sensor onto your robot.
wish, but be sure it provides a good, strong hold for the different materials used in this project (metal, plastic, and rubber). Constructing the Interface Circuit Piezo discs are curious creatures: when a voltage is applied to them, the crystalline ceramic on the surface of the disc vibrates. It is the nature of piezoelectricity to be both a consumer and a producer of electricity. When the disc is connected to an input, any physical tap or pressure on the disc will produce a voltage. The exact voltage is approximately proportional to the amount of force exerted on the disc:
FIGURE 30-32 The finished prototype of the piezo disc touch bar. One variation is to mount the discs a little lower so the metal bar physically deforms the disc rather than pushes against its center.
30.4 SOFT TOUCH AND COMPLIANT COLLISION DETECTION
557
apply a little pressure or tap and you get a little voltage. Apply a heavier pressure or tap, and you get a bigger voltage. The piezoelectric material on ceramic piezo discs is so efficient that even a moderately strong force on the disc will produce in excess of 5 or 10 V. That’s good in that it makes it easy to interface the discs to a circuit, since there is usually no need to amplify the signal. But it’s also bad in that the voltage from the disc can easily exceed the maximum inputs of the computer, microcontroller, or other electronic device you’re interfacing with. (Pound on a piezo disc with a hammer, and, though it might be broken when you’re done, it will also produce a 1000 V or more.) To prevent damage to your support electronics, attach two 5.1-V zener diodes as shown in Fig. 30-33, to each disc of the touch bar. The zener diodes limit the output of the disc to 5.1 V, a safe enough level for most interface circuitry. For an extra measure of safety, use 4.7-V zeners instead of 5.1 V. Note that piezoelectric discs also make great capacitors. This means that over time the disc will take a charge, and the charge will show up as a constantly changing voltage at the output of the disc. To prevent this, insert a resistor across the output of the disc and ground. In the prototype circuits, an 82k resistor eliminated the charge buildup without excessively diminishing the sensitivity of the disc. Experiment with the value of the resistor. A higher value will increase sensitivity, but it could cause an excessive charge buildup. A lower value will reduce the buildup but also reduce the sensitivity of the disc. It is also helpful to route the output of the disc to an op amp, preferably through a 100K or higher resistor. Mounting the Touch Bar Once you have constructed the piezo disc touch bar and added the voltage-limiting circuitry, you can attach it to the body of the robot. The front of the robot is the likely choice, but you can add additional bars to the sides and rear to obtain a near 360 degree sensing pattern. The width of the bar makes it ideal for any robot that’s between about 8 and 14 in wide. Since the sensing element of the touch bar, the aluminum tube, has a half-round shape, the sensor is also suitable for mounting on a circular robot base. For added compliancy, you may wish to mount the bar using a thick foam pad, spring, or shock absorber (shocks made for model racing cars work well). If the bar is mounting directly to the robot the sensor exhibits relatively little compliancy. You should mount the bar at a height that is consistent with the kinds of objects the robot is most likely to collide with. For a wall-hugging robot, for example, you may wish to mount the bar low and ensure that the half-round tube slopes downward. That way, the sensor is more likely to strike the baseboard at the bottom of the wall.
From Disc
Output 5.1 v Zener
5.1 v Zener
FIGURE 30-33 A suitable interface circuit for connecting a piezo disc to a TTLcompatible input or op amp.
558 OBJECT DETECTION
Software for Sensing a Collision The following code is a short sample program for reading the values provided by the piezo disc touch bar. The program is written for the BASIC Stamp 2 microcontroller and requires the addition of one or more serial-output analog-todigital converter chips (an ADC0831 was used for the prototype). You need only one ADC if it has multiple inputs; you’ll need two ADCs if the chips have but a single input. See the comments in the program for hookup information. ' For the BASIC Stamp 2 ' Uses an ADC081 serial Adress var byte CS con 13 Adata con 14 CLK con 15 Vref con 0 high Vref high CS
ADC ' A-to-D result: one byte ' Chip select is pin 13 ' ADC data output is pin 14 ' Clock is pin 15 ' VRef
' Deselect ADC to start
DO low CS shiftin AData, CLK, msbpost, [ADres\9] high CS debug ? Adres pause 100 LOOP ' Repeat
' ' ' ' '
Activate ADC Shift in the data Deactivate ADC Display result Wait 1/10 second
30.4.3 OTHER APPROACHES FOR SOFT-TOUCH SENSORS There are several other approaches for using soft-touch sensors. For example, the resistive bend sensor changes its resistance the more it is curved or bent. Positioned in the front of your robot in a loop, the bend sensor could be used to detect the deflection caused by running into an object. If you like the idea of piezoelectric elements but want a more localized touch sensor than the touch bar described in the previous section, you might try mounting piezoelectric material and discs on rubber or felt pads, or even to the bubbles of bubble pack shipping material, to create fingers for your ’bot.
30.5 From Here To learn more about . . .
Read
Connecting analog and digital sensors to computers, microcontrollers, and other circuitry
Chapter 14, “Computer Peripherals”
Building and using sensors for tactile feedback
Chapter 29, “The Sense of Touch”
Giving your robots the gift of sight
Chapter 32, “Robot Vision”
Using sensors to provide navigation assistance to mobile robots
Chapter 33, “Navigation”
CHAPTER
31
SOUND INPUT AND OUTPUT
T
he robots of science fiction are seldom mute or deaf. They may speak pithy warnings— the most famous probably being: “Danger, Danger, Will Robinson”—or squeak out blips and beeps in some “advanced” language only other robots can understand. Voice and sound input and output make a robot more humanlike, or at least more entertaining. What is a personal robot for if not to entertain? What’s good for robots in novels and in the movies is good enough for us, so this chapter presents a number of useful projects for giving your mechanical creations the ability to make and hear noise. The projects include using recorded sound, generating warning sirens, recognizing and responding to your voice commands, and listening for sound events. Admittedly, this chapter only scratches the surface of what’s possible today, especially with technologies like MP3 compressed digitized sound.
31.1 Cassette Recorder Sound Output Before electronic doodads took over robotics there were mechanical solutions for just about everything. While they may not always have been as small as an electrical circuit, they were often easier to use. Case in point: you can use an ordinary cassette tape and playback mechanism to produce music, voice, or sound effects. Tape players and tape player mechanisms are common finds in the surplus market, and you can often find complete (and still working) portable cassette players-recorders at thrift stores. With just a few 559 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
560
SOUND INPUT AND OUTPUT
FIGURE 31-1 A surplus cassette deck transport. This model is entirely solenoid driven and so is perfect for robotics.
wires you can rig a cassette tape player in the robot and have the sound played back, on your command. When looking for a cassette player try to find the kind shown in Fig. 31-1, which is solenoid controlled. These are handy for your robot designs because instead of pressing mechanical buttons, you can actuate solenoids by remote or computer control to play, fastforward, or rewind the tape. They can be somewhat difficult to find as they are usually built into more expensive soft-touch tape decks and are not readily found in surplus bins. For most cassette decks you only need to provide power to operate the motor(s) and solenoids (if any) and a connection from the playback head to an amplifier. Since you are not using the deck for recording, you don’t have to worry about the erase head or biasing
TABLE 31-1
Parts List for Cassette Tape Head Player Amplifier
IC1
LT1007 low-noise operational amplifier (Linear Technology)
R1
330K resistor
R2
4.9K resistor
R3
100-Ω resistor
C1
0.1 µF ceramic capacitor
31.2 ELECTRONICALLY RECORDED SOUND OUTPUT
561
+V C1 0.1
R1 5K
R3 330K R2 100Ω
Input
2 –
7
LT1007 3 + 4
6
Output
FIGURE 31-2 Preamplifier circuit for use with a magnetic tape playback head.
the record head. If the deck already has a small preamplifier for the playback head, use it. It’ll improve the sound quality. If not, you can use the tape head preamplifier shown in Fig. 31-2 (you can use a less expensive op amp than the one specified in the parts list in Table 31-1, but noise can be a problem). Place the preamplifier board as close to the cassette deck as possible to minimize stray pickup.
31.2 Electronically Recorded Sound Output While mechanical sound playback systems like the cassette recorder are adequate, they lack the response and flexibility of a truly electronic approach. Fortunately, all-electronic reproduction of sound is fairly simple and inexpensive, in large part because of the wide availability of custom-integrated circuits that are designed to record, store, and play back recorded sound. Most of these chips are made for commercial products such as microwave ovens, cellular phones, or car alarms.
31.2.1 HACKING A TOY SOUND RECORDER You can hack toy sound recorders, such as the Yak Bak, for use in your robot. These units, which can often be found at toy stores for under $10, contain a digital soundrecording chip, microphone, amplifier, and speaker (and sometimes sound effects generator). To use them, you press the Record button and speak into the microphone. Then, stop recording and press the play button and the sound will play back until you make a new recording. Fig. 31-3 shows a Yak Bak toy that was disassembled and hacked by soldering wires directly to the circuit board. The wires, which connect to a microcontroller or computer, are in lieu of pressing buttons on the toy to record and play back sounds. The buttons on most of these sound recorder toys are made of conductive rubber and are easily removed. To operate the unit via a microcontroller or computer, you bring the button inputs HIGH or LOW. (Which value you choose depends on the design of the circuit; you need to experi-
562
SOUND INPUT AND OUTPUT
FIGURE 31-3 A hacked Yak Bak can be used to store and play short sound snips. You can record sounds for later playback, which can be via computer control. This model has two extra buttons for sound effects, which are also connected to the robot’s microcontroller or computer.
ment to find out which to use.) Connect a 1K to 3K resistor between the I/O pin and the button input. Suppose you have a Yak Bak or similar toy connected to I/O pin 1 on a Basic Stamp 2. Assume that on the toy you are using, bringing the button input HIGH triggers a previously recorded sound snip. The control program is as simple as this: high 1 pause 10 low 1
The program starts by bringing the button input (the input of the toy connected to pin 1 of the BASIC Stamp) HIGH. The pause statement waits 10 ms and then places the button LOW again. The built-in amplifier of these sound recorder/playback toys isn’t very powerful. You may wish to connect the output of the toy to one of the audio output amplifiers described later in the chapter (see “Audio Amplifiers”).
31.2.2 USING THE ISD FAMILY OF VOICE-SOUND RECORDERS Toy sound recorders are limited to playing only a single sample. For truly creative robot yapping, you need a sound chip in which you can control the playback of any of several prerecorded snips. You can do this easily by using the family of sound storage and playback chips
31.2 ELECTRONICALLY RECORDED SOUND OUTPUT
563
produced by Information Storage Devices (ISD). The company has made these ChipCorder ICs readily available to the electronics hobbyist and amateur robot builder. You can purchase ISD sound recorder chips from a variety of sources, including Jameco and Digikey (see Appendix B). Prices for these chips vary depending on feature and recording time, but most cost under $10. While there are certainly other makers of sound storage/ playback integrated circuits, the ISD chips are by far the most widely used and among the most affordable. Adding a BS2 to a robot is a fairly simple operation, although it can be difficult to work through using just the data sheets. Using the circuit in Fig. 31-4 (with the parts listed in Table 31-2), you can create your own BS2 to an ISD chip interface circuit using BS2 ICD.bs2 (in the following). When wiring the circuit, make sure you use a reasonably large breadboard and that you leave lots of space between the chips and the end of the breadboard for the various resistors and capacitors. ' BS2 ISD2532 - Controlling the Operation of an IS2532 ' ' myke predko ' ' 05.08.27 ' ' Pin 8 - ISD2532 Chip Enable ' Pin 9 - ISD2532 Play/Record ' '{$STAMP BS2} '{$PBASIC 2.5}
1 24
VSS
23
3
ATN
_RES
22
4
VSS
VDD
21
5
P0
P15
20
6
P1
P14
19
7
P2
P13
18
8
P3
P12
27
Vdd
P4
P11
C1
C2 28
16
26
IC1 ISD2532
4x AA Batteries
+
C3
25 VCCD VCCA EOM 24 10 P10 15 P5 PD 27 11 P9 14 P6 P_R 23 12 P8 13 P7 CE C6 17 Vdd MIC 0.1 uF MIC C7 18 MIC REF 20 0.1 uF ANA IN 21 R5 R4 ANA OUT 1k 19 AGC 10k C5 R2 4.7k C4 R1 C8 R3 10k 10 uF 330k 0.1 uF 220 uF 9
SW1
220 uF
VIN
SIN
0.1 uF
SOUT
2
0.1 uF
1
BASIC Stamp 2
0.1 uF
Vdd
10 A8 9 A7 7 A6 6 A5 5 A4 4 A3 3 A2 2 A1 1 A0 12 VSSD 13 VSSA 26 XCLK
14 SP+ 15 SPSPKR
FIGURE 31-4 Circuit to allow a BS2 to control an ISD2532 solid-state sound recorder/player. While this circuit’s operation is controlled from a PC console, by changing the control software, it can be easily integrated into a robot.
564
SOUND INPUT AND OUTPUT
TABLE 31-2
Parts List for BS2 Control of an ISD Sound Recorder/Player Chip
BS2
Parallax BASIC Stamp 2
IC1
ISD2532 sound recorder/player
R1
330k resistor
R2
4.7k resistor
R3, R4
10k resistor
R5
1k resistor
C1
220 µF electrolytic capacitor
C2, C3
0.1 µF electrolytic capacitor
C4
10 µF electrolytic capacitor
C5–C7
0.1 µF ceramic capacitor
C8
220 µF electrolytic capacitor
SW1
Breadboard mountable SPDT switch
MIC
Electret microphone
SPKR
16 Ω speaker
Misc.
Large breadboard (6 in or longer), breadboard wiring, 4× AA battery clip, 4× AA alkaline batteries, BS2 serial port programmer interface
' Variable Declarations InputString VAR Byte(2) Temp VAR Byte LastCharFlag VAR Bit i VAR Byte CE PIN 8 P_R PIN 9 PD PIN 10 EOM PIN 11 '
'
Initialization HIGH CE LOW P_R HIGH PD Main Loop DO
' ' '
No Operation Start with Recording Hold the Chip High
'
Loop Forever
' ' ' '
Start with Null string Want to execute at least once Wait for Carriage Return Wait for a Char to be input
'
String Ended
DEBUG "Command (R/P)> " i = 0 InputString(i) = 0 LastCharFlag = 0 DO WHILE (LastCharFlag = 0) DEBUGIN STR Temp\1 IF (Temp = CR) THEN LastCharFlag = 1
31.2 ELECTRONICALLY RECORDED SOUND OUTPUT
565
ELSE IF (Temp = BKSP) THEN IF (i = 0) THEN DEBUG " " ' Keep Screen at Constant Point ELSE DEBUG " ", BKSP ' Backup one space i = i - 1 ' Move the String Back InputString(i) = 0 ENDIF ELSE IF (i >= 1) THEN DEBUG BKSP, 11 ' At end of Line or NON-Char ELSE ' Can Store the Character IF ((Temp >= "a") AND (Temp = LightLeft) THEN MotorControl = Forward ELSE MotorControl = Stop ENDIF End LeftMotorProcess
and used to control the left motor of the robot directly. In this function, the Left Motor will be active if the robot is to move forward (LeftLight equal to RightLight) or turn right (RightLight is greater than LeftLight). If the robot has to move left, then the motor stops and the left wheel becomes a pivot the robot turns around. The right motor function (RightMotorProcess) would be identical except that the comparison statement would be reversed, becoming; IF (LightLeft >= LightRight) THEN
As the application became more complex, then the functions governing the actions of individual outputs can be made more complex without affecting other output functions and additional ones could be added without affecting any of the original output functions. This approach may seem somewhat inefficient because much of the code will be repeated, but as an approach for your first attempts at getting a robot working, they will be quite effective, easy to code, and (most importantly) easy to debug and get running.
38.2 Allocating Resources In contrast to a PC, where there seems to be almost limitless resources available, a microcontroller or microprocessor used to control a robot has only a limited amount of resources that can be brought to bear on the task of controlling a robot. Before beginning to design the robot, the resources that will be required should be listed and a controller selected from the chips and system PCBs that have the required resources.
38.2.1 I/O PINS The resource that will seem to be the most restricted when deciding on which controller to use will be I/O pins: both digital and analog. During planning of the robot features, the dif-
38.3 GETTING A PROGRAM’S ATTENTION VIA HARDWARE
675
ferent I/O requirements must be cataloged and matched to I/O pins with the required capabilities. This task is not difficult, but forgetting to do it can cause a great deal of stress and rebuilding when you are finishing the robot later. When you are first starting out, invest in microcontrollers that have quite a few I/O pins available; larger chips can have 30 or so I/O pins that can be used for a variety of different tasks. These chips will be somewhat more expensive and physically larger than those that have a dozen or so I/O pins, but the extra I/O pins will be useful when you want to add another feature to your robot, LEDs, or a speaker to indicate different input conditions from the robot’s sensors that will be important for either debugging the application code or better understanding the input data being received by the controller.
38.2.2 INTERNAL FEATURES Along with I/O pins, most controllers have a number of other features that you will want to take advantage of in your application design. Timers, analog-to-digital converters, voltage comparators, and serial interfaces are all resources that must be managed like I/O pins as they are available only at specific pins and addresses within the devices. The BASIC Stamp 2, which has been used for demonstrating different functions, is unusual in the flexibility given to each pin. They can be used for digital I/O, serial I/O, PWM inputs and outputs, limited serial interfaces and so on, which are usually devoted to specific pins in a traditional controller. For this reason, you may want to use only a controller like a BS2 because you are not as constrained as you would be with other controllers and chips. The best way to manage limited internal features and resources is to treat them as central resources—available for the complete robot application rather than only specific functions. One of the best ways to ensure that the resources are available to all the functions in the robot is to continually execute the internal functions and make the results available to all the output procedures as global variables that can have status flags and values read by the output functions as inputs, just like digital I/O pins or register values to prevent any one function from affecting the value for the other output functions which also rely on the resource’s data.
38.3 Getting a Program’s Attention Via Hardware Even in systems that lack multitasking capability it’s still possible to write a robot control program that doesn’t include a repeating loop that constantly scans (polls) the condition of sensors and other input. Two common ways of dealing with unpredictable external events are using a timer (software) interrupt or a hardware (physical connection) interrupt. When using interrupts, they should set flags or other variable values to indicate that the interrupt has been requested and processed. During the main loop of the control program, the flags and variables should be used as inputs, just like object, sound, speed, and other standard sensors.
676
INTEGRATING THE BLOCKS
38.3.1 TIMER INTERRUPT A timer built into the computer or microcontroller runs in the background. At predefined intervals—most commonly when the timer overflows its count—the timer requests the attention of the microprocessor, which in turn temporarily suspends the main program, if it can spare the cycles. The microprocessor runs a special timer interrupt handler subroutine, which in the case of a task-based robot would poll the various sensors and other input looking for possible error modes. (Think of the timer as a heartbeat; at every beat the microprocessor pauses to do something special.) If no error is found, the microprocessor resumes the main program. If an error is found, the microprocessor runs the relevant section in code that deals with the error. Timer interrupts can occur hundreds of times each second. That may seem like a lot in human terms, but it can be trivial to a microprocessor running at several million cycles per second.
38.3.2 HARDWARE INTERRUPT A hardware interrupt is a mechanism by which to immediately request attention from the microprocessor. It is a physical connection on the microprocessor that can in turn be attached to some sensor or other input device on the robot. With a hardware interrupt the microprocessor can spend 100 percent of its time on the main program and temporarily suspend it if, and only if, the hardware interrupt is triggered. Hardware interrupts are used extensively in most computers, and their benefits are well established. Your PC has several hardware interrupts. For example, the keyboard is connected to a hardware interrupt, so when a key is pressed the request is sent to the processor to stop executing the current code and devote its attention to processing the data from the keyboard. The standard PC hardware has 16 hardware interrupt sources, which are prioritized by hardware within the PC down to just one interrupt request pin on the microprocessor. You can do something similar in your own robot designs.
38.3.3 GLASS HALF-EMPTY, HALF-FULL There are two basic ways to deal with error modes in an interrupt-based system. One is to treat them as “exceptions” rather than the rule:
• •
In the exception model, the program assumes no error mode and only stops to execute some code when an error is explicitly encountered. This is the case with a hardware interrupt, which will stop execution of the current application anytime an error condition is detected and used to cause an interrupt. In the opposite model, the program assumes the possibility of an error mode all the time and checks to see if its hunch is correct. This is the case with the timer interrupt in which the handler subroutine will poll all the robot’s sensors periodically.
The approach you use will depend on the hardware choices available to you. If you have both a timer and a hardware interrupt at your disposal, the hardware interrupt is probably the more straightforward method because it allows the microprocessor to be used more efficiently.
38.4 TASK-ORIENTED ROBOT CONTROL
677
38.4 Task-Oriented Robot Control As workers, robots have a task to do. In many books on robotics theory and application, these tasks are often referred to as goals. A robot may be given multiple tasks at the same time, such as the following: 1. 2. 3. 4.
Get a can of Dr. Pepper. Avoid running into the wall while doing so. Watch out for the cat and other ground-based obstacles. Bring the soda back to the “master.”
These tasks form a hierarchy. Task 4 cannot be completed before task 1. Together, these two form the primary directive tasks. Tasks 2 and 3 may or may not occur; these are error mode tasks. Should they occur, they temporarily suspend the processing of the primary directive tasks.
38.4.1 PROGRAMMING FOR TASKS From a programming standpoint, you can consider most any job you give a robot to be coded something like this: DO Task X DO WHILE (ERROR) Task Y LOOP LOOP UNTIL Task X complete
' ' '
The Primary Task An Error Condition The Error Correction Code
'
Continue Task X until it is Complete
X is the primary directive task, the thing the robot is expected to do. Y is a special function that gets the robot out of trouble should an error condition—of which there may be many—occurs. Most error modes will prevent the robot from accomplishing its primary directive task. Therefore, it is necessary to clear the error first before resuming the primary directive. Note that it is entirely possible that the task will be completed without any kind of complication (no errors). In this case, the error condition is never raised, and the Y functionality is not activated. The robot programming is likewise written so that when the error condition is cleared, it can resume its prime directive task.
38.4.2 MULTITASKING ERROR MODES FOR OPTIMAL FLEXIBILITY For a real-world robot, errors are just as important a consideration as tasks. Your robot programming must deal with problems, both anticipated (walls, chairs, cats) and unanticipated (water on the kitchen floor, no sodas in the fridge). The more your robot can recognize error modes, the better it can get itself out of trouble. And once out of an error mode, the robot can be reasonably expected to complete its task.
678
INTEGRATING THE BLOCKS
How you program various tasks in your robot is up to you and the capabilities of your robot software platform. If your software supports multitasking, try to use this feature whenever possible. By dealing with tasks as discrete units, you can better add and subtract functionality simply by including or removing tasks in your program. Equally important, you can make your robot automatically enter an error mode task without specifically waiting for it in code. In non-multitasking procedural programming, your code is required to repeatedly check (poll) sensors and other devices that warn the robot of an error mode. If an error mode is detected, the program temporarily branches to a portion of the code written to handle it. Once the error is cleared, the program can resume execution where it left off. With a multitasking program, each task runs simultaneously. Tasks devoted to error modes can temporarily take over the processing focus to ensure that the error is fixed before continuing. The transfer of execution within the program is all done automatically. To ensure that this transfer occurs in a logical and orderly manner, the program should give priorities to certain tasks. Higher-priority tasks are able to take over (subsume, a word now in common parlance) other running tasks when necessary. Once a highpriority task is completed, control can resume with the lower-priority activities, if that’s desired.
38.5 From Here To learn more about . . .
Read
Computer capabilities
Chapter 12, “An Overview of Robot ‘Brains’ ”
Programming computer systems
Chapter 13, “Programming Fundamentals”
Connecting computers and other control circuits to the outside world
Chapter 14, “Computer Peripherals”
Sensing objects around the robot
Chapter 30, “Object Detection”
CHAPTER
39
FAILURE ANALYSIS
Anything that can go wrong, will go wrong. —Murphy’s Law
L
egend has it that the original “Murphy” was a U.S. Air Force officer that worked on rocket sleds in the late 1940s and early 1950s. These sleds were used to learn about the effects of high accelerations (g forces) on the human body as well as to design appropriate restraint and safety systems for high-performance aircraft and spaceships. Computer simulations and mechanical models of the human body were not available at the time, so the tests were performed on a living person. The sleds were capable of tremendous speeds (approaching the speed of sound) and there was a very high probability for accidents due to mechanical failure. In readying a sled for a test and working through a myriad of problems, Murphy reportedly muttered the comment for which he was to become immortalized. You probably have already heard of Murphy’s Law and it has been referenced so many times in books that it has become trite. It was really put in here to introduce the following comment on it; one that you are sure to relate to as you work on your own robot designs: Murphy was an optimist. —Anonymous
39.1 Types of Failures Before trying to figure out how to fix a problem, the first thing that you will have to do is determine where the problem is occurring. In the following three sections, the three pri679 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
680
FAILURE ANALYSIS
mary sources of problems are listed and the types of failures that are typically ascribed to them. Once you determine where the problem lies, you can start looking at how to fix it so that it does not reoccur. A process for determining the root cause of a failure and ensuring that the corrective action will allow the robot to run until some other problem surfaces is given in the following sections of this chapter.
39.1.1 MECHANICAL FAILURE Mechanical problems are perhaps the most common failure in robots. The typical source of the problem is that the materials or the joining methods you used were not strong enough. Avoid overbuilding your robots (that tends to make them too expensive and heavy), but at the same time strive to make them physically strong. Of course, strong is relative: a lightweight, scarab-sized robot needn’t have the structure to support a two year old that a tricycle does. At the very least, however, your robot construction should support its own weight, including batteries. When possible, avoid slap-together construction, such as using electrical or duct tape. These methods are acceptable for quick prototypes but are unreliable for long-term operation. When gluing parts in your robot, select an adhesive that is suitable for the materials you are using. Epoxy and hot-melt glues are among the most permanent. You may also have luck with cyanoacrylate (CA) glues, though the bond may become brittle and weak over time (a few years or more, depending on humidity and stress). Use the pull test to determine if your robot construction methods are sound. Once you have attached something to your robot—using glue, nuts and bolts, or whatever—give it a healthy tug. If it comes off, the construction isn’t good enough. Look for a better way.
39.1.2 ELECTRICAL FAILURE Electronics can be touchy, not to mention extremely frustrating, when they don’t work right. Circuits that functioned properly in a solderless breadboard may no longer work once you’ve soldered the components in a permanent circuit, and vice versa. There are many reasons for this, including mistakes in wiring, unexpected capacitive and inductive effects, even variations in tolerances due to heat transfer. Certain electronic circuit construction techniques are better suited for an active, mobile robot. Wire-wrap is a fast way to build circuits, but its construction can invite problems. The long wire-wrap pins can bend and short out against one another. Loose wires can come off. Parasitic signals and stray capacitance can cause marginal circuits to work, then not work, and then work again. For an active robot it may be better to use a soldered circuit board, perhaps even a printed circuit board of your design (see Chapter 7, “Electronic Construction Techniques,” for more information). Some electrical problems may be caused by errors in programming, weak batteries, or unreliable sensors. For example, it is not uncommon for sensors to occasionally yield totally unexpected results. This can be caused by design flaws inherent in the sensor itself, spurious data (noise from a motor, for example), or corrupted or out-of-range data. Ideally, the programming of your robot should anticipate occasional bad sensor readings and basically ignore them. A perfectly acceptable approach is to throw out any sensor reading that is outside the statistical model you have decided on (e.g., a sonar ping that says an object is 1048 ft away; the average robotic sonar system has a maximum range of about 35 ft).
39.2 THE PROCESS OF FIXING PROBLEMS
681
39.1.3 PROGRAMMING FAILURE As more and more robots use computers and microcontrollers as their brains, programming errors are fast becoming one of the most common causes of failure. There are three basic kinds of programming bugs.
• •
•
Compile bug or syntax error. You can instantly recognize these because the program compiler or downloader will flag these mistakes and refuse to continue. You must fix the problem before you can transfer the program to the robot’s microcontroller or computer. Run-time bug, caused by a disallowed condition. A run-time bug isn’t caught by the compiler. It occurs when the microcontroller or computer attempts to run the program. An example of a common run-time bug is the use of an out-of-bounds element in an array (for instance, trying to assign a value to the thirty-first element in a 30-element array). Run-time bugs may also be caused by missing data, such as looking for data on the wrong input pin of a microcontroller. Logic bug, caused by a program that simply doesn’t work as anticipated. Logic bugs may be due to simple math errors (you meant to add, not subtract) or by mistakes in coding that cause a different behavior than you anticipated.
As you become experienced in programming, you will get a lot faster at finding problems as you understand where you normally make mistakes and learn how to use the tools at your disposal for finding and fixing the problems. When you first start working on robots, you will probably feel most uncomfortable about your skills in debugging programs, but as you gain experience, you will be amazed at your ability to produce code with relatively few errors, that operates efficiently, and can be debugged easily.
39.2 The Process of Fixing Problems When given a problem to fix, most people will try to find the easiest way to resolve it and move on; the term used for this process is debugging. Looking for and implementing the quick fix often yields an effective (and sometimes optimal) repair action. It does not resolve all problems and quite often masks them. With only experience in working on the most likely cause of the problem, you will become very frustrated very quickly and unable to identify the reason for the problem as well as the most effective repair. For these cases, you will need to perform a root cause failure analysis (often shortened to just failure analysis) to determine what exactly is the problem and what is the best way to fix it. The failure analysis that is outlined in the rest of this chapter applies to all three classes of failures that you will encounter in your robots (mechanical, electrical, and programming), which may seem surprising because each class seems so different from the other. Mechanical (chassis and drivetrain design and assembly) problems do not have anything in common with electrical or programming issues. What they do have in common is the process of understanding how the structure, circuit, or program should work, characterizing the problem, developing theories regarding what is actually happening, figuring out how to repair the problem, and testing your solution before finally applying the fix to the robot. The fol-
682
FAILURE ANALYSIS
lowing set of actions may seem like a lot of work to fix a problem like a nut that has fallen off due to vibration, but if you follow it faithfully, the skills you gain by fixing the simple problems will make the more difficult ones a lot easier to solve and will prevent the simple ones from happening again.
39.2.1 DOCUMENTING THE EXPECTED STATE Do you understand exactly what should be happening in your robot? Chances are you have a good idea of what the robot, or a part of the robot, should be doing at a given time but you have probably not looked in detail at what is actually happening. For a robot that has a failed glued plastic joint, you may have done an analysis of the forces on the joint when the robot is stationary, but have you looked at what happens during acceleration and deceleration? What about forces caused by vibration or large masses (such as batteries) shifting during operation? The forces during movement as well as changes in movement must be considered when looking at a mechanical failure. Similarly, for an electrical problem, do you understand what the actual currents flowing through the circuitry are? Starting and stopping robot drive motors when they are under load will require greater currents than on a bench being tested out. Have you calculated the temperatures of different components during operation as well as their effect on components close to them? If the robot seems to miss detecting objects in front of it, have you put in some consideration for switch bouncing or changing fields of view during operation? Electrical problems can be especially vexing when you are using third-party designs or circuitry. To predict what should be happening, you should review the basic electrical laws and make sure you fully understand the basic electrical formulas and conventions. Finally, for software, can you trace through the source code to understand what should be happening at any one particular time? How is the operation of the robot controller documented for different situations with varying inputs? A very important tool in understanding the operation of software is the simulator and how much time has been spent at understanding how the application should work. Many robot software applications are written quickly and debugged continuously to get the robot working as desired—this makes documenting the software a difficult and confusing chore unless you are very careful to keep track of different versions of software and the changes made to them. You will often find it easier to go back over the source code and try to map out how it is supposed to work and respond to different inputs. Documenting the expected operation of the robot at the time of failure is a timeconsuming task, but one that is critical to finding and ultimately fixing the problem. In many cases when you start understanding the operation of the robot at the level of detail needed to find and fix the problem, the reason for the problem will become apparent—but you should refrain from implementing the apparent fix until you have worked through the following five steps.
39.2.2 CHARACTERIZING THE PROBLEM After documenting and becoming very familiar with what is supposed to be happening in the robot, you will spend some time setting up experiments to observe what is actually hap-
39.2 THE PROCESS OF FIXING PROBLEMS
683
pening. The effort required for this is not trivial and will test your ingenuity to come up with different methods of observing what is happening while having a limited budget and resources for test equipment. Spending a few minutes thinking about the problem can result in some very innovative ways of observing the different aspects of the robot in operation and help guide you to the root cause of the problem. You will find that some failures are intermittent; that is to say they will happen at seemingly random intervals. By characterizing the operation of the robot and comparing the results to the documented expected operation, you should find situations where the operating parameters are outside the design parameters, leading to the opportunity for failure either immediately or at some later time. Once you become familiar with documenting the expected operation of your robot as well as characterizing different robot problems, you’ll discover that there really is no such thing as a random failure. Each failure mode has a unique set of parameters that will cause the failure and allow you to understand exactly what is happening. The conditions leading up to a mechanical failure can be extremely difficult to observe on the basic robot. Plastic or cardboard arrows attached to different points in the robot’s structure will help illustrate flexing that is not easily observed by the naked eye. A small cup of water can also be used to show the operating angle of different components of the robot as well as the acceleration of the robot during different circumstances. A digital camera’s photograph of the robot in operation, with indicators such as arrows and cups of water will help you to observe deformations of the robot’s structure and allow you to measure them by printing out the picture and measuring angles using a protractor. When searching for electrical problems during the operation of the robot, your best friend is the LM339 quad comparator along with a few LEDs and potentiometers. The potentiometers are wired as voltage dividers and used to provide different extreme values for the different electrical parameters that are going to be measured (Fig. 39-1). When the robot exceeds one of these parameters, an LED wired to the LM339 comparator output will light. This allows you to easily observe any out-of-tolerance electrical conditions during robot operation, requiring just a few minutes of setup. Depending on how the robot is powered, you may have to add a separate power supply (a 9-V radio battery works well to allow a good range on the potentiometers) to the circuit in order to test it if you suspect the robot’s power supply is sagging. If a programming failure is suspected, you will discover that the best method of characterizing what is happening is by recording the inputs followed by the outputs. Again, LEDs are your best tool for observing what are the inputs causing the bad outputs. You can also use an LCD (although this will require you to stand over the robot to see exactly what is happening) or output a different sound or message when there are specific inputs to the microcontroller. Once you have the actual inputs and output commands, you can set up a state diagram (showing the changing inputs and outputs) to help you understand exactly what the program is doing in specific cases. When coming up with methodologies for observing what is happening in the robot when the failure is taking place, remember Heisenberg’s Uncertainty Principle, which states that the apparatus used for measuring a subatomic particle parameter will affect the actual measurement. This is very possible in robotics when you are trying to characterize a failure; often the equipment used to record the failure will end up changing the behavior of the robot, hiding the true nature of the problem. For example, adding an LCD to display the
684
FAILURE ANALYSIS
Vcc
Vcc
Vcc
470
Vcc 470
Vcc In
+
10k
+
Vcc 10k
–
LED Lights When “In” is Less than Voltage at “–” Pin
–
In
LED Lights When “In” is More than Voltage at “+” Pin
FIGURE 39-1 The LM339 comparator, along with a potentiometer, resistor, and LED are effective tools for monitoring voltage levels within a robot. Note that it may be necessary to have a separate power supply for the LM339 if the robot’s power supply drops during operation.
inputs and outputs of the robot’s microcontroller during operation may require you to stand over it to monitor the LCD’s output, which may possibly result in you being detected by the robot and your presence causing the robot to behave differently than if you were further away from the robot.
39.2.3 HYPOTHESIZING ABOUT THE PROBLEM With a clear understanding of how the robot should behave and how it is actually behaving, the differences should become very obvious and allow you to start making theories regarding what is the root cause of the problem. When you are hypothesizing about the problem, it is very important to (a) keep an open mind as to the cause of the problem and (b) avoid trying to come up with solutions, no matter how obvious they seem. It is easy to short-circuit this process and decide upon an obvious fix without working through the rest of the failure analysis. Keeping an open mind is extremely difficult. To force yourself to look at different solutions, you should try to come up with at least three different possible root causes for the problem. To illustrate this point, consider the case of a differentially driven robot with a light plastic frame that scrapes along the ground during changes in robot direction at the point where the batteries are mounted (see Fig. 39-2). As well as being scraped, the operation of the
39.2 THE PROCESS OF FIXING PROBLEMS
Driving Wheel
685
Batteries Robot
Scrapes to Bottom of Robot
Front Caster
FIGURE 39-2 When the robot is sitting still, the battery pack does not touch the ground. But after operation, the chassis underneath the battery pack is scraped and the robot moves as expected.
robot seems to be erratic when the chassis comes into contact with the running surface. These observations are confirmed by photographing the robot during changes in direction. With this information, you could make the following theories regarding the problems the robot is having: 1. The robot is accelerating too quickly, and the chassis is distorting during starting, stop-
ping, and direction changing. 2. The inertia of the battery pack is causing the chassis to flex. 3. The motors are too powerful, and they are warping the chassis during startup or stop-
ping. 4. The caster is digging into the running surface during operation, causing the chassis to
distort. A generic theory could be that the chassis isn’t strong enough, but this will steer you toward a single solution (strengthening the chassis) while the four expanded theories give you a number of ideas to try and fix the problem. Along with these four theories, you could probably come up with more that you can compare against the data that you collect in the first two steps and see which hypothesis best fits the data. There’s a good chance that you will have to go back and look at different aspects of the robot; for example, if the caster was the problem, it should have some indications of high drag on a large part of its surface, not just the small area where it was in contact with the running surface.
39.2.4 PROPOSING CORRECTIVE ACTIONS Once you are comfortable with understanding the different possible root causes of the failure, you can start listing out possible corrective actions. Like the multiple possible root causes listed in the previous step, you should also list out multiple possible corrective
686
FAILURE ANALYSIS
actions. While some may jump out at you, after considering different options, a much more elegant and easier to implement solution may become obvious. In the previous section, it was mentioned that the obvious possible root cause of the robot scraping against the ground is that the chassis is simply not strong enough. The obvious solution to this problem is to strengthen the chassis. While it may fix the problem, it is probably not the optimal solution, as strengthening the chassis could require you to effectively redesign and rebuild the robot. Before embarking on this large amount of effort, you could review a number of different solutions: 1. 2. 3. 4. 5. 6.
Strengthening the chassis. Using a lighter battery pack. Decreasing the robot’s acceleration. Relocating the battery pack. Changing the front caster. Using larger drive wheels.
The amount of work required for each of the different solutions varies. Along with documenting the amount of work for each solution, the potential cost and length of time needed to implement the solution can be documented in order to be able to choose the best possible fix.
39.2.5 TESTING FIXES It is usually possible to quickly rig up a sample solution to test the effectiveness of a specific repair action before making it permanent. It is actually preferable to do this as it may become obvious that some repair actions are not going to be effective or are going to cause more problems than they solve. This is why multiple possible root cause problems are listed along with multiple repair actions for each root cause. When testing the solution, don’t spend a lot of time making it look polished; there’s a good chance that it will not be as good as some other solution and you will end up having to tear down the fix and try another one. Don’t be surprised if the most obvious cause of the problem and repair action aren’t right; over time your ability to suggest the most effective fixes will improve, but when you are starting out, listing as many as possible and trying them all out will guide you to the most effective solution to your problem. Finally, there’s a chance that multiple corrective actions will produce the best result. For the example here, minimizing the distortion of the robot’s chassis could be achieved by relocating the battery pack and using a lighter one. Testing multiple fixes together can result in even better solutions than if you were to doggedly look for a single, simple fix. Remember to record the results of your tests (using the same testing apparatus as you used to characterize the problem). Being able to compare a difference in a robot will result in confidence that the optimal solution will be found.
39.2.6 IMPLEMENTING AND RELEASING THE SOLUTION Once you have determined the “best” solution to the problem and implemented it, you should record it in a notebook for future use as chances are if you don’t experience it again,
39.3 FROM HERE
687
you will experience something like it. Keeping notes listing what you did along with what you saw and expected to see will make the effort in documenting the expected state along with characterizing the actual state much easier. Along with helping you with future problems, the notes will help you if the problem happens again (and there is a good chance that it will). In this case, you have a record of what has been tried and you can try something else. Ideally the fix should be fairly simple; by using this process you will discover that problems you thought would require you to rebuild the robot can be resolved very easily. You will also find that after a while it takes you less time to work through the full failure analysis process than to perform a simple debug repair action. The added bonus is that your repairs will be a lot more reliable and less likely to break under extreme stress in the future.
39.3 From Here To learn more about . . .
Read
Interfacing issues
Chapter 38, “Integrating the Blocks”
Mechanical structures
Chapter 3, “Structural Materials”
Electrical theory
Chapter 5, “Electrical Theory”
Programming operations
Chapter 13, “Programming Fundamentals”
This page intentionally left blank
CHAPTER
40
SETTING UP WORKSHOPS, DEMONSTRATIONS, AND COMPETITIONS
R
obotics is an exciting and fun hobby and one that can attract a lot of interest by getting together with other hobbyists or club members and staging a public event where many people can watch and interact with the robots. The event could consist of different robots battling it out in various competitions, a chance for your club to demonstrate what its members’ robots can do, or a workshop to give people a chance to experiment with robots on their own. Organizing an event can be a lot of fun and will bring some favorable publicity to you and your robotics club. Here are a few things to consider when putting together a show.
40.1 Choosing the Venue The first order of business will be deciding where the event is going to take place. There are many different public locations to choose from, including schools, community centers, libraries, and shopping plazas. All these locations should have a room large enough to house four or five large “pit” area tables for work to be done on the robots along with a competition/demonstration area big enough for at least half of the robots to be operating at any one time. Chairs for a gallery should be arranged around the competition/demonstration area and a table for the judges and organizers should be placed in such a way that the entire room is visible. Fig. 40-1 shows a basic floor plan for just such an area. This layout will allow the competitors/demonstrators the ability to perform last minute tweaks of their robots and give them ready access to the areas the robots will be running 689 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
SETTING UP WORKSHOPS, DEMONSTRATIONS, AND COMPETITIONS
“Pit” Area Judges/Organizers
690
Competition/Demonstration Area
Public Gallery
Windows FIGURE 40-1 Sample room layout for a robot event.
in. It will also make it obvious for visitors where they should be at any given time and not get in the way of the competitors or potentially stepping on robots. Often rooms will have large glass areas to bring in the sun. These areas should be to the backs of the gallery so visitors are not squinting from the sun to see what is going on. Before arranging chairs and tables, a few minutes should be spent surveying the room and deciding where everything should go. Along with taking time to think about where to place tables and chairs, you will also have to think about how to run power, network, public address and video wires and cables. Ideally, the cables should run around the perimeter of the room and be taped down to the edges of the floor to prevent any potential trip hazards. This is not always possible, so the cables should be located away from high-traffic areas and taped down with Gaffer’s or duct tape. If video displays are to be used in the room, then their screens should be located at a convenient location, away from where people will be traveling. The same goes for video projectors. Ideally they should be suspended from the ceiling, but if this is not possible, they should either be put on a raised platform or in a location where it is unlikely people will walk through.
40.1.1 VENUE NEEDS Setting up the room is one thing, while a major headache will be ensuring that all the basic needs are met. These include paying rent for the room and any administrative/custodial costs of the venue, getting insurance for the event (if it is required), making sure washroom facilities are open and available, as well as providing the opportunity for everyone to get refreshments. A major concern is child management; often a parent that is interested in the event will bring along small children hoping to interest them in robotics. These concerns
40.2 COMPETITION EVENTS
691
can be surprisingly major and can result in having to go through several potential venues before finding the one that works best with your resources. In today’s environment of reduced funding for public facilities, you will probably find yourself having to rent the space. These costs can range from very nominal to very expensive. Along with this, a security deposit may be required to ensure that any damage will be paid for. Asking how much the room will cost should be your first question, even before how big is it and what days it is available. Finding the money to pay for this can be difficult and may require a deposit up front and charging admission to visitors and taking a cut from selling refreshments. Club dues may be sufficient to pay for the venue, but this use should be agreed to well before the event. Fees can be minimized or avoided all together if the event is cosponsored by another group, such as a Boy Scout Troop, which already has the venue. In this case, the event could be primarily for the other group to observe and participate in. Along with money for renting the space, you may have to arrange for liability insurance for everyone attending. The venue should have some arrangements already made that you can take advantage of in terms of getting a reduced rate as well as minimizing the amount of work required to arrange the insurance. Insurance should always be purchased if it is not provided as part of the rental of the venue; more than once somebody has broken a window moving chairs or tripped over a robot or sumo platform and injured themselves. The small headache of making sure you are protected will save you a much larger one if something happens later. Biological needs should also be considered. Washrooms should be close by with no chance of anyone locking themselves in (or if they do, somebody with a key is available). Water, soda, doughnuts, and other snacks should also be available (proceeds can go to the robot club, the rental of the room, or prizes). The venue’s management must be consulted on these issues to make sure that washrooms are available and to understand any rules they have regarding providing refreshments. Finally, you should plan for younger children that are going to be bored with what is going on. While robots are generally fascinating for the general public, to toddlers and small children they are little more than animated toys that will become objects of frustration when they discover they can’t pick them up or play with them. Some distractions that will make the event run smoothly include having a TV and a DVD player set up showing children’s movies (animated movies are a good choice because they are engaging for a long period of time), and boxes of blocks or building materials should be available for the children’s play and minimizing conflicts over who has a certain toy. Chances are that some of the people involved in the event will have small children, and they can help plan for the children’s entertainment while the event is going on.
40.2 Competition Events Competitions are very popular for the people taking part in the event as well as members of the public. In Table 40-1, a number of popular event types are listed along with web sites where you can get more information about them. For many types of events, the organizers will have to provide sumo rings, scales, size gauges, and so on. In Table 40-1, you may have noticed that the FIRST (“For Inspiration and Recognition
692
SETTING UP WORKSHOPS, DEMONSTRATIONS, AND COMPETITIONS
TABLE 40-1
Different Robot Competitions
EVENT TYPE
WHERE TO FIND INFORMATION
Sumo-Bot
Robots are designed to search out and push another robot outside of a circular ring within a given amount of time. A set of rules for the different classes can be found at www.sorobotics.org/RoboMaxx/sumo-rules.html
Lego
Lego Mindstorms competitions involve teams that are given the task to design a robot that will compete in some area against other robots. Ideally, the teams are given the design constraints and are allowed to start building before visitors enter to avoid them spending time watching teams do nothing more than talk amongst themselves. Ideally, visitors should be allowed in when the robots are being tested before the competition begins.
Firefighting
Robots are given the task to find a candle in a house-like maze and extinguish it in the least amount of time. The Trinity College Fire Fighting Robot Competition is one of the most widely accepted, and their rules can be found at www.trincoll.edu/events/robot/Rules/default.asp
Line Following
Design a robot that can follow a meandering path accurately in the least amount of time. The typical track consists of a white surface with a black line about 3⁄4 in wide. Curves should have no less than a 4 in radius.
Maze Following
Maze-following robots are very popular and instructive for competitors to build. Rules for maze-following robots are generally finding the robot that can negotiate a random maze in the least amount of time. There doesn’t seem to be a standard for the size or complexity of the maze.
Combat Bots/Laser-Tag
Combat robots like the ones shown on television (e.g., RobotWars) are not reasonable for the open venues discussed in this book. But there are analogs to combat that can be performed that are very entertaining, such as laser-tag modified for robots. Circuitry for a type of laser-tag (called IR Tag) can be found at www.tabrobotkit.com
BEAM Robot Games
There are many different BEAM robot competitions available. Many of them are variations on the different competitions listed in this table. BEAM robots are generally inexpensive and easy to make, which makes them ideal as a way to get high school students interested in robotics. A list of BEAM robot competitions can be found at www.nis.lanl.gov/projects/robot//
Best . . .
Coming up with fun categories such as “best dressed” robot or “best robot dance” can be entertaining and fun for competitors and observers alike. This is an excellent way to introduce robotics to children and get them to start thinking about how robots work and are built.
40.3 ALERTING THE PUBLIC AND THE MEDIA
693
of Science and Technology,” www.usfirst.com) competition and other organized competitions are not listed. These competitions are generally large, centrally organized affairs that would be difficult to stage at a local or small level. This does not mean if you are part of a FIRST team that you cannot set up demonstrations of your robot, but you should recognize that it will be difficult for you to set up your own FIRST robot competition. It should go without saying, especially after the discussions regarding insurance and liability, that the competitions should be safe for the audience, competitors, and the venue they are taking place in. You should watch for robots that break the rules in ways that could result in injury or property damage such as a sumo-bot that has a powerful flipper for its competition, a LEGO robot that has a spinning action which could end up throwing parts, or a laser-guided robot that can shine laser light into somebody’s eyes. You should make sure to note in the competition entry form that any robot felt to be unsafe will not be allowed to run or compete.
40.2.1 SCROUNGING FOR PRIZES Coming up with ideas for prizes for a robot competition is something that requires a great deal of imagination and perseverance. Poor prizes will be received graciously, but well thought out prizes will really excite the competitors and have them coming back for more. Really, there is no such thing as a bad prize and the winners are sure to walk away happy no matter what they get, but the perfect prize will not only be enticing for future events but be an excellent advertisement for your group in the future. Imagination is required to come up with appropriate prizes for different people and their different skill, education, and resources. Having said this there are a number of different prizes that are always well appreciated. Tools that are appropriate for robot building such as rotary (Dremel brand) cutters, thermostatically controlled soldering irons, microcontroller development kits, and, ironically, robot kits themselves are always appreciated. Toys that mimic robots on TV or movies are good for a chuckle and will be valued for being more than they are worth. Homemade plaques and trophies, especially made from robot parts, are probably the most special type of prizes and ones that will be a source of pride for the winners for years to come. Of course, the authors’ books are considered to be the most special prizes that a competitor can receive. Having chosen the prizes, you will then have the task of figuring out how to pay for them. Again, many methods for paying for the venue can be used for raising money for prizes. Local retailers and manufacturers can be approached for donations of tools and equipment but care must be taken to ensure that you do not appear greedy or unwilling to work with the supplier and their corporate guidelines for giving.
40.3 Alerting the Public and the Media With the planning complete, the venue chosen and all the arrangements made, you will want to let people know that the event is going to take place. Today the obvious method for disseminating this information is either through email or updating your group’s web page.
694
SETTING UP WORKSHOPS, DEMONSTRATIONS, AND COMPETITIONS
Unfortunately, these methods are probably not going to be as effective as you would like as the only people that will see these announcements are those who are actively involved in robotics. Ironically, you will have to use more traditional methods of communications. Flyers should be left at community centers, libraries, schools, and local bulletin boards. A phone number and a web site should be available for people to find out more about the event as well as allow them to print out a page they can put up in their home to remind themselves of the event. You might want to ask people to register to come to the event to give you some idea of how many people will be coming. Community newspapers will often mention your event free of charge and may send a reporter/photographer (they are usually one and the same) to cover the event. They will usually require an email notifying them of the event. You should first contact the newspaper to learn the procedure for submitting your event (including learning the lead time for publishing on a specific date) as well as how reporters are assigned to stories. Most newspapers’ assignment editors task reporters to different events that morning. To maximize the chance that a reporter will be sent to your event, make sure that you send a media alert email to the assignment editor the day before so it is in their pile of events to cover. The same procedure should be followed for local TV stations. Remember that it is not unusual to not have reporters come to your event, no matter how hard you work to make sure the newspapers are aware of it. Community events like yours are given to reporters based on whether they will be in the area, and if it is possible for them to make it to the event, and whether a “big story” is happening.
40.4 From Here So far in this book the “From Here” sections of each chapter have been introspective— pointing you to different chapters of the book to get information reinforcing what is discussed in the chapter or giving you additional background information needed to work through the topics covered. Having reached the end of the book it is really time for you to go “From Here” and start experimenting with your own robot. Remember that the first goal is to have fun, and the second goal is to learn. Chances are your first attempt at designing and building your own robot will be long and arduous and will require you to perform a lot of redesigning, rebuilding, and reprogramming to get it to work exactly the way you want it to. When the robot starts working and running about on its own, all the hard work that took place to get you there will become totally worth it. Try not to feel discouraged that it took longer than you expected or that you weren’t as smart or as efficient as you thought you were; instead celebrate that you have built a robot. It will get easier as you build additional robots and you should feel proud that you have done something that only a small fraction of humanity has accomplished. The authors look forward to hearing from you, seeing your creations, and we hope that if we meet in competition, your robot won’t be better than ours.
APPENDIX
A
Further Reading
Interested in learning more about robotics? These books are available at most better bookstores, as well as at many online bookstores, including Amazon (www.amazon.com), Barnes and Noble (www.bn.com), and Fatbrain (www.fatbrain.com). This appendix also lists several magazines of interest to the robot experimenter. Both mailing and Internet addresses have been provided.
Contents Hobby Robotics LEGO Robotics and LEGO Building Technical Robotics, Theory and Design Artificial Intelligence and Behavior-Based Robotics Mechanical Design Electronic Components Microcontroller/Microprocessor Programming and Interfacing Electronics How-to and Theory Power Supply Design and Construction Lasers and Fiber Optics 695 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
696
FURTHER READING
Interfacing to Computer Systems Magazines Classic Robot Fiction
A.1 Hobby Robotics Build Your Own Robot! Karl Lunt, A K Peters, ISBN: 1568811020 Robots, Androids, and Animatrons: 12 Incredible Projects You Can Build John Iovine, McGraw-Hill, ISBN: 0070328048 The Personal Robot Navigator Merl K. Miller, Nelson B. Winkless, Kent Phelps, Joseph H. Bosworth, A K Peters Ltd., ISBN: 188819300X (contains CD-ROM of robot navigation simulator) 123 Robotics Experiments for the Evil Genius Myke Predko, McGraw-Hill, ISBN: 0071413596 (contains PCB for mounting a BS2/robot electronics) Applied Robotics Edwin Wise, Howard W Sams & Co, ISBN: 0790611848 Muscle Wires Project Book Roger G. Gilbertson, Mondo-Tronics, ISBN: 1879896141 Stiquito: Advanced Experiments with a Simple and Inexpensive Robot James M. Conrad, Jonathan W. Mills Institute of Electrical and Electronic Engineers, ISBN: 0818674083 Stiquito for Beginners: An Introduction to Robotics James M. Conrad, Jonathan W. Mills IEEE Computer Society Press, ISBN: 0818675144
A.2 LEGO Robotics and LEGO Building Dave Baum’s Definitive Guide to LEGO Mindstorms Dave Baum, Apress, ISBN: 1893115097 Unofficial Guide to LEGO MINDSTORMS Robots Jonathan B. Knudsen, O’Reilly & Associates, ISBN: 1565926927
A.4 ARTIFICIAL INTELLIGENCE AND BEHAVIOR-BASED ROBOTICS
697
Joe Nagata’s Lego Mindstorms Idea Book No Starch Press, ISBN: 1886411409 LEGO Crazy Action Contraptions Dan Rathjen, Klutz, Inc., ISBN: 1570541574 Extreme Mindstorms: An Advanced Guide to LEGO Mindstorms Dave Baum et al., Apress, ISBN: 1893115097
A.3 Technical Robotics, Theory, and Design Mobile Robots: Inspiration to Implementation Joseph L. Jones, Anita M. Flynn, Bruce A. Seiger, A K Peters Ltd., ISBN: 1568810970 Sensors for Mobile Robots: Theory and Application H. R. Everett, A K Peters Ltd., ISBN: 1568810482 Art Robotics: An Introduction to Engineering Fred Martin, Prentice Hall, ISBN: 0805343369 Robot Evolution: The Development of Anthrobotics Mark Rosheim, John Wiley & Sons, ISBN: 0471026220 Machines That Walk: The Adaptive Suspension Vehicle Shin-Min Song, MIT Press, ISBN: 0262192748 Robot DNA, Various Titles McGraw-Hill Remote Control Robotics Craig Sayers, Springer-Verlag, ISBN: 038798597 Artificial Vision for Mobile Robots: Stereo Vision and Multisensory Perception Nicholas Ayache, Peter T. Sander, MIT Press, ISBN: 0262011247
A.4 Artificial Intelligence and Behavior-Based Robotics An Introduction to AI Robotics Robin Murphy, MIT Press, ISBN: 0262522632
698
FURTHER READING
Robot: Mere Machine to Transcendent Mind Hans Moravec, Oxford University Press, ISBN: 0195116305 Behavior-Based Robotics: Intelligent Robots and Autonomous Agents Ronald C. Arkin, MIT Press, ISBN: 0262011654 Artificial Intelligence and Mobile Robots: Case Studies of Successful Robot Systems David Kortenkamp, R. Peter Bonasso, Robin Murphy, MIT Press, ISBN: 0262611376 Cambrian Intelligence: The Early History of the New AI Rodney Allen Brooks, MIT Press, ISBN: 0262522632 Vehicles: Experiments in Synthetic Psychology Valentino Braitenberg, MIT Press, ISBN: 0262521121 Intelligent Behavior in Animals and Robots David McFarland, Thomas Bosser, MIT Press, ISBN: 0262132931
A.5 Mechanical Design Five Hundred and Seven Mechanical Movements Henry Brown, Astragal Press, ISBN: 1879335638 Mechanical Devices for the Electronics Experimenter Britt Rorabaugh, Tab Books, ISBN: 0070535477 Mechanisms and Mechanical Devices Sourcebook, Second Edition Nicholas P. Chironis, Neil Sclater, McGraw-Hill, ISBN: 0070113564 Home Machinist’s Handbook Doug Briney, Tab Books, ISBN: 0830615733
A.6 Electronic Components Electronic Circuit Guidebook: Sensors Joseph J. Carr, PROMPT Publications, ISBN: 0790610981 Electronic Circuit Guidebook (various volumes) Joseph J. Carr, PROMPT Publications,
A.7 MICROCONTROLLER/MICROPROCESSOR PROGRAMMING AND INTERFACING
Volume 1: Sensors; ISBN: 0790610981 Volume 2: IC Timers; ISBN: 0790611066 Volume 3: Op Amps; ISBN: 0790611317 Build Your Own Low-Cost Data Acquisition and Display Devices Jeffrey Hirst Johnson, Tab Books, ISBN: 0830643486
A.7 Microcontroller/Microprocessor Programming and Interfacing 123 PIC Microcontroller Experiments for the Evil Genius Myke Predko, McGaw-Hill, ISBN: 0071451420 Programming and Customizing the BASIC Stamp Computer Scott Edwards, McGraw-Hill, ISBN: 0079136842 Microcontroller Projects with BASIC Stamps Al Williams, R&D Books, ISBN: 0879305878 The BASIC Stamp 2: Tutorial and Applications Peter H. Anderson (author and publisher), ISBN: 0965335763 Programming and Customizing the Picmicro Microcontroller Myke Predko, McGraw-Hill, ISBN: 0071361723 Design with Pic Microcontrollers John B. Peatman, Prentice Hall, ISBN: 0137592590 Microcontroller Cookbook Mike James, Butterworth-Heinemann, ISBN: 0750627018 Handbook of Microcontrollers Myke Predko, McGraw-Hill, ISBN: 0079137164 Programming and Customizing the 8051 Microcontroller Myke Predko, McGraw-Hill, ISBN: 0071341927 The 8051 Microcontroller I. Scott MacKenzie, Prentice Hall, ISBN: 0137800088
699
700
FURTHER READING
The Microcontroller Idea Book Jan Axelson, Lakeview Research, ISBN: 0965081907 Programming and Customizing the Hc11 Microcontroller Thomas Fox, McGraw-Hill Professional Publishing, ISBN: 0071344063 AVR RISC Microcontroller Handbook Claus Kuhnel Newnes ISBN: 0750699639
A.8 Electronics How-To and Theory Teach Yourself Electricity and Electronics Stan Gibilisco, TAB Books, ISBN: 0071377301 McGraw-Hill Benchtop Electronics Handbook Victor Veley, McGraw-Hill, ISBN: 0070674965 The TAB Electronics Guide to Understanding Electricity and Electronics G. Randy Slone, Tab Books, ISBN: 0070582165 Electronic Components: A Complete Reference for Project Builders Delton T. Horn, Tab Books, ISBN: 0830633332 The Forrest Mims Engineer’s Notebook Forrest M. Mims, Harry L. Helms LLH Technology Pub, ISBN: 1878707035 Engineer’s Mini-Notebook (series) Forrest M. Mims, Radio Shack Logicworks 4: Interactive Circuit Design Software for Windows and Macintosh Addison-Wesley, ISBN: 0201326825 (book and CD-ROM; includes software) Beginner’s Guide to Reading Schematics Robert J. Traister, Anna L. Lisk, Tab Books, ISBN: 0830676325 Printed Circuit Board Materials Handbook Martin W. Jawitz, McGraw-Hill, ISBN: 0070324883 The Art of Electronics Paul Horowitz, Winfield Hill, Cambridge University Press, ISBN: 0521370957
A.11 INTERFACING TO COMPUTER SYSTEMS
701
Student Manual for the Art of Electronics Paul Horowitz, T. Hayes, Cambridge University Press, ISBN: 0521377099
A.9 Power Supply Design and Construction DC Power Supplies Joseph J. Carr, McGraw-Hill, ISBN: 007011496X Power Supplies, Switching Regulators, Inverters, and Converters Irving M. Gottlieb, Tab Books, ISBN: 0830644040 Motors and Motor Control: Electric Motors and Control Techniques, Second Edition Irving M. Gottlieb, ISBN: 0070240124
A.10 Lasers and Fiber Optics Lasers, Ray Guns, and Light Cannons: Projects from the Wizard’s Workbench Gordon McComb, McGraw-Hill, ISBN: 0070450358 Optoelectronics, Fiber Optics, and Laser Cookbook Thomas Petruzzellis, McGraw-Hill, ISBN: 0070498407 Understanding Fiber Optics Jeff Hecht, Prentice Hall, ISBN: 0139561455 Laser: Light of a Million Uses Jeff Hecht, Dick Teresi, Dover, ISBN: 0486401936
A.11 Interfacing to Computer Systems Use of a PC Printer Port for Control & Data Acquisition Peter H. Anderson (author and publisher), ISBN: 0965335704 The Parallel Port Manual Vol. 2: Use of a PC Printer Port for Control and Data Acquisition Peter H. Anderson (author and publisher), ISBN: 0965335755
702
FURTHER READING
Programming the Parallel Port Dhananjay V. Gadre, R&D Books, ISBN: 0879305134 PC PhD: Inside PC Interfacing Myke Predko, Tab Books, ISBN: 0071341862 PDA Robotics Doug Williams, McGraw-Hill, ISBN: 0071417419 Real-World Interfacing with Your PC James Barbarello, PROMPT Publications, ISBN: 0790611457
A.12 Magazines Robot Science and Technology 3875 Taylor Road, Suite 200, Loomis, CA 95650 www.robotmag.com Circuit Cellar Magazine 4 Park St., Vernon, Ct 06066 www.circuitcellar.com/ Servo Magazine 430 Princeland Court, Corona, CA 91719 www.servomagazine.com/ Nuts & Volts Magazine 430 Princeland Court, Corona, CA 91719 www.nutsvolts.com Everyday Practical Electronics Wimborne Publishing Ltd. Allen House East Borough, Wimborne Dorset BH2 1PF United Kingdom Elektor www.elektor-electronics.co.uk
A.13 CLASSIC ROBOT FICTION
A.13 Classic Robot Fiction I, Robot Isaac Asimov Berzerker Fred Saberhagen Do Androids Dream of Electric Sheep? Philip K. Dick Tek War William Shatner The Hitchhiker’s Guide to the Galaxy Douglas Adams
703
This page intentionally left blank
APPENDIX
B
Sources
Contents Selected Specialty Parts and Sources General Robotics Kits and Parts Electronics/Mechanical: New, Used, and Surplus Microcontrollers, Single-Board Computers, Programmers Radio Control (R/C) Retailers Servo and Stepper Motors, Controllers Ready-Made Personal and Educational Robots Construction Kits, Toys, and Parts Miscellaneous Note: The listing in this appendix is periodically updated at www.robotoid.com. Internet-based companies that do not provide a mailing address on their web site are not listed. In addition, Internet-based companies hosted on a free web-hosting service (Tripod, Geocities, etc.) are also not listed because of fraud concerns.
705 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
706
SOURCES
B.1 Selected Specialty Parts and Sources BEAM Robots Solarbotics Bend Sensor Images Company Infrared Proximity/Distance Sensors Acroname HVW Technologies Infrared Passive (PIR) Sensors Acroname Glolab LCD Serial Controller Scott Edwards Electronics Microcontroller Kits and Boards DonTronics microEngineering Labs Milford Instruments NetMedia Parallax, Inc. Savage Innovations Scott Edwards Electronics, Inc. Motor Controllers (“Set and Forget”) Solutions Cubed Servo Motor Controller FerretTronis Lynxmotion Medonis Engineering Mister Computer Pontech Scott Edwards Electronics, Inc. Shape-Memory Alloy Mondo-Tronics
B.2 GENERAL ROBOTICS KITS AND PARTS
707
Sonar Sensors (Polaroid and Others) Acroname Speech Recognition Images Company Surplus Mechanical Parts and Electronic Components Active Surplus All Electronics Alltronics American Science & Surplus B.G. Micro C&H Sales Halted Specialties Co. Herbach & Rademan Martin P. Jones & Assoc. Wireless Transmitters (RF and Infrared) Abacom Technologies Glolab
B.2 General Robotics Kits and Parts Acroname, P.O. Box 1894, Nederland, CO 80466 (303) 258-3161 www.acroname.com Abacom Technologies, 32 Blair Athol Crescent, Etobicoke, Ontario M9A 1X5 Canada (416) 236-3858 www.abacom-tech.com A.K. Peters, Ltd. 63 South Avenue, Natick, MA 01760 (508) 655-9933 www.akpeters.com Amazon Electronics, Box 21, Columbiana, OH 44408 (888) 549-3749 www.electronics123.com Design and Technology Index, 40 Wellington Road, Orpington, Kent, BR5 4AQ UK +44 0 1689 876880 www.technologyindex.com
708
SOURCES
Images Company, 39 Seneca Loop, Staten Island, NY 10314 (718) 698-8305 www.imagesco.com Glolab Corp, 134 Van Voorhis, Wappingers Falls, NY 12590 www.glolab.com HVW Technologies, Suite 473, 300-8120 Beddington Blvd., SW Calgary, Alberta T3K 2A8 Canada (403) 730-8603 www.hvwtech.com Hyperbot, 905 South Springer Road, Los Altos, CA 94024-4833 (800) 865-7631 (415) 949-2566 www.hyperbot.com Lynxmotion, Inc. 104 Partridge Road, Pekin, IL 61554-1403 (309) 382-1816 www.lynxmotion.com TAB Electronics www.tabrobotkit.com Mekatronix, 316 Northwest 17th Street, Suite A, Gainesville, FL 32603 www.mekatronix.com Milford Instruments, 120 High Street, South Milford, Leeds LS25 5AG UK +44 0 1977 683665 www.milinst.demon.co.uk Mondo-Tronics, Inc., 4286 Redwood Highway, #226, San Rafael, CA 94903 (415) 4914600 www.robotstore.com Mr. Robot, 8822 Trevillian Road, Richmond, VA 23235 (804) 272-5752 www.mrrobot.com Norland Research, 8475 Lisa Lane, Las Vegas, NV 89113 (702) 263-7932 www.smallrobot.com Personal Robot Technologies, Inc. P.O. Box 612, Pittsfield, MA 01202 (800) 769-0418 www.smartrobots.com RobotKitsDirect, 17141 Kingview Avenue, Carson, CA 90746 (310) 515-6800 voice www.owirobot.com
B.3 ELECTRONICS/MECHANICAL: NEW, USED, AND SURPLUS
709
Sensory Inc., 521 East Weddell Drive, Sunnyvale, CA 94089-2164 (408) 744-9000 www.sensoryinc.com Solarbotics, 179 Harvest Glen Way, Northeast Calgary, Alberta, T3K 3J4 Canada (403) 818-3374 www.solarbotics.com Technology Education Index, 40 Wellington Road, Orpington, Kent, BR5 4AQ UK +44 0 1689 876880 www.technologyindex.com Zagros Robotics, P.O. Box 460342, St. Louis, MO 63146-7342 (314) 176-1328 www.zagrosrobotics.com
B.3 Electronics/Mechanical: New, Used, and Surplus Active Surplus 345 Queen Street West, Toronto, Ontario, Canada, M5V 2A4, (416) 593-0909 www.activesurplus.com All Electronics, P.O. Box 567, Van Nuys, CA 91408-0567 (800) 826-5432 www.allectronics.com Alltech Electronics, 2618 Temple Heights, Oceanside, CA 92056 (760) 724-2404 www.allelec.com Alltronics, 2300-D Zanker Road, San Jose, CA 95101-1114 (408) 943-9773 www.alltronics.com American Science & Surplus, 5316 North Milwaukee Avenue, Chicago, IL 60630 (847) 982-0870 www.sciplus.com B.G. Micro, 555 North 5th Street, Suite #125, Garland, TX 75040 (800) 276-2206 www.bgmicro.com C&H Sales, 2176 East Colorado Boulevard, Pasadena, CA 91107 (800) 325-9465 www.candhsales.com DigiKey Corp., 701 Brooks Avenue South, Thief River Falls, MN 56701 (800) 344-4539 www.digikey.com
710
SOURCES
Edmund Scientific, 101 East Gloucester Pike, Barrington, NJ 08007-1380 (800) 7286999 www.edsci.com Electro Mavin, 2985 East Harcourt Street, Compton, CA 90221 (800) 421-2442 www.mavin.com Electronic Goldmine, P.O. Box 5408, Scottsdale, AZ 85261 (480) 451-7454 www.goldmine-elec.com Fair Radio Sales, 1016 East Eureka Street, P.O. Box 1105, Lima, OH 45802 (419) 2276573 www.fairradio.com Gates Rubber Company, 900 South Broadway, Denver, CO 80217-5887 (303) 744-1911 www.gates.com Gateway Electronics, 8123 Page Boulevard, St. Louis, MO 63130 (314) 427-6116 www.gatewayelex.com General Science & Engineering, P.O. Box 447, Rochester, NY 14603 (716) 338-7001 www.gse-science-eng.com W. W. Grainger, Inc., 100 Grainger Parkway, Lake Forest, IL 60045-5201 www.grainger.com Halted Specialties Co. 3500 Ryder Street, Santa Clara, CA 96051 (800) 442-5833 www.halted.com Herbach and Rademan, 16 Roland Avenue, Mt. Laurel, NJ 08054-1012 (800) 848-8001 www.herbach.com Hi-Tech Sales, Inc., 134R Route 1 South Newbury St., Peabody, MA 01960 (978) 5362000 www.bnfe.com Hosfelt Electronics, 2700 Sunset Boulevard, Steubenville, OH 43952 (888) 264-6464 www.hosfelt.com Jameco, 1355 Shoreway Road, Belmont, CA 94002 (800) 536-4316 www.jameco.com
B.3 ELECTRONICS/MECHANICAL: NEW, USED, AND SURPLUS
711
JDR Microdevices, 1850 South 10th Street, San Jose, CA 95112-4108 (800) 538-5000 www.jdr.com Marlin P. Jones & Associates, Inc., P.O. Box 12685, Lake Park, FL 33403-0685 (800) 652-6733 www.mpja.com MCM Electronics, 650 Congress Park Drive, Centerville, OH 45459 (800) 543-4330 www.mcmelectronics.com McMaster-Carr, P.O. Box 740100, Atlanta, GA 30374-0100 (404) 346-7000 www.mcmaster.com Mouser Electronics, 958 North Main Street, Mansfield, TX 76063 (800) 346-6873 www.mouser.com PIC Design, 86 Benson Road, Middlebury, CT 06762 (800) 243-6125 www.pic-design.com Scott Edwards Electronics Inc., 1939 South Frontage Road, Sierra Vista, AZ 85634 (520) 459-4802 www.seetron.com Small Parts, Inc., 13980 Northwest 58th Court, P.O. Box 4650, Miami Lakes, FL 330140650 (800) 220-4242 www.smallparts.com Supremetronic, Inc. 333 Queen Street West, Toronto, Ontario, Canada, M5V 2A4, (416) 598-9585 www.supretronic.com Surplus Traders, P.O. Box 276, Alburg, VT 05440 (514) 739-9328 www.73.com TimeLine, Inc., 2539 West 237 Street, Building F, Torrance, CA 90505 (310) 784-5488 www.digisys.net/timeline/ Unicorn Electronics, 1142 State Route 18, Aliquippa, PA 15001 (800) 824-3432 www.unicornelectronics.com W.M. Berg, Inc. 499 Ocean Avenue, East Rockaway, NY 11518 (516) 599-5010 www.wmberg.com
712
SOURCES
B.4 Microcontrollers, Single-Board Computers, Programmers Boondog Automation, 414 West 120th Street, Suite 207, New York, NY 10027 www.boondog.com/ DonTronics, P.O. Box 595, Tullamarine, 3043 Australia (check web site for phone numbers) www.dontronics.com Gleason Research, P.O. Box 1494, Concord, MA 01742-1494 (978) 287-4170 www.gleasonresearch.com Kanda Systems, Ltd., Unit 17–18 Glanyrafon Enterprise Park, Aberystwyth, Credigion SY23 3JQ UK +44 0 1970 621030 www.kanda.com microEngineering Labs, Inc., Box 7532, Colorado Springs, CO 80933 (719) 520-5323 www.melabs.com MicroMint, Inc., 902 Waterway Place, Longwood, FL 32750 (800) 635-3355 www.micromint.com NetMedia (BasicX), 10940 North Stallard Place, Tucson, AZ 85737 (520) 544-4567 www.basicx.com Parallax, Inc., 3805 Atherton Road, Suite 102, Rocklin, CA 95765 (888) 512-1024 www.parallaxinc.com Protean Logic, 11170 Flatiron Drive, Lafayette, CO 80026 (303) 828-9156 www.protean-logic.com Savage Innovations (OOPic), 2060 Sunlake Boulevard #1308, Huntsville, AL 35824 (603) 691-7688 (fax) www.oopic.com Technological Arts, 26 Scollard Street, Toronto, Ontario, Canada M5R 1E9 (416) 9638996 www.technologicalarts.com Weeder Technologies, P.O. Box 2426, Fort Walton Beach, FL 32549 (850) 863-5723
B.6 SERVO AND STEPPER MOTORS, CONTROLLERS
713
Wilke Technology GmbH Krefelder 147 D-52070 Aachen, Germany +49 (241) 918 900 www.wilke-technology.com Z-World, 2900 Spafford Street, Davis, CA 95616 (530) 757-3737 www.zworld.com/
B.5 Radio Control (R/C) Retailers Tower Hobbies, P.O. Box 9078, Champaign, IL 61826-9078 (800) 637-6050 (217) 3983636 www.towerhobbies.com
B.6 Servo and Stepper Motors, Controllers Effective Engineering, 9932 Mesa Rim Road, Suite B, San Diego, CA 92121 (858) 4501024 www.effecteng.com FerretTronics, P.O. Box 89304, Tucson, AZ 85752-9304 www.FerretTronics.com Hitec RCD Inc., 12115 Paine Street, Poway, CA 92064 www.hitecrcd.com Medonis Engineering, P.O. Box 6521, Santa Rosa, CA 95406-0521 www.medonis.com Mister Computer, P.O. Box 600824, San Diego, CA 92160 (619) 281-2091 www.mister-computer.com Pontech (877) 385-9286 www.pontech.com Solutions Cubed, 3029 Esplanade, Suite F, Chico, CA 95973 (530) 891-8045 www.solutions-cubed.com Vantec, 460 Casa Real Plaza, Nipomo, CA 93444 (888) 929-5055 www.vantec.com
714
SOURCES
B.7 Ready-Made Personal and Educational Robots ActiveMedia Robotics, 44–46 Concord Street, Peterborough, NH 03458 (603) 924-9100 www.activrobots.com Advanced Design, Inc., 6052 North Oracle Road, Tucson, AZ 85704 (520) 575-0703 www.robix.com Arrick Robotics, P.O. Box 1574, Hurst, TX 76053 (817) 571-4528 www.robotics.com General Robotics Corporation, 1978 South Garrison Street, #6, Lakewood, CO 802272243 (800) 422-4265 www.edurobot.com, Newton Research Labs, Inc., 4140 Lind Avenue Southwest, Renton, WA 98055 (425) 251-9600 www.newtonlabs.com Probotics, Inc., Suite 223, 700 River Avenue, Pittsburgh, PA 15212 (888) 550-7658 www.personalrobots.com
B.8 Construction Kits, Toys, and Parts Valient Technologies (Inventa), Valiant House, 3 Grange Mills Weir Road, London SW12 0NE UK +44 020 8673 2233 www.valiant-technology.com
B.9 Miscellaneous Meredith Instruments, P.O. Box 1724, 5420 West Camelback Rd., #4, Glendale, AZ 85301 (800) 722-0392 www.mi-lasers.com Midwest Laser Products, P.O. Box 262, Frankfort, IL 60423 (815) 464-0085 www.midwewst-laser.com Synergetics, P.O. Box 809, Thatcher, AZ 85552 (520) 428-4073 www.tinaja.com Techniks, Inc., P.O. Box 463, Ringoes, NJ 08551 (908) 788-8249 www.techniks.com
APPENDIX
C
Robot Information on the Internet
Contents Electronics Manufacturers Shape-Memory Alloy Microcontroller Design Robotics User Groups General Robotics Information Books, Literature, and Magazines Surplus Resources Commercial Robots Video Cameras Ultrasonic Range Finders LEGO Mindstorms Sources on the Web Servo and Stepper Motor Information Quick Turn Mechanical and Electronics Parts Manufacturers
715 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
716
ROBOT INFORMATION ON THE INTERNET
C.1 Electronics Manufacturers Analog Devices, Inc. www.analog.com/ Atmel Corp. www.atmel.com/ Dallas Semiconductor www.dalsemi.com/ Infineon (Siemens) www.infineon.com/ Microchip Technology www.microchip.com/ Motorola Microcontroller www.mcu.motsps.com/ Precision Navigation www.precisionnav.com/ Sharp Optoelectronics www.sharp.co.jp/ecg/data.html Xicor www.xicor.com/
C.2 Shape-Memory Alloy www.toki.co.jp/BioMetal/index.html www.toki.co.jp/MicroRobot/index.html
C.3 Microcontroller Design Peter H. Anderson—Embedded Processor Control www.phanderson.com/
C.4 ROBOTICS USER GROUPS
“No-Parts” PIC Programmer www.CovingtonInnovations.com/noppp/index.html Iguana Labs www.proaxis.com/~iguanalabs/tools.htm LOSA—List of Stamp Applications www.hth.com/losa/ Myke Predko’s Microcontroller Reference www.myke.com/ PICmicro Web Ring http://members.tripod.com/~mdileo/pmring.html Shaun’s BASIC Stamp 2 Page www.geocities.com/SiliconValley/Orchard/6633/index.html
C.4 Robotics User Groups Seattle Robotics Society www.seattlerobotics.org/ Yahoo Robotics Clubs http://clubs.yahoo.com/clubs/theroboticsclub http://search.clubs.yahoo.com/search/clubs?p_robotics The Robot Group www.robotgroup.org/ Robot Builders www.robotbuilders.com/ B-9 Builder’s Club http://members.xoom.com/b9club/index.htm San Francisco Robotics Society www.robots.org/ Nashua Robot Club www.tiac.net/users/bigqueue/others/robot/homepage.htm Mobile Robots Group www.dai.ed.ac.uk/groups/mrg/MRG.html
717
718
ROBOT INFORMATION ON THE INTERNET
Dallas Personal Robotics Group www.dprg.org/ Portland Area Robotics Society www.rdrop.com/~marvin/
C.5 General Robotics Information Robotics Frequently Asked Questions www.frc.ri.cmu.edu/robotics-faq/ Legged Robot Builder http://joinme.net/robotwise/ Tomi Engdahl’s Electronics Info Page www.hut.fi/Misc/Electronics/ Boondog Automation Tutorials www.boondog.com\tutorials\tutorials.htm Find Chips Search www.findchips.com/ Robotics Resources www.eg3.com/ee/robotics.htm Robotics Reference http://members.tripod.com/RoBoJRR/reference.htm Bomb Disposal Robot Resource List www.mae.carleton.ca/~cenglish/bomb/bomb.html Introduction to Robot Building www.geckosystems.com/robotics/basic.html Robot Building Information, Hints, and Tips www.seattlerobotics.org/guide/extra_stuff.html Suppliers for Robotics/Control Models and Accessories http://mag-nify.educ.monash.edu.au/measure/robotres.htm
C.5 GENERAL ROBOTICS INFORMATION
Mobile Robot Navigation http://rvl.www.ecn.purdue.edu/RVL/mobile-robot-nav/mobile-robot-nav.html Robota Dolls www-robotics.usc.edu/~billard/poupees.html BASIC Stamp, Microchip Pic, and 8051 Microcontroller Projects www.rentron.com/ TAB Electronics Build Your Own Robot Kit Resource Page www.tabrobotkit.com Hila Research QBasic http://fox.nstn.ca/~hila/qbasic/qbasic.html Dennis Clark’s Robotics www.verinet.com/~dic/botlinks.htm Dissecting a Polaroid Pronto One-Step Sonar Camera www.robotprojects.com/sonar/scd.htm Polaroid Sonar Application Note www.robotics.com/arobot/sonar.html General Robot Info www.employees.org:80/~dsavage/other/index.html Standard Technologies of the Seattle Robotics Society www.nwlink.com/~kevinro/guide/ Tech Wizards www.hompro.com/techkids/ Android Workshop www.tgn.net/~texpanda/library.htm Hacking RAD Robot www.netusa1.net/~carterb/radrobot.html BEAM Robotics http://nis-www.lanl.gov/robot/
719
720
ROBOT INFORMATION ON THE INTERNET
C.6 Books, Literature, and Magazines Robotics Book Reviews www.weyrich.com/book_reviews/robotics_index.html Robot Books www.robotbooks.com/ Lindsay Publications www.lindsaybks.com/ Circuit Cellar www.circellar.com/ Midnight Engineering www.midengr.com/ Robotics Bookstore www.bectec.com/html/bookstore.html Robohoo www.robohoo.com/
C.7 Surplus Resources Silicon Valley Surplus Sources www.kce.com/junk.htm
C.8 Commercial Robots Electrolux Vacuum Robot www.electrolux.se/robot/meny.html Gecko Systems Carebot www.geckosystems.com/ iRobot www.irobot.com
C.11 LEGO MINDSTORMS SOURCES ON THE WEB
721
IS Robotics www.isr.com/ Nomadic Technologies www.robots.com/products.htm
C.9 Video Cameras Logitech QuickCam www.quickcam.com/
C.10 Ultrasonic Range Finders Ultrasonic Imaging Project http://business.netcom.co.uk/iceni/usi_project/ Interfacing Polaroid Sonar Board www.cs.umd.edu/users/musliner/sonar/
C.11 LEGO Mindstorms Sources on the Web LEGO Mindstorms home page www.legomindstorms.com/ LEGO Mindstorms Internals www.crynwr.com/lego-robotics/ RCX Software Developer’s Kit (from LEGO) www.legomindstorms.com/sdk/index.html RCX Internals http://graphics.stanford.edu/~kekoa/rcx/ RCX Tools http://graphics.stanford.edu/~kekoa/rcx/tools.html Scout Internals (from LEGO) www.legomindstorms.com/products/rds/hackers.asp
722
ROBOT INFORMATION ON THE INTERNET
LEGO Dacta (educational arm of LEGO) www.lego.com/dacta/ Pitsco (educational second sourcing for LEGO) www.pitsco-legodacta.com/ LUGNET Newsgroups (technical LEGO discussion boards; robotics group is largest) www.lugnet.com/ NQC (Not Quite C); (popular alternative programming environment for RCX) www.enteract.com/~dbaum/nqc/ Gordon’s Brick Programmer www.umbra.demon.co.uk/gbp.html LEGO on My Mind http://homepages.svc.fcj.hvu.nl/brok//LEGOmind/ Mindstorms Add-Ons http://www-control.eng.cam.ac.uk/sc10003/addon.html MindStorms RCX Sensor Input www.plazaearth.com/usr/gasperi/lego.htm
C.12 Servo and Stepper Motor Information R/C Servo Fundamentals www.seattlerobotics.org/guide/servos.html Modifying R/C Servos to Full Rotation www.seattlerobotics.org/guide/servohack.html Definitive Guide to Stepper Motors www.cs.uiowa.edu/~jones/step/index.html Servo-Motor 101 www.repairfaq.org/filipg/RC/F_Servo101.html Dual Axis Stepper Motor Controller http://members.aol.com/drowesmi/dastep.html Using the Allegro 5804 Stepping Motor Controller/Translator www.phanderson.com/printer/5804.html
C.13 QUICK TURN MECHANICAL AND ELECTRONICS PARTS MANUFACTURERS
C.13 Quick Turn Mechanical and Electronics Parts Manufacturers Mechanical Prototypes and Parts www.emachineshop.com/ Quick Turn PCB Prototypes www.apcircuits.com/ Quick Turn PCB Prototypes www.pcbexpress.com/
723
This page intentionally left blank
INDEX
555 timer, 153, 385–386, 505 servo motor, 394, 402 shape-memory alloy (SMA), 460–461 tone generator, 576–577 556 timer, with servo motor, 402–403, 408 567 toner decoder, 576 802.11 wireless network card, 161 2001: A Space Odyssey, 21 Air Muscle, 469 Airtronics, 400–401 Amazon.com, 45 Amvets, 35 Analog Devices, 644–646 analog sensor, interfacing, 201–204. See also operational amplifier (opamp) circuit. cell voltage divider, 204 potentiometer voltage divider, 204 signal amplification, 202 signal buffering, 202–203 voltage comparator, 201–202 analog-to-digital converter (ADC), 192, 201, 204–207 bit resolution, 206 bits used, 205 circuit, sample, 206–207 concept, 205 with discrete logic chips, 206 input, single or multiplexed, 206 integrated microcontrollers, 206 output, parallel or serial, 206 resolution, 205 successive approximation, 205 voltage span, 205 AND statements, 210–211, 247–249 anthropomorphism, 668 arm, revolute coordinate, 466–467, 471–481. See also arms and hands; grippers. balance, correcting, 479 center of gravity, 478 counterweights, 478–479 DC motor, continuous, 479 degrees of freedom, 471 design, refinements, 478 elbow and forearm, 474–478 gripper, 471–472 human arm, compared to, 466–467, 471 infrared LED, 479 open-loop servo system, 479 parts list, 473
arm, revolute coordinate (Cont.): phototransistor, 479 position control, 479–481 shaft encoder, incremental, 480–481 shoulder joint and upper arm, 472–473 stepper motor, 473, 479 switches, limit, 479 switches, optical, 479 weight, redistribution, 478 arm, types, 466–469. See also arms and hands; grippers. cartesian coordinate, 468–469 cylindrical coordinate, 467 polar coordinate, 467 revolute coordinate, 466–467, 471–481 arms and hands, 5, 19–20. See also arm, revolute coordinate; grippers. activation techniques, 469–470 built-on manipulators, 20 degrees of freedom, 466 end effectors, 20 General Electric, 19 human, compared to, 465–466 OWIKIT Robot Arm Trainer, 139 Robotix kit for, 134–135 stand-alone, 20 work envelope, 466 ASCII, 180, 194 balance, 310–311, 479, 643 base 2 numbers, 175–176 base 10 numbers, 175–176 BASIC Stamp 2 (BS2) application, selecting correct, 216 assembled development boards, 219–220 circuit diagram, 218 CMOS technology, 240 current for robot brain, 216 deadband in servo motors, 405 design architecture, 214 design suggestions, 252 developer options, 219–220 disadvantages, 214 ease of use, 252 EEPROM, 216–218 features, 213–214 from hacked toys, 143, 145–147 infrared (IR) light proximity sensor, 527–530 I/O Port Simulator, 223, 245–252 in joystick interface, 259
BASIC Stamp 2 (BS2) (Cont.): LCD interface, 241–245 as learning tool, 219 LED outputs, 236–239 masking values by ANDing, 210–211 mathematical expressions, 178 momentary on button, 239–240 multiple ways to perform same task, 236 PBasic (See PBasic.) pulse width modulation (PWM), 363–364 servo motor, 394, 401–405, 408 setup, 233–236 for sound output control, 563–565 tone decoding detection, 574 BASIC Stamp product families, 215–216 batteries AC/DC power converters (wall wart), 302 breakdown voltage, 292 for Buggybot, 128 capacitor filtering techniques, 291–292, 294; benefits, 292 capacitors, selecting, 291 care guidelines, 288–289 ceramic vs. bus, 290 conditions of, 284–285 cost, 281; and weight, 306 current, determining, 290 current surge at robot startup, 286 dropout voltage, 295 fuse, 289–290 leaking, 289 linear voltage regulator, 294–295 monitors, 298–300; with microprocessors, 300; zener, 300; zener/comparator, 299–300 for motors, solenoids, and electronics, 281 noise, from motors, 292 noise in power lines, reducing, 291–292, 294 overcurrent, determining, 290 power loss, 295 power supply: DC output, 303; from laptops, 303; for robot testing, 300–303 pulse width modulation (PWM), 303 for Roverbot, 425 safety precautions, 278 selecting, 286; based on weight, 306 short circuits, 289–290
725 Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.
726
INDEX
batteries (Cont.): shunted voltage, 292 storage, 288 supplies, separate, 291–292 switching voltage regulator, 295–297 toxic, 282 unsuitable for robots, 280 voltage regulation, 292–298 voltage requirements, multiple, 290–291 voltages: calculating, 293; obtaining higher, 279–280 volt-ohm meter, 282, 284 wall wart, 302 weight and cost, 306 zener diode, 292–293 batteries, properties ampere-hour (AH), 278 amp-hour current, 285 breakdown voltage, 292 capacity, 285–286 capacity and weight, 306 discharge curves, 285–286 discharge rates, 279, 291 heat, 278–279, 282, 288 internal resistance, 278, 281 life, useful, 285 memory effect, 282, 289 nominal cell voltage, 287 parallel vs. series connection, 279–280 polarity reversal, 282 power distribution, 289–292, 297 power loss, 128, 278 ratings, 284–287 in series, 279–280, 289 voltage, 284–285 batteries, rechargeable, 280–283, 287–289 DC power supply output, 303 rates, 286–287 recharger, 15, 287 in robot, 288 robot plugs itself in for, 300, 666 surplus stores, 44 vs. nonrechargeable, 15–16, 287 batteries, types alkaline, 15, 277–278, 281, 285, 287, 405, 534 carbon zinc, 280–281 gelled electrolyte (gel-cell), 284, 289–290, 449 heavy duty, 280 laptop computers, 282 lead acid, sealed, (SLA), 15–16, 44, 283–285, 287, 290, 306, 425 lithium and lithium-ion, 15, 282–283, 287 mercury, 15 motorcycle, 284 nickel cadmium (Ni-Cads), 281–283, 285–287, 289, 303, 306, 425 nickel-metal hydroxide (NiMH), 15–16, 277, 281–282, 287–288, 290, 303, 306; in toys, hacked, 140 penlight, 460 recommended, 277 zinc, 15, 280, 287 zinc chloride, 280 battery holder, 108–109, 119, 128 beacons, 621–622, 624
BEAM robotics, 153–154 competitive events, 153, 694 concept, 16, 22 disadvantages, 154 from electronics, household, 153 evolution of robots, 154 parts requirements, 154 Robosapien, 138 Tilden, Mark, 138, 153 beam splitters, from CD players, 35 behavior-based programming, 135, 666–669 belts. See pulleys and belts. bounce, 503–504 bouncer hardware, 504–505 software, 505–506 brain, 5, 154. See also microcontrollers; personal computers (PCs); personal digital assistants (PDAs); singleboard computers (SBCs). advantages of computer program, 154–155 disadvantages of making from discrete components, 154 inputs and outputs, 164–168 laptop, 155 PC motherboard, 155 Braitenberg, Valentino, 668 BRANCH statement, 230 breadboards, 84–85 breakdown voltage, 292 Brooks, Prof. Rodney, 666, 670 Buggybot, 123, 125–130, 457 bumper switches, 541, 545–548 bushings, from surplus stores, 44 cable harnesses, from VCRs, 35 Caidin, Martin, 10 capacitors, 54–56, 291–292, 294 anode and cathode, 55–56 breadboard, testing with, 84 bypass, 91–92 components, 54 decoupling, 91–92 design principles, 91 dielectric materials, 55 farad, 55 markings, explained, 55–56 measure, unit of, 55 piezo discs, 555–558 polarity, 56 power supply filtering, 55 selecting, 55 voltage rating for, 55 Capek, Karel, 22 Capsula gear motors, 135 unique parts, 135 caster, 315–317 size for drive wheels, 127 stabilizing, for wooden platforms, 118–119 support, for Buggybot, 127 support, for metal platforms, 127 CD players, parts, 35 center of balance, 310–311, 479 center of gravity, 311, 420, 449, 478 central processor, 5 chain plastic, from Capsula, 135 roller, from surplus stores, 44
CMOS chips, 91, 199–200, 240, 382–383, 385, 508. See also integrated circuits (ICs). combat bots, laser-tag competition, 694 comparator, 201–202, 299–300, 367–370 competitions, robot, 693–695 computer languages assembly, 155–156 BASIC, 156, 181, 186 C, 156, 181, 186 Java, 156 PBasic, 172, 210, 217, 220–232 (See also PBasic.) computer peripherals, parts, 36 computer programming AND, 182 arrays and character strings, 170, 180–181 ASCII, 180 assignment statements, 170, 176–180 background required, 5–6 base 2 numbers, 175–176 base 10 numbers, 175–176 behavior-based, 666–669; LEGO, 135, 666 bitwise port programming, 210–212 code, indenting, 183 comments, in BASIC and C, 186 comparison operators, 182 concepts, 170–186 console I/O, 170, 185 data types, 174 decision structures, 170, 181–183 delay, for continual looping, 186–187 floating point, definition, 174 flowcharting for, 171–173 GOTO statements, avoiding, 181 graphical vs. text, 187–188 IF/ELSE/ENDIF, 229, 239, 246–250, 260–262, 266–268, 506, 533, 564–565 integers, signed vs. unsigned, 174 internal features, 675 LEGO, 135, 172, 666 linear program execution, 170–171 mathematical expressions, 170, 176–179 mathematical operations: bitwise operators, 179–180; mask, 179; order of operations, 178–179; with parentheses, 178–179 numbers: base 2, 175–176; base 10, 175–176; binary, 175–177; decimal, 175–177; hexadecimal, 175–177; integers, signed vs. unsigned, 174 OR, 182 program template for robots, 226, 673 resources, allocating, 674–675 SELECT or SWITCH statements, 183 strings, 180; in BASIC and C, 181 subroutines and functions, 170, 183–185 text vs. graphical, 187–188 tokenized source code, 156 variables, 173–174, 222; and I/O ports, 170, 173–176
INDEX
computer programs BS2 GP2D12, 532–533 BS2 ISD2532, 563–565 BS2 LCD, 242, 244 BS2 Line Follow, 604, 611 BS2 Object Detection, 528–529 BS2 Object Ranging, 529–530 BS2 Polariod 6500, 619–621 BS2 Port IO, 245–250 BS2 PWM, 363 BS2 Teaching Pendant, 259–263 Button Demonstrations, 240–241 Calibrate, 403–404 Cylon Eye, 238–239 Debouncer, 506 Hello World, 235 LED Flash Demonstrations, 238–239 for sensing a collision, 558 Sony Remote Control Receiver Operation Methods, 266–268 storage data to register, 170 conductive foam, 508–511 from CMOS packaging, 508 for near-object detection, 544–545 resistance, 509 response curve, 510 for touch sensors, 508–511 transducer for, setting, 509 connectors, 88–89 construction and design. See also fasteners; finish, paint; materials, sourcing; materials, structural; plastic platforms; wooden platforms. body, 12–15 differentially driven robot, 17–18, 312–313, 454–455 electronics and mechanical items, salvageable: CD players, 35; computer devices, 36; fax machines, 35; floppy disks, 35; hard disks, 35; mechanical toys, 36; mice, 36; printers, 36; VCRs, 35 from Erector set, 132–134 (See also Erector set.) fasteners, 31–34 mobile vs. stationary robots, 10–11 platforms: from hacked toys, 140–147 from Robotix kit, 134–135 (See also Robotix) current, 48–50, 57, 285–286, 290, 329–330, 348 Cyborg, 10 data transmission, 622 DC motor control automatic control via relays, 348–350 bipolar transistor control, 351–355, 357, 359 direction, controlling, 350 double-pole, double-throw (DPDT) switch, 348–350 methods, ranking, 359 MOSFET transistors, 359 motor bridge control, 357–358 power MOSFET control, 355–357 relay motor control, 359 relays: activating, 349; single-pole, 348–349
DC motors, 345–373. See also motors. brushes, 346 commutator, 346 concept, 345–347 continuous, 359, 479; speed of, 330 current draw when stalled, 348 direction, reversing, 347–348 disadvantages, 375 efficiency, 348 fundamentals, 345–347 Minibot, 106 open feedback system, 393 open-loop continuous, 345 overdriving, 348 permanent magnet, 345 ratings, 347–348 rotational speed, effect on torque, 348 vs. servo motor, 393, 395, 401, 409 stator, 345 vs. stepper motors, 375, 379–380 suitability for robotics, 347 testing, for directionality, 326 transistors for, 58–60 underdriving, 348 windings, 346 DC motor speed control, 359–367 continuous DC motors, 359 with potentiometer, 360 with pulse width modulation (PWM), 360–367 deadband, 405 debouncer, 198–199, 504–506 DEBUG, 246, 248–250, 260–262, 270, 529–530, 558, 564–565 DEBUGIN, 246 degrees of freedom, 404, 466, 471, 496 design, 664–666. See also construction and design. differentially driven, 17, 18, 312–313, 454–455 diffraction gratings, from CD players, 35 digital multimeter (DMM), 50, 70–72 AC, measuring, 71–72 analog vs. digital, 71 DC, measuring, 71–72 ratings, maximum, 72 volt-ohm meter, 329, 389 zero adjust, 72 digital sensors, 192, 198–201 buffered input, 198–199 CMOS-to-TTL translation, 200 LED high/low voltage input and indicator, 198 opto-isolators, 199–200 switch debouncer, 198–199 TTL-to-CMOS translation, 200 zener diode shunt, 201 digital-to-analog conversion, 207 diodes, 56–57. See also LEDs. PN junction, 69 properties, 56 semiconductor, as a, 56 and static electricity, 69 zener, 56, 201, 292–293, 299–300 Disabled American Veterans, 35 disk drives, for parts, 35
727
distance, measuring, 367–373 calculating, 367–368 comparators, 367–370 counters, 367 direction, via quadrature encoding, 371–373 flip flop circuit, 372 phototransistor, infrared sensitive, 367, 371–372; stray light, effects on, 371 quadrature encoding, 371–373 shaft encoder, 367–373; in PC mice, 370 DO/LOOP, 227, 239, 246, 270, 363–364, 404, 530 for line following, 606–607, 611–612, 621 for sensing a collision, 558 for sound output control, 563–565 Doppler effect, 616–617 double-pole, double-throw (DPDT) switch, 109, 120, 132, 348–350 DO WHILE/LOOP, 229, 246–250, 260–262, 266–267, 364, 404, 564–565 drill, 124 drill press, 124 dropout voltage, 295 dual in-line packages (DIP), 61 Ebay, for robot parts, 45 EEPROM, 158, 260 electromagnetic mechanisms Fischertechnik kits, 136 electronics, for robots. See also capacitors; diodes; ground, earth; inputs and outputs (I/O); integrated circuits (ICs); object detection; resistors; sensors; sound input; symbols, electrical; transistors; vision, robot; wire gauge. background required, 5 components, 47–62 construction techniques, 79–92 design principles, 91–92 feedback and control systems, 22 inputs and outputs (I/O), 164–168 input sensors, 20–21 output, types, 21 static electricity, protecting from, 69–70 electronic theory, 47–51, 384 ampere (A), 48 Coulomb (C), 48 current (i), 48–50 Ohm’s law, 48, 50, 52; triangle, 50 parallel, wiring resistors in, 49, 51 resistance (R), 48–51; combining, 48–49, 51 series, wiring resistors in, 51 voltage (V), 47–48, 50–51 electrostatic discharge (ESD), 69–70. See also static electricity; work space. protection kits, 70 eMbedded Visual Tools, for PDAs, 159 emotions, 668 END statement, 230 energy watch robot, 191–192
728
INDEX
Erector set, 131–134 collector’s items vs. usability for robots, 132 for grippers, 486 manufacturers, 132, 138 wheel assembly, 132–133 event planning, 689–694 announcements to media and public, 693–694 competitions, 691–693 venue, 689–691 eyesight. See sensors, light; vision. failures, 679–687 electrical, 680 mechanical, 680 methods for fixing, 681–687 programming, 683 far-object detection, 520–521 Fastech toy construction kit, for Minibot, 107 fasteners adhesives or glues, 33 cable ties, 34 for hacked toys, 143, 145 hose clamps, 34 interlocking parts, 34 for Minibot, 108 nuts and bolts, types, 32 rivets, 33 rod, all-thread, 32–33 steel cables, 34 turnbuckles, 34 washers, 32 welding, 33 for wooden platforms, 119 fax machines, parts, 35 fiber optics cutting, 551 fiber types, 550–551 theory and background, 549–550 finish, paint, 36–37 fire detection systems, 629–640 fire extinguisher, 638–640 firefighting, 638–640 competition, 692 Fischertechnik kits, 135–136 engineering uses, 136 mechanical theory and design, 135–136 flame detection, 629–631, 670–671 FOR/NEXT, 228, 364 frame, robot, 12–13, 306–309 Frankenstein, Dr., 3 freqout, 530 fumes, detection of, 635–636 furniture, protecting from robot, 654–655 Futaba, servo motor, 397, 400 gamepad. See remote control, gamepad. garage sales, 35 gearboxes, 336 Tamiya, 138 gear reduction, 333–338 in grippers, 497 input and output shafts, 335 motors with, 335–337 pitfalls to DIY, 337 with R/C servo motors, 335 right-angle drives, 335 with stepper motors, 335
gears Capsula, 135 from fax machines, 35 grinding, 397 pitch, 338 pressure angle, 338 purpose, 333 ratio, 331 setscrew, 342 speeds, 334 sprockets, attaching to, 342 surplus stores, 44 tooth geometries, 338 types: bevel, 337; helical, 338; miter, 337; rack, 338; spur, 337–338, 492, 496; worm, 337–338, 490–491, 497 gear train, 398 General Electric, robotic arm, 19 glue, LEGOs, 135 Goodwill, 35 GOSUB, 247–250, 260–261 GOTO, 230 grippers, 5, 20, 471–472, 483–497 clapper, 483–486; parts list, 484 degrees of freedom, 496 end effectors, 483 Erector set, 486 gear reduction, 497 spur gear, 492, 496 two-pincher, 484, 486–494 worm gear, 490–491, 497 wrist rotation, 496–497 grippers, advanced actuation, 492–494 Radio Shack, Tony Armatron, 494 two-pincher, 487–494 grippers, flexible finger, 494–496 compliant grip, 494 ground earth, 60 symbol for, 60 ground loops, 92 hacking toys. See toys, hacking. HAL-9000, 21 Hall effect, 608, 612–613, 615 Halon, 638–640 hands and arms. See arm, revolute coordinate; arms and hands; grippers. Harvard architecture, 158 Haydon, 389 H-bridge, 58, 60, 109, 353–354, 357 headers, 88–89 heat detection, 636–638 Heinlein, Robert, 11 hexapods, 18 HIGH and LOW, 260–263, 349, 382, 404, 533, 564–565 for navigation, 603, 606, 611, 618, 621–622 Hitec, 400, 410 home, protecting from robot, 654–655 Honda Asimo, 653 Hot Paw BASIC, for PDAs, 159 hydraulic mechanisms Fischertechnik kits, 136 IF/ELSE/ENDIF, 229, 239, 246–250, 260–262, 266–268, 506, 533, 564–565 for navigation, 621
IF/THEN, 230 Images Company, 570 imaging array, from faxes, 35 impedances, parasitic, 85 infrared data port, for PDAs, 159 infrared heat, 534–535 infrared (IR) receiver modules, from VCRs, 35 infrared LED, 479 infrared remote control. See remote control, infrared. infrared sensors, 193, 507–508, 527–538, 596, 608, 655 inputs and outputs (I/O), 164–168 bitwise port programming, 210–212 digital-to-analog conversion, 167 external reset, 168 frequency and pulse management, 167 hardware interrupts, 168 input, as voltage level, 192 input, defined, 191 input pull-up, 168 input types (See sensors.) interfacing, parallel vs. serial, 193–194 lines, expanding, 208–209 methodologies, 193–194 motors, 195 output, defined, 191 output circuits, 195–198 output types, 195 parallel, 193–194, 206 peripherals, defined, 191 for robot vision, 589 sensors (See sensors.) serial, 194, 206 serial communications, 164–166; asynchronous, 164–167; Manchester encoding, 164–165; synchronous, 164–165, 531 switch debouncer, 168 integrated circuits (ICs), 73, 84, 91 breadboard, testing with, 84 code, unique, 61 with decoupling capacitor, 92 dual in-line packages (DIPs), 61 pin through hole (PTH), 61 with pull-up resistor, 92 intelligence, smart vs. dumb, 21 interrupts, 675–676 iRobot, 653 iron angle brackets, 30 joystick. See remote control, joystick. JR, 400 Kelvin (K) temperature scale, 636–637 K’Nex kits, 136–137 laptops, 163 LCDs, 241–245 lead lengths, short, 91–92 Learning Curve, 133 LEDs, 35, 56–57, 198, 236–239, 507–508 damage from current, 57 logic probe, 73 specifications, 57 for touch sensing systems, 507–508 from VCRs, 35
INDEX
LEGO, 131, 135, 410, 413, 469 behavior-based programming, 135, 666–669 disadvantages, 135 Mindstorms, 135; competitions, 694 Spytech, 135 Technic line, 135, 555 legs, 17–18, 312–313 light, detecting, 21, 152, 193, 579–597. See also vision, robot. circuit diagram, 152 line-following competition, 694 Linux, 160, 164, 220 locomotion, 17–19, 305–322. See also locomotion, advanced; motor drives; speed; steering. design considerations, 311–312 differential drive, 312 legs, 17–18, 312–313 with radio-controlled servos, 312 round vs. square robots, 321–322 with tracks, 18–19, 311–312 with wheels, 17, 311–312, 410 locomotion, advanced, 453–463 with pivoting wheel, 455–457 with steering wheel systems: dual motors, 455 with tracks, 453–455 logic probes, 73–74 Radio Shack, 74 specifications, 74 Macintosh, 220 Mars Rover, 11 Massachusetts Institute of Technology, 666, 670 materials, sourcing garage sales, 35 surplus stores, 44, 328, 389 thrift stores, 35 materials, structural, 13–15, 25–37. See also metal platforms; metals, for structure; plastic platforms; plastics; wood; wooden platforms. cardboard, 26 comparison chart, 26 foamboard, 15, 26 particle board, 26 mathematical expressions, 178 maze-following competition, 692 Meccano, 132–133 mechanical theory and design Fischertechnik kits, 135–136 mechanics, background in, 6 memory effect, 282, 289 mending plates, 30 metal alloy, shape-memory. See shapememory metal alloy (SMA). metal platforms, 123–130 battery holder, 128 for Buggybot, 125–130 frame, 126–127 motors and mounts, 126 support caster, 127 wheels, attaching, 126 wiring diagram, 129 working with metal, 124–125 (See also metalworking.) metals, for structure, 14, 26, 29, 435–436
metalworking, 124–125 finishing, 125 manipulating, 124–125, 127 marking, 124 saws, 124 tools for, 124–125 Metropolis, 13 Microchip MPC2150, for PDAs, 159–160 microcontrollers, 5, 154–159, 206. See also BASIC Stamp 2 (BS2). advantages, 155 Atmel AVR, 157 benefit, key, 156 boatloader equipped, 156 computer languages for, 156 cost, 155, 158 debugging features, 158–159 EEPROM, 158 Flash, 158 Freescale 68HC11, 157 Hitachi H8, 157 Intel 8018x, 156–157 Intel 8051, features, 156–157 manufacturer and developer preferences, 156 manufacturers, 156–158 memory areas, 158 Microchip, 156 PIC, 156 processors used with, 156 program instruction and data retrieval, 158 programming, third-party tools for, 158 PROM, 158 vs. single-board computers, 160 Von Newmann vs. Harvard architecture, 158 Microsoft, 159–160, 164 Milton-Bradley, 133 Mims, Forrest M. III, 203 Mindstorm, 135, 694 Minibot, 105–109, 131 from hacked toys, 131 with whiskers for object detection, 543 miter box, 124 Molon, 389 momentary on switch, 239–240, 502 MOSFET, 58, 60, 69, 355–357, 359, 382–383 motion detectors, 534–537 motor control, 348–359 motor drives, 313–317 camber placement, 313–314 casters, 315–317 centerline mount, 313–314 differentially driven, 313 front-drive mounting, 313–315 steering circle, 313–314 weight, 313 wheel placement, 313–314 Motorola MC68HC11, deadband in servo motors, 405 motors, 325–342. See also DC motors; servo motors; stepper motors. AC induction, 328 AC vs. DC, 325 brushless DC, 328 commutator brushes, 326 continuous, 326–327 control (See motor control.)
729
motors (Cont.): current draw, 329–330; Ohm’s law, 330; relationship to load, 329 DC (See DC motors.) dual-gear, 139 with gear reduction, 335–337 hacked parts from: CD players, 35; computers, 35–36, 328; fans, 328; faxes, 35; kitchen mixers, 328; surplus stores, 328; toys, mechanical, 36; VCRs, 35, 328 for Minibot, 108 mounting, 339–341; R/C servo, 341 operating voltage, 328–329 radio-controlled, 327 reversible, 325 Sel-Syn, 328 shaft, 341–342 specifications, 118, 328–332 speed, 330–331 stall current, 329 stepping, 326–327, 331 from surplus stores, 44 switched reluctance, 328 synchro, 328 synchronous, 328 torque, 331–332 unidirectional, 325 for wooden platform, 118 movement algorithms, 655–657 MOVITS kits, and hacked toys, 139 MS-DOS, 164 multiple robot interaction, 669–670 multitasking, 677 multitester. See digital multimeter (DMM) National Instruments’ LabView, 188 navigation, 599–628 beacons, 621–622, 624 compass bearing, 614–615 data transmission, 622 Doppler effect, 616–617 flowchart, 600 global positioning system (GPS), 626 gyroscopes, 626–627 inertial, 626–627 landmarks, identifying, 621–625 map matching, 627–628 odometry, 612–614 Polaroid, for ultrasonic ranging, 617–621 radar, 616 radio frequency identification, 622–623 speed of sound, 617–618 wall following, 600, 607–612 near-object detection, 520–521 distance measurement sensors, 520 limitations, 520–521 proximity sensors, 520, 523–530 near-object detection, compliant collision, 548–555 fiber optics: cutting, 551; fiber types, 550–551; theory and background, 549–550 whiskers, laser fiber, 548–555 near-object detection, contact, 541–548 bumper switches, 541, 545–548 pressure pad, conductive foam, 544–545 whisker, 542–544
730
INDEX
near-object detection, noncontact, 523–540 Fresnel lens, 537 heat, infrared, 534–535 infrared (IR) light proximity sensor, 523–530 motion detector, hacking, 534–537 passive infrared (IR) detection, 534–538 Sharp infrared (IR) object sensors, 530–534 ultrasonic sound, 538–541 near-object detection, soft touch, 548, 555–558 collision sensors, 555–558 LEGO Technic, 555 piezo discs, 555–558; as capacitors, 557 resistive bend sensor, 558 numbers base 2, 175–176 base 10, 175–176 binary, 175–177 decimal, 175–177 hexadecimal, 175–177 integers, signed vs. unsigned, 174 object detection, 5, 18–20, 519–558. See also far-object detection; nearobject detection; sensors. collision avoidance, 520 collision detection, 520 sensor redundancy, 522 simplicity, striving for, 521 sonar, 530 threshold between near and far, 521 Ohm’s law, 48, 50, 52, 330, 384 open feedback system, 393 open source software, 87 operating system. See computer languages; personal computers (PCs). operational amplifier (op-amp) circuit, 202–203, 425 opto-interrupters, from disk drives, 35 oscilloscope, 74–77 AC and DC voltage levels, testing, 74 analog, 75 bandwidth, 76 delayed sweep, 76 digital storage (DSO), 75 logic levels, testing, 74 PC-based, 77 probes, 76–77 resolution, adjusting, 75 sampling rate, 76 specifications, 77 trigger, 76 output. See inputs and outputs (I/O). OWIKITS kits, 139 Palm Pilot, 159 parallel connection, 193–194, 206, 279–280 parasitic impedances, 85 parts, 39–45 Amazon.com, 45 Ebay, 45 Internet sources, 44–45 mail-order companies, 45 manufacturers, 42 stores, 39–44 wholesalers and distributors, 41–42
PAUSE, 272, 529–530, 558, 607, 612, 621 PBasic, 172, 220–232 AND, 247–249 arrays, 222 assignment statements, 223–226 BRANCH, 230 capitalization, 222 code, indenting, 228 comments, 222 constants, 223 con statement, 223 DEBUGIN, 246 DEBUG statement, 246, 248–250, 260–262, 270, 529–530, 558, 564–565 decision structures, 226–231 DO/LOOP, 226–227, 238–239, 246, 270, 404, 530, 606–607 DO WHILE/LOOP, 229, 246–250, 260–262 END, 230 Functions, built-in, 231–232 GOSUB, 247–250, 260–261 GOTO, 230 HIGH and LOW, 236, 238, 260–263, 349, 382, 404, 533, 564–565 IF/ELSE/ENDIF, 229, 239, 246–250, 260–262, 606–607, 611–612 IF/THEN, 230 I(nput) command, 251 I/O pins, 223 for Linux, 220 for Macintosh, 220 mathematical operations, 224–225 FOR/NEXT, 228 O(utput) command, 251 parentheses, 225, 229 pin/port definitions, 221–223 register, changing value, 251 SELECT/CASE/SELECTEND, 229–230, 247–250 statements, 221–232 tokenizer, 220 variables, 222 PBasic interpreter, 217 peak inverse voltage (PIV), 56 personal computers (PCs), 161–164 conversion for robot use, 161–162 disassembling and installing, 162 keyboard, 162 laptops, 163 Linux, 164 Microsoft Windows, 164 motherboards, green, 162 MS-DOS, 164 open source tools, 164 operating systems, 163–164 power supply requirements, 162 robot control, 162 Unix, 164 USB thumb drive, 163–164 video display, operating without, 162 X-Windows-based environment, 164 personal digital assistants (PDAs), 159–160 pets, detecting collisions with, 655 Phelan & Collender, 97 photocells, 579–582, 585 photodetectors, 152, 612 photodiode, 35, 204, 580
photoresistors, 579–580 phototransistor, 204, 367, 371–372, 479, 507–508, 580, 601–603 piezo discs, 555–558, 650–652 piezoelectric. See touch sensors, piezoelectric. pin through hole (PTH) components, 61 in hacked toys, 147 plastic platforms ABS, 98, 100, 102, 103 acrylic, 98, 102, 103 bending and forming, 102 cellulosics, 98–99, 103 cements to use, 103–104 cutting, 100–101 drilling, 101–102 edges, polishing, 102–103 epoxies, 98–99 glue gun, 104 gluing, 103 from household items, 105–109 Minibot construction, 105–109 nylon, 98 painting, 104 phenolics, 98 Plexiglas, 106 polycarbonate, 98, 102 polyethylene, 98–100 polypropylene, 99–100 polystyrene, 103 polyurethane, 99–100, 103 purchasing, 105 PVC, 99–100, 102, 103, 105, 435–436, 442 silicone, 99–100 surfaces, preparing, 104 Testor, 104 plastics. See also plastic platforms. history, 97 Phelan & Collender, 97 for robot construction, 15 Wesley Hyatt, John, 97 plastics, for structure. See plastic platforms. G10FR4, 26 plastic sheet, rigid expanded, 15 Plexiglas, 26, 29 polystyrene, 26, 29 types: elastomer, 28–29; thermoplastics, 29; thermoset, 28 platforms, metal. See metal platforms. platforms, plastic. See plastic platforms. platforms, wooden. See wooden platforms. pneumatic mechanisms Fischertechnik kits, 136 point-to-point wiring, short circuits in, 86–87 potentiometer, 53–54, 201–202, 204, 360, 395–397, 402 power, formula, for motors, 361 power supply issues, 55, 216, 300–303 power systems, 15–16 pressure systems, 16 printed circuit board (PCB) breadboard, 85 disadvantage, 87 from hacked toys, 141–147 prototyping, 85–86, 143 universal solder boards, 85 programming. See computer languages; computer programming. PROM memory, 158, 217
INDEX
prototypes, 26, 30–31 with paper products, 26 of PCBs, 85–86 quick turn PCBs, 30–31, 87–88 proximity detector, 193, 608 proximity sensors, 520, 523–530 pulleys and belts, 339 cog type, 339 V type, 339 pulse width modulation (PWM), 303, 360–367, 395–396, 610 punches, spring-loaded, 124 pyroelectric infrared sensor, 193 quadrapods, 18 quadrature encoding, 371–373 quick turn mechanical prototype shops, advantages, 30–31 radio control. See remote control, radiocontrolled. Radio Shack, 71, 74, 494, 552, 572 remote control BS2 interface, 268 Capsula, 135 DO WHILE/LOOP, 266–267 from hacked toys, 141–143 IF/ELSE/ENDIF, 266–268 for near-object detection, 524–530 PAUSE, 272 Sony, packet, 266–267 for sound input sensors, 574 SWITCH statement, 267 remote control, gamepad, 255–258 circuitry, 257–258 for robot motion teaching tool, 258 remote control, infrared, 264–274 codes, receiving and processing, 268–270 components, 265 data packet, 265–266 electronic noise, filtering out, 265–266 microcontroller interface, 266–268 Robosapien, 138 for robot control, 270–273 Sharp standard, 265 signals, 266–272 of TVs, VCRs, adapting, 264–265, 524–530 universal remote control, 265 remote control, joystick, 255–258 Atari, 255 internal wiring diagram, 256 output assignment statements, 260 port pinout, 257 teaching pendant, 259 remote control, radio-controlled, 141, 273–274, 312, 341, 393, 397 over long distances, 273 with Tamiya, 138 transmitter/receiver, 273–274 resistance, 509 resistive bend sensor, 558 resistors breadboard, testing, 84 color coding, explained, 52–53 design principles for, 91 fixed, 52–53 ohm, 52 potentiometer, 53–54, 201–202 pull-up, 91–92, 615
resistors (Cont.): variable, 53–54 wattage rating, 53 Robosapien, 138 hacked for (PDAs), 138 robot control. See brain. Robotix, 131, 133–135 robots automaton, 11, 22 autonomous vs. teleoperated, 11–12 cyborg, 10 definitions, competing, 10, 663–664 famous, 11–22 indoors vs. outdoors, 319 mobile vs. stationary, 10–11 round vs. square, 321–322 self-contained or autonomous, 10 sizes and shapes, 13, 17 smart vs. dumb, 21 teleoperated, examples, 11 rods and squares, 30 Rokenbok, 140 roller chain. See chain, roller; sprockets and roller chain. Roomba, 653, 655–656 Rossum’s Universal Robot (R.U.R.), 22 rotation, measuring, 373 Rotwang, Dr., 13–14 round vs. square robots, 321–322 Roverbot, 417–429 base, 418–420 batteries, 425 casters, support, 425–426 center of gravity, 420, 429 fasteners, 420–421, 423–424 frame, 426–429 gearbox, 420 riser, 418, 420 speed, 429 wheels, 420–423 RS-232 programming interface, 156 safety precautions, 64 AC-to-DC conversion, 278 batteries, 278 Salvation Army, 35 saws, types, 124 schematics, symbols for, 61–62 Scooterbot, from hacked toys, 131 SELECT/CASE/SELECTEND, 229–230, 248–250, 261–263 sensors, 191–193. See also analog sensor, interfacing; analog-to-digital converter (ADC).; digital sensors; object detection; sound input sensors; tilt sensors; touch sensors; vision, robot. accelerometer, 193 analog, 192 CMOS logic chips, 199 gas or smoke, 193 Hall effect, 608, 612–613, 615 infrared range finder, 193 to keep robot from damaging home, 654–655 light, 193 magneto-inductive, 615 photodetectors, 152, 612 photodiode, 204 phototransistor, 204, 367, 371–372, 479 proximity detector, 193
731
sensors (Cont.): pyroelectric infrared, 193, 520, 523–530, 608 sonar, 193, 530 sound waves, 193 speech input or recognition, 193, 570–571 speed, change in, 193 temperature, 193, 636–638 TTL logic chips, 199 ultrasonic, 608–610, 655 voltage levels, interfacing, 198–199 Sensory Inc., 570 serial interface for I/O, 194 serial port, from PDA, 159 series connection, 51, 193–194, 206, 279–280, 289 servo motor control BASIC Stamp 2 (BS2), 404–405 batteries, alkaline, 405 deadband, avoiding, 405 dedicated, 404–405 degrees of freedom, 404 internal stop, determining, 406 Microchip PIC MCU, 404 radio-controlled, with multiple servos, 341, 404 refresh rate, 404 voltage margins, 405 servo motors, 393–413, 417, 479 555 timer, 394, 402 556 timer, 402–403 angular rotation, precision, 395 ball bearings, 398 BASIC Stamp 2 (BS2), 394, 401–405, 408 calculating rev/min, 399 closed feedback system, 393 color coding of wiring, 401 connectors, 399–401 control circuits, 401–406 cost, 398 vs. DC motor, 393, 395, 401, 409 digital proportional method, 396 gears, grinding, 397 gear trains, 398 landing gear retraction, 398 with LEGOs, 410, 413 lubrication, 407 manufacturers, 397, 400–401, 410 mechanical linkages, attaching, 409 mini-micro, 398–399 mounting, 411–413 output shaft, 396 pinouts, 400; color coding, 401 potentiometer, 395–397, 402; as variable voltage divider, 396–397 power drives, 398 pulse width modulation (PWM), 395–396 quarter-scale, 398–399 radio-controlled (R/C), 312, 393, 397 rotation, limited vs. continuous, 395 rotational limits, 397 sail winch, 398–399 specifications, 398–399 vs. stepper motor, 393, 395 timing, role of, 395 torque, 399 in toys, 394 transit time, or slew rate, 398–399 uses, 393, 395
732
INDEX
servo motors (Cont.): variable voltage divider, 396–397 wiring, 399–401; color coding, 401 servo motors, modified 556 timer, 408 BASIC Stamp 2 (BS2), 408 Calibrate program, 403–404 for continuous rotation, 406–409 control circuit board, 409 vs. DC motor, 409 limitations, 408 modification instructions, 406–407 software, 408 testing, 407–408 warranty, voided, 409 wheels, attaching, 410 shaft encoder, 367–373 shape-memory metal alloy (SMA), 458–463 Shelley, Mary, 3 shelving, 29–30 shiftout command, 209 short circuits in point-to-point wiring, 86–87 when soldering, 83 shunted voltage, 292 signal amplification, 202 signal buffering, 202–203 single-board computers (SBCs), 160–161 802.11 wireless network card, 161 cost, high, 160 kit vs. ready-made form, 161 Linux, 160 microcontrollers, comparison, 160 Microsoft, 160 mini-ITX, 160 with network interface to stream video, 161 PC/104, 160 skeletal structures, 12 smoke detection, 632–636, 670–671 software. See computer languages; open source software. soldering, 79–84 cleanup, 83–84 intermetallic regions, 80 joints, 80 maintenance, 83–84 procedure, 81–83 short circuits, 83 specifications, 81 tools and supplies, 68–69, 81–83 sonar, 193, 530 Sony Playstation controllers, 140 Sony Qiro, 653 Sony remote control packet, 267 sound, speed of, 617–618 sound generator, 5 sound input, 559, 570–577 567 decoder, 576–577 speech recognition, 193, 570–571 tone generator, variable frequency, 576–577; with 555 timer, 576–577 sound input sensors, 571–577 amplifier input stage, 572–574 microphone, 571–572 tone decoding detection, 573–576
sound output, 559–569 audio amplifiers, 568–569; gain-of50, 568; gain-of-200, 569 cassette recorder, 559–561 electronically recorded, 561–565 ISD voice-sound recorders, 562–565 sirens, 566–567 speech synthesis, 5, 571 Yak Bak, 561–562 sounds, detecting, 21, 193. See also sound input; sound input sensors. sound waves, 193 source code. See computer languages; computer programming. spacers, surplus stores, 44 speech input or recognition, 193, 570–571 speech synthesizer, 5, 571 speed, 320–322, 330–331 weight, influence on, 322 wheel diameter, 320, 322 speed, gears, 334 speed of motors, 320, 330–331 continuous DC, 330 gear reduction, 333–338 gear train, adjusting with, 330–331 recommended, 331, 333 sprockets and roller chain, 339 bicycle chain, 339 Capsula, 135 gears, attaching to, 342 surplus stores, 44 stall current, 329 static electricity, 69–70, 90–91, 355 anti-static supplies, 90 protecting electronics from, 69–70, 89–91 steering, 313–314 555 timer, 153 Ackerman, 318 car-type, 318–319 “crabbing,” 319 differential, 318; disadvantage, 319 indoors vs. outdoor robots, 319 omnidirectional, 320 terrain type, 318 with treads, 318; military tank, 318 tricycle, 319 with wheels, 318 stepper motor control with 555 timer, 385–386 actuation, 380 Allegro Microsystems UCN5804, 381–383 with chips, 381–382 CMOS chips, 382–383, 385 with computers, 380 with flip-flop, 384, 386 with logic gates, 382–383 MOSFET, 382–383 Ohm’s law, 384 with transistors, 380 translator circuit, 382–386 with TTL chips, 382–383, 385 stepper motors, 375–391, 473, 479 acceleration, gradual, 379 actuation techniques, 376–377 bipolar, 377, 386–389 braking effect, 379 concept, 375 cost, 387, 389 vs. DC motors, 375, 379–380 design considerations, 378–380
stepper motors (Cont.): four-step sequence, 376–377 manufacturers, 389 open feedback system, 393 phases, identifying, 389 pulse rate, 378–379 rotation, amount, 378 running torque, 379 vs. servo motors, 393, 395 sources, 387, 389 step angle, 378 stepper phasing, 378 surplus stores, disadvantages, 389 testing, 387 torque, relation to motor speed, 379 unipolar, 376–381, 388–389 volt-ohm meter, 389 wave step sequence, 376 wiring, 389–391 strain gauges, 510 subsumption architecture, 670–671 Sumo-Bot, 692 Superior Electric, 389 surface mount technology (SMT) components, from hacked toys, 147 SWITCH, 267 switches from fax machines, 35 momentary on, 239–240, 502 from VCRs, 35 symbols, electrical, 61–62 TAB SumoBot, 18 Tamiya, 138–139 task-oriented control, 677–678 teaching pendant, 263–264 temperature sensors, 193, 636–638 Testor, 104 Thompson-Airpax, 387, 389 thrift stores, 35 Tilden, Mark, 138 tilt sensors, 642–652 accelerometers, 644–650; motion detection, 645, 650; piezo ceramic disc, 650–652; shock and vibration measurement, 645, 650; telerobotic control, 645 balance system, 643 types, 642–643 timers 555 timer, 153, 385–386, 394, 402, 460–461, 505, 576–577 556 timer, 402–403, 408 tools, 63–78. See also digital multimeter (DMM); logic probes; oscilloscope. electronic, 68–69 optional, 66–68 precautions, 64 required, 65–66 torque, 331–332, 348, 379, 399 touch sensors, 193, 501–516 air pressure, 516 collision vs. touch, 501 data conversion, 510–511 feelers, 502 heat, 516 LEDs, 507–508 microphones, 516 resistive bend, 516
INDEX
touch sensors, mechanical bounce, 503–504 hardware debouncer, 504–505 momentary on switch, 502 software debouncer, 505–506 switch types, 502–503 touch sensors, mechanical pressure, 508–511 ADC0808 chip, 510–511 analog-to-digital conversion, 510–511 conductive foam, 508–511; from CMOS packaging, 508; resistance of, 509; response curve, 510; setting transducer for, 509 data conversion, 510–511 strain gauges, 510 touch sensors, optical, 507–508 infrared-sensitive phototransistor, 507–508 LEDs, 507–508 touch sensors, piezoelectric, 511–516 bend sensor, 515–516 ceramic discs, 512–513 concept, 512 crystals, 511–512 kynar piezo film, 513–514 leads, attaching, 514–515 man-made, 512 as mechanical transducer, 515–516 naturally occurring, 512 tactile feedback, 596–597 voltage output, 513 toys, hacking advantages of, 131 Chaos, 137 circuit boards, 139 circuitry, reconfiguring, 141–147 disadvantages of, 131 end-of-life, 141 Erector set, 131–134 Fischertechnik kits, 135–136 for grippers, 487, 489, 494–495 K’Nex kits, 136–137 LEGO, 131 mechanical parts, 36 and modifying power supply, 140 MOVITS kits, 139 OWIKITS kits, 139 PCBs from, 141–147 Robosapien, 138 Robotix, 131, 133–135 (See also Robotix.) Rokenbok, 140 Sony Playstation controllers, 140 Tamiya, 138–139 vehicles, converted, 140 wiring, complications with, 147 Yak Bak, for sound output, 561–562 Zoob, 137 tracks, 18–19 transistors, 57–60, 351–355, 357, 359, 380 codes, unique, 57 and DC motors, 58–60 H-bridge, 58, 60; for Minibot, 109 MOSFET, 58, 60, 69, 359 NPN bipolar, 58–60 PNP bipolar, 58–60 power, 57 ratings, 57 signal, 57
TTL logic chips, 199–200, 382–383, 385 with digital input, 199 for stepper motor control, 382–383, 385 ultrasonic sound, 538–541, 595, 608–610, 655 Unix, 164 variables, 170, 173–176, 184, 222 VCRs, hacking parts, 35, 328 Vehicles, 668 velocity. See speed. vibration, consequences of with breadboards, 85 with LEGO, 135 with microphone placement for sound input, 572 with motion detectors, 534 with PCs and DVDs, 164 with PCs and hard drives, 164 vibration, measuring with tilt sensors, 645, 650 vision, robot analog vs. digital output, 589 circuit diagram, 584 electronic shutter release control, 590 filters, 586–588 laser light, 593–595; from CD player, 593 lenses, 586–588 light-to-voltage sensor, 581–582 multiple-cell light sensors, 583–585 one-cell cyclops, 581–582 passive infrared, 596 photocells, 579–582, 585 photodiodes, 580 photoresistors, 579–580 phototransistors, 580 radar, 595–596 resolution, preferred, 588–589 sensitivity to color, 580–581 spectral response, 580 with tactile feedback, 596–597 trip point, 582 ultrasonics, 595 video imagers, 521 video systems, 588–592 voltage as output, 581–582 voltage threshold, 582 Voice Direct, 570 voltage, 47–51, 55–56, 198–199, 279–280, 284–285, 293, 405 voltage divider, 396–397 voltage regulation, 292–298 voltage requirements, 290–291 voltage span, 205 volt-ohm meter. See digital multimeter (DMM). Von Newmann architecture, 158 “Waldo,” 11 Walkerbot, 431–451 with arm and hand, 450–451 batteries, 449 center of gravity, 449 frame, 431–435 insects, compared to, 449–450 legs, 435–443, 449–451 motion control, DPDT switches, 449
733
Walkerbot (Cont.): motor, 444–448 prototype, 432 weight, 431 Walt Disney effect, 668 weight, 305–311, 313 batteries, 306 camber, types, 308–309 center of balance, horizontal, 310–311 center of gravity, vertical, 311 with decks, multiple, 307–308 of drive motors, 306, 313 features that add, 306 frame, 306–307; sagging, 308–309 and motor selection, 307 operational time, 306 reducing, benefits of, 306 speed, influenced by, 322 supereffect, 306 typical, 305 with unequal distribution, 310–311 Wesley Hyatt, John, 97 wheels, 17, 311–314, 318, 320, 322, 410, 455–457 bicycle, 17 WHILE/ENDWHILE, 506 whiskers, for object detection, 542, 544, 548–555 WiFi, 658 Windows, 164 Windows CE, for PDAs, 159 wire gauge, 49–52 wireless communications, 658 wire-wrapping, disadvantages, 87 wiring color coding, 401 complications with hacked toys, 147 point-to-point, short circuits in, 86–87 wooden platforms, 14, 26–28, 111–120 balsa, 113–114; as insulator, 114 caster, stabilizing, 118–119 cutting, 114–115 direction, controlling, 118–119 dowels, 114 drilling, 115 fasteners, 118–119 hardwood vs. hardboard, 112 motorized, 116–120 motors, attaching, 118 motors, specifications, 118 paint finish, 115–116 particleboard, 112 planking, 113 plywood, 14, 26–28, 111–113; grades, 112; plan for round and square base, 117–118 shaping, 115 work space electrostatic discharge (ESD), 69–70 ESD protection kits, 70 safety, 64 setting up, 64–65 static electricity control, 69–70 tools, 65–69 WRITE statement, 260–261 zener diode, 56, 201, 292–293, 299–300
ABOUT THE AUTHORS
GORDON MCCOMB is an avid electronics hobbyist who has written for TAB Books for a number of years. He wrote the best-selling Troubleshooting and Repairing VCRs (now in its third edition), Gordon McComb’s Gadgeteer’s Goldmine, and Lasers, Ray Guns, and Light Cannons.
MYKE PREDKO has 20 years of experience in the design, manufacturing, and testing of electronic circuits. An experienced author, Myke wrote McGraw-Hill’s best-selling 123 Robotics Projects for the Evil Genius; 123 PIC Microcontroller Experiments for the Evil Genius; PIC Microcontroller Pocket Reference; Programming and Customizing PIC Microcontrollers, Second Edition; Programming Robot Controllers; and others, and is the principal designer of both TAB Electronics Build Your Own Robot Kits.
Copyright © 2006, 2001, 1987 by The McGraw-Hill Companies, Inc. Click here for terms of use.