Analog To Digital Converter In 8051

Convert analog pluses to digital i.e binary 0s and 1s.

  • Types of ADC
    1.Digital Ramp ADC,
    2.Successive Approximation ADC,
    3.Flash ADC.
  • Most of the sensors & transducers are analog such as temperature, humidity, pressure.
  • To interface these sensors to micro-controllers we need to convert the analog output of these sensors to digital.
  • Some microcontroller have inbuilt analog to digital converter.
  • Microcontrollers that don’t have internal ADC, external ADC is used.
  • External ADC – ADC0808,ADC0804.

ADC 0804

  • Commonly used ADC is ADC0804.
  • ADC 0804 is a successive approximation type.
  • Inbuilt 8 analog channels with multiplexer.
  • Zero or full scale adjustment is not required.
  • 0 to 5V input voltage range with a single polarity 5V supply.
  • High speed and Low conversion time (100micro second).
  • High accuracy,8-bit resolution, Low power consumption (less than 15mW).

ADC 0804 PinOut


Steps To Program

Step1: Conversion

  • Send a low to high pulse to pin WR to start the conversion.
    1. Make CS = 0 (LOW)
    2. Make WR=0 (LOW)
    3. Make CS = 1 (HIGH)
    4. Make WR=1 (HIGH)

Step2: Read

  • Keep monitoring the INTR pin. If INTR is low, go to next step else keep checking the status.
  • A high to low pulse is sent to the RD pin to bring the converted data on the output pins.
    1. Make CS = 0 (LOW)
    2. Make RD=0 (LOW)
    3. Make CS = 1 (HIGH)
    4. Make RD=1 (HIGH)


 #include <REGX51.H>
 # define intr P1_0
 int adc_value;
 // Read Function To Read Alalog Value From TrimPot
 void read()
 P3_7=0;    // (CS)
 P3_6=0;    // (RD)
 P3_6=1;    // (RD)  
 P3_7=1;    // (CS)
 void Conversion()
 P3_7=0;    // (CS)
 P3_5=0;    // (WR)
 P3_5=1;    // (WR)
 P3_7=1;    // (CS)
 void main()