Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

maximize USB streaming throughput

Solved!
Go to solution

I'm trying to speed up my task at hand. I need to send bursts of digital data out, 83 bytes long each, at intermittent, but fast, intervals

 

I am using Port 0 on USB-6251 in high-speed USB mode.

 

Below some options I tried

 

1. "Software timed" streaming - sending 83 byte U8 arrays to single CH multi sample DIO write VI repeatedly, no timing configured. Easy but deathly slow, about 1ms per byte rate. I wonder if NI driver uses some sort of software  handshake for each byte in this mode, limiting speed to USB frame-to-frame interval. Is it possible to run faster in that mode?

 

2. Hardware timing. I used on board counter internal output to provide continuous DO clock, tested anywhere from 500Hz to 1 Mhz. Can be much faster than (1), but running into issues:

a. Finite sampling - configured buffer to the size of single burst (83 bytes). Use auto-start, write one array and stop after each write to reset the task. Stable, but stopping task slows the program allot. Any way around this limitation?

  bContinuous  sampling, buffer set to few thousand, writing 83-byte arrays periodically - faster, but frequent buffer over/under runs in Windows for obvious reasons. Any way to stabilize it? Perhaps fiddle with counter output instead of running it continuously?

 

 

  

 

 

0 Kudos
Message 1 of 4
(3,886 Views)
Solution
Accepted by topic author Fedor

Hi Fedor,

 

Can you quantify "fast"?  This will help us make suggestions toward accomplishing your goal.  Take a look at the attached example VI as it uses a generated square wave from an analog output to trigger a retriggerable counter.  These need to be physically wired together.  This pulse will be the sample clock for your output.  Hopefully this helps- let me know if you have any questions after testing it out!

Regards,


h_baker
National Instruments
Applications Engineer
Message 2 of 4
(3,844 Views)

Thanks for posting the code example.

 

What I am trying to to is to issue 83 bytes from the port0 to program external device, do a measurement (not shown in the attached code, since it's not relevant), then go to the next cycle and issue next 83 bytes. The code uses counter 0 to output re-triggerable pulse train 83 clicks long on a rising  edge of the PFI15 line. Port 0 is configured to use the counter internal output as a DO clock. To maximize update speed, I pre-fetch the DO array and then only toggle PFI15 line in the main loop. It still takes about 7ms per cycle on my machine, which seems to be a limitation of the software-timed  DO over USB.

 

I wonder if there're  ways to speed it up, to at least 1 ms per cycle. I would like to be able to issue a DO trigger in software to correlate with the measurement portion of the code.

 

 

0 Kudos
Message 3 of 4
(3,828 Views)

h_baker,

 

I re-designed my hardware setup and I was able to use AO sample clock line to trigger counter pulse trains, as well as my measurement system, in a way similar to your example. The only difference is that I can route the AO sample clock to counter trigger internally, and I don't use AO output at all.  

 

My current problem is getting the NI USB-GPIB device to take in the measured data fast enough (~2 kb/s) without running into errors. I'm taking measurements with SRS 830 lockin and I'm using so-called "FAST" GPIB mode for that device, where lockin dumps 4 bytes on the GPIB every 2 ms or so, and I'm using looped VISA read with NI USB-GPIB, but this causes occasional VISA timeout error at max speed for reasons that are not clear to me. But I guess this question is for different forum.

0 Kudos
Message 4 of 4
(3,815 Views)