Selecting the right sampling rate for your data acquisition system
This article will highlight some key aspects in selecting the correct sampling rate for your data acquisition hardware. At the end of the article, you will find additional resources which will provide further details.
Assume that you just purchased a brand new National Instruments Data Acquisition device capable of sampling 1MS/s. Take a moment to think about that, 1 million samples in just 1 second, and this is just an average device too, that’s a lot of data. You begin to ask yourself, do I really need to sample 1MS/s? Is there an optimal sampling rate that can give me the information I’m looking for without filling up my hard drive?
The answer is yes, there is a way to calculate the optimal sampling rate. To do this you need to know a few things about the signal you are measuring and the sensor you are using.
Knowing how quickly your signal will vary in time will help you determine the minimum sampling rate. According to the Nyquist Theorem, you need to sample your signal at least 2x the highest frequency.
Figure Minimum 2x Highest Frequency
In the above figure, you can see that the original time domain signal that you are trying to measure (left hand side) has a maximum frequency of 100 Hz. The picture to the right is the result of sampling the time-domain signal at 2x the highest frequency, or 200 Hz. You can see that the reconstructed signal (right hand side) looks similar to the original time domain signal, except that the exact shape of the signal has been lost. So was Nyquist wrong? No, his theorem states that you need to sample 2x the highest frequency of the signal you are trying to measure in order to preserve the frequency information. To get an accurate representation of the shape of the signal, you must sample 5x to 10x the highest frequency, as shown in the figure below.
Figure Sampling at 10x Highest Frequency
Just for completeness, the figure below demonstrates what happens when the signal is undersampled.
Figure Undersampled Signal
The reconstructed signal looks nothing like the original. In fact, the reconstructed signal is essentially a constant voltage, with no time-varying information captured. In addition, undersampling can manifest itself in other ways, as you will see next.
When selecting the appropriate sampling rate, it’s important to take into consideration that there may be other higher frequency signals that couple onto your signal. For example, if you are measuring temperature, which is considered a low frequency signal, noise from a nearby motor, or the overhead light may couple onto your thermocouple sensor. Therefore, your thermocouple wire is carrying temperature information, plus noise information.
Figure Frequency Content of Signal
The figure above is a frequency representation of the thermocouple signal. The main “temperature information” is varying at about 25 times / second (or F1). The other significant frequencies (e.g. significant because they have roughly the same amplitude as F1), namely 70 Hz, 160 Hz, and 510 Hz are noise signals that are being coupled onto the thermocouple. Sometimes, it’s not obvious that these higher frequencies exist and you may not even be aware of their presence until you have acquired your data. Moving forward with our example, and assuming we are not aware of the noise signals, we set up our data acquisition device to sample 100 samples / sec. The figure below is the result of sampling at 100 Hz.
Figure under sampled Aliased Signals
As you can see, frequencies F2, F3, and F4 appear as an alias next to our main frequency of interest (F1). Now we’re not sure if our original temperature signal is varying at 25 times / second or 10, or 30, or 40 times / second. As a side note, the formula used to calculate the alias frequencies is shown below:
Alias = | (closest integer multiple of sampling frequency * sampling frequency) – signal frequency) |
Alias F2 = | 100 – 70 | = 30 Hz; Alias F3 = |2*100 – 160 | = 40 Hz; Alias F4 = | 5*100 – 510 | 10 Hz
How do we solve this issue? Well, we can just sample 5x to 10x the highest frequency. In this case the highest frequency is 510 Hz, and therefore we should be ok with a sampling rate of 5 kHz, right? What about if there are noise signals at 5001 Hz? Then we can sample at 50 kHz, right? Nope, you can see that we’re in a “dog trying to catch its tail” situation. The solution to this is to use a low pass filter, BEFORE sampling. This low pass filter is sometimes referred to as an anti-aliasing filter. Before the signal is digitized (or sampled) it goes through a filter that attenuates high-frequency content. You can check the hardware specification to see if your device has an on-board low pass filter. Also, some sensors have a limited bandwidth. You won’t find this on simple thermocouples, however, an accelerometer will have a frequency bandwidth listed in their specification.
Please visit the additional resources below and feel free to contact us for any additional questions, or application specific questions.
Resources