communicating with USB in MATLAB
Mostrar comentarios más antiguos
is it possible to read data from USB port with java or C++ and import the data in MATLAB?in fact I am looking for a solution to read data from USB port and plot it in MATLAB
1 comentario
Smriti Thakur
el 3 de Jun. de 2020
Hi, I am new to matlab and have same question. I was to transfer data from USB to matlab,
and i can't find the wat anywhere. Some people say thta we have to make a virtual serial port and
then assign this port to usb. But I [don't know how to do that. AlSO, can somwone tell me if matlab' ...
support USB ports or not. If yes how ?]
Respuestas (2)
Image Analyst
el 5 de Feb. de 2012
0 votos
Why do you need to read it with a java or C++ program and import into MATLAB? Why don't you just read the values directly with MATLAB?
3 comentarios
sona
el 5 de Feb. de 2012
Image Analyst
el 5 de Feb. de 2012
Did you look up USB in the help? You'll see lots of stuff, such as this:
"If you have devices that present themselves as serial ports on your operating system, you can use them as virtual USB serial ports in MATLAB. Examples of such devices would be Bluetooth® devices and USB Serial Dongles.
MATLAB can communicate with these devices as long as the serial drivers provided by the device vendor are able to emulate the native hardware. Certain software, like HyperTerminal, does not require the device driver to fully implement and support the native hardware. "
Smriti Thakur
el 3 de Jun. de 2020
Hi, I am new to matlab and have same question. I was to transfer data from USB to matlab,
and i can't find the wat anywhere. Some people say thta we have to make a virtual serial port and
then assign this port to usb. But I [don't know how to do that. AlSO, can somwone tell me if matlab' ...
support USB ports or not. If yes how ?]
Walter Roberson
el 5 de Feb. de 2012
0 votos
Suppose that someone told you that they wanted to communicate with a telephone. Not communicate with someone by using a telephone: that they wanted to communicate with the telephone itself.
USB is a hardware specification (voltages, connector types), and a protocol for communications. USB is not a device. Individual devices can use the USB hardware and protocol to communicate, but it is not USB itself that is doing the communication.
You cannot communicate with a USB port. You can communicate with a device that is connected through USB. But to do that you need to know which of the defined USB sub-protocols that the device uses. Is the device communicating like a camera? Like a microphone? Like a hard-disk?
8 comentarios
sona
el 6 de Feb. de 2012
Walter Roberson
el 6 de Feb. de 2012
http://www.mathworks.com/matlabcentral/answers/12305-real-time-emg-data-plot-through-mathlab
http://ww1.microchip.com/downloads/en/DeviceDoc/39564c.pdf
http://www.electro-tech-online.com/microcontrollers/36817-serial-communication-pic-18f4550.html
Pulling together the information from the above:
The PIC18F452 does not have a built-in USB interface, so you would have to add an interface to USB if that was important to you. The manner in which the PIC communicated with the USB interface would depend upon your design decisions.
The PIC18F452 does have a USART, and it appears that the USART runs at TTL levels. This could be adjusted to work with RS232 using relatively common RS232 to TTL level convertor chips such as the MAX232. If that was done, then you would connect the device to the computer using a serial port -- and MATLAB *does* handle serial ports.
The main reason one might choose USB over RS232 is that USB can in theory transfer data at 480 Mbit per second (with full packets... if all the data is all ready to go...). On the other hand, USB is not suitable for real-time work: it is inherently not real-time. Unless special steps are taken (that are not directly supported in MATLAB) the minimum serial packet latency for USB is 40 ms, only 125 Hz.
If you are definitely going to use USB to interface the PIC then you are going to have to decide what kind of USB device you are going to present the PIC as... and if you are fortunate it will be one that MATLAB is able to talk to.
sona
el 8 de Feb. de 2012
Walter Roberson
el 8 de Feb. de 2012
USB cannot support real-time communication by its design.
Serial ports can support it to within the overhead and latency of sending and receiving a character.
Image Analyst
el 8 de Feb. de 2012
"real time" may mean different things (have different rates) to different people. Why don't you try it and see? It might be fast enough for your purposes. Don't discount it until you try it.
Walter Roberson
el 8 de Feb. de 2012
USB virtual serial ports buffer bytes, by design. (There is a USB-specific way to request early release of the packet but MATLAB does not provide an interface to that mechanism.) Hold time for more output is 40 ms. Usually real-time systems need to go faster than that (the situation is like having to use 1200 baud.)
sona
el 19 de Feb. de 2012
Walter Roberson
el 19 de Feb. de 2012
http://ww1.microchip.com/downloads/en/DeviceDoc/39564c.pdf
Table 16-5.
Absolutely the only reason to be restricted to 9600 baud on that device is if you are using the slowest oscillator supported by the PIC, 32768 Hz. ANY faster oscillator supports much much greater serial port speeds.
USB will in NO WAY help. There is NO USB interface on that device. You would have to feed the USB from the serial port, so if the serial port is too slow because you wanted to save half a cent on an oscillator, then USB is going to be even slower.
The last time I encountered an oscillator as slow as 32768 Hz was on my off-brand digital watch with a special snooze alarm in the early 1970's.
Categorías
Más información sobre Deployable Archive Creation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!