• No results found

13 Digital ↔analog conversion

In document 26501852 Hands on Electronics (Page 191-195)

In this chapter we will study simple techniques for generating and read-ing voltage or current levels, i.e., convertread-ing between analog (voltage or current) and digital (binary-number) information. The availability of high-speed, easy-to-use, inexpensive digital⇒analog and analog⇒digital con-verter chips has dramatically changed the way audio and video information are recorded and processed, as well as how computers are used in laboratory research and process control. The process of converting digital information into voltages or currents whose magnitudes are proportional to the digitally encoded numbers is called digital-to-analog (D/A) conversion. The reverse process is called analog-to-digital (A/D) conversion. The devices that carry out these conversions are called DACs and ADCs, respectively.

In this chapter, after building a simple DAC from a digital counter and an op amp, you will continue your exploration of analog/digital conversion by building a 4-bit tracking ADC. Having learned the basic operating princi-ples, you’ll use an ADC080x 8-bit successive-approximation A/D chip to digitize (i.e., convert to digital) an arbitrary AC signal. The original signal will then be re-created from the digitized data using a DAC080x D/A chip.

This exercise will also allow you to explore the limitations of ADC and DAC operations.

Please be sure to work through these circuits in advance, otherwise it is highly unlikely that you will successfully complete the exercises in a timely fashion! Carefully study the manufacturer’s data sheets which pro-vide extensive details on operation and performance. As always, complete schematic diagrams significantly improve debugging efficiency.

Apparatus required

Breadboard, oscilloscope, 74191, TIL311, 311 comparator, 741 op amp, resistors, capacitors, DAC0806 (or similar), ADC0804 (or similar), 7400, 7432, four 7474, 74112, 74138.

167

13.1 A simple D/A converter fabricated from familiar chips

Recall that when an op amp is set up as an inverting amplifier, the non-inverting input is grounded, and the non-inverting input, which is tied to the output through a feedback resistor, acts as a ‘virtual ground’. If a resistor R is connected from a voltage V to the inverting input of the op amp, a current V/R will flow. If you double the resistance, half as much current will flow. Suppose you have four resistors with the resistances R, 2R, 4R, and 8R. The corresponding current flows will be in the proportion 8:4:2:1 (see Fig. 13.1(a)).

A 74191 counter has four outputs Q3 through Q0, with Q3 the MSB (most significant bit) and Q0 the LSB (least significant). In addition it has four parallel-load inputs, count-enable and count-direction (up/down) inputs, and ripple-clock and terminal-count outputs for use when cascading multiple stages. If we feed the counter outputs to the inverting input of an op amp through resistors R, 2R, 4R, and 8R (in order from MSB to LSB), we get a 4-bit digital-to-analog converter. The current into the feedback resistor will be proportional to the number that corresponds to the state of the counter. Given a suitable feedback resistor such that the op amp does not saturate, the output voltage will be proportional to this current. To produce a desired output voltage, we can load into the counter any desired value; we can also increment or decrement the counter to get a voltage that changes in time in stepwise fashion (see Fig. 13.1(b)). This output can, of course, be observed on an oscilloscope or other measurement device.

D1

Fig. 13.1. (a) Simple D/A converter; (b) output waveform resulting from input counting sequence.

169 13 Digital↔analog conversion

To demonstrate D/A conversion, you will build such a 4-bit DAC. To reduce the chances of hooking up the circuit incorrectly,

 Begin by setting up a 74191 counter and make sure it is working properly:

hook up its outputs to a TIL311 display, clock it from a debounced switch, and verify that it goes through all sixteen states in order. Test it counting both up and down – you can control which way it counts using the ‘u/d’

input.

 Next, hook up the counter outputs to the summing junction of the op amp through resistors, as described above. Use a 2.2 k resistor to connect to Q3, a 4.7 k resistor for Q2, a 10 k resistor for Q1, and a 22 k resistor for Q0, and connect a 3.3 k feedback resistor. Connect a 1 kHz digital signal to the clock input of the counter and view the analog output on an oscilloscope.

Of course, if we wanted to produce accurate analog output voltages, we would need precision resistors, for example 2.50 k, 5.0 k, 10 k, and 20 k. Moreover, we would need to take into account the inevitable small differences among the high and low levels of the counter outputs. We shall not worry about these refinements, since it is our intention here merely to illustrate the basic idea of D/A conversion.

The output should be a fifteen-step staircase waveform (Fig. 13.1b), with each step having approximately the same height. To see a stable dis-play of the waveform, you can trigger the scope using the falling edge of the MSB.

 What full-scale output voltage do you expect (i.e. when the counter is at 15 in decimal or 1111 in binary)? What do you observe?

 Is the staircase rising or falling? Why is this? What simple change can you make to reverse the direction of the staircase?

 What are the output voltages corresponding to states 4, 5, 6, 7, and 8 of the counter? Measure the four resistances and the high and low voltage levels of the four counter outputs (Q0–Q3), and explain each DAC output voltage.

 Write down a complete circuit diagram with pin numbers. Explain in your own words how this circuit works.

Despite the common misconception that modern electronics is strictly digital, analog electronics is still going strong. For all practical purposes, our everyday world is analog. The digital representation of any waveform (music, for example) is only an approximation. To smooth out the discon-tinuities of digitized waveforms requires analog electronics.

13.2 Tracking ADC

To measure an analog signal you need to invert the process of D/A conver-sion. There are various ways of doing this, but, just as division is harder and slower than multiplication, and taking the square-root harder and slower than squaring, analog-to-digital conversion is harder and often slower than digital-to-analog.

Given a DAC, a counter, and a comparator, a simple approach is to increment the counter (starting from zero) until the DAC output crosses the analog input. Using the comparator to compare the analog input to the DAC output, you stop counting when the comparator output switches states. At that point, the counter holds a digital approximation to the magnitude of the input.

A simple variant of this circuit will follow (or ‘track’) changes in the input voltage. You can turn your 4-bit counter/DAC into such a tracking ADC by driving u/d from a comparator that compares the DAC output with the analog input voltage.

Use a potentiometer to make the analog input voltage: connect one end to ground and the other to −15 V. The slider controls the input volt-age, which you can vary between 0 V and −15 V. To stabilize the op-eration of the circuit, use some hysteresis by connecting a series 10 k resistor between the input voltage and the comparator noninverting in-put and 1 M between the comparator outin-put and the noninverting inin-put (see Fig. 13.2).

 Clock the counter at a few hertz and observe its state with the TIL311 as you vary the input voltage. What do you observe?

 How should the comparator inputs be configured: which signal should go to the inverting and which to the noninverting input? Is the output number ‘homing in’ on the expected value? If not, did you perhaps connect the comparator backwards? Explain, and if you did it wrong the first time, fix it.

 Record the output numbers for a few different input voltages.

 Why is the output number never stable? How (if at all) does this affect the precision of the voltage measurement?

Note that the tracking ADC is slow at following large input-voltage changes, since it has to count through all the intermediate values, but it has good performance if the input voltage changes gradually.

171 13 Digital↔analog conversion

Fig. 13.2. Simple A/D converter. (The polarity of the comparator inputs is left as an exercise for the reader.)

In document 26501852 Hands on Electronics (Page 191-195)