1 / 24

Intro to D/A Conversion & A/D Conversion

Learn about the process of digital-to-analog (D/A) conversion and analog-to-digital (A/D) conversion. Understand the difference between analog and digital signals, the mapping of binary numbers to voltage levels, and the design of D/A converters.

leathers
Download Presentation

Intro to D/A Conversion & A/D Conversion

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ECE 3430 – Introduction to Microcomputer SystemsUniversity of Colorado at Colorado Springs Lecture #18 Agenda Today: 1) Digital-to-Analog Conversion (D/A conversion) 2) Analog-to-Digital Conversion (A/D conversion) ECE 3430 – Intro to Microcomputer Systems Fall 2015

  2. Analog Signals vs. Digital Signals • Despite what you hear in the media, we don’t live in a digital world! • Electricity by its nature is analog! • Analog electrical signals have a continuous voltage and current range. • When analog signals are restricted to one of a series of discrete voltages, we can map each of these voltage levels to one of n numbers. When we do this, we call it digital. • Numbers are made up of digits—hence why it is called digital. • Today, almost all digital systems operate on two discrete voltage levels. This maps nicely into a binary domain. Because of this, people will use the terms binary and digital interchangeably although they don’t technically have to mean the same thing. ECE 3430 – Intro to Microcomputer Systems Fall 2015

  3. Analog Signals vs. Digital Signals • Different logic families (TTL, CMOS, ECL, et cetera) map different voltages to logic 0 and logic 1: • TTL: 0V = logic 0, +?V = logic 1 • CMOS: 0V = logic 0, +?V = logic 1 • ECL: -?V = logic 0, 0V = logic 1 • When negative logic is employed, the voltages that normally correspond to logic 0 and logic 1 are reversed! • On our breadboard in the lab, we treat +3.3V as a logic 1 and 0V as a logic 0. • Acronyms: TTL = Transistor-to-Transistor Logic (BJT) CMOS = Complementary Metal Oxide Semiconductor Logic (MOSFET) ECL = Emitter-Coupled Logic (BJT) ECE 3430 – Intro to Microcomputer Systems Fall 2015

  4. Digital-to-Analog Conversion (D/A) • Digital-to-analog conversion is the process of mapping a number to an analog voltage. • A single binary digit (bit) maps to one of two discrete voltages. • A series of binary digits (bits) maps to series of discrete voltages (resolution/precision): • An n-bit binary number can map to 2n voltage levels. • An 8-bit binary number can map to 256 voltage levels. • A device that takes a series of bits and outputs a voltage is called a digital-to-analog converter, D/A converter, or DAC. • These binary digits can be fed to the D/A converter as a serial bit stream or as a set of parallel inputs. • There are many ways to design D/A converters. The design of the D/A converter determines what range of analog voltages you will get for a set of digital inputs… ECE 3430 – Intro to Microcomputer Systems Fall 2015

  5. Digital-to-Analog Conversion (D/A) • Assume an 8-bit D/A converter is designed to output an analog voltage between 0 and +5V: 0 = 00000000 -> 0V 63 = 00111111 -> +1.25V 127 = 01111111 -> +2.5V 255 = 11111111 -> +5V • Basic equation: Vout = Din/(2n - 1) * Vmax • The output of a D/A converter can be shifted or amplified using additional analog circuitry. Voltage is proportional to number magnitude. Dividing number by two will divide the output voltage in half. ECE 3430 – Intro to Microcomputer Systems Fall 2015

  6. Digital-to-Analog Conversion (D/A) • Simple example of a serial, pulse-width modulated (PWM) D/A converter: • This D/A converter is simply a low-pass filter with rolloff frequency defined as follows: frolloff = 1/(2*π*R*C) where: R = resistor value (Ohms) C = capacitor value (Farads) ECE 3430 – Intro to Microcomputer Systems Fall 2015

  7. Digital-to-Analog Conversion (D/A) • The low-pass (RC) filter will be driven with a serial stream of bits (voltage fluctuations between 0V and Vcc/Vdd). • A low-pass filter will pass frequencies below the rolloff frequency and attenuate frequencies above the rolloff frequency. • Rolloff frequency is also sometimes called cutoff or turnover frequency. • To use this kind of serial D/A converter, we must use digital electronics to convert a binary number into a periodic square wave. • If we drive the bits at the filter at a rate much lower than the rolloff frequency, we would expect to see a square wave at the output of the D/A converter (clearly not what we want). • If we drive the bits at the filter at a rate much higher than the rolloff frequency, we would expect to see no oscillation on the output (high frequency is being filtered—what we want). ECE 3430 – Intro to Microcomputer Systems Fall 2015

  8. Digital-to-Analog Conversion (D/A) • However, the passive RC filter has a DC offset (due to charge accumulated on the capacitor). When a non-zero voltage is applied to the top terminal of the capacitor, it slowly starts charging to match that voltage. • When a zero voltage is applied to the top terminal of the capacitor, the capacitor starts discharging. • The voltage at the output of the D/A converter is simply the average voltage presented at Vin. • The average voltage of a square wave is proportional to the duty cycle. So, does the frequency matter at all? ECE 3430 – Intro to Microcomputer Systems Fall 2015

  9. Digital-to-Analog Conversion (D/A) • The frequency must simply stay much greater that the rolloff frequency. We just vary the duty cycle of the input waveform to control the analog output: 0% duty cycle -> 0V 25% duty cycle -> +1.25V 50% duty cycle -> +2.5V 100% duty cycle -> +5V How would you recommend we generate a waveform with fixed frequency and variable duty cycle in the MSP432? ECE 3430 – Intro to Microcomputer Systems Fall 2015

  10. Digital-to-Analog Conversion (D/A) • We could use output compare to generate a square wave with a programmable duty cycle and fixed frequency. A parallel D/A converter: • Each combination of bits yields a discrete voltage output… • Examples: R-2R Ladder DAC • Vref defines the maximum analog output (mapping to all 1’s). Vref Parallel Digital Input (n-bit input) D/A Analog Output ECE 3430 – Intro to Microcomputer Systems Fall 2015

  11. Digital-to-Analog Conversion (D/A) R-2R ladder: • Works well if all resistors (values of R) are “exactly the same”. • Each input is GND or Vcc/Vdd. • Current division (KCL) principles at play here. • Vout is proportional to the binary number provided on a(0)-a(n-1). • “Instantaneous” conversion time. ECE 3430 – Intro to Microcomputer Systems Fall 2015

  12. Digital-to-Analog Conversion (D/A) • 00000000 -> 0V 00000001 -> ~0.02V 00000010 -> ~0.04V 11111111 -> +5V Granularity in the output voltages. What if we needed 0.03V? • Use smaller voltage reference (assign smaller voltage to 11111111). • Use more bits. • With this kind of parallel D/A converter, we don’t need to create a periodic waveform. For the serial, PWM D/A, why not use a large capacitor to establish a low rolloff frequency so we don’t have to generate such a high- frequency square wave? ECE 3430 – Intro to Microcomputer Systems Fall 2015

  13. Analog-to-Digital Conversion (A/D) • Analog-to-digital conversion is the process of mapping an arbitrary voltage to one of n discrete numbers. • As with D/A converters, A/D converters are designed to work with a specific number of bits (resolution/precision). • An n-bit A/D converter will map a voltage to one of 2n numbers. • A device that accepts an analog voltage and produces a corresponding number to represent that voltage is called an analog-to-digital converter, A/D converter, or ADC. • The binary output of an A/D converter can be handed to another device in parallel or as a serial bit stream. • As with D/A converters, there are many ways to design A/D converters. • A/D converters use a reference voltage to define what voltage will yield the maximum binary output… ECE 3430 – Intro to Microcomputer Systems Fall 2015

  14. Analog-to-Digital Conversion (A/D) • An 8-bit A/D converter with +5V tolerant inputs and a voltage reference set to +5V will produce output as follows: 0V -> 0 = 00000000 +1.25V -> 63 = 00111111 +2.5V -> 127 = 01111111 +5V -> 255 = 11111111 • If the reference voltage were changed to +2.5V, then the digital output for +2.5V would be 11111111. • Some A/D converters have differential inputs (the input voltage is the difference between two input pins). • Some A/D converters have differential voltage references (to establish both a high and low voltage reference). Number magnitude is proportional to input voltage. Dividing voltage in half will yield a binary output half as big. ECE 3430 – Intro to Microcomputer Systems Fall 2015

  15. Analog-to-Digital Conversion (A/D) • Basic equation (for single input, single voltage reference): Dout = Vin/Vref * (2n - 1) • Basic equation (for differential input, single voltage reference): Dout = (V+in - V-in)/Vref * (2n - 1) • Applied voltages to an A/D converter can be scaled and shifted using additional analog circuitry to meet the requirements of the A/D converter. • A/D converters suffer from a phenomenon known as quantizationerror. A specific voltage will be “rounded” to the nearest whole number. This means that the digital output is not entirely accurate for all voltage inputs. What can be done to reduce quantization error? ECE 3430 – Intro to Microcomputer Systems Fall 2015

  16. Analog-to-Digital Conversion (A/D) So how does an analog-to-digital converter work? • One very common technique for doing analog-to-digital conversion is called the successive approximation method. • This method involves the use of an analog comparator, a D/A converter, control logic, and storage for a digital approximation (SAR): ECE 3430 – Intro to Microcomputer Systems Fall 2015

  17. Analog-to-Digital Conversion (A/D) • The successive approximation method executes sequentially (it takes a clock cycle for each bit in the final result). An 8-bit A/D would take 8 cycles to calculate the 8-bit result. • The approximation register is first cleared, then the most-significant bit is calculated first…then the others: • Guess bit to be 1. • Provide current value in approximation register to D/A converter. • Analog comparator compares D/A output with externally provided analog input. • Control logic clears the bit that it set if D/A output is larger than externally provided input (the initial guess was wrong). • Repeat above steps for all the other bits. ECE 3430 – Intro to Microcomputer Systems Fall 2015

  18. Analog-to-Digital Conversion (A/D) • The MSP432 ADC14 module uses successive approximation. • More specifically, the MSP432 ADC14 module uses a switched-capacitor DAC scheme instead of an older R-2R DAC approach. • Some uCs have an A/D module based on a Sigma-Delta (sometimes called Delta-Sigma) A/D converter scheme. • This A/D scheme is very complicated (w/r/t SAR) and beyond the scope of this course. • This type of converter gives you more precision—but slower to stabilize. • The only A/D converter we have on the P401R part is the ADC14. ECE 3430 – Intro to Microcomputer Systems Fall 2015

  19. Analog-to-Digital Conversion (A/D) Another alternative… Flash ADC: • Produces digital result “in a flash”! • Instantaneous output change. • Lots of circuitry required however. • Required in multimedia applications or any time rapid conversions are required. ECE 3430 – Intro to Microcomputer Systems Fall 2015

  20. A/D and D/A General Issues A/D and D/A General Issues: • Accuracy • How consistent are repeated conversions with a constant analog or digital input? • Resolution/Precision • If the analog or digital input changes very slightly, will the digital or analog output reflect the change? ECE 3430 – Intro to Microcomputer Systems Fall 2015

  21. A/D and D/A Uses • We live in an analog world, so input from many different sensors are analog in their nature. • Many forms of stimulus that a microcontroller needs to monitor are not electrical in nature: • Temperature • Pressure • Light • Weight • Airflow • Humidity • Et cetera • Transducers are used to transform the non-electrical quantities mentioned above into analog voltages (and vice-versa). • Now if a microcontroller is expected to understand this analog information (i.e. detect the temperature, pressure, amount of light, et cetera) it needs an A/D converter to convert this quantity to a number. ECE 3430 – Intro to Microcomputer Systems Fall 2015

  22. A/D and D/A Uses • Transducers are devices that convert one form of energy to another form of energy. For our purposes we are typically interested in converting non-electrical energy into electrical energy and vice-versa. • Examples of transducers: • Piezoelectric materials • Microphone/speakers • Photoelectric cells/light bulbs/LEDs • Electrical generators/electrical motors • …and the list goes on forever… • If a microcontroller expects to make sound, move an object with a motor, generate light, and so on, the digital information it contains must be translated. First a D/A converter converts digital information into a pure form of electricity (analog voltage). Then a transducer can change electrical energy into some other form of energy. ECE 3430 – Intro to Microcomputer Systems Fall 2015

  23. A/D and D/A Uses • The analog input to an A/D or the analog output of a D/A may not meet the electrical requirements for the transducer. • Signal conditioning (amplification and shifting) can be applied to these analog signals. • Operational amplifier circuits are often used for this. • The A/D or D/A voltage references may need to change for different applications. • Noise can be an issue. • Digital clock lines contain very high frequency components and can “rattle” nearby analog voltages. • AC sources are a common source of 50 or 60 Hz noise. • Noise can be dampened with capacitors and mitigated by decoupling analog and digital voltage rails. ECE 3430 – Intro to Microcomputer Systems Fall 2015

  24. The MSP432 (D/A and A/D) • Can reconfigure port pins to become analog inputs. • Our MSP432 (P401R) has only one ADC14 module. • Some uCs (not ours) have one or more D/A converters. • If an A/D converter or D/A converter is not built into your microcontroller, then you have to interface one externally (but this generally isn’t a big deal). • There are many standalone A/D and D/A converters on the market to choose from. ECE 3430 – Intro to Microcomputer Systems Fall 2015

More Related