Arduino used with MATLAB (2)

I want to make this topic strictly to understand how an Arduino board can

be used with Matlab's data acquisition toolbox or in any other way.

Hi,

i tried a lot to achieve a high sampling rate for all 8ADC channels but there are some limitations:

  1. the ADC (analog.read) needs about 100us to sample--> max. 10kHz is possible using 1 channel (you can make the ADC faster, but accuracy gets worse)

2 Using the serial.print command high values like 1023 need more time than low values. Dividing the value in high and low byte should solve this. I wrote an UART ISR, have to try it soon....

In Matlab using a Terminator and Callbacks was very slow, but also using loops i couldnt achieve more than about 600 Hz (1 channel!!!!!).

I dont know, maybe i did something wrong, or the Matlab/Arduino interface is too slow...

Hello,

I am trying to control an Arduino Mega from Matlab to automate the control of some routing switches for making measurements over a period of months. The speed of switching is not critical ... but keeping it running is. I have a compiled Arduino sketch and a Matlab script (I'm not using the data acquisition toolbox) that sends the necessary commands. It all works fine for about 30-80 commands and then hangs with Matlab waiting for a response that never comes. This is sometimes preceded by a few timeout errors which the system recovers from before the final hang. I have a rudimentary handshaking routine (Arduino sends back a byte after each command received and Matlab doesn't send next one until this is received). Reducing the baud rate and adding delays into either the Arduino or Matlab code makes no difference (in fact the hang occurs at exactly the same place). The only things that alter the point where the hang occurs seem to be changing the length of the command string in Matlab, altering the amount of code associated with receiving the command in the Arduino and changing the size of the buffer allocated in the Aruino for storing the incoming serial data. None of these cause predictable changes (i.e. making the buffer bigger doesn't let program run for longer).

I'm guessing that somehow the Arduino misses odd bits of incoming data if it happens to be doing something else when it arrives. One possibility that I haven't fully explored is changing the serial port protocol in Matlab - I am using the defaults. Is there a full description of the serial protocol that Arduino uses?

Any ideas gratefully received ...