This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

problem in 8051 to matlab communication

hi
i am final year student of electrical engineering and doing a project on 8051 microcontroller.
in this project,i have to interface the 8051 to maltab for real world data.i successfully complete the interfacing and communicate serially on proteus.data which is transfer from 8051 to matlab is not accurate when i send more than one character.in single character, matlab does not show any data.plz help me,how to solve that problem as i am using 8051 first time.

Parents
  • Hi,
    I have a similar problem. I want to send data from 89C51 to a matlab program-if P1^0 is set one data will be sent which will cause an action in the matlab program, if not some other data will cause a different result. I have no clue how to send data to matlab. I tried sending data to the hyperterminal but it either sends no data or some garbage data. Here's the code I've used:

    
    #include <reg51.h>
    sbit d1=P1^0;
    void main(void)
    {
    
     PCON=0xFF;
     TMOD=0x20;
     TH1=0xFA;
      SCON=0x50;
     TR1=1;
     if(d1==1)
     {SBUF='Y';
     while(TI==0);
     TI=0;
     }
    
     else
     {SBUF='N';
     while(TI==0);
     TI=0;
     }
     SBUF=0x0D;
     while(TI==0);
     TI=0;
     SBUF=0x0A;
     while(TI==0);
     TI=0;
    
    }
    


    When I run this in Keil, it shows the baud rate to be 9598 instead if 9600.

Reply
  • Hi,
    I have a similar problem. I want to send data from 89C51 to a matlab program-if P1^0 is set one data will be sent which will cause an action in the matlab program, if not some other data will cause a different result. I have no clue how to send data to matlab. I tried sending data to the hyperterminal but it either sends no data or some garbage data. Here's the code I've used:

    
    #include <reg51.h>
    sbit d1=P1^0;
    void main(void)
    {
    
     PCON=0xFF;
     TMOD=0x20;
     TH1=0xFA;
      SCON=0x50;
     TR1=1;
     if(d1==1)
     {SBUF='Y';
     while(TI==0);
     TI=0;
     }
    
     else
     {SBUF='N';
     while(TI==0);
     TI=0;
     }
     SBUF=0x0D;
     while(TI==0);
     TI=0;
     SBUF=0x0A;
     while(TI==0);
     TI=0;
    
    }
    


    When I run this in Keil, it shows the baud rate to be 9598 instead if 9600.

Children