How can I communicate with a USB instrument which is not VISA?
16 views (last 30 days)
Show older comments
Patrick Johnston
on 24 Aug 2018
Commented: Walter Roberson
on 29 Aug 2018
I need to control a USB stepper motor controller which is not a VISA instrument. How can I use USB without VISA?
0 Comments
Accepted Answer
Walter Roberson
on 27 Aug 2018
USB devices can often be opened as serial ports. If the device does not support VISA, then you will need to research the protocol.
If it is a line-oriented protocol then matters are often not so bad, but even with line oriented protocols, some devices have a fairly complicated command structure.
Some USB devices communicate with fixed length binary packets but still compatible with serial drivers. Sometimes the interfaces for these are fairly simple and sometimes the interface can get fairly complicated.
This approach requires that the device be willing to communicate with RS232 or TTL emulation. This approach does not work if the USB device registers itself as an audio or video device, or as a bulk data device (e.g. like a disk drive.) It is not possible to communicate directly from MATLAB to arbitrary USB devices: to work with such devices you need code that talks to the USB controller, giving USB controller commands and retrieving results, which requires a binary packet structure that cannot be created at the MATLAB level.
MATLAB also does not support any way of sending the USB controller a "push" packet, which effectively limits the number of back and forth serial interactions per second, as the USB drivers will wait for a while assuming that more serial data might arrive, only dispatching the packet when it fills up or a timeout occurs. The serial flush operation supported by MATLAB does not force the data to be sent: the serial flush operation is to remove any pending output from the output buffer.
9 Comments
Walter Roberson
on 29 Aug 2018
The GUI interface you were using should, I think, tell you which COM port is in use. Devices of this variety report their type as Communications devices, and implement "serial over USB". Serial over USB is close to being a raw stream of bytes presented as packets, but each packet also starts with a few bytes of emulated pin statuses like DTR.
More Answers (1)
Nanda Gupta
on 27 Aug 2018
I understand that you are trying to use USB Stepper Motor Controller with MATLAB. Unfortunately, Instrument Control Toolbox does not support USB devices without VISA interface as mentioned in the following documentation link for USB devices and Support for Instrument Control Toolbox:
One other way to communicate with this instrument could be to have an intermediate device that is supported by MATLAB and configure this device to talk to the stepper motor and MATLAB. Please note that this might just be one of the possibilities.
3 Comments
Nanda Gupta
on 27 Aug 2018
Yes, Arduino could be one such intermediate device. The technical support can not quote as to why USB without VISA is not supported. However, if you have DLLs in C routine, you can use this with the help of 'loablibrary' function in MATLAB. The following link talks more about the same:
Walter Roberson
on 28 Aug 2018
In turns out that Arduino is not required for this particular device.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!