Analog To Digital Conversion: Introduction
Analog To Digital Conversion: Introduction
►Introduction
In our daily life, anything we deal like sound, pressure, voltage or any measurable
quantity, are usually in analog form So what if we want to interface any analog
sensor with our digital controllers? There must be something that translates the
analog inputs to digital output, and so Analog to digital convertors come to play.
Usually we call them ADC (Analog to digital convertor). Before going to learn
how to interface an ADC with a controller we first take a look at basic methods of
analog to digital conversion.
Digital-Ramp ADC
Successive Approximation ADC
Flash ADC
►Digital-Ramp ADC
The successive approximation ADC is much faster than the digital ramp ADC
because it uses digital logic to converge on the value closest to the input voltage. A
comparator and a DAC are used in the process. A flowchart explaining the
working is shown in the figure below.
►Flash ADC
Now we lets take a look at the various Analog to Digital convertors that are most
commonly used with our controllers
Name Description
ADC0800 8-bit ADC
ADC0801 8-bit ADC 100us 0.25 LSB
ADC0802 8-bit ADC 100us 0.5 LSB
ADC0804 8-bit ADC 100us 1.0 LSB
ADC0808 8-bit 8 channel 100us ADC
ADC0809 8-Bit 8 channel ADC (=~ADC0808)
AD571 10-Bit, A/D Converter, Complete with Reference and Clock
MAX1204 5V, 8-Channel, Serial, 10-Bit ADC with 3V Digital Interface
MAX1202 5V, 8-Channel, Serial, 12-Bit ADCs with 3V Digital Interface
MAX195 16-Bit, Self-Calibrating, 10us Sampling ADC
There is a universal rule to find out how to use an IC. All you need is the datasheet
of the IC you are working with and take a look at the timing diagram of the IC
which shows how to send the data, which signal to assert and at what time the
signal should be made high or low etc.
.
The above timing diagrams are from ADC0804 datasheet. The first diagram
(FIGURE 10A) shows how to start a conversion. Also you can see which signals
are to be asserted and at what time to start a conversion. So looking into the timing
diagram FIGURE 10A. We note down the steps or say the order in which signals
are to be asserted to start a conversion of ADC. As we have decided to make Chip
select pin as low so we need not to bother about the CS signal in the timing
diagram. Below steps are for starting an ADC conversion. I am also including CS
signal to give you a clear picture. While programming we will not use this signal.
#include <REGX51.H>
#define adc_port P2 //ADC Port
#define rd P1_0 //Read signal P1.0
#define wr P1_1 //Write signal P1.1
#define cs P1_2 //Chip Select P1.2
#define intr P1_3 //INTR signal P1.3
void main()
{
while(1)
{
conv(); //Start conversion
read(); //Read ADC
P3 = adc_val; //Send the read value to P3
}
}
void conv()
{
cs = 0; //Make CS low
wr = 0; //Make WR low
wr = 1; //Make WR high
cs = 1; //Make CS high
while(intr); //Wait for INTR to go low
}
void read()
{
cs = 0; //Make CS low
rd = 0; //Make RD low
adc_val = adc_port; //Read ADC port
rd = 1; //Make RD high
cs = 1; //Make CS high
}