Sunday, December 1, 2013

Interfacing ADC0804 with AT89s52

    Today in this tutorial we will learn to interface ADC0804 with AT89s52 (a microcontroller from 8051 family). ADC0804 uses successive approximation for analog to digital conversion. If you are interested to know how successive approximation works or if you don't know about working principle of successive approximation method of conversion from analog to digital signal,I recommend you to read the post on successive approximation ADC.


    ADC0804 is a 8-bit successive approximation ADC which works with +5V dc voltage and has a resolution of 8 bits. The device is fed with differential analog input voltage which in turn provides output in form of digital signal which can be processed by any processor. The conversion time of ADC0804 cannot be faster than 110 microseconds and it has on-chip clock generator which can be used to provide clock pulse required for the operation of this device.

   Before going on the topic how to interface ADC0804, we will first know about the pins of ADC0804. The pin layout is shown in figure below and the description of each pins are then described.
Pin layout of ADC0804.
Fig a:- Pin Layout of ADC0804

CS:- This is an active low input pin. When this pin is at LOW logic level (i,e logic 0),ADC0804 is ready to operate.

WR:-This is an active low input pin. A LOW-to-HIGH pulse at this pin tells the ADC to start the conversion of applied analog input signal.

INTR:- This is an active low output pin to indicate the end of conversion.

RD:- This is an active low input pin.After the end of conversion the converted digital signal is stored in the internal register of ADC0804 chip. Before the data is lost it is required to read the digital data from those internal register. By sending a HIGH-to-LOW pulse at this pin, we can read the digital data through 8-bit parallel pins of ADC0804.

CLK IN:- This is an input pin to provide a clock source to ADC0804 required for conversion when an external clock source is used.

CLK R:- To use on chip clock generator of ADC0804, the CLK IN and CLK R pins needs to be connected with RC circuit as shown in figure belpw.

RC circuit to use on chip clock generator of ADC0804
Fig b:- On chip clock generator  circuitry
The suitable value of R and C used in the circuitry is 10k and 150pF respectively. But its not any hard rule to use the same value of R and C. You can use any value of R and C which can generate approximately 110us of conversion time.

Vin :- These (Vin+ and Vin-) are the pin where you apply differential analog input from any sensor.

Vref/2:- This is the reference voltage pin. If this pin is left not connected then the reference voltage will automatically become 5V. But for application where you require reference voltage to be less then 5V, an external source of appropirate voltage should be connected to this pin. An voltage divider circuit can be used to obtain the required reference voltage by utilizing the same power source which microcontroller and ADC0804 are using. Now, for example you require a reference voltage of 4 V, then 4V/2=2V voltage source source should be connected to this pin hence, this pin has got the name Vref/2.

AGND:- This is analog ground pin where an ground of analog input source is connected. Similarly, in DGND which is referred to as digital ground, the ground of working voltage source of the MCU or ADC is connected.

D0-D7:- These are a 8-bit parallel data pins of ADC0804.


The schematic required to interface ADC0804 with AT89s52 is shown in figure(c).

A schematic for interfacing ADC0804 with at89s52
Fig c:-schematic for interfacing ADC0804 with AT89s52


After assembling the components in the circuit board following the schematic shown in figure (c), we need to program the microcontroller to start the conversion of analog signal into digital signal and then read the converted digital signal stored in internal register of ADC after the end of the conversion.Here, the converted digital value of the corresponding analog signal is displayed with the help of LEDs.

Below is the algorithm which can be used for programming any microcontroller to convert analog signal to digital signal using ADC0804 .

  1. Send LOW level signal(LOGIC 0) to CS pin.
  2. Send a LOW-to-HIGH pulse to WR pin to initiate the conversion.
  3. Wait untill INTR pin is at logic 0.
  4. When INTR pin is at logic 0, send HIGH-to-LOW pulse to RD pin and then read the data from internal registers of ADC0804 using D0-D7 data pins.
This is how you can interface ADC0804 with AT89s52.To download the complete source code along with proteus simulation file click here.

You may also like to read:
Interfacing LM35 with 8051

No comments: