Digital design with CPLD applications and VHDL (R. Dueck, 2000)
.pdf610 |
C H A P T E R 1 2 • Interfacing Analog and Digital Circuits |
|
|
FIGURE 12.42 |
|
eoc/sc,oe,en |
|
State Diagram for Continuous- |
|
||
start |
|
||
Convert ADC Controller |
|
||
X/100 |
|
||
|
X /000 |
|
|
|
|
|
|
|
store |
wait 1 |
1/000 |
X /010 |
0/000 |
|
|
read |
wait 2 |
|
1/011 |
|
0/000 |
FIGURE 12.43
Simulation of Continuous-
Conversion ADC Controller
|
EXAMPLE 12.13 |
From the ADC0808 data sheet extract in Figure 12.37, determine the number of clock cy- |
|
|
cles required for the conversion of an analog signal. |
|
|
Solution For a clock frequency of 640 kHz, typical conversion time is given as 100 s. |
|
|
640 103 clock cycles (100 10 6 seconds) 64 clock cycles |
|
|
second |
|
|
|
|
EXAMPLE 12.14 |
Calculate the highest-frequency analog input that can be accurately converted by an |
|
|
ADC0808 controlled by a state machine represented by the state diagram of Figure 12.42 |
|
|
if the system clock frequency is 787 kHz. |
|
|
Solution One conversion cycle, Ts, requires 64 clock cycles for the ADC and an |
|
|
overhead of 13 clocks 2 s for the state machine for a total of 77 clock cycles 2 |
|
|
s. (Start to wait1 requires one clock cycle. An additional 8 cycles 2 s are needed |
|
|
before eoc goes LOW. According to Note 7 in Figure 12.37, the ADC conversion is |
|
|
complete one clock cycle before EOC goes HIGH. From this point back to start is 4 |
|
|
clocks.) |
612 |
C H A P T E R 1 2 • Interfacing Analog and Digital Circuits |
Figure 12.38, except that with multiple latches in the circuit, a counter and decoder are required to keep track of the selected channel.
The controller, whose state diagram is shown in Figure 12.45, generates the same control signals for the ADC as the system in Figure 12.38. When the conversion is complete and the controller detects a LOW on its eoc input, it reads the ADC output and transfers the contents to the selected 8-bit latch. The latch is selected, via the decoder, by the value of the counter (e.g., Q1Q0 11 selects analog input channel 3, decoder output Y3, and latch 3). The selected latch input is enabled (i.e., made transparent) by the controller during the transition from wait2 to read. At all other times all decoder outputs are LOW, disabling all latches, thus placing them in store mode. After the ADC data have been stored, the controller sets cnt_en HIGH, which allows the counter to be incremented on the next clock pulse. The next channel is now ready for a convert-and-store cycle. After all channels have been sampled, converted, and stored, the cycle begins again at channel 0 and continues indefinitely.
eoc/sc,oe,cnt_en, latch_en
X /0000 |
start |
X/1000 |
|
|
|
||
|
|
|
|
incr |
|
wait 1 |
1/0000 |
X /0010 |
|
|
0/0000 |
|
|
|
|
store |
|
wait 2 |
|
|
|
|
|
X /0100 |
read |
1/0101 |
0/0000 |
|
FIGURE 12.45
State Diagram for 4-channel Data Acquistion System
Figure 12.46 shows a simulation of the controller, counter, and decoder for the data acquisition system of Figure 12.44. During the read-and-store part of the cycle, only one of the latch enables, y0 to y3, is active when oe is active. The number of the active latch enable is the same as the counter value on the second last waveform. The last line in the simulation (controller|outputs3.Q) is the cnt_en line from the controller to the counter. The counter is incremented on the first positive edge of the clock after this line goes HIGH. This point is indicated by the cursor line on the transition from channel 1 to channel 2.
The circuit in Figure 12.44 could be expanded to convert all eight analog channels from the ADC, but the chosen CPLD (EPM7128SLC84) does not have enough I/O pins. Eight 8-bit latch outputs require 64 pins; the CPLD only has 60 user I/Os. An 8-channel system could be implemented if it used eight external latches, such as eight 74HC373 octal latches, or internal latches on a different CPLD. Note that the CPLD has enough logic cells to implement the system, just not enough I/O pins. The identical device in a different package (EPM7128SQC100; 100-pin quad flat-pack) can accommodate the entire system.
For an 8-channel system, the counter would need to be expanded to 3 bits and the decoder to a 3-line-to-8-line device.