Several devices collect data from sensors and need to send it to another unit, like a computer, for further processing. Data transfer/communication is generally done in two ways: parallel and serial. In the parallel mode, data transfer is fast and uses more number of lines. This mode is good for short range data transfer.
Serial communication on the other hand, uses only one or two data lines to transfer data and is generally used for long distance communication. In serial communication the data is sent as one bit at a time. This article describes the interfacing of 8051 microcontroller (AT89C51) with a computer via serial port, RS232. Serial communication is commonly used in applications such as industrial automation systems, scientific analysis and certain consumer products.
Serial Port
The microcontroller AT89C51 has an inbuilt UART for carrying out serial communication. The serial communication is done in the asynchronous mode. A serial port, like other PC ports, is a physical interface to establish data transfer between computer and an external hardware or device. This transfer, through serial port, takes place bit by bit.
IBM introduced the DB-9 RS-232 version of serial I/O standard, which is most widely used in PCs and several devices. In RS232, high and low bits are represented by flowing voltage ranges:
Bit
|
Voltage Range (in V)
|
|
0
|
+3
|
+25
|
1
|
-25
|
-3
|


SM0
|
SM1
|
SM2
|
REN
|
TB8
|
RB8
|
TI
|
RI
|
D7
|
D6
|
D5
|
D4
|
D3
|
D2
|
D1
|
D0
|
Project Source Code
###
// Program to test serial communication of controller with PC using hyper terminal #include<reg51.h> void ini() // Initialize Timer 1 for serial communication { TMOD=0x20; //Timer1, mode 2, baud rate 9600 bps TH1=0XFD; SCON=0x50; TR1=1; } void recieve() //Function to receive serial data { unsigned char value; while(RI==0); value=SBUF; P1=value; RI=0; } void transmit() // Funtion to transmit serial data { P2=P1-32; SBUF=P2; while(TI==0); TI=0; SBUF=P1; while(TI==0); TI=0; } void main() { while(1) { ini(); recieve(); transmit(); } }###
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.