Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Counter Timeout of 2 msec is actually 32 msec

I am using a PCI-6602 TIO board to measure 5 frequency channels one after another in a loop.  The measurement of the 5 channels must finish within the 20 msec overall loop time of the main data acquisition loop.  I have the measurement timeout set to 0.002 seconds in the call to DAQmx Read (Counter DBL 1 Chan 1 Samp).vi.   The five measurements are made successfully within this time frame as long as frequency signals are present on all 5 channels.

 

However, if no frequency signal is present on one of the channels, the actual elapsed time for the DAQmx Read to timeout is not 2 msec, it is 31 or 32 msec (suspiciously a multiple of Window's magic 16 msec timing number).  This is not acceptable because a timeout on one channel prevents the main acquisition loop from completing execution within the 20 msec DAQ loop time.

 

Is there a way to force DAQmx Read (Counter DBL 1 Chan 1 Samp).vi to implement a timeout of 4 msec or less?  Or at least less than 20 msec?

 

Thanks,

Hans 

  

0 Kudos
Message 1 of 7
(3,850 Views)

Hi Hans,

 

Do you receive any errors when a frequency signal is not present on one of the channels? What data are you receiving after 31 or 32ms? Can you please post a screenshot of your block diagram?

 

Thank you,

Simran K
National Instruments
Applications Engineer
0 Kudos
Message 2 of 7
(3,815 Views)

Hi Hans,

 

I would like you to know that we are aware of this issue, and it is currently being investigated as CAR 101486.

 

Thanks!

------
Zach Hindes
NI R&D
0 Kudos
Message 3 of 7
(3,803 Views)

Hi Simran and Zach,

 

Thanks for your replies and for looking into this issue.  Here are some screenshots of the counter VIs I'm using.

 

Let me know if you need any more info.

 

Thanks,

Hans

0 Kudos
Message 4 of 7
(3,792 Views)

A couple different thoughts:

 

1. You *might* be able to improve the response using a DAQmx Read property node set to configure "Advanced-->Wait Mode".  It appears that the "Poll" setting is the most likely one that may help you to get a better response time (at the expense of burning CPU while doing the polling).  "Yield" or "Sleep" are other options you might experiment with, but with "Sleep" you'll also need to specify "Advanced-->SleepTime".

 

2. Another possibility is to take a different approach to the problem.  By doing unbuffered measurements, each Read will want to wait for the next full freq interval or the specified timeout.  So there is going to be a guaranteed measureable execution time for doing the reads.  There will also be a latency time as you cycle through each channel 1 by 1 before you can use those new measured values.   The point is, you won't really get instantaneous 0-latency data no matter what. 

   So, another approach is to perform buffered measurements and simply query the buffer to read the most recent measurement already waiting in the buffer.  Then the Read call will never be waiting for new data.  There will be some latency between the time when that value was buffered until the instant you do the Read, but generally less than you'd have gotten with the unbuffered approach.

 

A. Problem 1: Only the first 3 buffered counter measurements can use DMA for buffering data.  The next 2 will need to be manually configured to use Interrupts, which can be a bit of an issue for measuring higher freq signals.  This is only a partially educated guess, but my confidence in such an approach would start to decrease as the measured frequencies increased above maybe 10 kHz.   (If you are well above 10 kHz, it may be better to measure the freqs by counting edges per 10 msec interval or something like that.  Then you'd have no problem with the buffering rate while still getting decent resolution.)

 

B. Problem 2: You'll need to use the DAQmx Read property node to set yourself up to read "the most recently buffered sample".  Set RelativeTo=MostRecentSample, Offset=(-1) and then when you call DAQmx Read, just request 1 sample.

 

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 5 of 7
(3,762 Views)

Thanks for the ideas Kevin.  I'll look into those.

 

However, I was hoping that NI would come up with a fix that would let me use my code as is without adding complexity to work around the problem.  Is there an estimated date for resolving the CAR?   Will it require a change to the DAQmx drivers?  Inquiring minds want to know.

 

Hans 

0 Kudos
Message 6 of 7
(3,712 Views)

I tried Kevin's first idea - setting the DAQmx Read Wait Mode property from the default of Wait for Interrupt to Poll which per the LabVIEW help is supposed to "check for samples as fast as possible" at the expense of using more CPU time.  Unfortunately, that had no effect on the time taken to timeout - it is still 31 or 32 msecs.

 

Kevin's second idea will add a lot of complexity to my code and would force me to use different measurement methods for different channels, even though all the frequency sources are identical.

 

Still hoping for a fix from NI in time to meet my schedule.  I'd need the fix in the next 2 weeks.

 

Thanks,

Hans 

0 Kudos
Message 7 of 7
(3,710 Views)