From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-DAQmx frequency sampling rate

Hi there!

 

I'm working on setting up a data acquisition Labview VI, to measure different signals on a test rig.

 

I'm using the NI-DAQmx assistance (the Express VI?) to continously measure analog signals (Variable current, voltage and temperatures). This is working just fine, and i can change the sampling rate by writing to the express VI. The idea is, that the user can change the sampling rate from around 1 to 500 Hz. 

 

We do however have a sensor that transmittes digital signals (a frequency), and are using a NI-9423 module to "read" it. As this is a digital signal, another NI-DAQmx express VI is needed to handle it (that's ok), but so far we can't figure out how to alter the sampling rate - it's apperently locked at 1kHz. 

 

Being that we want to merge the analog and digital signals to one array, we are recieving overflow errors from the "analog" DAQ, if it's not set at exactly 1kHz. 

 

So, in short - is it possible to change the sampling rate of a DAQmx recieving frequencies? So that we to DAQ assistences have the same sampling rate?

 

Help would be greatly appreciated!

 

- Nicklas

 

 

0 Kudos
Message 1 of 5
(3,938 Views)

Measuring a frequency at a given rate actually makes no sense at all.  A counter is based on counting pulses for a duration based on your max measured frequency.  What you should do is put the frequency task in another loop.  You can then use a notifier or global variable to pass the latest frequency measurement to your processing loop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 5
(3,928 Views)

Oh, ok - thanks!

 

Is there then any way to make sure that each signal is measured at the exact same time? Since splitting them into different loops will result in some timing complications. 

 

 

 

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

Unlike voltage measurements, which tend to be (more or less) instantaneous, frequency measurements take a finite (and often variable) amount of time.

 

If it is a slow signal then you measure the number of counts of your reference clock that occur in one period of your input signal. As your input signal varies in frequency, so does the measurement rate. If it is a fast signal, you can either measure how long it takes to get n cycles or your input (again variable) or you could count how many cycles of your input occur in a fixed time period.

 

The NI help on frequency measurements describes three different ways you can configure a counter to measure frequency.

 

The long and short of this is that generally counter measurements come at variable measurement rates which can be problematic to fit in with a fixed rate loggin system. If the measurement period is much smaller than your desired rate then you can wait and trigger a measurement at regular intervals. If not, you can let the counter run at its own rate, placing the latest result on a notifier, and in another loop just read the latest measurement from the notifier each time you want to record a result. Depending if you counter is running faster or slower than your desired logging rate you will end up with either missed samples or repeated samples. There are inherant timing inaccuracies in both approaches because, unlike analog measurements, the counter measurement is not made at 'that exact time, now!' but over a period of time which may be long or short compared to your logging rate.

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

Suppose you set up a separate loop to read your Frequency device at whatever speed is appropriate -- for the sake of this discussion, let's say 1 KHz.  So every millisecond, you get an estimate of the frequency of your device.

 

Now you have another loop taking analog samples at some other rate, and want to include the current frequency estimate.  One way to do this is to have the Frequency loop (running at its own, independent, rate) save the latest frequency in, say, a Functional Global Variable.  In your Analog loop, after you read your Analog samples, read the current (Frequency) value from the FGV.  You now have a "sample" of the frequency at the same time you sampled your analog data.

 

Note that this technique works whether the Frequency loop is faster or slower than the analog loop.  If the Frequency loop is significantly faster, and is noisy, you can consider "improving" your estimate by saving, say, the last 5 readings in the FGV and returning their mean -- this gives you something like a Poor Man's Low Pass Filter, with an attendant phase lag, of course.

 

Bob Schor

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