Файл: Microcontroller Programming. Thi Micro Chip PIC (Julio Sanchez, 2007).pdf
ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 14.06.2025
Просмотров: 8549
Скачиваний: 0
Circuit Components |
115 |
In order to accomplish this, data is first loaded into a parallel-in/serial-out shift register. The individual bits are then shifted out one at a time. The frequency of the driving clock in this case corresponds to the baud rate being used. To receive the data on a serial communications line a second type of shift register is used. In this case the operation is serial-in/parallel-out. The circuit that accomplishes this is based on
D-type flip-flops in which the Q outputs are connected to the D input lines.
The 74164 IC is one such device. In actual serial ports, the transmitting and receiving shift registers are contained in a single device called a UART (universal asynchronous receiver/transmitter).
6.4 Multiplexers and Demultiplexers
There are many situations in digital electronics where different signals must be sent out on a single output line, or several signals must be received in a single input line. The digital circuits that perform these operations are called multiplexers and demultiplexers. Multiplexers and demultiplexers are TTL analogs of the many-to-one and one-to-many mechanical switches.
6.4.1 Multiplexers
Multiplexing (also called muxing) is a way of combining data of two or more input channels into a single output channel. The hardware multiplexer, also called a mux, combines several electrical signals into a single one. In other words, the multiplexer performs a many-into-one function while the demultiplexer performs one-into-many. Sometimes multiplexers and demultiplexers are combined into a single device, which is still referred to as a “multiplexer.” Figure 6-24 shows the schematics diagram of a multiplexer.
A |
B |
S |
O |
||||||
A |
0 |
0 |
0 |
B (0) |
|||||
out (O) |
0 |
0 |
1 |
A (0) |
|||||
B |
0 |
1 |
0 |
B (1) |
|||||
0 |
1 |
1 |
A (0) |
||||||
1 |
0 |
0 |
B (0) |
||||||
1 |
0 |
1 |
A (1) |
||||||
sel (S) |
1 |
1 |
0 |
B (1) |
|||||
1 |
1 |
1 |
A (1) |
||||||
Figure 6-24 Multiplexer Schematics
The truth table in Figure 6-24 describes the multiplexer operation. The line labeled “sel” in the illustration is the selector line. If the selector is low (S = 0) then input line, B, is mirrored in the output line O. Otherwise, input line A is vectored to the output.
116 |
Chapter 6 |
The Boolean expression for the multiplexer in Figure 6-24 is:
O = (A S) (B ←S)
Often, a multiplexer circuit is preceded by a decoder circuit so that input can be compressed into fewer lines. For example, a four-to-one multiplexer receives a binary value in the range 0 to 3 (00 to 11) on two input lines and sets high one of four output lines accordingly. Figure 6-25 shows the circuit diagram for such a device.
S1 S0
2-to-4 line decoder
I0
I1
O
I2
I3
Figure 6-25 Two-Bit to One-of-Four Multiplexer
In the circuit of Figure 6-25 there are four input lines. Which one of these four lines is copied to the multiplexer output depends on the binary value in the two S lines at the top of the illustration. The 2-to-4 line decoder converts this value into one of four selector lines, which are in one of these four states:
LLLL LLHL LHLL HLLL
Whichever line is high from the decoder output selects the corresponding input line. By analogy to the circuit in Figure 6-25, an 8-input multiplexer has eight data inputs and three binary selection inputs, which are converted into one-of-eight selection lines by the decoder. By the same token, a 16-input multiplexer requires four binary digits in the decoder input, which are converted into one-of-sixteen selection lines.
Alternatively, the decoder circuit can be eliminated by using multiple AND gates and negating the input signals, as shown in Figure 6-26.
In Figure 6-26 assume that the input bits are both low, that is, S1 = 0 and S2 = 0. The first-level NOR gates change the L signals to H. The two high signals go into the first multiple AND gate, as shown by the solid lines in the illustration. This determines that the first input line (I0) is copied to the circuit output. In fact, the four inverters at the top of the illustration perform the function of the two-to-four decoder in the circuit of Figure 6-25.
Circuit Components |
117 |
S1 |
S0 |
I0 |
|
I1 |
O |
I2 |
|
I3 |
Figure 6-26 Multiplexer with Multiple AND Gates
6.4.2 Demultiplexers
A demultiplexer takes one data input and a number of selection inputs, and returns multiple outputs. So while the multiplexer performs a many-into-one operation, the demultiplexer performs a one-into-many. For example, a 4-output demultiplexer has one data input line, two selection inputs, and four data output lines. Figure 6-27 shows such a circuit.
S1 |
S0 |
I |
O0 |
O1 |
|
O2 |
|
O3 |
Figure 6-27 Two-Bit into Four-of-One Demultiplexer
118 |
Chapter 6 |
Demultiplexers can be made to act as decoders by holding the input line high. For example, the circuit in Figure 6-27 performs as a binary to four-line decoder if the I line is held high. The binary bit patterns on the two input lines are converted into a single output in one of the four output lines. Thus, if there were four devices, each one connected to one of the output lines, the demultiplexer circuit would select which one is enabled according to the binary value of the input.
6.4.3 Multiplexer and Demultiplexer ICs
Several ICs are available that perform multiplexing and demultiplexing operations. For example, the 74138 is a 3-line to 8-line decoder and demultiplexer. With this IC any of eight inputs can be selected by placing the corresponding 3-bit number on the device’s three address lines. The 74151 is a 1-of-8 data selector/multiplexer. This device routes data from eight sources to a single output line. Here again, a 3-bit selector is used to determine which of the eight inputs is routed to the output.
An important use of the multiplexer ICs is to encode row and column addresses into the address lines of dynamic RAM, although more often tristate buffers such as the 74541 are used. Another important use of multiplexers is in implementing dual-port memories for video displays.
6.5 Input Devices
Electronic devices, including computers and microcontrollers, often receive the data and commands required for their operation. In computer technology the most common input device is the keyboard, which allows entering text data as well as keystroke orders. Alternate computer input devices are the mouse, trackballs, light pens, graphical tablets, scanners, speech recognition devices, optical character recognition devices, and many others. Although these devices are not excluded from use in microcontroller-based systems, a more typical case is that microcontroller input devices are much simpler and limited. In this section we discuss the two most commonly used devices for microcontrollers: the switch and the keypad. Keep in mind that specialized systems often use special input devices; for example, a radio receiver could be the input device for a radio-controller microcontroller system.
6.5.1 Switches
The electrical switch is a device for changing current flow in a circuit. Although mechanical switches find use in fields such as railroads and fluid flow control, here we refer to switches used in controlling electrical power or electronic telecommunications.
In abstract terms the switch is often referred to as a “gate”, in the same sense as the logic gates discussed in Chapter 5. In this sense an electronic device can be viewed as a system of logic gates. The simplest electrical switch has two components, called contacts, that touch to make the circuit and separate to break the circuit. The terms make and break are commonly used in this context. The selection of material for the contacts is important since corrosion can form an insulating layer that prevents the switch from performing its function. One possible solution is plating the contacts with noble metals, such as gold or silver.
Circuit Components |
119 |
In a switch, the actuator is the part that applies the operating force to the contacts. Common switch types are rocker, toggle, push-button, DIP, rotary, tactile, slide, keylock, snap-action, thumbwheel, and several others. Figure 6-28 shows several switches commonly found in microcontroller circuit boards.
Figure 6-28 Electrical Switches
In switches, contacts are “closed” when there is no space between them, thus allowing electricity to flow. When the contacts are separated by a space, they are “open.” In this case no electricity flows through the switch.
Switches are classified according to the various contact arrangements. In the normally open switch the contacts are separated until some force causes them to close. In the normally closed switch the contacts are held together until some force separates them. Some switches can be selected to operate as either normally open or normally closed. The term pole is used in reference to a single set of contacts on a switch. The term throw refers to the positions that a switch can adopt. Figure 6-29, on the following page, shows some common switch designs and their electrical symbols.
A multi-throw switch can have two possible transient behaviors as it transits from one position to the other one. One possibility is that the new contact is made before the old one is broken. This make-before-break action ensures that the line is never an open circuit. Alternatively, there is a break-before-make action, where the old contact is broken before the new one is made. This mode of switch operations ensures that the two fixed contacts are never shorted. Both designs are in common use.
120 |
Chapter 6 |
Diagram |
Electronic |
Description |
||||||||||
abbreviation |
||||||||||||
SPST |
Single pole, single throw. |
|||||||||||
On-off switch such as |
||||||||||||
a household light switch. |
||||||||||||
L1 |
SPDT |
Single pole, double throw. |
||||||||||
C |
SPCO |
Single pole, changeover. |
||||||||||
Changeover switch. C is |
||||||||||||
L2 |
connected to either L1 or |
|||||||||||
L2. |
||||||||||||
DPST |
Double pole, single throw. |
|||||||||||
Equivalent to two SPST |
||||||||||||
switches operated by the |
||||||||||||
same mechanism. |
||||||||||||
DPDT |
Double pole, double throw. |
|||||||||||
Equivalent to two SPDT |
||||||||||||
switches operated by the |
||||||||||||
same mechanism. |
||||||||||||
Figure 6-29 Switch Symbols and Types
A biased switch is one in which the actuator is automatically returned to a certain position, usually by the action of a spring. A push-button switch is a type of biased switch, of which the most common type is a push-to-make switch. In this case, the contact makes when the button is pressed and breaks when it is released. A push-to-break switch, on the other hand, breaks contact when the button is pressed. Many other special function switches are available; for example, tilt switches, such as the mercury switch, in which contact is made by a blob of mercury inside a glass bulb as the switch is tilted. Other specialized switches are activated by vibration, pressure, fluid level (as in the float switch), linear or rotary movement, the turning of a key, a radio signal, or a magnetic field.
6.5.2 Switch Contact Bounce
Switch contact bounce is a common problem of electrical switches. Switch contacts are metal surfaces that are forced into contact by an actuator. Due to momentum and elasticity, the striking action of the contacts causes a rapidly pulsating electrical current instead of a clean transition from zero to full current. Parasitic inductance and capacitance in the circuit can further modify the waveform resulting in a series of sinusoidal oscillations.
Switch bounce sometimes causes problems in logic circuits that are not designed to cope with oscillating voltages, particularly in sequential digital logic circuits. Sev-