McGraw-Hill - The Robot Builder''''s Bonanza Episode 2 Part 4 docx

35 233 0
McGraw-Hill - The Robot Builder''''s Bonanza Episode 2 Part 4 docx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Q1 4011 (1/4) V+ 1 2 3 g d s 7 14 Control Control Load Q1 4011 (1/4) V1+ 1 2 3 g d s 7 14 Load V2+ FIGURE 29.4 Power MOSFET inter- face. +V Q1 Q2 Q3 Q4 4011 (1/4) +12V 1 2 3 4 5 6 g g d d g d s s s 7 14 0.1 C1 0 1Forward Reverse Direction control g d s M1 4011 (1/4) D1 D3 D2 D4 D1-D4: 1N4002 Q1-Q4: n-channel MOSFET FIGURE 29.5 Discrete component H-bridge interface. Ch29_McComb 8/18/00 2:16 PM Page 441 V+ M1 Enable/PWM Direction Brake FIGURE 29.6 Packaged H-bridge interface. V+ 4 6 2 3 7 Input Output + - 741 FIGURE 29.7 Non-inverting buffer follower interface. S1 Microprocessor/ microcontroller input FIGURE 29.8 Direct connection of switch/digital input. 555 120K S1 0.1 +V 6 7 2 3 10K Microprocessor/ microcontroller input FIGURE 29.9 Switch debouncer input. Ch29_McComb 8/18/00 2:16 PM Page 442 Fig. 29.11 shows how to interface TTL (5 volt) to CMOS circuits that use different power sources (use this circuit even if both circuits run under ϩ5 vdc). Fig. 29.12 shows the same concept, but for translating CMOS circuits to TTL circuits that use different power sources. USING OPTO-ISOLATORS Note that in both circuits the ground connection is shared. You may wish to keep the power supplies of the inputs and control electronics totally separate. This is most easily done using opto-isolators, which are readily available in IC-like packages. Fig. 29.13 shows the basic concept of the opto-isolator: the source controls a light-emitting diode. The input of the control electronics is connected to a photodetector of the opto-isolator. Note that since each “side” of the opto-isolator is governed by its own power supply, you can use these devices for simple level shifting, for example, changing a ϩ5 vdc sig- nal to ϩ12 vdc, or vice versa. ZENER DIODE INPUT PROTECTION If a signal source may exceed the operating voltage level of the control electronics, you can use a zener diode to “clamp” the voltage to the input. Zener diodes act like valves that turn on only when a certain voltage level is applied to them. As shown in Fig. 29.14, by putting a zener diode across the ϩV and ground of an input, you can basically shunt any excess voltage and prevent it from reaching the control electronics. INTERFACING DIGITAL INPUTS 443 S1 Microprocessor/ microcontroller input Buffer or interver (Schmitt trigger shown) +V or Gnd FIGURE 29.10 Buffer input. Output +5vdc Input 1K 10K 2N2222 e b c TTL (Any Gate) CMOS (Any Gate) +12vdc (or higher than TTL supply) FIGURE 29.11 TTL-to-CMOS translation interface. Ch29_McComb 8/18/00 2:16 PM Page 443 Zener diodes are available in different voltages; the 4.7- or 5.1-volt zeners are ideal for interfacing to inputs. Use the resistor to limit the current through the zener. The wattage rating of the zener diode you use depends on the maximum voltage presented to the input as well as the current drawn by the input. For most applications where the source signal is no more than 12–15 volts, a quarter-watt zener should easily suffice. Use a higher wattage resistor for higher current draws. 444 INTERFACING WITH COMPUTERS AND MICROCONTROLLERS Output +5vdc Input 1K 10K 2N2222 e b c +12vdc (or higher than TTL supply) CMOS (Any Gate) TTL (Any Gate) FIGURE 29.12 CMOS-to-TTL translation interface. Input Output +5vdc 4.7K 680Ω +V Opto-isolator FIGURE 29.13 Opto-isolator. Zener Limiting resistor (as needed) Zener Output Input FIGURE 29.14 Zener diode shunt. Ch29_McComb 8/18/00 2:16 PM Page 444 Interfacing Analog Input In most cases, the varying nature of analog inputs means they can’t be directly connected to the control circuitry of your robot. If you want to quantify the values from the input you need to use some form of analog-to-digital conversion (see the section “Using Analog-to-Digital Conversion” later in this chapter for more information). Additionally, you may need to condition the analog input so its value can be reliably mea- sured. This may include amplifying and buffering the input, as detailed later in this section. VOLTAGE COMPARATOR The voltage comparator takes a linear, analog voltage and outputs a simple on/off (LOW/HIGH) signal to the control electronics of your robot. The comparator is handy when you’re not interested in knowing the many possible levels of the input, but you want to know when the level exceeds a certain threshold. Fig. 29.15 shows the voltage comparator circuit. The potentiometer is used to determine the “trip point” of the comparator. To set the potentiometer, apply the voltage level you want to use as the trip point to the input of the comparator. Adjust the potentiometer so the output of the comparator just changes state. Note that the pullup resistor is used on the out- put of the comparator chip (LM339) used in the circuit. The LM339 uses an open collec- tor output, which means that it can pull the output LOW, but it cannot pull it HIGH. The pullup resistor allows the output of the LM339 to pull HIGH. SIGNAL AMPLIFICATION Many analog inputs provide on and off signals but not at a voltage high enough to be use- ful to the control electronics of your robot. In these instances you must amplify the signal, which can be done by using a transistor or an operational amplifier. The op-amp method is the easiest in most cases, and the LM741 is probably the most commonly used op-amp. Fig. 29.16 shows the basic op-amp as an amplifier. R1 sets the input impedance of the amplifier; R2 sets the gain. INTERFACING ANALOG INPUT 445 +12vdc 3 12 2 4 5 R2 10K Output 339 IC2 Input Reference voltage FIGURE 29.15 Voltage comparator input. Ch29_McComb 8/18/00 2:16 PM Page 445 SIGNAL BUFFERING The control electronics of your robot may “load down” the input sources that you use. This is usually caused by a low impedance on the input of the control electronics. When this happens, the electrical characteristics of the sources change, and erratic results can occur. By buffering the input you can control the amount of loading and reduce or eliminate any unwanted side effects. The op-amp, as shown in Fig. 29.17, is but one common way of providing high-imped- ance buffering for inputs to control electronics. R1 sets the input impedance. Note that there is no R2, as in Fig. 29.18. In this case, the op-amp is being used in unity gain mode, where it does not amplify the signal. OTHER SIGNAL TECHNIQUES FOR OP-AMPS There are many other ways to use op-amps for input signal conditioning, and they are too numerous to mention here. A good source for simple, understandable circuits is the Engineer’s Mini-Notebook: Op-Amp Circuits, by Forrest M. Mims III, which is available through Radio Shack. No robotics lab should be without Forrest’s books. COMMON INPUT INTERFACES Figs. 29.18 and 29.19 show common interfaces for analog inputs. These can be connected to analog-to-digital converters (ADC), comparators, buffers, and the like. The most com- mon interfaces are as follows: ■ CdS (cadmium-sulfide) cells are, in essence, variable resistors. By putting a CdS cell in series with another resistor between the ϩV and ground of the circuit, a varying volt- age is provided that can be read directly into an ADC or comparator. No amplification is typically necessary. ■ A potentiometer forms a voltage divider when connected as shown in Fig. 29-19. The voltage varies from ground and ϩV. No amplification is necessary. ■ The output of a phototransistor is a varying current that can be converted to a voltage by using a resistor. (The higher the resistance is, the higher the sensitivity of the device.) The output of a phototransistor is typically ground to close to ϩV, and therefore no fur- ther amplification is necessary. 446 INTERFACING WITH COMPUTERS AND MICROCONTROLLERS IC1 741 +V 2 3 + - 6 4 7 R1 R2 Input Output FIGURE 29.16 Op-amp amplifier. Ch29_McComb 8/18/00 2:16 PM Page 446 ■ Like a phototransistor, the output of a photodiode is a varying current. This output can also be converted into a voltage by using a resistor (see Fig. 29.18). (The higher the resistance, the higher the sensitivity of the device.) This output tends to be fairly weak— on the order of millivolts instead of volts. Therefore, amplification is usually required. Using Analog-to-Digital Conversion Computers are binary devices: their digital data is composed of strings of 0s and 1s, strung together to construct meaningful information. But the real world is analog, where data can be most any value, with literally millions of values between “none” and “lots”! Analog-to-digital conversion is a system that takes analog information and translates it into a digital, or more precisely binary, format suitable for your robot. Many of the sensors USING ANALOG-TO-DIGITAL CONVERSION 447 +V 2 3 + - 6 4 7 Output IC1 741 R1 Input FIGURE 29.17 Op-amp buffer. +V Light-dependent resistor (CdS cell) Output FIGURE 29.18 Voltage divider. +V Potentiometer Output FIGURE 29.19 Potentiometer. Ch29_McComb 8/18/00 2:16 PM Page 447 you will connect to the robot are analog in nature. These include temperature sen- sors, microphones and other audio transducers, variable output tactile feedback (touch) sensors, position potentiometers (the angle of an elbow joint, for example), light detectors, and more. With analog-to-digital conversion you can connect any of them to your robot. HOW ANALOG-TO-DIGITAL CONVERSION WORKS Analog-to-digital conversion (ADC) works by converting analog values into their binary equivalents. In most cases, low analog values (like a weak light striking a photodetector) might have a low binary equivalent, such as “1” or “2.” But a high analog value might have a high binary equivalent, such as “255” or even higher. The ADC circuit will convert small changes in analog values into slightly different binary numbers. The smaller the change in the analog signal required to produce a different binary number, the higher the “resolution” of the ADC circuit. The resolution of the conversion depends on both the voltage span (0–5 volts is most common) and the number of bits used for the binary value. Suppose the signal spans 10 volts and 8 bits (or a byte) are used to represent various lev- els of that voltage. There are 256 possible combinations of 8 bits, which means the span of 10 volts will be represented by 256 different values. Given 10 volts and 8 bits of conversion, the ADC system will have a resolution of 0.039 volts (39 millivolts) per step. Obviously, the resolution of the conversion will be finer the smaller the span or the higher the number of bits. With a 10-bit conversion, for instance, there are 1024 possible combination of bits, or roughly 0.009 volts (9 millivolts) per step. INSIDE THE SUCCESSIVE APPROXIMATION ADC There are a number of ways to construct an analog-to-digital converter, including succes- sive approximation, single slope, delta-sigma, and flash. Perhaps the most commonly used is the successive approximation approach, which is a form of systematized “20 questions.” The ADC arrives at the digital equivalent of any input voltage within the expected range by successively dividing the voltage ranges by two, narrowing the possible result each time. Comparator circuits within the ADC determine if the input value is higher or lower than a built-in reference value. If higher, the ADC “branches” toward one set of binary values; if lower, the ADC branches to another set. While this sounds like a roundabout way, the entire process takes just a few microsec- onds. One disadvantage of successive approximation (and some other ADC schemes) is that the result may be inaccurate if the input value changes before the conversion is com- plete. For this reason, most modern analog-to-digital converters employ a built-in “sample and hold” circuit (usually a precision capacitor and resistor) that temporarily stores the value until conversion is complete. ANALOG-TO-DIGITAL CONVERSION ICS You can construct analog-to-digital converter circuits using discrete logic chips—basically a string of comparators strung together. But an easier approach is a special-purpose ADC integrated circuit. These chips come in a variety of forms besides conversion method (e.g., successive approximation, discussed in the last section): 448 INTERFACING WITH COMPUTERS AND MICROCONTROLLERS Ch29_McComb 8/18/00 2:16 PM Page 448 ■ Single or multiplexed input. Single-input ADC chips, such as the ADC0804, can accept only one analog input. Multiplexed-input ADC chips, like the ADC0809 or the ADC0817, can accept more than one analog input (usually 4, 8, or 16). The control cir- cuitry on the ADC chip allows you to select the input you wish to convert. ■ Bit resolution. The basic ADC chip has an 8-bit resolution (the ADC08xx ICs discussed earlier are all 8 bits). Finer resolution can be achieved with 10- and 12-bit chips. A few 16-bit analog-to-digital ICs are available, but these are not widely used in robotics. One of the most popular 12-bit ADC chips is the LTC1298, which can transform an input voltage (usually 0–5 volts) into 4096 steps. ■ Parallel or serial output. ADCs with parallel outputs provide separate data lines for each bit. (10- and 12-bit converters may still only have eight data lines; the converted data must be read in two passes.) Serial output ADCs have a single output, and the data is sent 1 bit at a time. Serial output ADCs are handy when used with microcontrollers and single-board computers, where input/output lines can be scarce. In the most com- mon scheme, a program running on the microcontroller or computer “clocks in” the data bits one by one in order to reassemble the converted value. The ADC08xx chips have parallel outputs; the 12-bit LTC1298 has a serial output. INTEGRATED MICROCONTROLLER ADCS Many microcontrollers and single-board computers come equipped with one or more analog-to-digital converters built in. This saves you the time, trouble, and expense of connecting a stand-alone ADC chip to your robot. You need not worry whether the ADC chip provides data in serial or parallel form since all the data manipulation is done internally. You just tell the system to fetch an analog input, and it tells you the result- ing digital value. On the downside, the ADCs on most microcontrollers are typically more limited than the stand-alone variety. For example, with most stand-alone ADCs you can set a particular span of voltages, say from 2 volts to 4.5 volts, rather than the usual 0 to 5 volts. The full bit range (8, 10, 12 bits, etc.) then applies to this narrow span. The result is better overall resolution since the same number of bits is used with a smaller voltage range. Most ADCs built into microcontrollers and computers have no way to set the span, which makes lim- ited-range conversions less accurate. Additionally, you’re stuck with the ADC resolution that is built into the microcontroller or computer. If the chip uses 8-bit resolution and you need 10 or 12, you’ll have to add an outboard converter. SAMPLE CIRCUITS Fig. 29.20 shows a basic circuit for using the ADC0809, which provides eight analog inputs and an 8-bit conversion resolution. The input you want to test is selected using a 3- bit control sequence—000 for input 1, 001 for input 2, and so on. Note the ~500 kHz time base, which can come from a ceramic resonator or other clock source or from a resistor/capacitor (RC) time constant. If you need precise analog-to-digital conversion, you should use a more accurate clock than an RC circuit. Fig. 29.21 shows the pinout diagram for the popular ADC0804, an 8-bit successive approximation analog-to-digital conversion IC with one analog input. USING ANALOG-TO-DIGITAL CONVERSION 449 Ch29_McComb 8/18/00 2:16 PM Page 449 450 INTERFACING WITH COMPUTERS AND MICROCONTROLLERS Analog Inputs (8) Input Select Digital outputs +5V 21 MSB LSB 20 19 18 Q1 Q7 Q6 Q5 Q4 Q3 8 Q2 15 14 Q0 17 IN1 IN0 IN2 IN3 IN4 IN5 IN6 IN7 26 27 28 1 2 3 4 5 1 2 3 4 5 6 7 0 A1 A2 A4 Sc Start Conversion Eoc End of conversion Clk 500kHz In Ale 11 Vcc OE 229 +Rf 12 Gnd 13 -Ref 16 25 24 23 6 7 10 FIGURE 29.20 Basic hookup circuit for the ADC0809 analog-to-digital converter. VCC VREF/2 VIN+ VIN- AGND /CS /RD /WR DGND CLKR CLKIN /INTR DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 20 9 6 7 8 1 2 3 10 19 4 5 18 17 16 15 14 13 12 11 ADC0804 FIGURE 29.21 Basic hookup circuit for the ADC0804 analog-to- digital converter. Ch29_McComb 8/18/00 2:16 PM Page 450 [...]... Printer Error On-Line PE ACK Busy 2 5 7 9 11 13 1 15 IC3 743 67 3 4 6 10 12 14 13 14 15 16 17 18 OE OE GND 8 To Pins 1 8 -2 5 FIGURE 30 .4 Schematic for the Robot Experimenter’s Interface 18-pin wire-wrap socket Ch30_McComb 8 /29 /00 8: 34 AM Page 46 7 ROBOT EXPERIMENTER’S INTERFACE TABLE 30.5 46 7 PARTS LIST FOR THE ROBOT EXPERIMENTER’S INTERFACE IC1–IC3 743 67 TTL Hex Inverter/Buffer IC Misc 18-pin wire-wrap socket,... Write the line as follows: OUT 888, 3 A limitation of the demux is that you can’t control more than one device connected to it at any one time You can’t, for example, attach both drive motors to the demux outputs and have +5vdc 24 Vcc 0 Pin 2 Pin 3 23 22 2 Pin 5 21 20 3 4 4 5 5 6 6 7 7 8 9 Data Input A B Inputs Pin 4 2 8 18 1 Enable 1 3 19 741 54 C 9 10 D 10 11 11 13 12 14 13 15 14 16 15 17 Gnd 12 FIGURE... Stamp II (but not the Basic Stamp I), the BasicX - 24 , and several others To use the Shiftout command, you indicate the data you want to send and the I/O pins of the microcontroller that are connected to the 745 95 You then send a short pulse to the Latch line, and you’re done! A key benefit of the 745 95 is that you can “cascade” them to expand the I/O options even more There are still other ways to expand... Solder the data output, status, and control line conductors to the proper pins of the 743 67 ICs Route the outputs to the bottom of the wire-wrap socket A finished interface should look something like the one in Fig 30.5 Using the interface requires you to provide a ϩ5 vdc source Do not try to power the interface from the parallel port! Use a length of 22 AWG solid Ch30_McComb 8 /29 /00 8: 34 AM Page 46 6 46 6... Vcc To Pin 1 To Pin 2 To Pin 3 To Pin 4 To Pin 5 To Pin 6 Strobe Data 0 Data 1 Data 2 Data 3 Data 4 14 1 15 IC1 743 67 3 5 7 9 11 1 13 2 4 6 10 12 6 3 5 7 9 11 7 8 9 10 11 2 3 4 5 OE OE GND 8 +5vdc 16 Vcc To Pin 7 To Pin 8 To Pin 9 To Pin 15 To Pin 16 Data 5 Data 6 Data 7 LF/CR Initialize 2 4 6 10 12 IC2 743 67 12 1 15 OE OE GND 8 +5vdc 16 Vcc To Pin 17 To Pin 15 To Pin 13 To Pin 12 To Pin 10 To Pin 11... pins of the 743 67 The inputs of the three 743 67s are connected together The outputs of each feed to the specific device To turn on bits 0 and 1 on device 2, enter the following lines into Basic and run the program: OUT 888, 3 OUT 890, 2 The first line of the program outputs a decimal 3 to the data output register That places the binary bit pattern 00000011 on the parallel port data output lines The next... Count The LEDs connected to each of the data lines should flash on and off very rapidly Some of the LEDs will flash more than the others; this is normal When the program finishes all of the LEDs should stay lit If the LEDs do not flash, recheck your wiring and make sure Ch30_McComb 8 /29 /00 8: 34 AM Page 46 9 USING THE PORT TO OPERATE A ROBOT: THE BASICS 46 9 the program has been typed correctly The LEDs... ancient!) The logical names are assigned to these ports as they are found Table 30.1 shows the port addresses for the parallel ports in the PC Applications software often use the logical port names instead of the actual addresses, but in attaching a robot to the computer we’ll need to rely on the actual address—hence the need to go into these details Ch30_McComb 8 /29 /00 8: 34 AM Page 46 1 THE FUNDAMENTAL... This is the third and most sophisticated way to sap all the power out of the parallel port You can disable the 743 67 hex buffer IC, which is used to link the port to the outside world In the Robot Experimenter’s Interface, the ENABLE lines of the chip, pins 1 and 15, are held LOW by tying them to the ground, so data is passed from the input to the output When the ENABLE pins are brought HIGH, the outputs... Clear all Serial clock Serial data in 745 95 Serial-in/parallel out shift register 15 13 A 1 /G B 12 C 2 3 D 10 4 E 5 F 6 G 11 7 H Parallel outputs 14 H' 9 To additional 745 95s, if any FIGURE 29 .22 The 745 95 serial-in/parallel-out (SIPO) shift register lets you expand the data lines and select multiple lines at the same time Bitwise Port Programming Controlling a robot typically involves manipulating . Q1 40 11 (1 /4) V+ 1 2 3 g d s 7 14 Control Control Load Q1 40 11 (1 /4) V1+ 1 2 3 g d s 7 14 Load V2+ FIGURE 29 .4 Power MOSFET inter- face. +V Q1 Q2 Q3 Q4 40 11 (1 /4) +12V 1 2 3 4 5 6 g g d d g d s s s 7 14 0.1 C1 0 1Forward Reverse Direction control g d s M1 40 11 (1 /4) D1 D3 D2. outputs +5V 21 MSB LSB 20 19 18 Q1 Q7 Q6 Q5 Q4 Q3 8 Q2 15 14 Q0 17 IN1 IN0 IN2 IN3 IN4 IN5 IN6 IN7 26 27 28 1 2 3 4 5 1 2 3 4 5 6 7 0 A1 A2 A4 Sc Start Conversion Eoc End of conversion Clk 500kHz In Ale 11 Vcc OE 22 9 +Rf 12 Gnd 13 -Ref 16 25 24 23 6 7 10 FIGURE. inter- face. +V Q1 Q2 Q3 Q4 40 11 (1 /4) +12V 1 2 3 4 5 6 g g d d g d s s s 7 14 0.1 C1 0 1Forward Reverse Direction control g d s M1 40 11 (1 /4) D1 D3 D2 D4 D1-D4: 1N40 02 Q1-Q4: n-channel MOSFET FIGURE 29 .5 Discrete component H-bridge interface. Ch29_McComb 8/18/00 2: 16

Ngày đăng: 10/08/2014, 04:22

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan