12 Converting Between Digital and Analog

Similar documents
Reading: HH Sections , (pgs , )

CHAPTER 11: Flip Flops

NTE2053 Integrated Circuit 8 Bit MPU Compatible A/D Converter

EXPERIMENT NUMBER 5 BASIC OSCILLOSCOPE OPERATIONS

Chapter 6: From Digital-to-Analog and Back Again

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Electronic Circuits Spring 2007

Chapter 19 Operational Amplifiers

A Lesson on Digital Clocks, One Shots and Counters

Op-Amp Simulation EE/CS 5720/6720. Read Chapter 5 in Johns & Martin before you begin this assignment.

Conversion Between Analog and Digital Signals

A Lesson on Digital Clocks, One Shots and Counters

Digital to Analog and Analog to Digital Conversion

ARRL Morse Code Oscillator, How It Works By: Mark Spencer, WA8SME

AUTOMATIC NIGHT LAMP WITH MORNING ALARM USING MICROPROCESSOR

Operational Amplifier - IC 741

QUICK START GUIDE FOR DEMONSTRATION CIRCUIT BIT DIFFERENTIAL ADC WITH I2C LTC2485 DESCRIPTION

Lab 1: The Digital Oscilloscope

Frequency Response of Filters

AVR127: Understanding ADC Parameters. Introduction. Features. Atmel 8-bit and 32-bit Microcontrollers APPLICATION NOTE

1. Learn about the 555 timer integrated circuit and applications 2. Apply the 555 timer to build an infrared (IR) transmitter and receiver

Lock - in Amplifier and Applications

Programmable Single-/Dual-/Triple- Tone Gong SAE 800

PCM Encoding and Decoding:

Objectives: Part 1: Build a simple power supply. CS99S Laboratory 1

Use and Application of Output Limiting Amplifiers (HFA1115, HFA1130, HFA1135)

DIGITAL-TO-ANALOGUE AND ANALOGUE-TO-DIGITAL CONVERSION

TESTS OF 1 MHZ SIGNAL SOURCE FOR SPECTRUM ANALYZER CALIBRATION 7/8/08 Sam Wetterlin

A Digital Timer Implementation using 7 Segment Displays

Physics 120 Lab 6: Field Effect Transistors - Ohmic region

Sequential Logic: Clocks, Registers, etc.

FREQUENCY RESPONSE OF AN AUDIO AMPLIFIER

Digital to Analog Converter. Raghu Tumati

Cornerstone Electronics Technology and Robotics I Week 15 Voltage Comparators Tutorial

LAB 7 MOSFET CHARACTERISTICS AND APPLICATIONS

Transistor Amplifiers

1. Oscilloscope is basically a graph-displaying device-it draws a graph of an electrical signal.

Interfacing Analog to Digital Data Converters

Step Response of RC Circuits

AP-1 Application Note on Remote Control of UltraVolt HVPS

The components. E3: Digital electronics. Goals:

Basics of Digital Recording

Operational Amplifiers

Lab 11 Digital Dice. Figure Digital Dice Circuit on NI ELVIS II Workstation

Electronics. Discrete assembly of an operational amplifier as a transistor circuit. LD Physics Leaflets P

Lab 5 Operational Amplifiers

Having read this workbook you should be able to: recognise the arrangement of NAND gates used to form an S-R flip-flop.

Measuring Electric Phenomena: the Ammeter and Voltmeter

1.1 The 7493 consists of 4 flip-flops with J-K inputs unconnected. In a TTL chip, unconnected inputs

Introduction to Digital Audio

Lab Unit 4: Oscillators, Timing and the Phase Locked Loop

Theory of Operation. Figure 1 illustrates a fan motor circuit used in an automobile application. The TPIC kω AREF.

Pulse Width Modulation (PWM) LED Dimmer Circuit. Using a 555 Timer Chip

Micro-Step Driving for Stepper Motors: A Case Study

12-Bit, 4-Channel Parallel Output Sampling ANALOG-TO-DIGITAL CONVERTER

LM 358 Op Amp. If you have small signals and need a more useful reading we could amplify it using the op amp, this is commonly used in sensors.

Scaling and Biasing Analog Signals

Section 3. Sensor to ADC Design Example

Electronic WorkBench tutorial

Bipolar Transistor Amplifiers

Digital Sampling Oscilloscope

Decimal Number (base 10) Binary Number (base 2)

Lab 7: Operational Amplifiers Part I

ECEN 1400, Introduction to Analog and Digital Electronics

Electrical Resonance

Evaluating AC Current Sensor Options for Power Delivery Systems

EET272 Worksheet Week 9

Counters and Decoders

PLL frequency synthesizer

Little LFO. Little LFO. User Manual. by Little IO Co.

LM118/LM218/LM318 Operational Amplifiers

Supply voltage Supervisor TL77xx Series. Author: Eilhard Haseloff

POCKET SCOPE 2. The idea 2. Design criteria 3

Chapter 12: The Operational Amplifier

Current Loop Tuning Procedure. Servo Drive Current Loop Tuning Procedure (intended for Analog input PWM output servo drives) General Procedure AN-015

Reading assignment: All students should read the Appendix about using oscilloscopes.

Routinely DIYers opt to make themselves a passive preamp - just an input selector and a volume control.

EXPERIMENT 3: TTL AND CMOS CHARACTERISTICS

LABORATORY 2 THE DIFFERENTIAL AMPLIFIER

Redesigned by Laurier Gendron (Aug 2006 ) Download this project in PDF. Horn circuit. Train Circuitry

Measuring Resistance Using Digital I/O

DATA SHEET. TDA1543 Dual 16-bit DAC (economy version) (I 2 S input format) INTEGRATED CIRCUITS

Making Accurate Voltage Noise and Current Noise Measurements on Operational Amplifiers Down to 0.1Hz

Lab E1: Introduction to Circuits

OPERATIONAL AMPLIFIER


The Operational Amplfier Lab Guide

Lab #9: AC Steady State Analysis

More Op-Amp Circuits; Temperature Sensing

Low Cost Pure Sine Wave Solar Inverter Circuit

Features. Applications

Digital Logic Elements, Clock, and Memory Elements

Ultrasound Distance Measurement

MAS.836 HOW TO BIAS AN OP-AMP

SIMPLE HEART RATE MONITOR FOR ANALOG ENTHUSIASTS

SINGLE-SUPPLY OPERATION OF OPERATIONAL AMPLIFIERS

Chapter 9 Latches, Flip-Flops, and Timers

SG2525A SG3525A REGULATING PULSE WIDTH MODULATORS

Analog Representations of Sound

Clock Recovery in Serial-Data Systems Ransom Stephens, Ph.D.

Transcription:

12 CONVERTING BETWEEN DIGITAL AND ANALOG 12 Converting Between Digital and Analog For many applications, it is necessary to convert analog signals from a circuit or sensor to digital signals that can be manipulated by a computer, and vice versa. The simplest such tasks can be be performed by a comparator, but more generally, an ADC (analog-to-digital converter) or DAC (digital-to-analog converter) will be required. In this lab, we will explore a few aspects of these processes. This lab will require two days. Reading: HH sections 4.23 24, 9.15 16, 9.20 22 (pgs. 229 232, 612 618, 621 631) 12.1 Comparator A comparator is a high-gain differential amplifier, much like an op amp. It is not designed, however, to be operated with negative feedback. Instead, it provides a binary output, railing high if the input V + > V and low if V + < V. In this way, it can serve as a simple interface between analog and digital systems. The pin designations for the LM311 comparator are shown in Fig. 1(a). The Balance inputs can be used to adjust the offset voltage, just as in an op amp, while the Strobe input can be used to force the output low, regardless of the inputs. We will not be using either of these features and you can leave pins 5 and 6 unconnected. An interesting feature of the LM311, and most comparators, is that it has an opencollector output, represented schematically in 1(b). Here an external pull-up resistor must be used to complete the circuit. Typically, a value of 1 kω is a good compromise between high speed and low power dissipation. Note that the need for an output resistor is not always made perfectly clear in device datasheets, but the circuit will not function correctly without one. An advantage of the open-collector output scheme is seen in Fig. 1(c), where the pull-up voltage can be varied. This lets the comparator serve as a very simple DAC: it converts 0-10 V Gnd In+ In- V- 1 2 3 LF311 8 7 6 4 5 V+ Out Balance/Strobe Balance V V in 1k (a) (b) (c) Figure 1: LM311 comparator. (a) Pin designations. (b) Open collector output configuration. (c) Circuit for lab. 12-1

