I am trying to establish a serial link in Matlab with an Arduino board. Reading data from the board goes well. However, writing data to the board takes about a second for each block of information I send.
The code I am running to write data:
s = serial(comprt,'BaudRate',9600,'DataBits',8);
fopen(s);
fprintf(s, '%c', 'c');
fprintf(s, '%u %u %u %u \n', [A B C D]);
pause(1);
fprintf(s, '%c', 'a');
pause(1);
A, B, C, D are 8-bit numbers anywhere from 0 - 255, 'c' and 'a' are characters commands that do stuff on the Arduino board and tap into the firmware on the board.
If I do not include the pause(1) commands, so when I do not stop Matlab from executing the next command for at least a second, the serial information doesn't get through.
Can anyone help me to speed up writing stuff to the serial port? I checked with the Arduino editor, and when I enter equivalent commands via their interface, everything is fine. So the delays are not related to the Arduino board or device drivers, it's definitely on the Matlab side of things.