Interfacing ADC With 8051
Interfacing ADC With 8051
8051
Introduction
• Many times we need to collect data from different sensors
and many sensors give us data in analog form.
• Output from some sensors such as humidity, temperature
(thermistor), light (LDR), pressure is in analog form.
• So, analog to digital converters (ADC’s) are required to
convert the analog output of these sensors to a digital code.
• ADC’s convert the analog quantity (mostly voltage) to a
digital number.
• Some microcontrollers like Atmel AVR and Microchip PIC
have inbuilt ADC’s. But 8051 microcontroller needs an
external ADC.
ADC808
• ADC0808 is most commonly used analog to digital
converter.
• It is an 8-bit analog to digital converter IC.
• It converts an analog input to 8-bit digital code.
• The number of discrete levels produced by ADC for a given
analog input range is called resolution of ADC.
• ADC0808 has a resolution of 8-bits which means for a given
analog input range it can produce 256 (2n) levels or 256
digital codes.
• Suppose our input voltage range is 0 to 1 volt. In this case
output of ADC0808 will be 00H for 0 volt and it will be FFH
for 1 volt.
ADC808
• ADC0808 uses the successive approximation technique for
conversion and the conversion time is around 100µs.
• It has 8 analog input channels and 8-channel multiplexer for
selecting a particular channel.
• We can connect 8 sensors or 8 analog sources to ADC0808.
• The inbuilt 8-channel multiplexer has 3 select lines A, B and C.
• We can select any channel from 0 to 7 by giving digital input
(either 0 or 1) to these lines.
• Pin number 22 of ADC0808 ALE (address latch enable) is used
to latch the address from select lines A, B and C.
ADC808 Configuration
• Pin number 12 and 16 are vref+ and vref- pins for setting the reference
voltage. By setting the reference voltage we can find step size.
Q = Vref (+) – Vref (-)/2n
• Where Q is the step size and n indicates the resolution of ADC. For a voltage
range of 0 to 1 volt, step size will become 3.90625mV.
• Timer0 of 8051 is used for generating clock frequency for ADC0808. Timer0
is used in mode 2 i.e. 8-bit auto-reload mode. Interrupt for timer0 is enabled.
Every time the interrupt is generated P2.5 pin toggles its state.
Steps to program ADC0808:
• Firstly provide bits to address lines or select lines A, B and C to
select an input channel (IN0 to IN7).
• Provide a low (0) to high (1) pulse to ALE, so it can latch the
address from address lines.
• Give a high (1) to low (0) pulse to SOC to indicate start of
conversion.
while(1)
{
msdelay(1000);
analog_to_digital();
x = x*0.00390625; //For a voltage range of 0 to 1 volt
}
}
INTERFACING DAC WITH
8051
Introduction
• The digital-to-analog converter (DAC) is a device
widely used to convert digital pulses to analog signals.