12.2 Schmitt Trigger 12 CONVERTING BETWEEN DIGITAL AND ANALOG an input digital signal at standard logic levels to an output signal that switches between whatever voltage the analog circuit requires. Construct this circuit, taking V in from a DIO pin, and using the variable power supply to generate the pull-up voltage. Use 1 for the positive supply and ground for the negative supply. Observe the output on the scope, and note how you get a digitally controlled version of the VPS voltage. How close to zero does the output get in its low state? Does the low value depend on the VPS voltage? Conversely, if you use for the pull-up voltage and the variable supply for the input, the the circuit serves as a basic inverting ADC. It provides a single-bit output that is low when the input is above the threshold and high when it is below the threshold. Modify the circuit of 1(c), accordingly, and observe the output with the Digital Reader while the input level is varied. You might notice that if you slowly step the input across the threshold, the reader display light flickers. When the input is very close to the threshold, even very small noise signals can cause the comparator state to change. To observe this effect more clearly, drive the input with a 500 khz triangle wave from the function generator, using a pp amplitude and a 2. dc offset. Observe both the input and output with the scope. You should see the output switching as expected. Trigger the scope on the input signal, and adjust the trigger level so that the output switches just after the start of the trace. If you now zoom in on the output transition, you should be able to see multiple back-and-forth transitions between states, due to input noise. You can imagine that using a signal such as this as the trigger for a digital circuit would be problematic. Fortunately, the problem has a straightforward fix, the Schmitt trigger. 12.2 Schmitt Trigger A Schmitt trigger consists of a comparator combined with positive feedback, as seen in Fig. 2(a). The effect of the feedback is to create hysteresis in the switching behavior. If the circuit output is originally low, then the signal at V + will be lower than V in. Therefore, V in must rise somewhat higher than V ref before the output will switch. Once the output is high, V + will be higher than V in, so V in will have to drop somewhat lower than V ref before the output will switch low again. The difference between the two input thresholds is termed R2 hysteresis R1 1k V in (a) V ref LM311 (b) 0 V V ref V in Figure 2: (a) Schmitt trigger circuit. (b) Hysteresis curve. 12-2

