Showing posts with label Serial communication between PC and 8051. Show all posts
Showing posts with label Serial communication between PC and 8051. Show all posts

Saturday, March 23, 2013

Serial communication between PC and 8051

Serial communication is widely used when the control system has to be actuated from the computer(PC).I will show you as how to send data from PC to 8051. In return, 8051 will acknowledge the data which we sent. So basic component  required in serial communication is MAX232 IC. It is used to convert Rs232 voltage levels to TTL and vice versa. Read more here. Max232.

I have used Matlab to send data serially from PC, and used 8051 to receive the serial data and display appropriately. Simulation is done in Proteus.
Serial communication between PC and 8051


We have used Virtual serial port emulator. Connect two ports in pair. I have connected COM2 and COM3.  Edit  COMPIM as COM3. Next, write a serial code which travels through COM2 in  MATLAB.Since both com ports are in pair, if you write in COM2 data will get through COM2 and through rest of circuitry.



I have used compim. So that matlab and proteus are connected.I have used 2 inverters in the main circuit before max232 because, MAX232 inverts the data.These inverters are very important.Otherwise you'll not be able to send the serial data and serial communication fails.
Here is the Simple Matlab code for serial communication, shown below
fprintf(s,'2') will send 2 to the 8051..  In the code I have written such that, if i send '2' from PC to 8051 serially. 8051 will receive the serial data and checks if it received correctly and acknowledges by displaying "got2" in the virtual terminal.
Serial communication Proteus simulation


Set the circuit as shown in the figure. And if anyone needs project code and simulation. Let me know!