Analogue-to-Digital Converters, (ADCs) allow micro-processor controlled circuits, Arduinos, Raspberry Pi, and other such digital logic circuits to communicate with the real world. In the real world, analogue signals have continuously changing values which come from various sources and sensors which can measure sound, light, temperature or movement, and many digital systems interact with their environment by measuring the analogue signals from such transducers.
While analogue signals can be continuous and provide an infinite number different voltage values, digital circuits on the other hand work with binary signal which have only two discrete states, a logic “1” (HIGH) or a logic “0” (LOW). So it is necessary to have an electronic circuit which can convert between the two different domains of continuously changing analogue signals and discrete digital signals, and this is where Analogue-to-Digital Converters (A/D) come in.
Basically an analogue to digital converter takes a snapshot of an analogue voltage at one instant in time and produces a digital output code which represents this analogue voltage. The number of binary digits, or bits used to represent this analogue voltage value depends on the resolution of an A/D converter.
For example a 4-bit ADC will have a resolution of one part in 15, (24 – 1) whereas an 8-bit ADC will have a resolution of one part in 255, (28 – 1). Thus an analogue to digital converter takes an unknown continuous analogue signal and converts it into an “n”- bit binary number of 2n bits.
But first let us remind ourselves of the differences between an analogue (or analog) signal and a digital signal as shown:
Analogue and Digital Signals
Here we can see that as the wiper terminal of the potentiometer is rotated between between 0 volts and VMAX, it produces a continuous output signal (or voltage) which has an infinite number of output values relative to the wiper position. As the potentiometers wiper is adjusted from one position to the next, there is no sudden or step change between the two voltage levels thereby producing a continuously variable output voltage. Examples of analogue signals include temperature, pressure, liquid levels and light intensity.
For a digital circuit the potentiometer wiper has been replaced by a single rotary switch which is connected in turn to each junction of the series resistor chain, forming a basic potential divider network. As the switch is rotated from one position (or node) to the next the output voltage, VOUT changes quickly in discrete and distinctive voltage steps representing multiples of 1.0 volts on each switching action or step as shown.
So for example, the output voltage will be 2 volts, 3 volts, 5 volts, etc. but NOT 2.5V, 3.1V or 4.6V. Finer output voltage levels could easily be produced by using a multi-positional switch and increasing the number of resistive elements within the potential divider network, therefore increasing the number of discrete switching steps.
Then we can see that the major differences between an analogue signal and a digital signal is that an “Analogue” quantity is continuously changing over time while a “Digital” quantity has discrete (step by step) values. “LOW” to “HIGH” or “HIGH” to “LOW”.
So how can we convert a continously changing signal with an infinite number of values to one which has distinct values or steps for use by a digital circuit.
The process of taking an analogue voltage signal and converting it into an equivalent digital signal can be done in many different ways, and while there are many analogue-to-digital converter chips such as the ADC08xx series available from various manufacturers, it is possible to build a simple ADC using discrete components.
One simple and easy way is by using parallel encoding, also known as flash, simultaneous, or multiple comparator converters in which comparators are used to detect different voltage levels and output their switching state to an encoder.
Parallel of “Flash” A/D converters use a series of interconnected but equally spaced comparators and voltage references generated by a series network of precision resistors for generating an equivalent output code for a particular n-bit resolution.
The advantage of parallel or flash converters is that they are simple to construct and do not require any timing clocks as the instant an analogue voltage is applied to the comparator inputs, it is compared against a reference voltage. Consider the comparator circuit below.
An analogue comparator such as the LM339N which has two analogue inputs, one positive and one negative, and which can be used to compare the magnitudes of two different voltage levels.
A voltage input, (VIN) signal is applied to one input of the comparator, while a reference voltage, (VREF) to the other. A comparison of the two voltage levels at the comparator’s input is made to determine the comparators digital logic output state, either a “1” or a “0”.
The reference voltage, VREF is compared against the input voltage, VIN applied to the other input. For an LM339 comparator, if the input voltage is less than the reference voltage, (VIN < VREF) the output is “OFF”, and if it is greater than the reference voltage, (VIN > VREF) the output will be “ON”. Thus a comparator compares two voltage levels and determines which one of the two is higher.
In our simple example above, VREF is obtained from the voltage divider network setup by R1 and R2. If the two resisors are of equal values, that is R1 = R2, then clearly the reference voltage level will be equal to half the supply voltage, or V/2. So for a comparator with an open-collector output, if VIN is less than V/2, the output is HIGH, and if VIN is greater than V/2, the output is LOW acting as a 1-bit ADC.
But by adding more resistors to the voltage divider network we can effectively “divide” the supply voltage by an amount determined by the resistances of the resistors. However, the more resistors we use in the voltage divider network the more comparators will be required.
In general, 2n– 1 comparators would be required for conversion of an “n”-bit binary output, where “n” is typically in the range from 8 to 16. In our example above, the single bit ADC used 21– 1, which equals “1” comparator to determine if VIN was greater or smaller than the V/2 reference voltage.
If we now create a 2-bit ADC, then we will need 22– 1 which is “3” comparators as we need four different voltage levels corresponding to the 4 digital values required for a 4-to-2 bit encoder circuit as shown.
2-bit Analogue to Digital Converter Circuit
This will give us a 2-bit output code for all four possible values of analogue input of:
2-bit A/D converter Output
|0 to 1 V||0||0||0||0||0||0|
|1 to 2 V||0||0||1||X||0||1|
|2 to 3 V||0||1||X||X||1||0|
|3 to 4 V||1||X||X||X||1||1|
Where: “X” is a “don’t care”, that is either a logic “0” or a logic “1” condition.
So how does this analogue-to-digital converter work. For an A/D converters to be useful it has to produce a meaningful digital representation of the analogue input signal. Here in this simple 2-bit ADC example we have assumed for simplicity that the input voltage VIN is between 0 and 4 volts, so have set VREF and the resistive voltage-divider network to drop 1 volt across each resistor.
When VIN is between 0 and 1 volt, (<1V) the input on all three comparators will be less than the reference voltage, so their outputs will be LOW and the encoder will output a binary zero (00) condition on pins Q0 and Q1. When VIN increases and exceeds 1 volt but is less than 2 volts, (1V<VIN<2V) comparator U1 which has a reference voltage input set at 1 volt, will detect this voltage difference and produce a HIGH output. The priority encoder which is used as the 4-to-2 bit encoding detects the change of input at D1 and produces a binary output of “1” (01).
Note that a Priority Encoder such as the TTL 74LS148 allocates a priority level to each individual input. The priority encoders output corresponds to the currently active input which has the highest priority. So when an input with a higher priority (D1 compared to D0) is present, all other inputs with a lower priority will be ignored. So if there are two or more inputs at logic level “1” at the same time, the actual output code on D0 and D1 would only correspond to the input with the highest designated priority.
So now as VIN increases above 2 volts, the next reference voltage level, comparator U2 detects the change and produces a HIGH output. But because input D2 has a higher priority than inputs D0 or D1, the priority encoder outputs a binary “2” (10) code, and so on when VIN exceeds 3 volts producing a binary code output of “3” (11). Clearly as VIN reduces or changes between each reference voltage level, each comparator will output either a HIGH or a LOW condition to the encoder which inturn produces a 2-bit binary code between 00 and 11 relative to VIN.
This is all well and good, but priority encoders are not available as 4-to-2 bit devices, and if we use a commercially available one such as the TTL 74LS148 or its CMOS 4532 equivalent which are both 8-bit devices, then six of the binary bits would not be used. But a simple encoder circuit can be made using digital Ex-OR gates and a matrix of signal diodes as shown.
2-bit ADC Using Diodes
Here the outputs of the comparators are encoded using Exclusive-OR gates before being fed to the diodes. Two external pull-down resistor are used at their outputs and ground (0V) to ensure a LOW condition and stop the outputs from floating when the diodes are reverse biased.
So as with the previous circuit, depending upon the value of VIN determines which comparator produces an output signal HIGH (or LOW) to the exclusive-OR gates producing a HIGH output if one input or the other input is HIGH, but not both, (Boolean expression is Q = A.B + A.B). These Ex-OR gates could also be constructed using the combinational logic AND–OR–NAND gates.
The problem here with both designs of 4-to-2 converters is that the resolution of this simple 2-bit A/D converter is 1 volt because as we have seen, the analogue input voltage at VIN must change by one full volt in order for the encoder to change its output code. One way to improve the resolution of the output is to increase it to a 3-bit A/D converter using more comparators.
3-bit Analogue-to-Digital Converter
The parallel ADC above converts the analogue input voltage in the range from 0 to over 3 volts to produce a 2-bit binary code. Since a 3-bit digital logic system can generate 23 = 8 different digital outputs, the analogue input voltage can therefore be compared against eight reference voltage levels with each voltage level being equal to one eighth (V/8) of the reference voltage. Thus we could now measure a resolution of 0.5 (4/8) volts and would require 23– 1 comparators for a 3-bit binary code output between 000 (0) and 111 (7) as shown.
3-bit Analogue to Digital Converter Circuit
This will give us a 3-bit output code for all eight possible values of analogue input of:
3-bit A/D converter Output
|0 to 0.5 V||0||0||0||0||0||0||0||0||0||0||0|
|0.5 to 1.0 V||0||0||0||0||0||0||1||X||0||0||1|
|1.0 to 1.5 V||0||0||0||0||0||1||X||X||0||1||0|
|1.5 to 2.0 V||0||0||0||0||1||X||X||X||0||1||1|
|2.0 to 2.5 V||0||0||0||1||X||X||X||X||1||0||0|
|2.5 to 3.0 V||0||0||1||X||X||X||X||X||1||0||1|
|3.0 to 3.5 V||0||1||X||X||X||X||X||X||1||1||0|
|3.5 to 4.0 V||1||X||X||X||X||X||X||X||1||1||1|
Where again “X” is a “don’t care”, that is either a logic “0” or a logic “1” input condition.
Then we can see, that by increasing the resolution of the ADC, not only increases the number of output binary bits, but also increases the number of comparators and voltage levels needed.
Thus a 4-bit resolution requires 15 (24– 1) comparators, an 8-bit resolution requires 255 (28– 1) comparators, while a 10-bit analogue-to-digital converter would require 1023 comparators, etc. So for this type of Analogue-to-Digital Converter circuit, the higher the number of output bits required, the more complex becomes the circuit.
However, the advantage of this type of parallel or flash A/D converter is that its real-time conversion rate is relatively fast and can be easily built as part of a project if only a few binary bits are required to produce a read out on a digital display to show the voltage value of an analogue input signal.
As well as taking an analogue input signal from a sensor or transducer and converting it using an analogue-to-digital converter into a digital binary code as part of an input interfacing circuit, we can also take a binary code and convert it into an equivalent analogue quantity using a Digital-to-Analogue Converter for output interfacing to control a motor or actuator, or commonly in audio applications.
In the next tutorial about digital circuits, we will look at the a digital-to-analogue converter, or simply DAC, which are the exact opposite of the analogue-to-digital converters looked at here. DAC’s use op-amps and resistive divider networks to convert an “n”-bit binary number into an equivalent analogue output voltage, or current signal.