From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
01-12-2022 11:13 AM
Hello,
I'm trying to determine the appropriate number of samples per cycle of a given frequency. My test setup uses an external clock to synchronize multiple measurements and devices. The vi seen below was designed to adjust the clock frequency based on the input test frequency and the samples per cycle. So I'm trying to figure out what the right number of samples per cycle would be for a wide range of potential test frequencies.(Say 100Hz to 200kHz)
Is there a general rule of thumb when coming up with a sample rate? Based on the vi below, can it be determined what the designer intended the sample rate to be?
I've searched throughout the code (I didn't write it) and haven't been able to discover where a sample rate calculation is taking place.
Thanks!
01-12-2022 11:17 AM
For sinewaves, at least 10 samples per cycle are required to quantize the waveform into proper sine shape.
The higher the samples per cycle, the cleaner you can quantize your signal in the time domain.
01-12-2022 11:21 AM
Look up "Nyquist frequency". Your sampling frequency should be at least the Nyquist frequency of the highest frequency; the higher the better. Within reason, of course.
01-12-2022 11:25 AM
Thanks for the reply!
So is it typical to use the same sample rate across a wide range of frequencies? Or is it desirable to use a higher sample rate at lower frequencies and a lower rate at higher frequencies?
I've seen instances in the code where the sample rate is changed based on the frequency, but I have yet to determine a pattern or formula that was used to get a samples per cycle value.
01-12-2022 11:51 AM
@JayWW wrote:
So is it typical to use the same sample rate across a wide range of frequencies? Or is it desirable to use a higher sample rate at lower frequencies and a lower rate at higher frequencies?
I've seen instances in the code where the sample rate is changed based on the frequency, but I have yet to determine a pattern or formula that was used to get a samples per cycle value.
I would typically just use the maximum rate for the range of frequencies you care about. It just makes it easier in code to only have the one sample rate.
The two rules of thumb are Nyquist (Fs>2x the max frequency), which is based on Frequency Domain analysis, and Fs>10x the max frequency, which is based more on time domain analysis.
01-12-2022 12:45 PM
@crossrulz wrote:
@JayWW wrote:
So is it typical to use the same sample rate across a wide range of frequencies? Or is it desirable to use a higher sample rate at lower frequencies and a lower rate at higher frequencies?
I've seen instances in the code where the sample rate is changed based on the frequency, but I have yet to determine a pattern or formula that was used to get a samples per cycle value.
I would typically just use the maximum rate for the range of frequencies you care about. It just makes it easier in code to only have the one sample rate.
The two rules of thumb are Nyquist (Fs>2x the max frequency), which is based on Frequency Domain analysis, and Fs>10x the max frequency, which is based more on time domain analysis.
Thanks for tying our two posts together in a neat package. 🙂