Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxWriteDigitalLines slow execution time (1-2ms, buffered write)

Solved!
Go to solution

Hi!

 

I am writing a program that runs an X-Series DAQ as a master SPI device, using the DAQmx ANSI C function library.

 

As described on the page Serial Protocol Communication Reference Design for Digital Waveform Devices (http://www.ni.com/example/31200/en/), for every SPI communication I need to write digital samples to an output buffer using the command DAQmxWriteDigitalLines.  I'm using the daqmx>>correlated DIO section of this guide as I'm the output of a counter as the clock for digital input/output timing.

 

Unfortunately, execution of this function generally takes 1-2ms.  Very occasionally (~5-10% of iterations), this function takes only 100-200 microseconds to execute.  The time taken to execute does not depend on the number of samples that I'm writing to the buffer.

 

My questions are 1) Is this 1-2ms execution time typical and 2) is there any way to speed this up, so that it consistently takes only ~100-200 microseconds?  Currently this function is the only part of the SPI routine that takes order of ms (and not 10s to 100s of microseconds) to execute.

 

I have timed the DAQmxWriteDigitalLines command in example WriteDigChan-ExtClk.c as well - it also takes approximately 2ms to execute.  

 

Equipment specs:

PXIe chassis, with PXIe-8370

Computer: Intel Core2 Duo CPU, 2.93GHz, 2GB RAM, Windows 7

 

Thanks in advance!

 

0 Kudos
Message 1 of 2
(2,603 Views)
Solution
Accepted by topic author mwolfe

Hi again!

 

I believe I have solved the problem!

 

I queried the write wait mode using DAQmxGetWriteWaitMode, and found that I was checking for available buffer space once every 1 ms (this mode is DAQmx_Val_Sleep, sleep time found using DAQmxGetWriteSleepTime).  Using  DAQmxSetWriteSleepTime, I reduced this sleep time to 0.1ms. This works!  I suppose I could also play around with the other write wait modes (see http://zone.ni.com/reference/en-XX/help/370471AB-01/mxcprop/attr22b1/).

 

0 Kudos
Message 2 of 2
(2,532 Views)