Spread the love
____________________________________________________________________________________________________
- What is serial COM ?- A computer transfers data by two methods called serially and parallelly, both have its own merits and demerits according to application. Here we discuss only about serial communication. In serial com data are transfers bit by bit from transmitter to receiver as its name suggest serially.
- About & Types serial COM-
- If data transmitted one way a time, it is referred to as half duplex.
- If data can go both ways at a time, it is full duplex.
Following are the pin connectors that are used to connect microcontroller with PCs.
- Serial data communication uses two methods:
- Synchronous method transfers a block of data at a time
- Asynchronous method transfers a single byte at a time
- Asynchronous serial data communication is widely used for character-oriented transmissions
(1) Each character is placed in between start and stop bits, this is called framing (8-bit = single character)
(2) Block-oriented data transfers use the synchronous method
- The start bit is always one bit, but the stop bit can be one or two bits. Due to the extended ASCII Characters, 8-bit ASCII data is common. In modern PCs, the use of one stop bit is standard. Assuming that we are transferring a text file of ASCII characters using 1 stop bit, we have a total of 10 bits for each character including 8 character with 1 start and 1 stop bit.
- The rate of data transfer in serial data communication is stated in bps (bits per second). Another widely used terminology for bps is baud rate. It is modem terminology and is defined as the number of signal changes per second. In modems, there are occasions when a single change of signal transfers several bits of data.
- The data transfer rate of given computer system depends on communication ports incorporated into that system
- IBM PC/XT could transfer data at the rate of 100 to 9600 bps
- Pentium-based PCs transfer data at rates as high as 56Kbps
- In asynchronous serial data communication, the baud rate is limited to 100Kbps.
- Microcontroller used CMOS logics generally, so we need a line driver such as the MAX232 chip which is required to convert RS232 voltage levels to CMOS levels, and vice versa.
- Following diagram is shown interfacing diagram of 8051 with PC and use of MAX232 IC.
- To allow data transfer between the PC and an 8051 system without any error, we must make sure that the baud rate of 8051 system matches the baud rate of the PC’s COM port.
- Applications- Communication between computer and microcontroller.
1. Circuit Diagram Of SERIAL COMMUNICATION Of 8051
_______________________________________________________________________________________________________
2. Circuit Diagram Of SERIAL COMMUNICATION Of 8051 With LCD
1. Program of SERIAL COMMUNICATION Of 8051
In this program controller send “www.firmcodes.com” to PC or Laptop and it will display on the hyper terminal of PC or Laptop
/******************************************************* IDE :- Keil DEVELOPED BY:- FIRMWARE DEVELOPER (www.firmcodes.com) WHAT PROGRAM DO:- CONTROLLER SEND "WWW.FIRMCODES.COM" BY SERIAL COMMUNICATION *******************************************************/ #include<reg51.h> char serial_receive(); // initialize controller to work as serial communication void serial_initialize(); // receive data to controller via rxd pin to computer,s hyper terminal void serial_transmit(unsigned char x); // transmit data to computer,s hyper terminal from controller via txd pin unsigned rec; // gloable variable void delay(int x); void main() { serial_initialize(); // call the initialize function while(1) { serial_transmit('W'); // call transmit function delay(10000); // calling of delay function serial_transmit('W'); // call transmit function delay(10000); // calling of delay function serial_transmit('W'); // call transmit function delay(10000); // calling of delay function serial_transmit('.'); // call transmit function delay(10000); // calling of delay function serial_transmit('F'); // call transmit function delay(10000); // calling of delay function serial_transmit('I'); // call transmit function delay(10000); // calling of delay function serial_transmit('R'); // call transmit function delay(10000); // calling of delay function serial_transmit('M'); // call transmit function delay(10000); // calling of delay function serial_transmit('C'); // call transmit function delay(10000); // calling of delay function serial_transmit('O'); // call transmit function delay(10000); // calling of delay function serial_transmit('D'); // call transmit function delay(10000); // calling of delay function serial_transmit('E'); // call transmit function delay(10000); // calling of delay function serial_transmit('S'); // call transmit function delay(10000); // calling of delay function serial_transmit('.'); // call transmit function delay(10000); // calling of delay function serial_transmit('C'); // call transmit function delay(10000); // calling of delay function serial_transmit('O'); // call transmit function delay(10000); // calling of delay function serial_transmit('M'); // call transmit function delay(10000); // calling of delay function serial_transmit(0x0d); // call transmit function delay(40000); delay(40000); } } void serial_initialize() { TMOD=0x20; //timer 1 in mode2 (8-bit auto-reload) to set baud rate TH1=0xfd; // to make baud rate of 9600hz , crystal oscillator =11.0592Mhz SCON=0x50; /*make SM0=0 and SM1=1 present in SCON register, so that we select, Serial Mode 1, 8-bit data,1 stop bit, 1 start bit make REN=1 present in SCON register ,it allows 8051 to receive data on RxD pin*/ TR1=1; // to start timer IE=0X90; // to make serial interrupt interrupt enable } char serial_receive() { /* RI bit is present in SCON register*/ while(RI==0); // wait untill hole 8 bit data is received completely. RI bit become 1 when reception is compleated rec=SBUF; // data is received in SBUF register present in controller during receiving RI=0; // make RI bit to 0 so that next data is received return rec; // return rec where funtion is called } void serial_transmit(unsigned char x) { SBUF=x; // 8 bit data is put in SBUF register present in controller to transmit // TI bit is present in SCON register while(TI==0); // wait untill transmission is compleated. when transmittion is compleated TI bit become 1 TI=0; // make TI bit to zero for next transmittion } void delay(int x) { int i; for(i=0;i<x;i++); }
PROTEUS File for SIMULATION(Password Of RAR file is :-firmcodes.com)
_______________________________________________________________________________________________________
2. Program of SERIAL COMMUNICATION Protocol Of 8051 with LCD
In this program data entered from the hyper terminal of PC or Laptop is appeared on the LCD connected to the controller
/************************************************************** IDE :- Keil DEVELOPED BY:- FIRMWARE DEVELOPER (www.firmcodes.com) WHAT PROGRAM DO:- DATA SEND FROM PC DISPLAYED ON LCD USING 8051 ***************************************************************/ #include<reg51.h> // header file of 8051 sfr lcd=0xa0; // data of lcd at port 2 sbit rs=P3^5; // rs pin at P3.5 sbit rw=P3^6; // rw pin at P3.6 sbit en=P3^7; // en pin at P3.7 void delay(); // for delay void cmd(); // lcd in command mode void display(); // lcd is in display mode char serial_receive(); // initialize controller to work as serial communication void serial_initialize(); // receive data to controller via rxd pin to computer,s hyper terminal void serial_transmit(unsigned char x); // transmit data to computer,s hyper terminal from controller via txd pin unsigned rec; // gloable variable void main() { int x=0; serial_initialize(); // call the initialize function /* initialization of lcd*/ lcd=0x38; cmd(); lcd=0x0e; cmd(); lcd=0x01; cmd(); lcd=0x06; cmd(); lcd=0x80; cmd(); while(1) { serial_receive(); // call the receive function lcd=rec; display(); // display function is called if(x==15) { lcd=0xc0; cmd(); } else if(x==31) { lcd=0x01; cmd(); } x++; } } void serial_initialize() { TMOD=0x20; //timer 1 in mode2 (8-bit auto-reload) to set baud rate TH1=0xfd; // to make baud rate of 9600hz , crystal oscillator =11.0592Mhz SCON=0x50; /*make SM0=0 and SM1=1 present in SCON register, so that we select, Serial Mode 1, 8-bit data,1 stop bit, 1 start bit make REN=1 present in SCON register ,it allows 8051 to receive data on RxD pin*/ TR1=1; // to start timer IE=0X90; // to make serial interrupt interrupt enable } char serial_receive() { /* RI bit is present in SCON register*/ while(RI==0); // wait untill hole 8 bit data is received completely. RI bit become 1 when reception is compleated rec=SBUF; // data is received in SBUF register present in controller during receiving RI=0; // make RI bit to 0 so that next data is received return rec; // return rec where funtion is called } void serial_transmit(unsigned char x) { SBUF=x; // 8 bit data is put in SBUF register present in controller to transmit // TI bit is present in SCON register while(TI==0); // wait untill transmission is compleated. when transmittion is compleated TI bit become 1 TI=0; // make TI bit to zero for next transmittion } void cmd() { unsigned char i; rs=0; rw=0; en=1; for(i=0;i<2;i++); en=0; delay(); } void display() { unsigned char i; rs=1; rw=0; en=1; for(i=0;i<2;i++); en=0; delay(); } void delay() { unsigned int i,j; for(i=0;i<100;i++) for(j=0;j<153;j++); }
PROTEUS File for SIMULATION(Password Of RAR file is :-firmcodes.com)
Content for the tab VIDEO