12.3 The AD7569 DAC/ADC12 CONVERTING BETWEEN DIGITAL AND ANALOG the hysteresis, as illustrated in Fig. 2(b). This technique reduces the sensitivity to noise, since the input signal would need to fluctuate by an amount larger than the hysteresis in order to affect the output. Of course, hysteresis also reduces the accuracy of the comparator, since the output no longer precisely measures how V in compares to V ref. Wire up the circuit using R 1 = 10 kω and a 100 kω potentiometer for R 2, with the pot resistance initially maximum. Use the scope to observe the switching behavior with a 500 Hz triangle wave drive, and compare to what you observed before. Does the output now exhibit a single clean transition? To analyze the circuit and calculate the hysteresis, note that the R 1 and R 2 resistors form a voltage divider between the output and the input, so that V + = R 2V in + R 1 R 1 + R 2. The output will change states when V + = V ref. Solving for V in in that condition gives ( V in = 1 + R ) 1 V ref R 1. R 2 R 2 If varies by (here ), the corresponding hysteresis V in will be V in = R 1 R 2. Note that this analysis assumes the output pullup resistor is small compared to R 1 + R 2, so that the voltage drop across it is not significant. You can observe the hysteresis in your circuit using the oscilloscope s XY mode. In XY mode, the horizontal sweep is controlled by the Ch 1 signal, rather than a temporal ramp. This allows the scope to diplay the Ch 2 signal as a function of the Ch 1 signal instead of as a function of time. Attach your function generator signal to the scope Ch 1, and the circuit output to Ch 2. Set the trigger source to Ch 1, but display only Ch 2. Then put the scope in XY mode by depressing both the B and Alt buttons near the cursor control knob. Set the scope to display Ch 2 only. Finally, turn the input signal frequency up to 10 khz. You should now see the hysteresis curve on the scope, with a noticeable difference between where the output signal drops and rises. The horizontal separation of these points gives V in. Measure it, and compare to the above formula for your resistor values. (Note that you ll have to display Ch 1 to see what voltage scale it is set at.) Vary the pot, and describe how the hysteresis responds. When designing a Schmitt trigger, you would set the hysteresis based on the amount of noise in the input signal. Integrated Schmitt triggers circuits are also available, such as the 7414 hex inverter. The nominal hysteresis level for the 7414 is 0.8 V. Once you have completed this section, disassemble the comparator circuit and put it away. 12.3 The AD7569 DAC/ADC When more than one bit of A/D conversion is needed, it is normally best to use an appropriate IC chip. You can choose from a variety of chips using a variety of methods. To give you a 12-3

12.4 Negative Supply 12 CONVERTING BETWEEN DIGITAL AND ANALOG 1 uf R2 + + 1 uf Adj R1-1 In Out (a) Adj In Out (b) Figure 3: LM337 negative voltage regulator. (a) Pin designations. (b) Wiring diagram. little familiarity with the topic, we will examine one general purpose chip here, the AD7569 from Analog Devices. The AD7569 is a complicated device. It contains both a DAC and ADC, with 8 bits precision each. The ADC uses the successive approximation register technique. The chip also features a variety of control signals designed to allow flexible interfacing with different systems. A datasheet for the device will be provided to each group, and you should consult it for reference. Note that the datasheet also describes the AD7669, which we are not using. A few things to look at now: Page 1: The functional block diagram gives an overview of what the chip does. Note that the data lines DB0... DB7 form a bus that serves as the output for the ADC and the input for the DAC, depending on the control signals applied. Page 6: Pin designations. We have the DIP configuration. Some paper labels with the pin numbers are available that you can tape to the top of the chip, to avoid pin counting errors. Page 7: Pin function descriptions. Note that there are three different grounds provided. In precise work, it would be desirable to keep the digital and analog grounds separate, to avoid putting digital noise on your analog signal. We shall not worry about that here, and just tie all the grounds together. Note also that the CS pin is not described very well. When this pin is high, the data lines are set to the off state of three-state logic. This allows the data bus to be shared with other devices. Since we have only one device to worry about, we will keep CS tied low. Page 10 12: The Digital Interface section explains how the DAC and ADC are controlled by the digital signals. This is the key information that explains how to make the chip work. Skim through it now, and refer back to it when constructing the circuits below. Page 15: Unipolar vs Bipolar operation. We will be using bipolar operation, so make sure you understand Table V. This is called two s-complement encoding, and is the standard way to represent negative values in binary. 12.4 Negative Supply For bipolar operation, the AD7569 requires supply voltages of ±. Our breadboards supply +, but not -. (We could use the variable power supply, but we will want to use that as a signal source.) We can conveniently derive - from our -1 supply using an LM337 12-4

