Forum
Register Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
aboharbf

Junior Member
Registered:
Posts: 16
Reply with quote  #1 
Reading one of the first papers (Achieving behavioral control with millisecond resolution in a high-level programming environment) and I came across the mention of USB DAQ Cards being problematic. From the article:

"Importantly, we found that accessing data samples from USB DAQ devices took significantly longer than from PCI devices. Specifically, using two USB-6008 devices from National Instruments, the maximum number of unique samples retrievable per second was only 200–400 (compared with at least 1–2 kHz for PCI devices, above), despite the 10 kHz maximum sampling rate of these devices. So, although these devices tend to be several hundred dollars cheaper than the PCI devices, their slower performance may make them less suitable for real-time behavioral control."

Is this still the case? Given USB 3.0 and improved USB DAQ Cards, would you run into the same problems if you pursued this solution today?
0
ryklin

Administrator
Registered:
Posts: 241
Reply with quote  #2 
I'm not aware of any USB 3.0 daq devices, but if/when they become available we will test them. I have used 2.0 devices and qualitatively they worked fine for some test cases. The new ML2 is much faster at sampling, so you should try using that. Otherwise, you should use NIMH daq with older ML releases.
0
monkeylogic

Administrator
Registered:
Posts: 3
Reply with quote  #3 
The problem with USB was that the protocol had a large overhead and delivered data in packets with notable lags between them.  So although you might be able to get a data stream at 10kHz, you didn't actually get all those chunks of data in a manner that was close-enough-to-real-time to be useful for rapid responses to behavioral events at the target  1ms timescale.  Newer USB protocols may work better, but we haven't tested them.
0
Jaewon

Senior Member
Registered:
Posts: 344
Reply with quote  #4 

It is true that USB is not as fast as its spec says in practice, but it is actually MATLAB DAQ that should be blamed for the data transfer lags observed in the first paper. New samples are available almost instantly when they are acquired in NI-DAQmx, but MATLAB DAQ just doesn't read them timely. Some test results are attached below. These figures are generated by a script included in NIMH ML2, daqtoolbox\examples\benchmark\benchmark_continuous_sampling.m and zoomed in.


NI-USB 6008, USB2, NIMH DAQ.png   
[MATLAB R2016a, NIMH DAQ, NI-USB 6008, 1 kHz, 8 Channels, USB2]

NI-USB 6008, USB3, NIMH DAQ.png   
[MATLAB R2016a, NIMH DAQ, NI-USB 6008, 1 kHz, 8 Channels, USB3]

It seems that there is a difference between using USB2 and USB3. In the test with USB2, the transfer rate was just slightly above 500 transfers/s, while USB3 can fetch new samples at the same speed as the sample rate. However, the machine I used for the USB2 test was slower and using more USB devices, so there could be some other reason. Anyway, from these results, I say you can do near-realtime-tracking fine with USB devices.


NI-USB 6008, USB3, MATLAB DAQ.png 
[MATLAB R2014a 32-bit, MATLAB DAQ, NI-USB 6008, 1 kHz, 8 Channels, USB3]

This is the USB3 test performed on the same machine, but with MATLAB DAQ. It is obvious why it looked as if USB devices were not good enough.


0
ryklin

Administrator
Registered:
Posts: 241
Reply with quote  #5 
Great, so we can use the NI-USB 6008!
0
aboharbf

Junior Member
Registered:
Posts: 16
Reply with quote  #6 
This is great news! so ML2 is using the NI-DAQmx by default or is it using MATLAB DAQ? Is there any special type of configuring required if I'm interested in using NI-USB 6008 for a future set up? (Thinking portable set up with a Laptop).
0
ryklin

Administrator
Registered:
Posts: 241
Reply with quote  #7 
That's not how it works, so let me explain:

NI-DAQmx is the driver provided by national instruments. It's the base level.

Matlab developed an interface on top of NI-DAQmx which is called Matlab DAQ. This higher level interface is too slow for our purposes. Instead we developed our own interface for Matlab to work with NIDAQmx, that is called NIMH-DAQ. It is a substitute for Matlab-DAQ. All recent versions of MonkeyLogic (ML1 or ML2) use NIMH-DAQ. However, ML2 only works with NIMH-DAQ, but ML1 can work with either Matlab-DAQ or NIMH-DAQ -- that is up to the user.

Also, NIMH-DAQ works with all National Instruments cards, including USB devices. Matlab's DAQ may not work with them all. 
0
aboharbf

Junior Member
Registered:
Posts: 16
Reply with quote  #8 
Ah ok, that makes sense. Thanks a lot for clearing it up.
0
Jaewon

Senior Member
Registered:
Posts: 344
Reply with quote  #9 
The PC that I used for USB2 also has USB3 ports, so I ran the same test by plugging NI USB-6008 to one of the USB3 ports. The transfer rate was about 500 Hz, just like the USB2 test above. So I guess it is not a problem of whether the port is USB2 or USB3. The other computer of mine used for the first USB3 test is newer by a few years, so it may have a better USB controller. You may want to run the script on you machine and check the transfer rate.
0
aboharbf

Junior Member
Registered:
Posts: 16
Reply with quote  #10 
That's very interesting - so it is simply a matter of using a new computer? Once I am actually in the process of implementing this, I will report back with the results from my tests.
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation: