You are on page 1of 2

Analogue to Digital Conversion Aim To interface ADC 0804 with 89C51 and build an Analogue to Digital Converter.

Introduction Analogue to Digital converters are among the most widely used devices for data acquisition. Digital computers use binary (discrete) values, but in the physical world everything is analogue (continuous). Temperature, pressure (wind or liquid), humidity, and velocity are few examples. A physical quantity is converted to electrical (voltage, current) signals using transducers whose output is in the form of analogue signal. Therefore we need an analogue-to-digital converter to translate the analogue signal to digital numbers, so that a microcontroller can read and process them. An ADC has n-bit resolution, where n = 8,10,12 or 16 bits. The higher resolution ADC, provides a smaller step size. 8 bit gives 256 steps that is 5 V /256 = 19.53 mV step, and 10 bit gives 4.88 mv step and so on. Conversion time is defined at the time it takes for the ADC to convert the analogue signal to digital signal. ADC0804 is a 8 bit ADC from National Semiconductors. It works with +5 V, conversion time is of the order of 110 usec. Experimental set up The hardware is wired as per the circuit shown below.
+5 V 220 LED 20 ADC0804 +IN -IN VCC/VREF VREF/2 CLKR CLKIN CS RD WR 6 7 9 19 4 1 2 3 1 10 8 GND GND 10K 150pF 2 10K +5 V +5V 3 220 LED 220 LED 220 LED 39 38 37 36 35 34 33 32 1 2 3 4 5 6 7 8 19 18 220 LED 31 220 LED 9 P0.0/AD0 P0.1/AD1 P0.2/AD2 P0.3/AD3 P0.4/AD4 P0.5/AD5 P0.6/AD6 P0.7/AD7 P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 XTAL1 XTAL2 RST EA/VPP AT89C51 +5V P2.0/A8 P2.1/A9 P2.2/A10 P2.3/A11 P2.4/A12 P2.5/A13 P2.6/A14 P2.7/A15 P3.0/RXD P3.1/TXD P3.2/INTO P3.3/INT1 P3.4/TO P3.5/T1 P3.6/WR P3.7/RD PSEN ALE/PROG 21 22 23 24 25 26 27 28 10 11 12 13 14 15 16 17 29 30 18 17 16 15 14 13 12 11 5 DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 INTR 220 LED 220 LED 11.0592 MHz Y1 10uf 4.7K 33pf

S. Oulaganathan, Vice Principal, SMVEC

Mar 2007

Operation of ADC Analogue input is given to Vin +. The other input Vin is grounded. Analogue ground pin 8 is also grounded along with digital ground pin 10. The conversion process is understood by following the timing diagram shown Start of below.
conversion /WR End of conversion

/INTR

/RD

DATA

/WR is an input to ADC, when it is taken to logical low and high, the conversion starts. After few tens of micro second, (depending on the RC value connected to CLKR and CLKIN) ADC indicates the end of conversion by lowering /INTR to logical low. Then the /RD has to be lowered to zero to read the data. The digital equivalent value (of the analogue voltage at Vin+) appears on the data output lines D0 to D7 of ADC. CS Chip select for the IC is permanently grounded to select it always. (if multiple ADC ICs are used then they can be selected using CS) The data port of ADC is connected to the port P1 of 89C51, other control lines /WR, /RD and / INTR are connected to port P3. Vref/2 pin is left open, so the input analogue range is now 0 to + 5 V. If a different range is required, for eg., 3 V, then this pin Vref/2 has to be connected to a 1.5 V source. Eight LEDs connected to port P1 indicates the digital value. The data read from ADC on port P2 are bit inverted and transferred to port P1 to make LED light up for logical 1. The C code of the program is given below. #include<reg51.h> sbit rd = P3^3; sbit wr = P3^1; sbit INTR = P3^0; unsigned char value; void main() { INTR = 1; rd = 1; wr = 1; while(1) { wr = 0; wr = 1; while(INTR == 1); rd = 0; value = P2; P1 = ~value; /* bit inverted to make LED light up for logical 1 */ rd = 1; } }
S. Oulaganathan, Vice Principal, SMVEC Mar 2007