Вы находитесь на странице: 1из 6

Interfacing ADC0808 with Serial port (RS232)

& 8051 microcontroller using clock from Dflip flop


Many a times, it is required to receive signals from different sensors and to monitor the related data on a
PC. In such cases, an ADC is required to convert analog signals, from the sensors, to digital pattern. Also,
this data transfer can be carried out through the serial port, RS232, of the computer. This circuit
demonstrates the principle and operation ADC0808 interfacing using serial port via 8051 microcontroller
(AT89C51). The circuit is divided into four parts: clock, ADC, controller and serial port. This circuit can be
used as an intermediate module in many important applications.

ADC0808 which is an 8-bit resolution ADC has eight analog input pins to take inputs. The circuit uses
a preset for providing the analog input. The clock for driving the ADC0808 is taken from the crystal of the .
The controller AT89C51 uses a crystal of frequency 11.0592 MHz. As this frequency is too high for the
ADC, it is divided using a D flip-flop and then given to the ADC0808. The circuit uses four D flip-flops by
employing 74LS74

. It is a 14 pin IC with two internal D flip-flops. The circuit uses two ICs to divide the
frequency by 16. The circuit diagram shows the connection of the D flip-flop ICs.

The output pins of the ADC are connected to the port P0 of the microcontroller. Pins ALE, OE, SC and
EOC (pins 22, 9, 6 & 7 respectively) are connected to pins P1^0, P1^3, P1^1 & P1^2 of the
microcontroller AT89C51

, respectively. Selector pins A, B and C (pins 25, 24, 23) of the ADC are connected to P2^4,
P2^5 & P2^6 pins of controller.

The output from the ADC comes on port P0 and is stored into the SBUF register. This data is
then transmitted serially to the serial port of the PC using the serial transmitter pin TxD
(pin11) of the controller.

Hyper-terminal shows character corresponding to the ASCII values 0-255. (Refer serial port interfacing
with AT89C51

for hyper-terminal settings)

// Program to read ADC 0808. The output pins are connected to LED's. external clock
is used for driving the ADC 0808.
#include<reg51.h>
sbit ale=P1^0; //address latch enable
sbit oe=P1^3; //output enable
sbit sc=P1^1; //start conversion
sbit eoc=P1^2; //end of conversion

sbit ADD_A=P1^4; // Address pins for selecting input channels.


sbit ADD_B=P1^5;
sbit ADD_C=P1^6;
sfr input_port=0x80; //p0 port

void transmit() //serial port transmission


{
SBUF=input_port;
while(TI==0);
TI=0;
}

void delay(unsigned int count) // Function to provide time delay in msec.


{
int i,j;
for(i=0;i<count;i++)
for(j=0;j<1275;j++);
}

void main()
{
eoc=1;
input_port=0xFF;
ale=0;
oe=0;
sc=0;
TMOD=0x20;

TH1=0xFD; //timer1 setting for serial communication


SCON=0x50;
TR1=1;
while(1)
{
ADD_C=0; // Selecting input channel 2 using address lines
ADD_B=0;
ADD_A=1;
delay(2);
ale=1;
delay(2);
sc=1;
delay(1);
ale=0;
delay(1);
sc=0;
while(eoc==1);
while(eoc==0);
oe=1;
transmit();
delay(2);
oe=0;
}
}

Вам также может понравиться