Discussion in "8051 Discussion Forum" started by    Kelvin    Jan 23, 2008.
Wed Jan 23 2008, 09:20 pm
#1
Hello everybody, how can i interface a 8051 microcontroller with matlab. I have finished the code at microcontroller side and i have displayed it on PC using Visual basic. But now i want to display it on PC using MATLAB. Can anybody help.
Thu Jan 24 2008, 08:43 pm
#2
No body here to help?
Thu Jan 24 2008, 09:06 pm
#3
hai kevin

u can use the serial port in 8051 to send data serialy. In matlab there is a command to receive your data serialy. The command is

ser= serial('COM1','BaudRate',9600,'DataBits',8);
fopen(ser)
% while(1)
for i=1:1000
fwrite(ser,4);% asci C
end
fclose(ser);

try this and see.

Thank you
 ajay_bhargavshyam like this.
Tags interfacing matlab serial port
Fri Jan 25 2008, 12:05 am
#4
thank you swat!
Fri Jan 25 2008, 09:59 am
#5
thank you swat, i will try it.
Sat Mar 29 2008, 02:36 pm
#6
Heres the code which i wrote to get the data from the serial port and to display it. But it shows error in matlab. anybody can debug it.

s= serial('COM1','BaudRate',9600,'DataBits',8);
fopen(s)
fprintf(s,'*IDN?')
while(1)
{
idn = fscanf(s);
}
Sat Mar 29 2008, 02:47 pm
#7
what is the exact error? can you please copy and paste it here..
most probably its syntax error coz you are using C codes in matlab. Check swat's code how he has written C codes..

and instead of fscanf try using fread(s,NO_OF_BYTES)
Thu Feb 20 2020, 02:28 pm
#8
With regards to the particular characters sent to the microcontroller, you should assume that this is a MATLAB newsgroup and that I might not know the 8051 assembly language that you are using.
I also do not have the Test and Measurement Toolbox, and as you had not previously mentioned that you were using that, I had no way of guessing it.
If you don't know about the graphics interface, then you had better find out, because the *supported* ways of reading individual keys from a keyboard require using the graphics interface.
When you have finished assuming that we will "just know" things you have failed to mention despite having been asked about them, read these reference pages:
http://www.mathworks.com/help/toolbox/instrument/serial.html .
If you are interested to learn MATLAB course then visit CETPA.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Bobbyerilar
Thu Mar 28 2024, 08:08 am
pb58
Thu Mar 28 2024, 05:54 am
Clarazkafup
Thu Mar 28 2024, 02:24 am
Walterkic
Thu Mar 28 2024, 01:19 am
Davidusawn
Wed Mar 27 2024, 08:30 pm
Richardsop
Tue Mar 26 2024, 10:33 pm
Stevencog
Tue Mar 26 2024, 04:26 pm
Bernardwarge
Tue Mar 26 2024, 11:15 am