Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

serial port reading.

Asked by vijil viswam on 29 Feb 2012

Here i submit a matlab program, which read ASCII values from a serial port to which an arduino board is connected.

for i = 0: 10
fclose(instrfindall); %close all serial comms
s=serial('COM25','BaudRate',9600); %start serial port to arduino
fopen(s); %open port
out = fgets(s); %read data from arduino, which waited until start
disp(out) %display arduino data
fclose(instrfindall);
end

The program read data successfully,but the problem is, its can't read data synchronously from arduino output port(COM25).(ie, some line of data is missing). kindly give me a solution for this problem and kindly give me a correct code also.

0 Comments

vijil viswam

Products

No products are associated with this question.

1 Answer

Answer by Walter Roberson on 29 Feb 2012
Accepted answer

Do not continually close and open the serial port.

The default for serial ports is to read asynchronously. You have to change the serial port properties to read synchronously.

You have not changed your serial port terminator character, as is needed for arduino. See the MATLAB File Exchange contribution that shows a GUI for interacting with arduino devices.

0 Comments

Walter Roberson

Contact us