Arduino Due Native USB communication with Matlab

15 views (last 30 days)
Hello,
I am currently sending data from the Arduino native USB port and I want to plot it on matlab.
Now I am tring to use high-speed comunication and as far as I understand this port does not transfer data in a specific Baud-Rate.
I need to send from the arduino about 25kB of data each second (about 12,500 samples of 2 Bytes).
In order to send the information am using at the arduino end this function: SerialUSB.write();
Now I need to recive this data to matlab.
My questions:
  1. How can I recive this data at this rate?
  2. This data are audio samples - how can I plot it?
Another importent thing is that all of that NEEDS TO BE REAL-TIME.

Answers (2)

Prasad Parameswaran
Prasad Parameswaran on 21 Oct 2019
SerialUSB approach is recommended when using Arduino Due USB port. The BaudRate vale is not revelent while using SerialUSB.
The performance can be improved by writing data asynchronously and trying to read only if bytes are available.
The following link might help in use of Arduino Due for high speed Communication.
  2 Comments
Aviel Moos
Aviel Moos on 27 Oct 2019
Thank you for your response.
About the Arduino I know how to use usb communication. The problem was the matlab part.
Do you know if serial object uses Asynchronous or Synchronous communication?
asma sarouji
asma sarouji on 6 Feb 2020
I have some questions about the Arduino and the USB port

Sign in to comment.


Walter Roberson
Walter Roberson on 6 Feb 2020
Edited: Walter Roberson on 6 Feb 2020
I need to send from the arduino about 25kB of data each second (about 12,500 samples of 2 Bytes).
If that is buffered into full packets of 1020 data bytes each then I think you can get that rate. However if those are individual packets then I don't think you can get anywhere even remotely close.
There are two major designs for USB in Arduino. The one that is in most Arduino uses the UART to transfer bytes to a USB controller, and the USB controller has an 8ms or 16ms buffer timeout because it suspects that you want to transfer more bytes. 16ms is only 62.something packets per second. But with you wanting to send much higher rate than that the data would indeed get automatically buffered until the 1020 data bytes mark was hit and that would get sent as a whole. This strategy is not suitable for REAL TIME work.
The arduino that use that FTDI usb chip do not have any hardware connection to the pins on the chip that would permit flushing packets early.
The other major usb design for arduino has a USB chip more directly connected that permits lower latency and does offer ways to request that packets be flushed.
However, USB itself is based on a master/slave relationship that polls only 1000 times per second.
USB 2.x does not permit devices to send interrupts to request service outside of the normal 1000 polling cycle. USB 3.something did add provisions for that.
USB can be an acceptable bulk data transport protocol, but it is not suitable for Real-time small packet work.

Categories

Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!