12.5 DAC 12 CONVERTING BETWEEN DIGITAL AND ANALOG negative voltage regulator. This device and its wiring diagram are shown in Fig. 3. It produces an output voltage ( = ( 1.2olts) 1 + R ) 2 R 1 from an input voltage more negative than this. R 1 should be around 100 Ω. Obtain a chip and wire up the circuit to produce an output voltage close to -. Record the voltage you obtain. Note that there is a positive voltage version of this device, the LM317. Voltage regulators provide a simple and convenient way to generate various supply voltages from a single source. 12.5 DAC We shall first use the AD7569 to implement a simple DAC. Obtain a chip and wire the supply voltages, noting that V DD is positive and V SS is negative. (The notation refers to the drain and source of a FET.) Wire all three grounds to a common ground, and tie CS low. Tie Range high. We won t be changing any of these settings. To operate as a DAC, tie Reset and Read high, and ST low. Whenever an upward transition is applied to the WR input, the chip will read the eight data lines, convert them to an analog voltage, and output that voltage on the pin. To start, use a DIP switch to control the WR input. Tie the pin to through a 1 kω resistor, and also to ground through a switch. We don t need to worry about debouncing the switch here, because we don t mind if the chip performs the DAC conversion several times whenever we flip the switch. Start with the switch closed (so WR is low). Take the DB0 7 lines (here acting as inputs) from the DIO pins, which will be controlled by the Digital Writer tool. Monitor the output with your scope and a voltmeter. Power up the circuit, and set the DIO signals to all zeros. Switch WR high and then low again. Does the output voltage go to zero? Try several different digital inputs, and verify that that output voltage responds appropriately in each case. Make a table in your report of the signals you applied and the resulting outputs. Be sure to include some negative values in your exploration. What is the minimum step size for the output voltage? More often, the inputs for a DAC are generated electronically. As a simple example, set up a 74LS193 counter as in Lab 11. Drive its clock with the sync pulse from the function generator. The same signal can drive the WR pin of the AD7569. Use the four outputs of the counter to drive pins DB0 3 of the DAC, and tie pins DB4 7 low. Observe the output on the scope. You should see a sawtooth ramp, and at higher speeds, the discrete output levels should be evident. What do you observe at very high clock speeds, for instance 500 khz to 5 MHz? The DAC is specified to have a 1 µs settling time. Are your observations consistent with that? 12.6 ADC Converting from analog to digital is a little more complicated because there are two different modes of operation. In Mode 1, the conversion timing is controlled with the RD and ST pins, while in Mode 2, only the RD signal is used and the timing is more automatic. 12-5

12.7 Nyquist Sampling Theorem 12 CONVERTING BETWEEN DIGITAL AND ANALOG Either mode requires a clock signal to drive the successive approximation register circuitry. This can be generated internally, by tying a resistor and capacitor in parallel from the Clk pin to ground. The recommended values (see Fig. 21 on page 15 of the datasheet) are R = 7.3 kω and C = 68 pf. If these values aren t available, try to choose a similar pair with about the same RC. Mode 1 is convenient for manual operation. Connect RD and ST to a pair of DIO pins that are set low. Tie WR low. Apply a voltage to V in from the variable power supply, but do not exceed ±2.. Monitor all eight DB pins on DIO channels with the Digital Reader. Monitor the input level with a voltmeter. To make a conversion, first toggle RD high, which temporarily disables the DB pins. Then apply a rising edge to ST, which initiates the conversion. Set ST low again, and then set RD low again to display the new data. Try a handful of input levels, both positive and negative. Again, make a table of the results in your report, and make sure they are what you expect. How repeatable are the results, and what does the repeatability indicate about the noise in the circuit? To make a more automatic measurement, let us digitize a sine wave. Here it will be more convenient to use Mode 2 of the ADC. If ST is tied high, then a conversion will start whenever RD goes low. After the conversion, the new values will automatically be updated to the outputs. See for instance Figure 12 in the datasheet. To drive RD, we can use a DIO pin with the digital writer in the Alternating 1/0 s configuration, in which the bits automatically toggle at about 7 Hz. Drive the input with a 0.2 Hz sine wave, with 1 Vpp amplitude and 0.6 V offset. Observe the digital outputs on the Digital Reader. The output changes too fast to track directly, but as the input signal oscillates up and down, you should see the bit pattern shift from the left to the right. If we wanted to take the trouble, it would be simple to store such data into a RAM chip for later retrieval. 12.7 Nyquist Sampling Theorem When converting between digital and analog values, the Nyquist Sampling Theorem provides important guidance on the relation between signal bandwidth and sampling frequency. It states that in order to accurately encode a signal of frequency f, the wave form must be sampled at a frequency of at least 2f. Thus if your signal contains frequency components up to 10 khz, your ADC/DAC system must run at at least 20 khz. If the sampling rate is slower than this, the digitized wave form will be inaccurate. We can use the AD7569 chip to see this effect in action. We wil start with an analog sine wave and digitize it. If the sample rate is too low, Nyquist indicates that our digitized version will be erroneous. It is hard to tell this by looking at the digital values, however, so we will instead try to recreate the analog signal with the ADC. If there are no errors, the initial and final wave forms should be similar. We shall observe what happens when this is not the case. The 7 Hz trigger signal from the Digital Writer is to slow to be convenient here. So first, build a circuit to generate your own trigger using a 7555 timer chip, as in Lab 11. Pick a resistor/capacitor pair to give a clock frequency between 50 khz and 100 khz. Measure this frequency using your scope. 12-6

