Go Down

Topic: Communication with MATLAB_Old Questions But New Ideas (Read 1 time) previous topic - next topic


Mar 22, 2012, 05:46 am Last Edit: Mar 22, 2012, 08:29 am by nuttracy Reason: 1
hi everyone
I am now working on connecting the MATLAB with Arduino. I tried two ways.
1. Using MATLAB GUI to design a interface
2. Using MATLAB M File to communicate with Arduino directly.
My problems are:
the same code in two ways
Code: [Select]

str = get(s1, 'TransferStatus');
if ~(strcmp(str, 'write') || strcmp(str, 'read&write'))
str1 = get(s1, 'TransferStatus');
My Questions are :
In MATLAB GUI it can run smothly, but in M File it needs
Code: [Select]
pause(1.5); before fwrite().
1.if I do not put a pause, Arduino cannot receive data from Matlab successfully. and I can see a warning of time in MATLAB Command Window.
2.If I do not want to use the pause()in M file, can I use other ways to solve it?

Thanks a lot.


I didn't find any of the poll choices appealing, so I didn't vote. Sorry.
The art of getting good answers lies in asking good questions.


Sorry Paul, In fact, it is not a vote. It's just a question.
I am wondering if someone could help me with this problem?

Thanks a lot.


It is not clear which baudrate you are using, you could try to lower the speed as the Arduino might not be able to handle it adequately.

Can you post the arduino code? It might be optimizable ...
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


The baud_rate is 57600, and I have some delay functions in the Arduino code. I cannot change both of them due to the application requirement.

I think I find some explanations:
In the beginning, both the MATLAB and Arduino need sometime to build the connection. This phenomenon occurs both in the MATLAB GUI and M files.

And in MATLAB GUI, if the auto send peroid is too short, the MATLAB can still receive many incomplete data. But if I use a buffer to save the data and judge the length before print it in GUI, this problem can somewhat be solved in the display module.
In the MATLAB M FIles, I just examine the received data with a desired length every time without buffer. So, when the incomplete data coming, MATLAB shows a warning of time. If I want to solve the problem in M files, I can also use a buffer. But it will be more complicated than GUI. Therefore, I decide to use GUI to continue my project.

Thanks for your time.

Go Up