Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 40 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
40
Dung lượng
1,03 MB
Nội dung
Table 12-1 shows a list of some specifications to several different types of microcontrollers. The number of input and output (I/O) lines represent the total number of individual control lines a microcontroller can have. This list combines both digital and analog I/O together. Digital I/O represents a data line where the input and output values are either 5 volts or 0 volts. This is to represent a binary 1 ora0—or, in other words, and on or an off state. An analog I/O signal line repre - sents a line that can interpret a variable anywhere between 0 and 5 volts. A microcontroller’s processor speed is the actual clock speed. Some microcontrollers require the four clock cycles to execute a single command, while other microcontrollers can execute a command in a single clock cycle. The time required to execute a command doesn’t represent the time required to execute a line of programming code. When you write a program, each line will use many different internal commands that the microcontroller understands; thus, program speeds are always slower than clock speeds of a microcontroller. The specificationthatis really important is the execution time, which is the number of program instructions exe - cuted per second. Notice in Table 12-1 the difference in execution times when com - pared to the clock speeds of the microcontroller. For programming space, the common term that is used to represent how much “memory” a microcontroller has is electrically erasable programmable read only memory (EEPROM), which is the number of - kilobytes of programming memory available on the microcontroller. In the microcontroller world, memory repre- sents how much variable space the program can keep track of, not the amount of 262 Build Your Own Combat Robot Feature Basic Stamp 2 Basic Stamp 2SX Basic Stamp 2P Basic Stamp 1 BasicX-24 OOPic BrainStem Handy Board Bot Board I/O Lines 18 18 12 8 16 31 25 30 38 Processor speed, MHz 20 50 20 4 8 20 40 2 8 Execution time 4000 10000 12000 2000 65000 2000 9000 N/A N/A EEPRPOM Kbytes 2 16 16 256 bytes 32 4 16 32 2 Multitasking No No No No Yes Yes Yes Yes Yes Package, inches 24-pin DIP 24-pin DIP 24-pin DIP 14-pin SIP 24-pin DIP 2×3.5 2.5×2.5 4.25×3.15 2.2×3.2 Language* Basic Basic Basic Basic Basic Basic, C, and Java TEA C Basic, C TABLE 12-1 Microcontroller Comparison n Chapter 12: Robot Brains 263 space in which programs can fit. The concept is different than how regular PCs re - fer to memory. In Table 12-1, all the values shown are in kilobytes, except for the Basic Stamp 1—which has only 256 bytes of programming space. To some people, this doesn’t sound like a lot, but 256 bytes represents quite a lot of programming space in a microcontroller. Some microcontrollers execute one command at a time, and some can execute multiple commands at the same time. For some applications, such as controlling 16 different R/C servos in an animatronics movie puppet, being able to execute multiple commands simultaneously, or multitasking, can be helpful. The microcontroller used in your bot can be either a small circuit board that connectors plug into, or a large integrated circuit. One of the common sizes for the microcontrollers is the 24-pin dual inline pin (DIP) socket. Basic Stamp started with this size, and several different companies have made Basic Stamp variants that are pin-for-pin, identical. Unfortunately, no one programming language can be used to program all microcontrollers. Many of the languages are based on the popular Basic program - ming language or the C programming language. If you know how to program in either of these languages, you should be able to program one of these microcontrollers. Basic and C are called high-level languages, and they are easy to learn and un- derstand when compared to using the assembly language. A compiler compiles (or converts) the high-level language into a low level language that the microcontroller actually understands. For example, here is a simple instruction written in Basic that is easy to understand: X = Y + Z If this is written in assembly language, it would look like this: MOVF Y,0 ADDWF Z,0 MOVWF X,0 This isn’t easy to understand. The preceding assembly language example will be different from microcontroller to microcontroller, but the Basic language will be the same regardless of the microcontroller. When you get started in the world of microcontroller programming—or, as the electrical engineers like to call it, programming embedded controllers—pick some - thing you like and stick with it until you master it. Interfacing a microcontroller with the outside world is the same regardless of which microcontroller you choose. Master the interfacing techniques on one microcontroller before you move on to another type of microcontroller. If you ever want to start a microcontroller “war,” log onto one of the robot clubs’ e-mail list servers and ask the question “What is the best microcontroller?”— and watch what happens. Many people think the microcontroller they use is the best, but there’s really only one correct answer to this question: the best microcontroller is the one that you know how to use and program. Every microcontroller has its advantages and disadvantages. Some microcontrollers have features that make certain tasks easier than other micro- controllers. For example, a number of microcontrollers have a built-in feature that can directly read in an analog voltage, and other microcontrollers have multitasking capabilities. Although users of these types of microcontrollers may claim they are better than other types of microcontrollers, that’s not necessarily true. You can always find a way to make a microcontroller work to meet your spe - cific needs, particularly if you’re handy with electronics and/or programming. A “weak” microcontroller with good programming can outperform a “good” microcontroller with bad programming. A search of the internet will yield dozens of companies that sell different types of microcontrollers. All of the different manufacturers have documentation that explains the capabilities of their products, an explanation of the programming language, and sample programs that illustrate the microcontrollers’ capabilities. When selecting a microcontroller, keep in mind what you want it to do, and com- pare it with the literature you have collected. Then choose the microcontroller based on how well it can fit your needs and how well you understand its program- ming language. The next few sections offer a short introduction to several of the popular avail- able microcontrollers, and at the end of this chapter is a short discussion of microcontroller applications. Basic Stamp Throughout this book are many references to the Basic Stamp from Parallax, Inc. Basic Stamp applications include servo mixing—reading R/C servo signals to op - erate switches to turn on weapons. For the beginner getting started with microcontrollers, the Basic Stamp is prob - ably the best unit to start with. Parallax has created a rather extensive set of tutori - als on how to use microcontrollers, basic programming, electronics, sensor integration, and actuator applications. All of its easy-to-understand tutorials can be downloaded from its Web site for free. Probably the best place to learn about microcontrollers is to purchase one of Parallax’s Board of Education Robotic (BoeBot) Kits and go through all of their experiments—see Figure 12-2. After you have worked through the tutorials, you should have a pretty good understanding of how to use a Basic Stamp inside com - bat robots. An excellent book on the subject is Programming and Customizing the Basic Stamp by Scott Edwards. 264 Build Your Own Combat Robot Most Basic Stamp units come in 24-pin, dual-inline packages (see Figure 12-3). They can be plugged into a prototyping board, and a 9-volt battery is all that is needed to supply power to the unit. With some wire and a few resistors and capac- itors, you can be up and running with your first Basic Stamp application. Chapter 12: Robot Brains 265 FIGURE 12-2 The BoeBot from Parallax, Inc. (courtesy of Parallax, Inc.) FIGURE 12-3 Parallax’s new Basic Stamp module called the BS2p. (courtesy of Parallax, Inc.) To program a Basic Stamp microcontroller, you will need a PC that runs Win - dows or DOS. The language is relatively simple for most of us to learn, because it is based on the BASIC computer language. Parallax had to make a few modifica - tions to the language to make it work with Parallax products, but it is quite easy to learn and get up to speed with. BrainStem The BrainStem, by Acroname, Inc., is a new microcontroller board that has entered into the robotics community. This miniature microcontroller has been showing some really unique capabilities. Table 12-1 lists some of its specifications. The programming language used is called TEA, or Tiny Embedded Application, which is almost identical to the industry-standard ANSI C. This microcontroller is shown in Figure 12-4. It has some interesting features that are not found on other microcontrollers, including four dedicated radio controlled (R/C) servo ports. Thus, without any special programs, you can control four different servos, or four different electronics speed controller (ESCs). It also has a built-in port for control- ling the Sharp GP2D02 Infrared range sensor. The BrainStem has software library support for Java, C, and C++ on Microsoft’s Windows systems, and the PalmOS, MacOS, and Linux computer operating systems. 266 Build Your Own Combat Robot FIGURE 12-4 BrainStem microcontroller (courtesy of Acroname, Inc.) Chapter 12: Robot Brains 267 Handy Board The Handy Board is a powerful veteran microcontroller board that has been around for a long time. First developed at MIT (Massachusetts Institute of Tech - nology) by Fred Martin, this microcontroller board uses the popular 68HC11 microcontroller from Motorola. The programming environment is called Interac - tive C, which is similar to the traditional ANSI C. This microcontroller has four built-in motor controllers for directly driving four different very-low-current (< 1.0 amps) motors, and it has a built-in liquid crystal display (LCD) screen for displaying information. BotBoard The BotBoard was developed by Kevin Ross and Marvin Green using the same 68HC11 microcontroller used by the Handy Board.The size of this board is signif - icantly smaller, however, and it doesn’t have the built-in features of the Handy Board. Because many people didn’t want those extra features, this board offers a smaller and lower-cost solution to obtain the same level of power of the Handy Board. Karl Lunt has developed a version of the Basic programming language for the 68HC11 microcontrollers, which is called Sbasic. You can download it from Karl’s Web site at www.seanet.com/~karllunt/. Karl is also the author of an excel- lent book about robots called Build Your Own Robot (see Appendix B). Other Microcontrollers Many other microcontrollers are out there. The OOPic uses an object-oriented programming language. The BasicX-24 and Basic Micro’s Atom look almost like the Basic Stamp and are pin-for-pin compatible, but are faster, have more program - ming space, and uses a multitasking operating system. These microcontrollers are starting to gain a lot of popularity. A high-end microcontroller is the Robominds microcontroller, which uses the Motorola 68332, 32-bit microcontroller. It’s very fast and very powerful. Most of the microcontroller boards described here use either the Microchip PICs, the Atmel AVR chips, or the Motorola 68HC11 or 68HC12 chips as the core microcontroller. All of these microcontroller board companies have added some components to their boards to make their microcontrollers easy to use. When you get more experienced with microcontrollers, try experimenting directly with the PICs and the AVR chips. They are the microcontrollers found in most electronic appliances and systems. 268 Build Your Own Combat Robot Following is a short list of some of the most-popular microcontroller Web sites: ■ Basic Stamps www.parallaxinc.com ■ BrainStem www.acroname.com ■ BasicX www.basicx.com ■ OOPic www.oopic.com ■ Handy Board www.handyboard.com ■ BotBoard www.kevinro.com ■ PIC www.microchip.com ■ Basic Micro, Atom Chip www.basicmicro.com ■ 68HC11 and 68HC12 www.motorola.com ■ Robominds www.robominds.com ■ AVR www.atmel.com M icrocontroller Applications The following discussion offers several examples of the various applications for which microcontrollers can be used. Although they are not directly associated with combat robots, these features can be adapted to building combat robots. All of these examples are based on the BrainStem microcontroller from Acroname. Keep in mind when reading the following examples that virtually any microcontroller can be used to accomplish these applications. The Robo-Goose The Robo-Goose is a robot that can be driven by a human operator via remote control. The operator drives the robot using a standard R/C-type transmitter (much like a combat robot). What is different here is that the receiver sends the control commands into a BrainStem microcontroller module that manipulates the input and translates it into meaningful output for the motors on the goose. One input determines the steering and the other the speed of the goose. The BrainStem is performing a servo mixing function. Figure 12-5 shows a photo - graph of the Robo-Goose. Chapter 12: Robot Brains 269 The mechanics for the Robo-Goose are two thruster motors lying below the surface in the water that can run to create forward or reverse thrust in the goose, as shown in Figure 12-6. FIGURE 12-5 Robo-Goose, a robotic goose that is controlled by a traditional R/C system and a BrainStem microcontroller to perform a servo mixing function. (courtesy of Acroname) FIGURE 12-6 The underwater thruster system used with the Robo-Goose. (courtesy of Acroname) 270 Build Your Own Combat Robot The Robo-Goose demonstrates an important concept in robotics control that we will call microcontroller assisted control. The inputs coming from the operator are translated into commands that affect certain motions on the robot. In mathe - matics, this is called a mapping; and in the case of the goose, two inputs (steering and forward motion) are translated, or mapped, into forward and reverse com - mands for the right and left thruster motors on the goose. The BrainStem Bug The BrainStem bug also uses microcontroller-assisted control to manipulate many different outputs from two simple inputs. The two outputs from the R/C receiver are fed into a small parallel microcontroller core consisting of three networked BrainStem controllers. Each BrainStem controls two legs, one for the front pair, one for the middle, and one for the back pair of legs. Figure 12-7 shows a photo - graph of the walking robot. Simple forward and backward commands from the transmitter are translated into complex walking patterns with six servo actuators controlling the left legs and six more controlling the right legs of the robot. In this case, the assistance of the computer becomes crucial to the operation of the robot. Twelve servo actuators control the robot, and complex patterns are used to make the robot walk forward and backward, turn right and left, and even spin right or left while stepping in place. FIGURE 12-7 BrainStem bug, a six-legged walking robot that uses three BrainStems to interpret two R/C input signals to control 12 different servos. (courtesy of Acroname) Chapter 12: Robot Brains 271 Imagine trying to control the same robot with 12 sticks on the R/C transmitter while trying to do battle with another robot that is speeding toward you. The com - puter-enhanced R/C is crucial to sophisticated mechanical designs. 1BDI, an Autonomous Robot 1BDI takes the microcontroller control to the limit by completely controlling the robot without a human operator. This robot was designed to find a lit candle in a maze using vision, put out the candle using a fan, and then find its way out of the maze using its memory of how it got to the candle in the first place. Figure 12-8 shows a photograph of this fire-fighting robot. The heart of 1BDI’s control is a BrainStem controller that is running a TEA program to read input from the sensors and to control the motors. The robot has various sensors to find walls using infrared light, to find lines on the floor using re - flected light, and to sense whether the wheels have stopped spinning or not. 1BDI also has a secondary microcontroller system driven by a BSX-24 microcontroller that does vision processing from a charge-coupled device (CCD) camera similar to what you might find in a hand-held commercial digital camcorder. The CCD array takes an image, and the BSX-24 processes the data to seek out the distinct shape of the candle. The BSX-24 can also distinguish yellow tubes placed in the robot’s path that are meant to be color-keyed furniture for the robot to avoid. The programming for autonomous robots is typically much more so- phisticated than that of microcontroller-assisted robots. Every possibility the ro- bot may encounter must be handled so that the robot is not easily disabled. Building a robust autonomous robot is at the forefront of today’s research in both robotics and artificial intelligence. FIGURE 12-8 A fully autonomous robot, named 1BDI, built to compete in the fire-fighting contest. (courtesy of Acroname) [...]...272 Build Your Own Combat Robot The Rover, Teleoperated with Feedback The Robo-Goose uses one-way communications to control the robot If you drive the robot out of view around a clump of trees, you will have little luck in driving the robot back into view because you have no feedback from the robot The Rover was designed to give more feedback to the... loses the round 277 2 78 Build Your Own Combat Robot In robotic sumo, there are three rounds in a match, and the first bot to win two rounds wins that match In robotic sumo, there are two different general classifications: remote-controlled sumo bots, and fully autonomous sumo bots The difference between the two, obviously, is that an autonomous sumo bot must operate completely on its own No form of human... with any special amendments to the rules that are club specific An excellent illustrated guide to American robot sumo, created by David Cook, is located at www.robotroom.com/SumoRules.html This guide also lists several of the robot sumo clubs throughout the world 279 280 Build Your Own Combat Robot The Sumo Ring Specification The sumo ring is basically a large, smooth, flat disk made from solid black... infrared phototransistor built into a single small package Both of these sensors operate well at distances from 0.04 to 0.20 inches from the surface FIGURE 13-7 Mini sumo body assembly 287 288 Build Your Own Combat Robot FIGURE 13 -8 Schematic of a simple infrared detector pair for sumo edge detection (courtesy of Bill Harrison) Two different sensor packages should be used in a mini sumo Each sensor should... the growth in popularity of a more aggressive form of robot combat the kind of contests fought on BattleBots, Robot Wars, Bot Bash, and Robotica As exciting as these contests may be to watch and participate in, the costs to build these bots are significantly higher than those in sumo robotics Most of the BattleBots-type robots cost at least $3,000 to build, and some of them cost more than $40,000 On the... for miniature robotics applications, such as a mini sumo bot FIGURE 13-4 The internal potentiometer retaining plate found inside a Futaba FP-S1 48 server 283 284 Build Your Own Combat Robot FIGURE 13-5 Cutting off the feedback shaft inside an R/C server Building a Mini Sumo The main components of a mini sumo are a body frame, motors, wheels, microcontroller, sensors, and batteries For this project, we’ll... popular robot contests in the world Robot sumo was originally started in Japan in the late 1 980 s by Hiroshi Nozawa, and was later introduced to United States robotics clubs by Dr Mato Hattori Robot sumo is a robotic version of one of Japan’s most popular sports, sumo wrestling Instead of two humans trying to push each other out of a sumo ring, two robots attempt the same feat Since its creation, robot. .. drive the robot back into the obstruction as the robot gets closer to the obstruction You could call this “driving by Braille,” as the sense of touch is being simulated and vision is not being used In a combat robot, you will be able to see the environment around the robot, but what about what is happening inside the robot? Is a motor overheating, are the batteries going dead, did one of your drive... mini sumo around like a tank—each stick controls each wheel To get better driving control where one stick is used for forward and reverse control, and the other stick is used for turning 285 286 Build Your Own Combat Robot left or right, an elevon/v-tail mixer can be placed between the R/C receiver and the R/C servos The mixer can be obtained at most hobby stores At this point, you will be ready to compete... four gears on the top of the servo Carefully lift the top middle gear off the center spindle shaft, and set down inside the top of the case Then pull the output gear/shaft from the servo 281 282 Build Your Own Combat Robot FIGURE 13-2 Internal gears to a standard R/C servo You’ll notice a small brass shaft from a potentiometer The potentiometer is used to monitor the actual position of the servo’s output . of 262 Build Your Own Combat Robot Feature Basic Stamp 2 Basic Stamp 2SX Basic Stamp 2P Basic Stamp 1 BasicX-24 OOPic BrainStem Handy Board Bot Board I/O Lines 18 18 12 8 16 31 25 30 38 Processor speed, MHz 20. both robotics and artificial intelligence. FIGURE 12 -8 A fully autonomous robot, named 1BDI, built to compete in the fire-fighting contest. (courtesy of Acroname) 272 Build Your Own Combat Robot The. by Bill Harrison of SineRobotics. Except for the weight of the bot, every other specifi - cation is exactly half of the international sumo class. 2 78 Build Your Own Combat Robot The size specifications