Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Serial Communication & Matlab

Status
Not open for further replies.

scoppulal

Full Member level 2
Joined
Apr 18, 2004
Messages
122
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,298
Activity points
1,007
matlab serial communication

Hello!

I have to send command a modem via serial port and want to use Matlab Serial Communication tool.

I used instrfind and matlab recognized the modem, anyway when I try to send AT commands I have no reply from the modem itself!

Also the follwoing message appears:
"Warning: A timeout occurred before the Terminator was reached."

Here follows the code I used:

porta_ser = serial('COM8');
porta_ser.BaudRate = 4800;
porta_ser.DataBits = 8;
porta_ser.Parity = 'none';
porta_ser.StopBits = 1;
porta_ser.FlowControl = 'none';
porta_ser.Terminator ='CR';
fopen(porta_ser);

fprintf(porta_ser,'ATI3')
pause(.1);
fscanf(porta_ser)

fclose(porta_ser);
delete(porta_ser);


Could anybody help please?
Thanks in advance
 

serial communication matlab

program seems to be correct.. so no issues.. try with some other buadrate...
or check if port connection is perfect or not... timed out results due data unocurred event during reading cycle...
 
matlab serial port communication

hi, we do some work with matlab serial comm. with mobile serialport. after scan we wait for 2 or 3 sec .and then we proceed. so wait 2 or 3 sec after scanf and before closing the connection
 

serial communication in matlab

HI!

I forgot to mention that everything is fine if I send the AT command using HyperTerm.

I put the "waits" into my code but nothing changes...

Any other idea, please?

Thanks
CIAO
 

matlab serial

Do little bit more for you...

Type command window

>>tmtool

you will get test and measurement window...
next thing go for scan for instrument hardware

you will get options for serial communication..
open device communication status it will generate session log
matlab code required for the program...

you can read or write also to check your instrument...

based on idea you can modify your program little bit.. and implement that...
wait will not work in mine idea...some solution is always.. there..
it is not much difficult....

or try attached file.. i am sure this will definately work.. yepee


HAPPY :D:D
 

matlab serial communication codes

Hi mate!
unfortunately your code doesn't work :( attached you see what matlab "tells" me.

I used TMTOOL as well with same results :(((

Thanks for any further help.
Hello
 

matlab serial port ,test

sir,

the file you have attached shows nothing wrong...

i.e will definately work..

the case you not feeding any data.. so seesion is timed out...
code i have checked properly...
if u r able to read data by hyperterminal then here also it has to display...

check...

HAPPY :D :D
 

matlab serial terminator

First of all I want to thank you for your help.

I try to explain what I need to have: I have to send AT commands to a modem and check how long it takes to perform some actions.

If I send "ATI3", for example, like I do using HyperT I expect to see a reply with some infos.
Using that piece of code I have no reply.

I don't have to feed data... I just send a command and wait for the modem to reply with a message.

It seems that it is waiting the terminator character... maybe, if I could send the termination it will reply with the info I need.

Still trying to understand... I'm not a professional programmer :)

Thanks
 

serial fscanf matlab

thanks for ur patience...

for that case also tmtool, i.e test and measurement tool... will work...

r u using any specific class for communication.. i won't think so....

might be some other cases...
see the paper for AT in matlab simulink for better idea...

HAPPY :D:D
 

Assuming that u hit enter in HyperTerminal while communicating, try replacing fwrite(porta_ser, ['ATI3' 13 10]), instead of fprintf(porta_ser,'ATI3) in ur matlab code
 

Hi,
I have a cooler and a pressure gauge which I need to operate from Matlab. Both devices are connected to the computer via a serial port. I've been using the Matlab Instument Toolbox Test & Measurement tool to try and communicate with these machines. The problem is that I don't get any data from them, and as far as I know, can't send them any data either.
The manual for the cooler can be found here, and a description of the RS-232 interface in part 4 of that document. I've set up the baud speed, number of data bits and stop bits, parity and terminator as specified. But if I try to send any commands to the device, I get no reply before the timeout.
I've sent the data in ASCII format and I've tried the different data formats, but I get no response. Can you tell me what is it that I'm doing wrong?
 

there r two methods which i know for serial interfacing with matlab.

1. you can write simple S Function program, which already given with the software, just you have to modify some statements.
2. using tmtool in CP, you can creat drive for serial communication in matlab.


both will work, first one will easy to develop

HAPPY : )

Hi,
I have a cooler and a pressure gauge which I need to operate from Matlab. Both devices are connected to the computer via a serial port. I've been using the Matlab Instument Toolbox Test & Measurement tool to try and communicate with these machines. The problem is that I don't get any data from them, and as far as I know, can't send them any data either.
The manual for the cooler can be found here, and a description of the RS-232 interface in part 4 of that document. I've set up the baud speed, number of data bits and stop bits, parity and terminator as specified. But if I try to send any commands to the device, I get no reply before the timeout.
I've sent the data in ASCII format and I've tried the different data formats, but I get no response. Can you tell me what is it that I'm doing wrong?
 

Re: matlab serial communication

In case ur problem is still not solved.....try using fread command instead of fscan to recieve data and fwrite to send data.......I faced the same problem and now it works :)

Hello!

I have to send command a modem via serial port and want to use Matlab Serial Communication tool.

I used instrfind and matlab recognized the modem, anyway when I try to send AT commands I have no reply from the modem itself!

Also the follwoing message appears:
"Warning: A timeout occurred before the Terminator was reached."

Here follows the code I used:

porta_ser = serial('COM8');
porta_ser.BaudRate = 4800;
porta_ser.DataBits = 8;
porta_ser.Parity = 'none';
porta_ser.StopBits = 1;
porta_ser.FlowControl = 'none';
porta_ser.Terminator ='CR';
fopen(porta_ser);

fprintf(porta_ser,'ATI3')
pause(.1);
fscanf(porta_ser)

fclose(porta_ser);
delete(porta_ser);


Could anybody help please?
Thanks in advance
 

Re: matlab serial communication

Hi, I reply also for many users having the same problem (google often forward to this topic), don't forget about the sign of end the line"

for example if you set:
Code:
porta_ser.Terminator ='CR';

You have to send something like this after the message from your uC:
Code:
Serial.print("\r");

and for 'LF' it is '\n' :)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top