In many applications data collected from multiple sensors is transmitted to PC for display or further analysis. The conversion of data from analog to digital form is done using an ADC. The digital data from the ADC is transferred to the computer using serial port. This circuit demonstrates the principle and operation of interfacing an ADC0808 with serial port of PC using the microcontroller AT89C51. The circuit is divided into three parts: ADC, controller and serial port. This circuit can be used as an intermediate circuit in many applications.
ADC0808 which is an 8-bit resolution ADC has eight input channels i.e., it can take a maximum of eight analog inputs. The circuit uses the first analog input pin to take the analog input signals from the preset.
Project Source Code
###
// Program to read ADC 0808. The output pins are connected to serial port. Controller interrupt is used to generate the clock 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 clk=P1^7; // clock 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 timer0() interrupt 1 // Function to generate clock of frequency 500KHZ using Timer 0 interrupt. { clk=~clk; } 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=0x22; //timer0 setting for generating clock of 500KHz using interrupt enable mode. TH0=0xFD; IE=0x82; TR0=1; 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; } }###
Circuit Diagrams
Project Components
Project Video
Filed Under: 8051 Microcontroller.
Filed Under: 8051 Microcontroller.
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.