Engineers unfamiliar with data-acquisition (DAQ) systems and sampled data may not know about the Nyquist sampling theorem, or worse, they might misunderstand it. Electrical engineers extract the Nyquist criterion from the theorem and sometimes state it as the need to sample a signal at twice its frequency. They are almost right.
If you sample a sine wave at exactly twice its frequency, the data you get may represent a straight line (dc) or a triangular waveform. So, you must sample a sine wave at more than twice its frequency to obtain useful sampled data.
The >2f criterion works for a sine wave because it occurs at only one frequency. A more precise interpretation of the Nyquist theorem says you must sample at more than twice the frequency of the signal's bandwidth. For a sine wave, frequency equals bandwidth. But what sample rate would you use to digitize a square wave? It depends on the amount of information you require. In most cases, you cannot simply sample at slightly above the square wave's frequency.
A square wave — and most real-world signals — have more than one frequency component. The square wave comprises smaller and smaller fractional portions of odd harmonics — 3f, 5f and so on — of the square-wave fundamental frequency. The diagram, above, shows a square wave and the six harmonics used to create it in Excel. Adding an infinite number of harmonics would produce a perfect square wave.
But a DAQ system doesn't have an infinite bandwidth (BW), so you compromise. Determine the highest frequency component you want to measure. For a 1-KHz square wave, you might decide to capture signals out to the 11th harmonic to produce reasonable sampled data. That means a sample rate of >22 Ksamples/sec. But the square wave probably includes 13th, 15th and other harmonics. So you may need a low-pass anti-alias filter to remove those signal components because they exist at frequencies that a discrete sampling process can “fold” and make them appear like “alias” signals in your data.
If you use an 8-bit (1 part in 256) ADC, the amplitudes of those higher harmonics may not affect your measurements, but if you use, say, a 16-bit (1 part in 65,536) ADC, it's likely you will digitize some unwanted harmonics, so an anti-alias filter becomes a must.
Although in theory using an anti-alias filter and sampling at >2(BW) should suffice, engineers often have their own rules of thumb for sample rates. Generally, I won't sample at fewer than five to 10 times a signal's bandwidth. The more samples, the better, but as sample rates increase, so does the amount of data you collect and store.
Useful Links
-
To download the Excel square-wave spreadsheet, go to http://rbi.ims.ca/5724-530.
-
“Drop the Alias,” Design News, April 10, 2006: http://rbi.ims.ca/5724-531.
-
“Undersampling Shifts Frequency,” Design News, Sept. 4, 2006: http://rbi.ims.ca/5724-532.