Communication Between ADC0804 and 8051
Communication Between ADC0804 and 8051
8051
Introduction
Objectives: After this unit students will
Understand the ADC0804, its features and functions.
Understand how the ADC0804 communicates with the 8051 microcontroller.
Develop teamwork, research, and presentation skills.
Theory
I. Overview
ADC0804 is a low voltage integrated circuit used to convert low voltage analog signal to
8-bit digital signal. It works from 0 to 5 volts, has 1 analog input pin and 8 output pins.
ADC0804 has an internal clock, and can connect to an external clock to change its
frequency. Minimum conversion time is 110 microseconds with internal or external
clock.
Pinout of ADC0804:
Pin Name Description
CS(Chip Chip select is used if more than 1 ADC module is
1
Select) used. By default grounded.
2 RD(Read) Read pin must be grounded to read the Analog value
Write pin should be pulsed high to start data
3 WR(Write)
conversion
External clock can be connected here, other RC can be
4 CLK IN
used for accessing internal clock
5 INTR(Interrupt) Goes high for interrupt request.
6 Vin(+) Differential Analog input +. Connects to ADC input.
7 Vin(-) Differential Analog input -. Connects to ground.
8 Ground Analog Ground pin connected to ground of circuit.
9 Vref/2 Reference voltage for ADC conversion.
10 Ground Digital Ground pin connected to ground of circuit
Eight output Data bit pins from which output is
11 to 18 Data bit 0 to 7
obtained.
19 CLK R RC timing resistor input pin for internal clock.
20 Vcc Powers the ADC module, uses +5V
Figure 1: Pinout of ADC0804
II. Where to use ADC0804
This IC is very Ideal to use with Microprocessors like Raspberry Pi, Beagle bone etc.. Or
even to use as a standalone ADC module. Every ADC module requires a clock to function;
this IC comes with its own internal clock so you don’t have to worry about it. Hence, if
you are looking for a compact ADC module with a decent resolution of 8-bit then this IC
is for you.
III. How to use ADC0804
Since the IC comes with an internal clock we do not need many components to make it
work. However to make the internal clock to work we have to use a RC circuit. The IC
should be powered by +5V and the both ground pins should be tied to circuit ground. To
design the RC circuit simply use a resistor of value 10k and capacitor of 100pf (approx)
and connect them to CLK R and CLK IN pins as shown in the circuit below. The chip select
(CS) and Read (R) pin should also be grounded. The Vref pin is left free because by
default without any connection it will be connected to +5V.
The digital output will be obtained from the pins DB0 to DB7 and the analog voltage
should be connected to V in(+) pin as shown in the circuit. Also note that another end of
the voltage source (sensor/module) should also be grounded to the circuit for the ADC
conversion to work. Now, for the ADC Conversion to start we have to make the
Write(WR) pin to go high momentarily. This can be done by connecting the pin to I/O of
MPU and toggling it high before every ADC read. Only if this is done the ADC value on
the output side will be updated.
- Create Hex code: Right click on Target 1 -> Option -> Output -> Tick “Create Hex File”.
- Source code for main.c:
#include <REGX51.H>
#define CS P3_0
#define RD P3_1
#define WR P3_2
#define INTR P3_3
#define Data P1
int kq;
void ADC_Read(){
CS = 0;
WR = 0;
WR = 1;
while(INTR);
RD = 0;
kq = Data;
RD = 1;
}
void hienThi(){
int chuc, donVi, i;
chuc = kq/10;
donVi = kq%10;
for(i = 0; i< 100; i++){
P2_0 = 1; P0 = hex[chuc]; delay_ms(5); P2_0 = 0;
P2_1 = 1; P0 = hex[donVi]; delay_ms(5); P2_1 = 0;
}
}
void main(){
while(1){
ADC_Read();
kq = kq/0.512;
hienThi();
}
}
- Verify simulation.
Self-learning instruction for students
Problem 2: Read temperature from humidity sensor, display said temperature on LCD, and
trigger light warning if humidity is less than 50%. Given the range of humidity sensor is 0 to 100
percent, translated to output voltage from 0 to 5 volts.
Instruction:
- Create diagram using Proteus.
- Create block diagram to solve problem.
- Program in Keil C.
- Verify simulation/work on actual circuit.