Does Matlab support USB communication?
3 answers
Can you provide your device with a virtual USB COM port? Then, normal MATLAB COM port calls ( overview ) work well.
s1 = serial(port,'BaudRate',57600,'Parity','none','Stopbits',1, ...
'Terminator','CR/LF'); % there are more properties to play with
fopen(s1);
fprintf(s1, 'text'); % appends terminator
resp = fscanf(s1); % waits for terminator
fwrite(s1, [1 2 3 4 5], 'uint8'); % writes binary chars, no terminator
resp = fread(s1, s1.BytesAvailable, 'char'); % reads all available bytes as chars
fclose(s1);
These calls don't need the Data Acquisition Toolkit, which is nice, and in my experience I work with both ASCII and binary data.
On some computers, we found that the FOPEN call lasted forever. For some reason this is due to Bluetooth virtual COM ports on some laptops. So we ended up writing a very simple .NET DLL that combined the Microsoft .NET serial port class and then imported it into Matlab as an ActiveX server. But hopefully the above will get you started.
+3
source to share