Interfacing 8051 with ADC 0808 and DAC 0808

Analog to Digital Converter (ADC):

            In most of our Microcontroller based projects, if we need to interface a sensor whose output is a voltage range corresponding to the input what it senses, (like Temperature, Humidity, Gas concentration, Pressure, Light Intensity etc.) which needs to be taken to the Microprocessor or Microcontroller to act upon or for further processing, then we need a Mediator between the analog voltages and the Digital Signals of Microcontroller. An ADC (Analog to Digital Converter) is just the device to do it.

It has the following characteristics:

  • The input to the A/D converter is a voltage. A/D converters may be designed for voltages from 0 to 10v, from -5 to +5v, etc., but they almost always take a voltage input. In any event, the input is an analog voltage signal for most cases.
  • The output of the A/D converter is a binary signal, and that binary signal encodes the analog input voltage.  So, the output is some sort of digital number, which can be read by a computer.

ADC0808, ADC0809 data acquisition component is a monolithic CMOS device with an 8-bit analog-to-digital converter, 8-channel multiplexer and microprocessor compatible control logic. Easy interfacing to microprocessors is provided by the latched and decoded multiplexer address inputs and latched TTL TRI-STATE® outputs.

Key Specifications Of ADC 0808:

  • Resolution: 8 Bits
  • Single Supply: 5 VDC
  • Low Power: 15 mW
  • Conversion Time: 100 μs

Absolute Maximum Ratings

  • Supply Voltage (VCC) (Note 3) 6.5V
  • Voltage at Any Pin Except Control Inputs −0.3V to (VCC+0.3V)
  • Voltage at Control Inputs  (START, OE, CLOCK, ALE, ADD A, ADD B, ADD C) −0.3V to +15V

Flow Chart of Reading Data from ADC:


Digital to Analog Converter (DAC):

            To interface the Microcontroller to the real world where just an ON/OFF control is not sufficient enough, for example a Proportional Valve which requires an Analog voltage ranging within certain voltage levels, or a voltage controlled fan/motor speed controller, or brightness of an LIGHT which depends proportionally to the input voltage, we need a device which can take the digital output data of the microcontroller and give a analog electrical quantity. A DAC is a device for just that purpose.

 DAC 0808:

A DAC is a device which gives a current output which is proportional to the input digital data. But in real world applications we mostly need a voltage output, hence a current to voltage converter is mostly connected to the output of a DAC as shown above.

The output Current of the DAC is given as,


Schematic of Interfacing ADC 0808 and DAC 0808 with AT89c51 Microcontroller:




The Code:

;ADC 0808 Interfacing with Atmel 89C51 uC

;Interrupt Driven Method


adc_a      bit   p2.0        ;define ADC pins connected

adc_b      bit   p2.1        ;to the pins of Microcontroller

adc_c      bit   p2.2

adc_sc      bit   p2.3

adc_ale     bit   p2.4

adc_oe      bit   p2.5



      .org  0000h       ;set start address to 0000h

      sjmp  main        ;jump to main program


      .org  0003h       ;address of the ISR



      setb  adc_oe            ;enable the Output port of ADC


      mov   A, p1       ;move converted data from ADC to Accumulator

      mov   p0, A       ;move the data to DAC's I/p port'

      clr   adc_oe

      reti              ;return from ISR to main Program


main:mov   IE, #81h    ;enable Int0

      setb  TCON.0            ;enable edge triggered


      mov   p1, #0ffh   ;set p1 as i/p port



      clr   adc_oe            ;disconnect adc's data bus from Microcontroller

      clr   adc_ale

      clr   adc_sc


      clr   adc_a       ;set the address of I/P channel of ADC

      clr   adc_b

      clr   adc_c


      setb  adc_ale           ;latch the address

      setb  adc_sc            ;give a pulse for Start Conversion

      clr   adc_ale

      clr   adc_sc


loop_here:  mov   r6, #2fh    ;this is what the Microcontroller

repeat:     djnz  r6,repeat  ;is busy doing;Note:THIS SHOULD BE GREATER

      ljmp  main        ;THAN THE TIME REQUIRED FOR CONVERSION i.e. approx 100uS


      END               ;end of main program


The Simulated CRO Waveform:


 The Proteus Simulation Video (Flash Recording):



The Proteus Design File and The code can be downloaded from this link (zip) or this link (rar).