The purpose of this lab activity is to explore the concepts of analog to digital conversion by building explanatory examples.
Analog-to-Digital converters (ADC) translate analog signals, real world signals like temperature, pressure, voltage, current, distance, or light intensity, into a digital representation of that signal. This digital representation can then be processed, manipulated, computed, transmitted or stored.
Figure 1. Analog to Digital conversion
An ADC samples an analog waveform at uniform time intervals and assigns a digital value to each sample. The digital value appears on the converter’s output in a binary coded format. The value is obtained by dividing the sampled analog input voltage by the reference voltage and them multiplying by the number of digital codes. The resolution of converter is set by the number of binary bits in the output code.
Figure 2. Digital output code
An ADC carries out two processes, sampling and quantization. The ADC represents an analog signal, which has infinite resolution, as a digital code that has finite resolution. The ADC produces 2N digital values where N represents the number of binary output bits. The analog input signal will fall between the quantization levels because the converter has finite resolution resulting in an inherent uncertainty or quantization error. That error determines the maximum dynamic range of the converter.
Figure 3. Quantization Process
The sampling process represents a continuous time domain signal with values measured at discrete and uniform time intervals. This process determines the maximum bandwidth of the sampled signal in accordance with the Nyquist Theory. This theory states that the signal frequency must be less than or equal to one half the sampling frequency to prevent aliasing. Aliasing is a condition in which frequency signals outside the desired signal band will, through the sampling process, appear within the bandwidth of interest. However, this aliasing process can be exploited in communications systems design to down-convert a high frequency signal to a lower frequency. This technique is known as under-sampling. A criterion for under-sampling is that the ADC has sufficient input bandwidth and dynamic range to acquire the highest frequency signal of interest.
Figure 4. Sampling Process
Sampling and quantization are important concepts because they establish the performance limits of an ideal ADC. In an ideal ADC, the code transitions are exactly 1 least significant bit (LSB) apart. So, for an N-bit ADC, there are 2N codes and 1 LSB = FS/2N, where FS is the full-scale analog input voltage. However, ADC operation in the real world is also affected by non-ideal effects, which produce errors beyond those dictated by converter resolution and sample rate. These errors are reflected in a number of AC and DC performance specifications associated with ADCs.
Figure 5. Transfer Function for an Ideal ADC
Any analog input in this range gives the same digital output code.
ADALM2000 Active Learning Module
Solder-less breadboard, and jumper wire kit
1 OP482 operational amplifiers
2 AD654 Voltage-to-Frequency Converter
3 1kΩ resistor
5 10kΩ resistor
1 nF capacitor
Flash analog-to-digital converters, also known as parallel ADCs, are one of the fastest way to convert an analog signal to a digital signal. Flash ADCs are ideal for applications requiring very large bandwidth, but they consume more power than other ADC architectures and are generally limited to 8-bit resolution. Typical examples include data acquisition, satellite communication, radar processing, sampling oscilloscopes, and high-density disk drives.
Flash ADCs are made by cascading high-speed comparators. For an N-bit converter, the circuit employs 2N-1 comparators. A resistive-divider with 2N resistors provides the reference voltage. Each comparator produces a 1 when its analog input voltage is higher than the reference voltage applied to it. Otherwise, the comparator output is 0. The point where the code changes from ones to zeros is the point at which the input signal becomes smaller than the respective comparator reference-voltage levels.
Consider the circuit presented in Figure 6.
Figure 6. Flash ADC - analog side circuit
The circuit represents the analog side of a 2-bit Flash ADC with the architecture known as thermometer code (unary code) encoding. For this type of circuit additional logical circuitry is used to decode the unary code to appropriate digital output code.
As mentioned before, flash ADCs are made using high-speed comparators, but for convenience, we are going to use the OP482 quad op-amp to illustrate the principle. Alternatively, you can build the circuit using four AD8561 comparators.
Build the following breadboard circuit for 2-bit Flash ADC.
Figure 7. Flash ADC - analog side breadboard circuit
Supply the circuit to +/-5V from the power supply. Configure AWG1 of the Signal Generator to Rising Ramp Sawtooth with 5V amplitude, 2.5 offset and 100Hz frequency. Use AWG2 as 5V constant reference voltage for the ADC.
Configure the Logic Analyzer so that the digital channels DIO0, DIO1, DIO2, DIO3 form a channel group decoded for Unary code.
A plot with the output signals are presented in Figure 8.
Figure 8. Flash ADC - output code
The plot represents the output thermometer code for the 2-bit Flash ADC with all possible output values, by varying the input analog voltage through the entire available range (0-5V).
For this particular application AD654 Voltage-to-Frequency converter is used as an analog-to-digital converter.
Figure 9. Voltage-to-Frequency Converter as ADC
In order to achieve the conversion, the output of the converter should be connected to a microcomputer that has an interval timer/event counter.
The total number of signal edges (rising or falling) counted during the count period is proportional to the input voltage. For this particular setup a 1 V full-scale input voltage produces a 100 kHz signal. If the count period is 100 ms, then the total count will be 10,000. Scaling from this maximum is then used to determine the input voltage. Thus, a count of 5000 corresponds to an input voltage of 0.5 V.
Build the following breadboard circuit for Voltage-to-Frequency Converter as ADC.
Figure 9. Voltage-to-Frequency Converter as ADC - breadboard connections
Supply the circuit to +5V from the power supply. Configure AWG1 of the Signal Generator to 1V constant voltage
Configure the scope such that the output signal is displayed on channel 1 and enable the frequency measurement from the channel 1 Measure tab.
A plot with the output signal is presented in Figure 10.
Figure 10. Voltage-to-Frequency Converter as ADC at full scale input voltage
The plot represents the output signal of the Voltage-to-Frequency Converter for a 1V full scale input voltage. Notice that the corresponding output frequency is 100kHz.
Now set the input voltage at 0.5V. A plot with the output signal is presented in Figure 11.
Figure 11. Voltage-to-Frequency Converter as ADC at half scale input voltage
The plot represents the output signal of the Voltage-to-Frequency Converter for a 0.5V half scale input voltage. Note that output frequency is now 50kHz.
The successive approximation ADC converts the continuous analog waveform into a discrete digital representation via a binary search through all possible quantization levels before finally converging upon a digital output for each conversion.
Usually, the SAR ADC circuit consists of four subcircuits:
Figure 12. SAR ADC - Typical Architecture
The SAR is initialized so that the most significant bit (MSB) is equal to a digital 1. This code is fed into the DAC, which then supplies the analog equivalent of this digital code (Vref/2) into the comparator circuit for comparison with the sampled input voltage. If this analog voltage exceeds Vin the comparator causes the SAR to reset this bit; otherwise, the bit is left a 1. Then the next bit is set to 1 and the same test is done, continuing this binary search until every bit in the SAR has been tested. The resulting code is the digital approximation of the sampled input voltage and is finally output by the SAR at the end of the conversion (EOC).
Figure 13. SAR ADC example (4-bit)
Figure 13 shows an example of a 4-bit conversion. The y-axis represents the DAC output voltage. In the example, the first comparison shows that VIN < VDAC. Thus, bit 3 is set to 0. The DAC is then set to 0100 and the second comparison is performed. As VIN > VDAC, bit 2 remains at 1. The DAC is then set to 0110, and the third comparison is performed. Bit 1 is set to 0, and the DAC is then set to 0101 for the final comparison. Finally, bit 0 remains at 1 because VIN > VDAC.
In order to emphasize the operation principle of the SAR ADC with ADALM2000, we will use for the DAC part the circuit sudied in the Resistor Ladder Digital to Analog Converter lab, but for this setup we will use a 4-bit DAC (instead of 8-bit). The output of the DAC will be connected to a comparator, while the SAR will be simulated via a script that performs the binary search based on the comparator's output and generates the proper binary value.
Figure 14. SAR ADC schematic
Build the following breadboard circuit for SAR ADC.
Figure 15. SAR ADC breadboard connections
Two Precision Rail-to-Rail op-amps from the OP484 integrated circuit were used for the SAR ADC, one is used for the R-2R Ladder DAC, and the other one as comparator between the DAC output and input voltage.
Supply the circuit to +/-5V from the power supply. Configure the scope so that the comparator output signal is displayed on channel 1 and the DAC output on channel 2.
Group the first 4 digital channels in the Logic Analyzer and set the decoder to parallel.
Download the SAR ADC script from the link in the Resources section.
Run the script using the Scopy interface. (A guide on how to use scripts with Scopy can be found here: Scopy - Scripting Guide )
Visualize the digital output behavior on the Logic Analyzer. An animated plot example is presented in Figure 16.
Figure 16. SAR ADC digital output
The digital code is updated using the successive approximation method based on the feedback received from the comparator output.
Visualize the apporximation behavior of the DAC output in time domain using the Oscilloscope. A plot example is presented in Figure 17.
Figure 17. SAR ADC approximation plot
The output value trying to reach the input value (which is set to 2V in the script ) after several approximation steps.
The Dual-Slope ADC (or a variant) is at the heart of many of the most accurate digital voltmeters. This architecture has a few useful characteristics: only a few precision components are required as most error sources cancel out, it can be configured to reject particular noise frequencies such as 50Hz or 60Hz line noise, and it is insensitive to high-frequency noise.
Figure 18. Dual-Slope ADC structure
The converter operates by applying the unknown input voltage to an integrator for a fixed time period (called “runup”), after which a known reference voltage, of opposite polarity to the input, is applied to the integrator (called “rundown”). Thus, the input voltage can be calculated from the reference voltage and the ratio of the rundown to runup times:
Figure 19. Dual-Slope ADC Integrator output waveforms
By inspection, the accuracy of the dual-slope converter is not affected by the tolerance of most of the components:
The reference voltage does need to be accurate, as it directly affects the measurement. Another error source is dielectric absorption in the integrator capacitor, so polypropylene or polystyrene is ideal, and aluminum electrolytic are not appropriate.
Figure 20. Dual-Slope ADC Integrator output waveforms
Figure 20 shows the frequency response of a dual-slope ADC. The input is sampled for a fixed time interval (runup), the voltage at the beginning of runup has as much influence on the result as the voltage at the end of runup. This is sometimes called a “boxcar average”, and it has the effect of rejecting disturbances (noise) that occur at frequencies of 1/T, 2/T, 3/T, etc. An integration time of 200ms corresponds to 10 cycles of 50Hz noise, and 12 cycles of 60Hz noise, so this is often chosen as the runup time as it rejects line noise in any country in the world.
Open the LTspice file DualSlope.asc
Figure 21. Dual-Slope ADC Integrator Schematic
Run the simulation, probing the Vintegrate node:
Figure 22. Dual-Slope ADC Integrator Simulation 1
The simulation adds 60Hz line noise to a DC input voltage. Several cases are run by the .step directive – input voltages of 1V, 2V, 3V, 4V 5V, and several different phases of the 60Hz line noise. Because the 200ms runup time is an integer number of 60Hz line cycles, the noise falls into a null in the frequency response and rundown time is unaffected, regardless of phase. Change the frequency to 62.5Hz, which lies at a peak in the frequency response:
Figure 23. Dual-Slope ADC Integrator Simulation 2
Build the following breadboard circuit for the dual-slope ADC, and make the indicated connections to the M2K.
Figure 24. Dual-Slope ADC Integrator Breadboard Circuit
Open Scopy. A Scopy initialization file is included to aid in setup,Dual_slope_scopy_setup.ini
Power Supply: Tracking enabled, set to +/-5V
Digitial IO: DIO2 set to OUT, set to 1
Pattern Generator: Group DIO0, DIO1, Pattern: Import (load file dual_slope_pattern.csv ) Frequency set to 5Hz.
Signal Generator: Channel 1 initally set to constant +2.5V
Oscilloscope: 200ms timebase, Ch1 set to 400mV/division. Falling-edge trigger, 200mV (this triggers the M2K at the start of the integrator’s reset interval.)
Figure 25. Dual-Slope ADC Integrator waveform
With the reference tied to the -5V supply and the input voltage set to 2.5V, notice that rundown is 2 divisions (400ms) while runup is 1 division (200ms). Thus:
Vin = 5V * (200ms / 400ms) = 2.5V
By varying the input voltage we can notice a change in the runup time. An animated plot is presented in Figure 26.
Figure 25. Dual-Slope ADC Integrator waveform for different input voltages
Using the formula presented above and different runup time values, can you compute/guess the input voltages applied?
A practical implementation of a dual-slope converter would use a microcontroller to control the integrator and set the runup / measure the rundown times. Most microcontrollers have counter peripherals, making this a fairly easy task.
Some additional resources:
Return to Lab Activity Table of Contents