Azzera filtri
Azzera filtri

How can I communicate with a USB instrument which is not VISA?

12 visualizzazioni (ultimi 30 giorni)
I need to control a USB stepper motor controller which is not a VISA instrument. How can I use USB without VISA?

Risposta accettata

Walter Roberson
Walter Roberson il 27 Ago 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 Commenti
Patrick Johnston
Patrick Johnston il 29 Ago 2018
WOW! Thanks! I take it that COM3 is somehow attached to the USB hardware... I won't get a chance to test this until, probably, tomorrow, but thank you, Mr. Roberson!
Walter Roberson
Walter Roberson il 29 Ago 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.

Accedi per commentare.

Più risposte (1)

Nanda Gupta
Nanda Gupta il 27 Ago 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 Commenti
Nanda Gupta
Nanda Gupta il 27 Ago 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
Walter Roberson il 28 Ago 2018
In turns out that Arduino is not required for this particular device.

Accedi per commentare.

Categorie

Scopri di più su Hardware Discovery and Setup in Help Center e File Exchange

Prodotti


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by