12.7 Nyquist Sampling Theorem 12 CONVERTING BETWEEN DIGITAL AND ANALOG Using the DAC and ADC together is relatively straightforward. The ADC puts its results on the data bus shortly after the RD signal drops low, and holds them there until the signal goes high. The DAC takes it s values from the bus when the WR signal goes high. So if we wire RD and WR together, then the DAC will always have the current value available when needed. The data pins can be simply left open. In fact, this scheme is not ideal, because it relies on a logic race. In practice, the DAC needs to have its inputs held on the bus for about 10 ns after the WR signal rises, because it takes that long to transfer the data into its internal register. On the other hand, the ADC takes about 10 ns to clear the bus after the RD signal goes high. So our scheme will only work if the clear time of the ADC is a little longer than the hold time of the DAC. In fact, it is. A better design would not leave this to chance, but would instead delay the RD signal slightly by, for instance, passing it through two inverters before applying it to the chip. For simplicity, however, we won t bother with that here. To implement this, apply the signal from your 7555 timer chip to both the RD and WR pins. (Make sure the ST pin is still held high.) Drive the ADC input with a sine wave with 1 Vpp amplitude, and monitor both the input and the output on the scope. Start with an input frequency of about 1 khz. You should see the output follows the input nicely. To understand the Nyquist phenomenon, start by observing the output wave only, using it as your trigger source. This is appropriate, because you would not normally have the input signal available when you are later trying to reconstruct it from the digitized data. (For instance, if you digitally recorded a music concert, you would not have the original analog sound signal available when you later tried to play back your recording.) Observe the signal as you gradually increase the input wave frequency. The signals will probably be clearest if you adjust the trigger level to near the top (or bottom) of the wave form. You can locate these points as the edges of the range over which the scope triggers. Does the signal still look like a sine wave as you approach and then exceed half the timer frequency? What happens if the input frequency is close to the timer frequency? To help see what is going on, display the input and output signals together on the scope. Keep using the output signal for the trigger, however. Sweep over the input frequencies again. It should be clear that near the Nyquist frequency, the samples occur at basically random times within the wave form, leading to a jumbled output signal. Can you explain why the output appears as it does when the input frequency is near the timer frequency? Finally, change the scope to trigger on the input signal. In this configuration, does anything special seem to happen as you pass through the Nyquist frequency? By using the input signal as a reference, the scope is able to sort the jumbled output signal levels appropriately, so that it looks like the output is more or less correct. What do you observe at the timer frequency now? The fact that an under-sampled high frequency signal is reconstructed at a lower frequency is called aliasing. It can be a source of confusion, since it causes spurious signals to occur at frequencies you don t expect. The best solution is to always use a low-pass filter on the input to an ADC so that signal components above the Nyquist frequency are attenuated away rather than aliased. 12-7