LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I determine the actual sampling rate?

In the process of my active noise control experiment, I need to acquire a signal at a known sample rate.

I have set up my control loop to work in real-time at 2.5kHz to control a 1kHz tone. This sampling rate is defined by setting the scan rate of the input card (PXI-6052E)to 2500 scans/sec.

The 1000Hz signal that is then acquired by the system also appears to have an amplitude modulation of a much lower frequency than than of the 1000Hz. The only reason that I can think of for this is that the analog input is actually being sampled a rate which is very close but slightly higher than 2.5kHz by a few samples per second.

Has anyone else had this problem, or know how to get round the problem?
0 Kudos
Message 1 of 5
(5,520 Views)
AI Start.vi has an output parameter labeled "actual scan rate", which may differ slightly from the requested scan rate, depending on the hardware capabilities.

What happens is the board will try to divide down its internal timebase to a value close to the requested rate using an integer divisor. The available timebases are 20MHz and 100kHz, and in both cases, are evenly divisible by 2500. Therefore, I would expect the actual scan rate to be 2500Hz.

Using Route Signal.vi, you could export the scan clock to the connector (PFI7), and diagnose the rate with a scope. Or you can feed the signal back into one of the counters and diagnose it with another VI.
0 Kudos
Message 2 of 5
(5,520 Views)
In order for my active control experiment to be successful, the error signal (the signal which is being acquired at the microphones) needs to be stable. At the moment with the sampling rate very slightly higher than 2.5kHz the error signal varies in amplitude over time. Is there any way therefore, once the actual scan rate has been deduced that the acquisition card can be "forced" to sample at exactly 2.5kHz?
0 Kudos
Message 3 of 5
(5,520 Views)
Matt,

If your tone is 1kHz, try sampling at 2kHz, 3kHz, or n kHz (for n = integers > 1). A sampling rate of 2.5kHz will only represent the original 1 kHz as far as frequency is concerned.

Let's assume your 1kHz tone and 2.5kHz sampling start at EXACTLY the same time. After 1 ms, you will have completed exactly 1 cycle of your 1kHz tone, and you'll have 2 samples. In the next 1 ms, you will have completed another cycle of your 1kHz tone, but this time you'll have 3 additional samples (not 2)!

Because the samples are evenly spaced, your first cycle will appear to have a different amplitude than your second cycle (even though they are in fact taken from the same signal).

So, the amplitude modulation you've described is nothing more tha
n an artifact of your chosen sample rate.
0 Kudos
Message 4 of 5
(5,520 Views)
I agree with Bob,

By sampling at more than 2 kHz you are being compliant with Nyquist theorem, which means that the frequency content of your signal is being correctly acquired. That does not mean that the sine wave will look "pretty" on your indicator. For a direct visual presentation you might want to sample at more than 10x the maximum frequency content of your signal.

By sampling at 2.5 KHz all you guarantee is that you'll be able to reproduce the original signal when outputting the acquired samples (using a DAC) and passing the signal through a low-pass filter (which the analog acquisition already assumes for the input, in order to avoid aliasing)

The visual modulation effect you are seeing is caused by two things:

1) Your
sampling rate is not a multiple of your tone frequency.
2) Your tone frequency might not be exactly 1 kHz. Any deviation in frequency from 1 kHz will not only break point #1 above, but also make the modulation effect appear to vary over time.

Again, the issue is not critical because your signal is being correctly sampled, as far as signal processing theory is concerned. If you want to perform tone measurements then I suggest you use the tools included in LabVIEW for tone measurements.

This tutorial reinforces the concepts:
Bandwidth, Sample Rate, and Nyquist Theorem

I hope this helps,

Alejandro
0 Kudos
Message 5 of 5
(5,520 Views)