Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Faster static digital signals in USB 6259, using C#?

Hello,
 
I'm trying to generate multiple static digital signals using the USB 6259 and C# (VS2005).
The problem is that the speed I get seems very slow.
I used the WriteDig sample from the NI sample set for VS2005, and I timed the WriteSingleSampleMultiLine command like this:
 
double start = System.DateTime.Now.Millisecond;
writer.WriteSingleSampleMultiLine(true,dataArray);
double end = System.DateTime.Now.Millisecond;
double total = end - start;
writeButton.Text = total.ToString();
 
The time I am getting is 15ms or 30ms. Is there any way to speed up the static generation of digital signals?
 
Thanks, Andrei.
0 Kudos
Message 1 of 5
(3,988 Views)

Hello Andrei,

I would suggest that you use the DAQmxTaskControl method to commit the task before running it.  This may help improve the execution time.

It is important to keep in mind, however, that you are performing static (software-timed) I/O, which is undeterministic.  The time this code will take to execute will vary from system to system, depending on available bandwidth and resources.  There is no specified maximum amount of time that this function should take to complete.

Let me know if you have any other questions, and whether or not commiting the task first helps improve the execution speed.

0 Kudos
Message 2 of 5
(3,975 Views)
I would like to correct the last post recommending to Commit the task.  For On Demand (software-timed) tasks, the fastest approach is actually to Start the task outside the loop (not Commit).  Then you should be able to perform fast reads and writes of digital output channels.  From C I can get reads/writes in Windows in about 10-30us on my computer after starting the task.  I don't know about C# performance - it's probably a little slower.
 
 
 
 
0 Kudos
Message 3 of 5
(3,965 Views)

Sorry I just saw you are using USB, not PCI/PXI. 

Static digital Reads and Writes on the USB bus are going to be much slower than using PXI.  The USB 2.0 bus has a minimum theoretical latency of about 200 microseconds.  With a digital device, we see between 200 microseconds and 10 ms per read or write.

Starting or committing the device will help slightly, but the USB bus will be the bottleneck.  If you need better performance, you should switch to PCI/PXI or PCIe.

0 Kudos
Message 4 of 5
(3,963 Views)

Hello,

Thank you for your replies. However, we are not getting the neccesary speed using the static method. Now we are trying the Waveform method...

Andrei.

0 Kudos
Message 5 of 5
(3,879 Views)