LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Frequency measurement using DAQ assistant

Hi,
 
I am currently using DAQ assistant to measure a frequency input through a PCI-6221. The range of frequencies I need to measure for this application is 0 to about 250000 Hz. While I'm building the program I'm using a frequency generator as the source and this works well for high frequencies, but as the frequency approaches 0 Hz the measurement gets slower and slower. Is there an easy way to fix this as I need a fast/consistent rate of response over all frequencies.
 
I'm a complete beginner and any help would be appreciated!  
0 Kudos
Message 1 of 4
(4,676 Views)
First, I have no experience with Frequency measurements, Smiley Sad but I think what you are seeing makes sense.  To measure a high frequency, it needs to acquire a larger number of pulses.  But for low frequencies, that same number of pulse takes longer to acquire.
 
I noticed the DAQ assistant for Frequency measurement has 3 settings for measurement method.  The default was 1 counter (low frequency).  There was also 2 counters (high frequency) and 2 counters (large range).  I think the large range one is the one you would want to use, but experiment with those settings to see if they help.
0 Kudos
Message 2 of 4
(4,663 Views)

Hi,

Please try the 2 Counter (large range) measurement method inside the DAQ Assistant.  This method will use one counter to divide down the counter input and the other to measure the input.  The divisor should be set to the number of periods used to calculate the frequency of the unknown signal.  Since there is a large range, please select the divisor based on the higher value.  A larger value will produce a more accurate measurement, however too large of a value might cause the count register to roll over. 

There is also a helpful example titled Measure Digital Frequency – Buffered – Continuous – Large Range 2 Counter.  This example is located under <Help> <Find Examples> <Browse Tab> <Hardware Input and Output> <DAQmx> <Counter Measurements> <Digital Frequency>.  This example is going to do the same thing as the DAQ Assistant, but will be more efficient.  The example program only loops the DAQmx read.vi, where the DAQ Assistant is looping the entire process.  This might also help save some processing time. 

 

Samantha
National Instruments
Applications Engineer
0 Kudos
Message 3 of 4
(4,641 Views)

There are going to be trade-offs when you try to handle such a wide range of possible input frequencies.  There is some excellent in-depth info available here.  3 related examples are given here.

Here's a general thought if you want your software to update its frequency reading at a constant rate of, say, 10 times a second for example.

Put your frequency-querying code in a loop that's timed to run 10 times a second.  This may be an official Timed Loop or could be a while loop containing a "Wait for msec multiple" time delay function.  Before calling DAQmx Read, first call a DAQmx Read property node to query for the # of available samples.  If that # is 0, then skip the call to DAQmx read and report a "0" frequency for that loop cycle.  If the number is > 0, read them all and use the latest one(s) to report your frequency.  The specifics will vary with which of the 3 methods you choose for measuring frequency / period.

Finally, note that any of this in-depth programming will require that you wean yourself away from the DAQ Assistant and do more of the DAQ programming manually.  Studying the examples will be a huge head-start.

-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 4 of 4
(4,631 Views)