Friday, January 23, 2015

Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]



Basically a microcontroller or computer can communicate with other computer through serial communication.
  If we would like to make a successful communication between PC(Desktop) and microcontroller, we need a protocol named Rs 232 protocol. Generally we use Rs232 for long distance connection.If you have a laptop , you need a " Usb to Serial Converter ". Because laptop doesn't have serial port .Usually desktop contains a serial port but laptop doesn't .

Please Watch these :


Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]
Usb to Serial Converter

Take a look on DB9 Connector's and it's Pinout.For serial communication we will need this connector .
Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]
We will use only three pins (RX,TX & GND) .Here TX to transmit  data and RX to receive data. Now look at the picture given below :

                                                        RS 232 Cable Length 

Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]
In this tutorial we will use baud rate 9600. You can use another rate, if you want. We need an IC named maxim 232 or max 232 for communication. Look at the picture i have given blow :
Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]
Max 232
We need this ic for rs232 protocol .In this tutorial we will connect pic18f2550's Tx pin  with T1 and pic18f2550's Rx with R1out. Let's create a project in proteus 8. If you don't have proteus 8 you can download with crack  from this site.

Proteus Circuit :

If you are a beginner, Please follow the steps .

Step 1:

Step 2:

Step 3:

Step 4:

Step 5:

Step 6:


Step 7: Now complete circuit as i given below .

If you don't know how to interface LCD display and push button with microcontroller. Please follow these  :  Lcd display & Push button. You will get download link at the last end of this page .

Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]
Rs 232, Serial Communication with Microcontroller 


Please Look at here  :


 Virtual Terminal in proteus
How to find Virtual Terminal
Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]
DB9 Settings
Now Create a project in MikroC so that we can create hex file for the microcontroller .

MikroC Project :

Step 1:

Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]

Step 2:

Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]

Step 3:
Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]

MikroC Uart Library :

Here we use x=1;

  • UARTx_Init
  • UARTx_Data_Ready
  • UARTx_Tx_Idle
  • UARTx_Read
  • UARTx_Read_Text
  • UARTx_Write
  • UARTx_Write_Text
  • UART_Set_Active

Visite the link to get all details about Uart Library
  #Source Code :
   





  sbit LCD_RS at RB7_bit;   
  sbit LCD_EN at RB6_bit;   
  sbit LCD_D4 at RB5_bit;   
  sbit LCD_D5 at RB4_bit;   
  sbit LCD_D6 at RB3_bit;   
  sbit LCD_D7 at RB2_bit;   
  sbit LCD_RS_Direction at TRISB7_bit;   
  sbit LCD_EN_Direction at TRISB6_bit;   
  sbit LCD_D4_Direction at TRISB5_bit;   
  sbit LCD_D5_Direction at TRISB4_bit;   
  sbit LCD_D6_Direction at TRISB3_bit;   
  sbit LCD_D7_Direction at TRISB2_bit;   
  void main() {   
  int i=0,ck=0;   
  char dat[13];   
  CMCON = 0x07; // To turn off comparators   
  ADCON1 = 0x00;   
  TRISA=0x01;   
  CMCON = 0x07; // To turn off comparators   
  ADCON1 = 0x0F;   
  Lcd_Init();   
  Uart1_Init(9600);   
  delay_ms(1000);   
   UART1_Write_Text("Please Press The Start Button");   
    Lcd_Cmd(_LCD_CLEAR);    // Clear display   
   Lcd_Cmd(_LCD_CURSOR_OFF);   
   Lcd_Cmd(_LCD_CLEAR);   
   Lcd_out(1,1,"Press Start Btn");   
   Lcd_out(2,1,"Press Enter");   
   delay_ms(100);   
  while(1){   
  if(PORTA.f0==0){   
  ck=3 ;   
   UART1_Write_Text("  A=led1,B=led2,C=led3,D=led4,E=led5 \n Enter-:");   
    Lcd_Cmd(_LCD_CLEAR);   
   Lcd_out(1,1,"A ,B ,C, D, E");   
   Lcd_out(2,1,"Press Enter");   
   delay_ms(100);   
  }   
  while (ck==3) {   
     if (UART1_Data_Ready()) {   
      UART1_Read_Text(dat, "\r", 8);   
      for (i=0; i<strlen(dat); i++) {   
       dat[i] = toupper(dat[i]);  //this function make all the char Capital   
              // If you enter smal or Capital leter ,it doesn't matter   
      }   
      if (!strcmp(dat, "A")) {   
      PORTA=0x03;   
   UART1_Write_Text("Led1 is On Enter Here-:");   
   Lcd_Cmd(_LCD_CLEAR);   
   Lcd_out(1,1,"Led1 is On");   
   Lcd_out(2,1,"Press Enter");   
   delay_ms(100);   
      } else if (!strcmp(dat, "B")) {   
       PORTA=0x05;   
       UART1_Write_Text("Led2 is On Enter Here-:");   
        Lcd_Cmd(_LCD_CLEAR);   
   Lcd_out(1,1,"Led2 is On");   
   Lcd_out(2,1,"Press Enter");   
   delay_ms(100);   
      }   
      else if (!strcmp(dat, "C")) {   
       PORTA=0x09;   
        Lcd_Cmd(_LCD_CLEAR);   
   Lcd_out(1,1,"Led3 is On");   
   Lcd_out(2,1,"Press Enter");   
   delay_ms(100);   
       UART1_Write_Text("Led3 is On Enter Here-:");   
      }   
      else if (!strcmp(dat, "D")) {   
       PORTA=0x21;   
        Lcd_Cmd(_LCD_CLEAR);   
   Lcd_out(1,1,"Led4 is On");   
   Lcd_out(2,1,"Press Enter");   
   delay_ms(100);   
       UART1_Write_Text("Led4 is On Enter Here-:");   
      }   
       else{   
       PORTA=0x01;   
   Lcd_Cmd(_LCD_CLEAR);   
   Lcd_out(1,1,"Something Wrong");   
   Lcd_out(2,1,"Press Enter");   
   delay_ms(100);   
   UART1_Write_Text("Something is Wrong!!! \n A=led1,B=led2,C=led3,D=led4,E=led5 \n Enter-: ");   
      }   
     }   
    }   
    }   
     }

