I am using MATLAB and Arduino to control an atomic force microscope I am doing research on. I am running a GUI through MATLAB. I was previously using the Arduino IO Support package, however my imaging software requires a lot of data collection and analogread() takes a long time to communicate to the device. (I have increased baud rate to no avail).
The communication between MATLAB and Arduino is very slow using the support package so I have begun using serial communication to run both Arduino IDE and MATLAB simultaneously. Sending variables generated by my GUI to Arduino IDE, using the serial communication, gives me a lot faster results. However each time I have to open the serial connection it is very slow.
The serial communication will give me faster results for things like imaging and engaging my probe because I have to use large for loops to step through my controllers resolution values. My GUI also allows for immediate control of the probe. If I only need to send one writeDigitalPin() it is much faster to use that than wait for the serial port to open.
My serial communication works properly when I don't open the arduino communication function written into the support package. However, opening the arduino() function in matlab closes my arduino.ino file because the port can't open both methods at the same time.
Is there a way to use both methods of communication. Can I close the arduino function and open the .ino file with MATLAB? How is this done? I know you can open .exe files but the .ino files do not seem to work. All advice is appreciated