Accesing Serial Port Using Matlab

Status
Not open for further replies.

Circuit_seller

Full Member level 5
Joined
Sep 23, 2002
Messages
300
Helped
17
Reputation
34
Reaction score
7
Trophy points
1,298
Activity points
2,350
Hi

Does anyone have experience working with serial port in matlab.
I have tested it, by connecting COM1 to COM2 directly and writing to one, to read from another. but matlab goes busy and halted.
Can anyone advise me?

Thanks in advance.
 

Always take care to clean the serial buffer by reading all characters arrived from the port.

If the 's' is the serial port identifier you opened,
always check variable

's.BytesAvailable'

to see number the characters waiting in que to be read.
 

Hi Circuit_seller

There are two toolbox's for matlab. One is Instrument control and the
other is "Data aquisition" (?). In one of these there is a command
ser(?,?), it communicates with the serial port. In matlab type
help ser if there is no ser.m file that means you dont have the toolbox.
You can go to matlabs website and in "Support" you can search for
this type of command. Try these links.

h##p://www.mathworks.com/matlabcentral/fileexchange/loadCategory.do
h##p://www.mathworks.com/matlabcentral/fileexchange/loadFileList.do?objectType=search&criteria=serial+port&objectId=110

Good luck
 

Hi

thanks for your helps.
I have found a bug using serial object in matlab.
When i have trying to get data from COM1, matlab is gone busy.
But if first i send a char with COM1 then reading data will be ok.
Maybe the port should be worm up in matlab.

Regards
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…