Step 4:
Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]

Result Output:

Now load the hex file to the microcontroller .
Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]
Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]
Output : Press the Start Button .
Rs 232, Serial Communication
Rs 232, Serial Communication 
Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]
Rs 232, Serial Communication 


                                   Download Proteus File & MikroC File

Thank You!

10 comments:

  1. Very nice blog...
    Great information provided. We also provide PIC Microcontroller Training in Noida. I appreciate your work.

    ReplyDelete
  2. Thank you very much, i would like to ask you about the project related to 8051 micro-controller using the same principle. I would like to communicate with you regarding such project. My email address is tusadhao@gmail.com. I am anticipating response from your side.
    Thank you again.

    ReplyDelete
    Replies
    1. Sorry my comment option wasn't working and maybe I missed that mail on my inbox but If I did't I would say the same thing as I'm going to tell now. I've never worked with 8051 but all functionalities should be same. Thank you.

      Delete
  3. If you do not have the serial key and if none of the IDM serial keys 2019 mentioned above you can try downloading IDM cracked version from a website........ idm crack

    ReplyDelete
  4. very interesting post.this is my first time visit here.i found so mmany interesting stuff in your blog especially its discussion..thanks for the post!
    ultrasonic level sensor for diesel tank

    ReplyDelete
  5. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value. Im glad to have found this post as its such an interesting one! I am always on the lookout for quality posts and articles so i suppose im lucky to have found this! I hope you will be adding more in the future... Arduino library for Proteus

    ReplyDelete
  6. Hi, can you share more details about it, what is the actual error and how can we sort out it. Also check sublimation ink paper using household iron and explore out the new things.

    ReplyDelete

Ain't getting any visitors!
Please Share and Bookmark posts.

Tags

: (1) 18F2550 (1) 36KHz (3) and (1) arduino (1) Based (1) battery (1) Bipolar (1) Blinking (1) blinks (1) Bluetooth (1) bluetooth device interfacing (1) bluetooth module (1) button (1) circuit (1) clock (1) control (1) crystal oscillator (3) Db9 (1) DC Motor (2) digital (2) Digital Voting Machine (1) digital voting machine using pic (1) display (2) DS1307 (1) electronic (1) embedded c programming tutorial (11) embedded c tutorial (11) experiment kit (4) external interrupt (4) flash (1) flashing (1) Gas Leakage detector (1) HC-06 (1) home (1) how (1) How to (10) i2c tutorial (1) in (1) indicator (1) infrared Connection (3) interface (8) interfacing (3) Interrupt (3) Introduction (1) IR Connection (3) IR Receiver (4) IR Transmitter (4) key pad (1) keyboard (1) keypad (1) lavel (1) Lcd 16x2 (2) lcd 2x16 (2) led (1) lm35 (2) LPG (1) machine (1) make (1) Make bootloader (1) making (1) matrix (1) max232 (1) membrane keyboard (2) meter (2) Micocontroller (1) microchip (4) microchip pic (2) microchips (3) microcontroller (9) microcontroller based (3) microcontroller programming (3) Microcontroller Project (4) Microcontroller Projects (1) microcontroller_project (2) microcontrollers (4) Microprocessor (2) mikroC (5) mikroc code to start and stopstart and stop dc motor (1) mikroc pro for pic (2) Motion detector (1) MQ-9 Gas Sensor (1) musical (1) NEC Protocol (4) pcb (5) PIC (3) pic controller (11) pic microcontroller (11) pic microcontroller tutorial (11) pic programming (1) pic programming in c (12) pic proteus (1) Pic Tutorial (12) pic18 (2) pic18f2550 (11) picmicrocontroller (4) picRFモジュール (1) PIR Motion Sensor (1) printed circuit board (1) proteus (6) pulse width modulation (1) push (1) push button (1) PWM (1) real (1) rf transmitter (3) Rs 232 (1) Rs232 (1) scroll (1) scrolling (1) Serial communication (1) Serial Connection (1) Serial Port (1) serial port rs232 (1) Servo Motembedded c programming tutorial (1) simulation (2) Soil Moisture Meter (1) speed control (1) step by step (7) step bystep (1) Stepper Motor (2) text (2) Thief Detector (1) time (1) timer (4) timer0 (4) tone (1) TSOP38236 Receiver (4) tutorial (2) Unipolar (1) USART Connection (1) USB (1) usb 1.0 (1) USB bootloadere (1) USB HID (1) using (9) voltmeter (1) voting (1) water level indicator (3) with (2) work (1)

Traffic Feed


Live Traffic Feed
Visitor Tracking

Leave Your Message Here

Name

Email *

Message *

Like on Facebook