Robotic Systems ECE 401RB Fall 2007 Lecture 7: Processors Part 1 The following notes are from: Chapter 12, G. McComb, and M. Predko, Robot Builder's Bonanza, Third Edition, Mc- Graw Hill, 2006. I. Introduction Some consider machines to be robots if they are at least remote controlled. But this leaves the intelligence in the hands of the remote controller. These robots may still have sensors. But the sensor information must be sent to the remote controller to make the control decisions. What types of sensors might provide this type of feedback to a remote controller? Touch Vision Chemical Maybe sound But most would say a robot needs to have autonomy. Receive sensor inputs. Process and interpret the sensor inputs. Make decisions. According to some plan or objective. - Carrying out specific, pre-planned actions. In response to sensor inputs. - Adjusting the plan given sensor inputs. - Responding to unexpected sensor inputs. - Like those that indicate danger to the robot. Lecture 7, Page 1 of 21
A computer of one type or another, therefore, needs to be present within a robot. Can consist of a simple assortment of electronic components. Up to an advanced computer. And the computer must be able to interface with all of the other parts of the robot. Sensors Motors Power distribution II. Intelligence from Discrete Components Discrete components can be used by themselves to control a robot. No microprocessor. Using transistors, resistors, etc. Given the knowledge from your lab, how could a light following robot be designed purely from discrete components? Light sensor could be used as a switch. Turn on the motors when the light is in front of the robot. Lecture 7, Page 2 of 21
This makes the robot reverse direction upon seeing bright light. Light shining on the photodetector turns on the circuit. Which turns on a relay to reverse the motor. You can also reverse the polarities to make the robot follow the light instead. No turning is possible for this simple case. How could the robot be improved to turn to follow the light? Two light sensors. One connected with each motor. The designer is the one providing the intelligence here, not much from the robot. - Although sensing the light is a very simple form of intelligence. Lecture 7, Page 3 of 21
Additional simple circuitry could be added. A 555 timer could be used to create time delays. For example, run for 5 seconds then stop. To wait a time delay before moving. Etc. The biggest problem with this type of robot is configurability. Hardware changes are required each time the behavior of the robot is to be changed. New wiring. Using breadboards, but breadboards can have loose connections. III. Line Tracing Example This can be accomplished using a few integrated logic circuits and a small assortment of transistors and resistors. Assume some kind of high contrast line is placed on the floor. White on black or black on white does not matter. Use an LED to illuminate below the robot and a phototransistor to sense the reflected light. These two devices paired together in a package are commonly available. Mount detectors on the bottom for the robot. Two detectors set apart roughly twice the width of the line. Lecture 7, Page 4 of 21
Then use a sensor circuit that provides an output if the light is detected. R2 determines the sensitivity of the phototransistor and its voltage range. The output is sent to a comparator circuit. Lecture 7, Page 5 of 21
These are integrated into an overall motor control circuit. And finally, relays control the motors. Lecture 7, Page 6 of 21
Here is the list of parts used for this example. Adjustments The robot may waddle it was down the track. - Overcorrecting for errors each time. This depends on the switching speed of the relays. - Faster-acting relays would create smoother movement. Also, the sensors could be placed a different distance apart. - Closer together or farther apart would make the robot jerk back and forth less? Farther apart would mean longer times between switching. Closer would mean faster switching, but less distance each time. Lecture 7, Page 7 of 21
How would a computer controlled approach help here? It could use the history of the readings to know how quickly to respond. It could respond more gradually over time depending on how much correction is needed. IV. Intelligence from Microcontrollers Here software changes are all that is required Not necessarily hardware changes. Options for computer control Microcontroller Personal Digital Assistant, like a Palm Pilot. Single-board computer Personal computer motherboard or laptop. Microcontrollers are a very good option Low cost Simple power requirements Usually 2.5 V to 5 V. Most can be programmed using software. Create the program on a PC. Then download the program to the microcontroller using a simple hardware interface. The microcontroller operates on its own once disconnected from the PC. Lecture 7, Page 8 of 21
There are literally hundreds of choices of microcontrollers. What do you imagine are the differences between them? Cost (as little as $1.00) Available inputs/outputs. Ease of programming. Programming language. Size Power requirements. People will frequently keep using the same controller. Once they have experience with it and its programming procedures. Microcontrollers do not have large, complicated operating systems. Operation is quite simple. Requires a few configuration commands. Otherwise, software is quite straightforward. The programming module can be costly. Much more costly than the microcontroller itself. There are two forms that a program can take. A regular program, compiled down to machine code as in a normal computer. Referred to as stand-alone microcontrollers. Can usually be programmed in a variety of high-level languages. - Like C, BASIC, Java. Lecture 7, Page 9 of 21
A program which makes use of special instructions available from the microcontroller. May have a series of very complex commands that can be used. This simplifies the work of the person writing the program, since important functions are already created. Referred to as a bootloader-equipped microcontroller. - The bootloader adds the special commands. Programmed in a predetermined high-level language. - For example, the BASIC Stamp 2 uses BASIC. Microcontrollers are available at 8, 16, or 32-bit processors. Most robot applications do not require more than eight bits. Complete Computer System on a Chip A key benefit of microcontrollers is that they combine a microprocessor component with various I/O that are typically needed to interface with the real world. Example configuration of the 8051 microcontroller. - CPU - CPU reset and clocking support circuitry. - Hardware interrupts - Built-in timer or counter. - Programmable full-duplex serial port. - 32 I/O lines Some microcontrollers have greater or fewer I/O lines. Not all have hardware interrupt inputs. Some also have analog-to-digital conversion. Some have voltage comparison. A big plus is the CPU reset and clocking support circuitry. The microcontroller, therefore, only needs a power input and decoupling capacitor. Unlike TTL or CMOS which need clocks. Lecture 7, Page 10 of 21
Program and Data Storage A low-cost microcontroller will only have a few thousand bytes of program storage. This may seem small. But this amount of memory is usually more than adequate. Possibly depending on the programming method. Two options for use of memory One common area for all programs and data storage. - With a single data bus. - Called a Princeton or Von Neumann architecture. - This is common also on standard desktop computers. Lecture 7, Page 11 of 21
Programs stored in one place and data in another. - Two buses are used. - Most modern microcontrollers use this. - Called the Harvard architecture. The difference between the two is not trivial. - The Harvard architecture can run faster, since it can fetch programs and data simultaneously. - The Von Neumann architecture must switch between programs and data. - But the Von Neumann architecture is superior for real-time operating systems. The Harvard architecture will use EEPROM (electronically erasable programmable ROM) for programs and RAM for data. A version of EEPROM used often is Flash. Two data storage specifications will commonly be seen for microcontrollers. Programming will be different for the two different architectures. At the assembler level. Should be no different when using a high-level language. Chip Programming Programming is now much easier than it used to be. Older microcontrollers used PROM and EEPROM that required tools to erase them before a new program could be burned into them. All microcontrollers have programmers. Not people programmers, but software to program the microcontrollers. Range in price from $25 to several thousand dollars. An important consideration is debugging features and capabilities. And how the hardware accomplishes the debugging. Lecture 7, Page 12 of 21
V. Personal Digital Assistants Palm pilots and other personal digital assistants (PDAs) can be used as a small robot controller. They have many of the advantages of microcontrollers. But what additional advantages do they provide? Power supply LCD display Stylus, and maybe small keyboard input. No need for a separate computer to create programs. Good volatile and non-volatile storage. What do you suppose is the main difficulty with using PDAs? Interfacing with motors and sensors. Two types of PDAs to consider. Palm O/S Has several programming languages and native programming environments that could be considered. - The HotPaw BASIC programming environment is very popular. - Lets a programmer develop, compile, and run BASIC applications on a PDA. Lecture 7, Page 13 of 21
There are lots of older Palm devices that could be used. - And obtained at a low cost. Windows CE Offers essentially the same features as Palm devices. Microsoft offers a number of embedded Visual Tools for CE devices. - Included embedded Visual BASIC. - Which can be written and tested on a PC before downloading to a PDA. Two choices for connecting the PDA to the robot. Serial port Similar to a PC s RS-232 port. - Although it does not implement all handshaking or produce valid RS-232 voltage levels. This is a lower cost option. Infrared IRDA data port. Fairly high speed (9.6 to 115.2 kbps). Uses a complex communications protocol. A number of chips are available that can implement this interface. Only can communicate reliably over ranges less than 1 meter. A direct electrical connection between the PDA and the robot is avoided. - Eliminates possible problems with electrical noise. An intelligent device is still also needed. It uses a serial connection with the PDA. - And interfaces with the sensors and motors. This can be found in a pre-packaged serial interface chip. - Or another small microcontroller could be used. VI. Single-Board Computers An older approach was to use single-board computers (SBCs). Could be programmed like microcontrollers. In assembly language or a higher level language. But also have the I/O interfaces already implemented. Built-in RS-232 or Ethernet interfaces. So application transfer is simple. Lecture 7, Page 14 of 21
The PC/104 form factor was commonly used. Offered tremendous flexibility but at fairly high cost. Most modern single-board computers are really full PCs built into a small circuit board. A very popular form-factor is the mini-itx. A complete PC in 6.7 inches by 6.7 inches. Supports many megabytes of memory. Can run Windows or Linux. - So standard PC development tools can be used. What do think are the downside of using SBCs? Power requirements several voltages and high capacity batteries that heavy. Installing and running a full operating system. I/O operations. Several voltages are needed. - High capacity batteries and several voltage regulator circuits are needed. - Weight and size of these results in SBCs only being used in large robots. Disk drives are unreliable in a robot. Why? Robots vibrate and move. - Disk drives also require a great deal of power. I/O interfacing would usually need to come through USB ports. - Functions can be sophisticated and difficult to program. Despite the downsides, SBCs offer good possibilities. Debugging is quite simple. Could add wireless capabilities with very little work. - Like streaming video. Lecture 7, Page 15 of 21
Single-board computer kits There are several popular SBCs available as kits. BotBoard Miniboard HandyBoard - Designed by instructors at MIT. VII. Personal Computers A personal computer can be used to control a robot. Constantly tethered to the computer, since the computer gives the commands. By cable. Or by wireless. But the computer can go with the robot. Computer would be on board the robot, so it would need to be small size. But still only feasible for large robots. Power supply requirements would be hard to meet. Several supply voltages. Lots of power. Need to be able to access I/O. I/O cards designed for USB ports are available. Must be able to program the computer to control the robot. Must adapt the mass storage capability. Disk drives are not practical. Should be able to boot and run completely from a USB flash drive. Need detailed technical information about the computer. Lecture 7, Page 16 of 21
A PC may seem an unlikely option for robot control. Why might there still be advantages to using a PC? Expansion slots. Large software base. Readily available technical information. Easy to obtain at a low cost. Used, old machines can be obtained at thrift stores or on-line auctions. - As long as an older machine still has software support. - Operating system, applications, drivers, etc. Do not install the entire PC. Only use the motherboard. - Will require tight voltage regulation. - Newer motherboards are much more efficient regarding power consumption. Or use a laptop. - Do not try to use the laptop batteries to power other parts of the robot. - Some batteries will automatically shut off, others will run down faster and could be damaged. Make sure BIOS can be adjusted. - To run without a keyboard. - To run without a display. Lecture 7, Page 17 of 21
Operating system choice is very important. Determine what features are needed. See what can be loaded or not loaded. The graphical user interface (GUI) is a big use of resources and memory. Without the GUI, the operating system might take up a fairly small amount of space on a USB drive. See what tools are available with that operating system. There are a variety of open source tools available. There are several Linux robotic communities. VIII. Inputs and Outputs Microcontrollers provide a basic, two-state input and output of 0 or +5 volts. These need to be translated to outputs for sensors and motors. And allow for inputs from a variety of sensors. They also provide serial communications. This is the most common form of computer interfacing. Multiple bits are sent in a stream over time on a single wire. Several formats are used. - Depending on how the communication is to occur - Depending on the need to have regularly occurring edges for clock synchronization. Lecture 7, Page 18 of 21
Synchronous serial communications are the most likely to be used. Three most common types of synchronous serial communications. Inter-integrated circuit (I2C) - Created by Phillips. - Two or more microcontrollers can communicate. - One is a master, the others are slaves. - Slaves can be special devices for interrogating sensors or operating motors. Microwire - By National Semiconductor - Used for interfacing a microcontroller with electronics. - Such as memory and analog-to-digital convertors. Serial peripheral interface (SPI) - By Motorola Lecture 7, Page 19 of 21
Asynchronous serial communications The beginning of a transmission is indicated by a start bit. An error control bit can be placed at the end of the data bits. Like the parity bit we saw in an earlier lecture. But this is rarely used. - Since cables are not usually very noisy. Would be different if using wireless. Most popular approach is RS-232 (more accurately EIA-232). Uses +12 V and 12 V instead of TTL 0 and +5 V. Data Conversion Analog-to-Digital converters (ADCs) And conversely DACs. Transform analog voltages to digital, binary values. Could be on a separate circuit. Could be included in the microcontroller. Lecture 7, Page 20 of 21
Comparators Can compare a voltage against some setpoint. Then the output is high or low to indicate above or below the setpoint. Other inputs and output Timers to determine the frequency of an incoming digital signal. PWM outputs Can be used with a capacitor and resistor to create a rudimentary form of digital-to-analog conversion. Can create a sound output. What other use have we seen of this? Speed control of a DC motor. Pulse accumulators Automatic counters. Usually can be doing counting when the rest of the microcontroller is doing something else. Hardware interrupts Special inputs to get the attention of the microcontroller. Microcontroller temporarily suspends normal program execution to run an interrupt handling subroutine. External reset To reset the microcontroller. Switch debouncer To ignore the temporary noise when a switch is closing. Input pull-up Resistors to keep from seeming like there is a signal when the microcontroller is not generating one. Lecture 7, Page 21 of 21