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.
Check the red wire.
No, you don't interface the 8051 to Matlab.
The 8051 doesn't have any specific "Matlab" interface - it neither knows nor cares anything of Matlab.
The 8051 does have a UART (Serial Port) which can be used to send bytes and/or receive bytes - but it makes absolutely no difference whatsoever to the 8051 what is connected to the other end of the serial link.
So start by testing with a connection to something simple like hyperterminal...
transfer from 8051 to matlab is not accurate when i send more than one character post your well commented and indented code and someone will help you.
Erik
post your well commented and indented code and someone will help you
these must be scary words, both posters who got this reply disappeared
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.
sorry, here's the code again with comments...
#include <reg51.h> sbit d1=P1^0; void main(void) { PCON=0xFF; //to set PCON.7 for baud rate TMOD=0x20; //timer 1 mode 2 TH1=0xFA; //for baud rate 9600 SCON=0x50; TR1=1; //start timer 1 if(d1==1) {SBUF='Y'; //sends Y while(TI==0); TI=0; } else {SBUF='N'; //sends N while(TI==0); TI=0; } SBUF=0x0D; //sends carriage return and line feed while(TI==0); TI=0; SBUF=0x0A; while(TI==0); TI=0; }
you clearly do not believe in commenting or indenting, so I only gave the scribbles a quick glance. Had it been code I would have looked more.
anyhow, nobody can help you if you keep your crystal freq and what derivative you use a secret.
I managed to post the above while you were correcting the lack of comments and indenting. anyhow xtal? derivative?
I am using AT89C51 (no data appeared in hyperterminal) and also AT89C52 (garbage data appeared), with xtal frequency 11.059MHz.
... have a MAX232(equivalent) inbetween.
try sending 'U' (capital U) constanly and have a look with a scope, you should see a squae wave of 4800 Hz.
I am using AT89C51 (no data appeared in hyperterminal) and also AT89C52 (garbage data appeared), with xtal
what is your reset? how do you program the chips?
Yes, I have a MAX232. I programmed the chips using Intelligent Universal Programmer kit and LabTool software. I will try your suggestion. Didn't get your question, 'what is your reset?'?
Didn't get your question, 'what is your reset?'?
do you have a silly RC reset or a decent reset chip?
#include <reg51.h> void main(void) { PCON=0xFF; //to set PCON.7 for baud rate TMOD=0x20; //timer 1 mode 2 TH1=0xFA; //for baud rate 9600 SCON=0x50; TR1=1; //start timer 1 while (1) { SBUF='U'; //sends U while(!TI); TI=0; } }
I have used a ready to solder microcontroller 'kit'. It doesn't have a chip specifically dedicated to resetting (such as MAX1232?), it's just an RC reset.
It doesn't have a chip specifically dedicated to resetting (such as MAX1232?), it's just an RC reset. too bad
what does your scope show when you run the scoping code I show above?
at the TXD pin, at the RS232 line