ADC and DAC Interfacing With 8051
ADC and DAC Interfacing With 8051
➢ An ADC has n-bit resolution where n can be 8, 10, 12, 16 or even 24 bits.
➢ The higher-resolution ADC provides a smaller step size, where step size is the smallest
change that can be discerned by an ADC. This is shown in Table 5.5.1.
[Source: “The 8051Microcontroller and Embedded Systems: Using Assembly and C” by Mohamed Ali Mazidi,
Janice Gillispie Mazidi, Rolin McKinlay]
➢ Conversion time is defined as the time it takes the ADC to convert the analog input to
a digital (binary) number.
➢ In parallel ADC, we have 8 of more pins dedicated to bringing out the binary data, but
in serial ADC we have only one pin for data out.
ADC804 CHIP:
➢ In ADC804 conversion time varies depending on the clocking signals applied to the
CLK R and CLK IN pins, but it cannot be faster than 110μs.
Vref/2: (Pin 9)
• It is used for the reference voltage.
• If this pin is open (not connected), the analog input voltage is in the range of 0 to 5 volts
(the same as the Vcc pin).
• If the analog input range needs to be 0 to 4 volts, Vref/2 is connected to 2 volts.
Table 5.5.2 shows the Vin range for various Vref/2 inputs.
[Source: “The 8051Microcontroller and Embedded Systems: Using Assembly and C” by Mohamed Ali Mazidi,
Janice Gillispie Mazidi, Rolin McKinlay]
D0-D7 are the digital data output pins.
• These are tri-state buffered and the converted data is accessed only when CS =0 and RD
is forced low.
• To calculate the output voltage, use the following formula
Where Dout = digital data output (in decimal), Vin = analog voltage, and Step size
(resolution) is the smallest change, which is (2 * Vref/2)/256 for ADC 0804
Analog ground is connected to the ground of the analog Vin and digital ground is
connected to the ground of the Vcc pin.
• The reason that to have ground pin is to isolate the analog Vin signal from transient
voltages caused by digital switching of the output D0 – D7. This contributes to the
accuracy of the digital data output.
The two method of creating a DAC is binary weighted and R/2R ladder.
The Binary Weighted DAC, which contains one resistor or current source for each
bit of the DAC connected to a summing point. These precise voltages or currents sum to
the correct output value. This is one of the fastest conversion methods but suffers from
poor accuracy because of the high precision required for each individual voltage or
current. Such high-precision resistors and current-sources are expensive, so this type of
converter is usually limited to 8-bit resolution or less.
The R-2R ladder DAC, which is a binary weighted DAC that uses a repeating
cascaded structure of resistor values R and 2R. This improves the precision due to the
relative ease of producing equal valued matched resistors (or current sources). However,
wide converters perform slowly due to increasingly large RC-constants for each added
R-2R link.
The first criterion for judging a DAC is its resolution, which is a function of the
number of binary inputs. The common ones are 8, 10, and 12 bits. The number of data
bit inputs decides the resolution of the DAC since the number of analog output levels is
equal to 2n, where n is the number of data bit inputs. Therefore, an 8-input DAC such as
the DAC0808 provides 256 discrete voltage (or current) levels of output. Similarly, the
12-bit DAC provides 4096 discrete voltage levels. There also 16-bit DACs, but they are
more expensive.
DAC 0808:
➢ The digital inputs are converter to current (Iout), and by connecting a resistor to the
Iout pin, we can convert the result to voltage.
➢ The total current provided by the Iout pin is a function of the binary numbers at the
D0-D7 inputs of the DAC0808 and the reference current (Iref), and is as follows
➢ Ideally, we connect the output pin to a resistor, convert this current to voltage, and
monitor the output on the scope.
➢ But this can cause inaccuracy; hence an opamp is used to convert the output current
to voltage.
➢ Now assuming that Iref = 2mA, if all the inputs to the DAC are high, the maximum
output current is 1.99mA.
➢ In real life, however, this can cause inaccuracy since the input resistance of the load
where it is connected will also affect the output voltage.
➢ For this reason, the lref current output is isolated by connecting it to an op-amp such
as the 741 with Rf = 5K ohms for the feedback resistor.
➢ Assuming that R= 5K ohms, by changing the binary input, the output voltage changes
as shown in Example 2.
Example 2:
In order to generate a stair-step ramp, set up the circuit in Figure 5.5.4 and connect the
output to an oscilloscope. Then write a program to send data to the DAC to generate a
stair-step ramp.
CLR A
AGAIN: MOV P1,A ; SEND DATA TO DAC
INC A ; COUNT FROM 0 TO FFH
ACALL DELAY ; LET DAC RECOVER
SJMP AGAIN
Example 3:
Write an ALP to generate a triangular waveform.
SENSOR INTERFACING:
LM35 TEMPERATURE SENSORS:
➢ The LM35 series sensors are precision integrated-circuit temperature sensors whose
output voltage is linearly proportional to the celsius (centigrade) temperature.
[Source: “The 8051Microcontroller and Embedded Systems: Using Assembly and C” by Mohamed Ali Mazidi,
Janice Gillispie Mazidi, Rolin McKinlay]
The sensors of the LM34 series are precision integrated-circuit temperature sensors
whose output voltage is linearly proportional to the Fahrenheit temperature.
It outputs 10mV for each degree Fahrenheit temperature.
SIGNAL CONDITIONING AND INTERFACING THE LM35 TO THE 8051
[Source: “The 8051Microcontroller and Embedded Systems: Using Assembly and C” by Mohamed Ali Mazidi,
Janice Gillispie Mazidi, Rolin McKinlay]
➢ The change of resistance must be translated into voltages in order to be of any use to
an ADC.
➢ Since the ADC0848 has 8-bit resolution with a maximum of 256 (28) steps and the
LM35 (or LM34) produces l0 mV for every degree of temperature change, we can
condition Vin of the ADC0848 to produce a Vout, of 2560 mV (2.56 V) for full-scale
output.
➢ Therefore, in order to produce the full-scale Vout of 2.56 V for the ADC0848, we
need to set Vref = 2.56.
➢ The LM336-2.5 zener diode to fix the voltage across the 10K pot at 2.5V.
➢ The use of the LM336-2.5 should overcome any fluctuations in the power supply.
CONVERSION:
MOV B,#10
DIV AB
MOV R7,B
MOV B,#10
DIV AB
MOV R6,B
MOV R5,A
RET
DATA_DISPLAY:
MOV P0,R7
ACALL DELAY
MOV P0,R6
ACALL DELAY
MOV P0,R5
ACALL DELAY
RET