This circuit demonstrates the principle and operation of collecting data from ADC0804 and sending it to PC via serial communication using 8051 microcontroller (AT89C51). The circuit is divided into three parts: ADC, Controller and Serial Port. This circuit can be used as an intermediate in many applications.Click to read more about Serial Port(RS232).
ADC0804 which is an 8-bit resolution ADC has only one input channel connected to variable resistance (preset) to give the analog input. In place of preset, analog input from a sensor can also be used. (Refer interfacing ADC0804 with AT89C51)
The output pins of the ADC are connected to port P1 of the microcontroller. Write (WR) pin 3 is connected to P2.0 i.e. pin 21 of controller. Read (RD) pin 2 is connected to P2.1 i.e. pin 22 of controller. Interrupt (INTR) pin 5 is connected to P2.2 i.e. pin 23 of controller.
The data coming on the port P1 is stored in the SBUF register of the MCU. The serial communication of controller with PC is done using the TxD pin 11 of the microcontroller AT89C51. The IC Max 232 is used to ensure compatibility between controller and serial port (Refer serial port interfacing through controller).
The program continuously monitors the output of ADC0804 and transmits it to the serial port. The input to the ADC is supplied through a preset. When the value of preset changes, the corresponding output changes and is displayed on the hyper-terminal.
Hyper Terminal shows character corresponding to the ASCII values 0-255 (Refer serial port interfacing through controller for hyper-terminal settings).
Project Source Code
###
// Program to read the values of ADC and serially tranmitting it to PC. #include<reg51.h> sbit wr= P2^0; // Write pin. It is used to start the conversion. sbit rd= P2^1; // Read pin. It is used to extract the data from internal register to the output pins of ADC. sbit intr= P2^2; // Interrupt pin. This is used to indicate the end of conversion. It goes low when conversion is complete. void transmit() // Function for serial tranmission of data. { SBUF=P1; while(TI==0); TI=0; } void delay(unsigned int msec ) // The delay function provides delay in msec. { int i ,j ; for(i=0;i<msec;i++) for(j=0; j<1275; j++); } void adc() //Function to read the values from ADC and tranmit serially. { rd=1; wr=0; delay(2); wr=1; while(intr==1); rd=0; transmit(); delay(2); intr=1; } void init() // Intialize timer 1 in mode 2 for serial transmission. The baud rate is set to 9600bps. { TMOD=0x20; TH1=0xFD; SCON=0x50; TR1=1; } void main() { P1=0xff; // Declare P1 as input port. init(); while(1) { adc(); } }###
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.