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

Matlab to 8051 communication

Hai...i tried to send the letter 'L','S','R' from matlab just opening in command line and typing...

se=serial('COM7');
set(se,'BaudRate',9600);
fopen(se);
fprintf(se,'%c','L','async');
fclose(se)

in matlab uc(at89c51)...and in response it should change its port settings accordingly...
Here is my code...

#include<reg51.h>
sbit mlp=P1^0;
sbit mln=P1^1;
sbit mrp=P1^2;
sbit mrn=P1^3;
void main(void)
{
  char i;
  SCON=0x50;  // to receive and transmitt serially
  TMOD=0x20;   // timer in mode 2 8 bit auto reload mode
   TH1=-3;   // baud rate 9600
   TR1 = 1;
   while(1)
     {
           if(TI==1)
                        TI=0;

                else if(RI ==1)
                        {
                                i=SBUF;
                                RI=0;
                        }
                if(i=='S')
                {
                mlp=mrp=1;
                mrn=mln=0;
                }
                else if(i=='L')
                {
                mlp=mrn=1;
                mrp=mln=0;
                }
                else if(i=='R')
                {
                mlp=mrn=0;
                mrp=mln=1;
                }
                else
                {
                mlp=mrn=0;
                mrp=mln=0;
                }
           }


}


I have my uc connections on bread board...and i dnt knw wat is the Tx,Rx pin in my connector...
So what i did was put a 2k Resistor in between so that not to fry the ckt accidentatally in case i changed the pins...the character is not at all being sent...the four pins are in 0 condition...see the ELSE part...in abv prgm... Please help... re soon...please....

Parents
  • There also exists USB-to-serial cables that delivers logic-level signals. This type can be found with 3.3V or 5V logic levels and can then be connected directly to the processor pins.
    these are so rare that I doubt you have one such (if you bought it in a computer store it is not), so the rest of this post is based on you do not have a such.

    If you have a USB-to-serial cable with any internal MAX-chip, then that chip is there to create RS-232 signals, i.e. to create a standard RS-232 port.
    so with these signals connected directly to your uC it went pop, blop fizzz ad burned one or both of the Rx and Tx pins.

    It doesn't matter if fprintf executed "flawlessly".
    this seems to indicate that the Tx pin survived. RS232 levels are such that SOME inputs will correctly catch TTL levels.

    Yes, you can use just ground + tx on the cable,
    if you did it went pop, blop fizzz ad burned one or both of the Rx and Tx pins.

    Put A MAX232 (equivalent) on your board, replace the uC and buy a new cable.

    In the unlikely event it 'works' after just adding the MAX232(equivalent) STILL replace the uC and buy a new cable. The previous persom that I know of that 'forgot' the MAX232 did not buy new parts because "evrything worked" later he spent a very long time debugging because the weakened parts finally broke (went intermittent)

    Erik

Reply
  • There also exists USB-to-serial cables that delivers logic-level signals. This type can be found with 3.3V or 5V logic levels and can then be connected directly to the processor pins.
    these are so rare that I doubt you have one such (if you bought it in a computer store it is not), so the rest of this post is based on you do not have a such.

    If you have a USB-to-serial cable with any internal MAX-chip, then that chip is there to create RS-232 signals, i.e. to create a standard RS-232 port.
    so with these signals connected directly to your uC it went pop, blop fizzz ad burned one or both of the Rx and Tx pins.

    It doesn't matter if fprintf executed "flawlessly".
    this seems to indicate that the Tx pin survived. RS232 levels are such that SOME inputs will correctly catch TTL levels.

    Yes, you can use just ground + tx on the cable,
    if you did it went pop, blop fizzz ad burned one or both of the Rx and Tx pins.

    Put A MAX232 (equivalent) on your board, replace the uC and buy a new cable.

    In the unlikely event it 'works' after just adding the MAX232(equivalent) STILL replace the uC and buy a new cable. The previous persom that I know of that 'forgot' the MAX232 did not buy new parts because "evrything worked" later he spent a very long time debugging because the weakened parts finally broke (went intermittent)

    Erik

Children