# Analog Sampling Basics

Publish Date: Aug 15, 2014 | 117 Ratings | 4.11 out of 5 |  PDF

## Overview

This tutorial is part of the National Instruments Measurement Fundamentals series. Each tutorial in this series, will teach you a specific topic of common measurement applications, by explaining the theory and giving practical examples. This tutorial covers the basics of analog sampling.

Watch an online demonstration on analog sampling basics here.

For the complete list of tutorials, return to the NI Measurement Fundamentals Main page.

### 1. Bandwidth Definition and Calculations

Bandwidth is defined as the measure of a circuit or transmission channel to pass a signal without significant attenuation over a range of frequencies. Bandwidth is measured between the lower and upper frequency points where the signal amplitude falls to -3 dB below the pass-band frequency. The -3 dB points are referred to as the half-power points.

Units
Hertz (Hz)

Example
If you input a 1 V, 100 MHz sine wave into high-speed digitizer with a bandwidth of 100 MHz, the signal will be attenuated by the digitizer’s analog input path and the sampled waveform will have amplitude of approximately 0.7 V. The value of ~0.7 V can be calculated by using the following equation:

-3 dB = 20 LOG (Vppout / Vppin)

Where

Vppout = Peak to peak Voltage of the output waveform
Vppin = Peak to peak Voltage of the input waveform = 1 V (in the above example)
-3 = 20 LOG (Vppout / 1)
Vppout = 0.7079 V = 0.7 V approximately

Figure 1. Attenuation of a 100 MHz sine wave when passed through a 100 MHz Digitizer

Figure 2. Typical 100 MHz Digitizer Input Response

Theoretical amplitude error of a measured signal
It is recommended that the bandwidth of your digitizer be 3 to 5 times the highest frequency component of interest in the measured signal to capture the signal with minimal amplitude error (bandwidth required = (3 to 5)*frequency of interest). The theoretical amplitude error of a measured signal can be calculated from the ratio (R) of the digitizer's bandwidth (B) in relation to the input signal frequency (fin).

Equation 1. Amplitude error

Where

R = B / fin

Using equation 1, the error in amplitude when measuring a 100 MHz sine wave with a 100 MHz high-speed digitizer, which yields a ratio R=1, is approximately 29.3%. Referring to figure 1, this would mean that if the input waveform has peak to peak amplitude of 1 V, then the output waveform would have peak to peak amplitude of approximately 0.707 V.

As another example, if you input a 75 MHz sine wave to a National Instruments oscilloscope which has a bandwidth of 150 MHz, it yields a ratio R= 2. Using equation 1, this means that the theoretical error in amplitude would be approximately 10.6%

Rise Time
Another important topic related to the bandwidth is rise time. The rise time of an input signal is the time for a signal to transition from 10% to 90% of the maximum signal amplitude and is inversely related to bandwidth.

Figure 3. Rise time for a signal is the time span from 10% to 90% of its maximum amplitude

It is recommended that the rise time of the digitizer input path be 1/3 to 1/5 the rise time of the measured signal to capture the signal with minimal rise time error. The theoretical rise time measured (Trm) can be calculated from the rise time of the digitizer (Trd) and the actual rise time of the input signal (Trs).

Equation 2. Theoretical rise time

For example, if a sinusoid signal with a rise time of 15 ns is passed through the NI 5122 High-Speed Digitizer which has a rise time of 3.5 ns, using equation 2 the theoretical measured rise time for the sinusoid signal would be approximately 15.4 ns.

View Interactive Presentation

### 2. Sampling Rate

Sampling rate is the rate at which data is sampled.

Sampling rate is not directly related to the bandwidth specifications of a high-speed digitizer. Sampling rate is the speed at which the digitizer’s ADC converts the input signal, after the signal has passed through the analog input path, to digital values. Hence, the digitizer samples the signal after any attenuation, gain, and/or filtering has been applied by the analog input path, and converts the resulting waveform to digital representation. The sampling rate of a high-speed digitizer is based on the sample clock that controls when the ADC converts the instantaneous analog voltage to digital values.

There are several products available in the market like National Instruments M-series Data Acquisition, Digital Signal Acquisition, Digital Multimeters and several others that have different specifications for the maximum sampling rate. The choice of the most appropriate device for your application will depend on the signal you are measuring.

 Product Bandwidth Sampling rate Resolution Digital Multimeter (DMM) 300 kHz 1.8 MS/s 10 bits to 23 bits Dynamic Signal Acquisition (DSA) 81.9 kHz Up to 204.8 kS/s 24 bits M-series Data Acquisition 700 kHz Up to 1.25 MS/s 16 bits, 18 bits S-series Data Acquisition 1.3 MHz Up to 10 MS/s 12 bits, 14 bits, 16 bits High-Speed Digitizers 150 MHz 200 MS/s 8 bits to 21 bits

Units
Samples/second (S/s)

Example
National Instruments High-Speed Digitizers support a variable effective sampling rate derived from the maximum sampling rate of the device. The maximum sampling rate of the device is determined by the rate at which the Crystal Oscillator (a hardware component of your device) oscillates. Lower sampling rates are however made possible by dividing the maximum sampling rate by an integer value. For example, the NI 5124 High-Speed Digitizer has a maximum sampling rate of 200 MS/s and can be set to rates of 200/n MS/s, where n = 1,2,3,4...

Figure 4. Sampling of a sine wave using a 3 bit digitizer

### 3. Nyquist Theorem and Nyquist Frequency

Nyquist Theorem: Sampling rate (f s) > 2 * highest frequency component (of interest) in the measured signal The Nyquist theorem states that a signal must be sampled at a rate greater than twice the highest frequency component of interest in the signal to capture the highest frequency component of interest; otherwise, the high-frequency content will alias at a frequency inside the spectrum of interest (pass-band).

Note: The definition of Nyquist Frequency is not consistent in the measurement world. It is sometimes being used to describe the sampling rate in the theorem and other times it is used to describe the highest frequency component in the theorem. In this tutorial we will use Nyquist Frequency to describe the highest frequency component allowed to avoid Aliasing for a given sampling frequency.

A question often asked is, “How fast should I sample?”
Figure 5 shows the effects of various sampling rates. In case A, the sine wave of frequency f is sampled at the same frequency f. The reconstructed waveform appears as an alias at DC. However, if you increase the sampling rate to 2f, the digitized waveform has the correct frequency (same number of cycles) but appears as a triangle waveform. In this case f is equal to the Nyquist frequency. By increasing the sampling rate to well above f, for example 5f, you can more accurately reproduce the waveform. In case C, the sampling rate is at 4f / 3. The Nyquist frequency in this case is (4f / 3) / 2 = 2f / 3. Since f is larger than the Nyquist frequency, this sampling rate reproduces an alias waveform of incorrect frequency and shape.

Figure 5. Effects of various sampling rates while sampling a signal

### 4. Aliasing and Anti-Aliasing Filters

If a signal is sampled at a sampling rate smaller than twice the Nyquist frequency, false lower frequency component(s) appears in the sampled data. This phenomenon is called Aliasing.

The following figure shows a 5 MHz sine wave digitized by a 6 MS/s ADC. The dotted line indicates the aliased signal recorded by the ADC. The 5 MHz frequency aliases back in the pass-band, falsely appearing as a 1 MHz sine wave.

Figure 6. Sine wave demonstrating Aliasing

Alias frequency
The alias frequency is the absolute value of the difference between the frequency of the input signal and the closest integer multiple of the sampling rate.

Alias Freq. = ABS (Closest Integer Multiple of Sampling Freq. – Input Freq.)

where

ABS means the absolute value.

Real-world signals often contain frequency components that lie above the Nyquist frequency. These frequencies are erroneously aliased and added to the components of the signal that are sampled accurately, producing distorted sampled data. In systems where you want to perform accurate measurements using sampled data, the sampling rate must be set high enough (about 5 to 10 times the highest frequency component in the signal) to prevent aliasing, or an optional anti-aliasing filter (a low pass filter that attenuates any frequencies in the input signal that are greater than the Nyquist frequency) must be introduced before the ADC to restrict the bandwidth of the input signal to meet the sampling criteria.

For example, in the NI 4461 Dynamic Signal Acquisition device, the analog inputs have both analog and digital filters implemented in hardware to prevent aliasing. Input signals are first passed through a fixed analog filter to remove any signals with frequency components beyond the range of the ADCs. Then digital anti-aliasing filters automatically adjust their cutoff frequency to remove any frequency components above half the programmed sampling rate.

Example
Assume fs, the sampling frequency, is 100 Hz and that the input signal contains the following frequencies: 25 Hz, 70 Hz, 160 Hz, and 510 Hz. These frequencies are shown in the following figure.

Figure 7. Original frequencies present in the input signal

As shown in the following figure, frequencies below the Nyquist frequency (fs/2 = 50 Hz) are sampled correctly. Frequencies above the Nyquist frequency appear as aliases. For example, F1 (25 Hz) appears at the correct frequency, but F2 (70 Hz), F3 (160 Hz), and F4 (510 Hz) have aliases at 30 Hz, 40 Hz, and 10 Hz, respectively.

Figure 8. Original and aliased frequencies that appear in the measured signal after passing through a ADC

Alias F2 = |100 – 70| = 30 Hz
Alias F3 = | (2)100 – 160| = 40 Hz
Alias F4 = | (5)100 – 510| = 10 Hz

View Interactive Presentation

### 5. Quantization Error

Quantization is defined as the process of converting an analog signal to a digital representation. Quantization is performed by an analog-to-digital converter (A/D converter or ADC).

If we can convert our analog signals to a stream of digital data, we can take advantage of the power of the personal computer and software to do any manipulation or calculation on the signals. To do this, we must sample our analog waveform at well-defined discrete (but limited) times so we can maintain a close relationship between time in the analog domain and time in the digital domain. If we do this, we can reconstruct the signal in the digital domain, do our processing on it, and later, reconstruct it into the analog domain if we need to.

Figure 9. When converting an analog signal to digital domain, signal values are taken at discrete time instants

The time resolution we have is limited by the maximum sampling rate of the ADC. Even if we were able to increase our sampling rate forever, it would still never be purely “continuous time” as is our input signal, as shown in figure 9. For most real world applications, this is still very useful despite its limited nature. But obviously the usefulness of our digital representation increases as our time and amplitude resolution increases. The amplitude resolution is limited by the number of discrete output levels an ADC has.

For example, a 3-bit ADC divides the range into 23 or eight divisions. A binary or digital code between 000 and 111 represents each division. The ADC translates each measurement of the analog signal to one of the digital divisions. Figure 10 shows a 5 kHz sine wave digital image obtained by a 3-bit ADC. As shown in figure 11, the digital signal does not represent the original signal adequately because the converter has too few digital divisions to represent the varying voltages of the analog signal. However, increasing the resolution to 16 bits to increase the ADC number of divisions from eight (23) to 65,536 (216) allows the 16-bit ADC to obtain an extremely accurate representation of the analog signal. This inherent uncertainty in digitizing an analog value is referred to as the Quantization error. The quantization error depends on the number of bits in the converter, along with its errors, noise, and non-linearities.

Thus, given a resolution (such as 16 bits), the number of binary levels may be calculated using:

Further, given a Device Input Range (such as 0V to 10V) of a given signal, the code width may be calculated using:

Compare 16-bit resolution to 3-bit resolution (8 levels and 1.25V code width) in the following figure.

Figure 10. Digital image of a 5 kHz sine wave obtained by a 3 bit ADC

Figure 11. Quantization error when using a 3 bit ADC

Figure 12 shows what it would look like to acquire a signal given a 2.5 V input range using a 14-bit digitizer (NI 5122 High-Speed Digitizer) vs. an 8-bit digitizer (NI 5112 High-Speed Digitizer). You can see the accuracy gained with the 14-bit digitizer given the fact that it has 16,384 discrete voltage steps to represent the input signal compared to 256 levels for an 8-bit digitizer or oscilloscope.

Using high-resolution digitizers also give you the ability to take multiple types of time AND frequency domain measurements using one instrument. This graph clearly shows the advantages of using a high resolution digitizer for time domain and frequency domain measurements.

• 8-bit = 256 discrete levels
• 12-bit = 4,096 discrete levels
• 14-bit = 16,384 discrete levels

Figure 12. 8-bit versus 14-bit Measurement

### 6. Dithering

During Quantization, in the time domain, we could almost completely preserve the waveform information by sampling fast enough. In the amplitude domain we can preserve most of the waveform information by dithering.

Dithering involves the deliberate addition of noise to our input signal. It helps by smearing out the little differences in amplitude resolution. The key is to add random noise in a way that makes the signal bounce back and forth between successive levels. Of course, this in itself just makes the signal noisier. But, the signal smoothes out by averaging this noise digitally once the signal is acquired.

Note: Mathematically averaging the digital signals without dithering does not remove the quantization steps. It simply rounds them out a little, as shown in figure 13b.

Figure 13. Effects of dithering and averaging on a sine wave input

Example

On some National Instruments E-Series Data Acquisition (DAQ) products, like the NI M Series High-Accuracy Multifunction DAQ device, dithering is completely software enabled or disabled (you are unable to decide how it averages). When you enable the software, it adds approximately 0.5 LSBrms of Gaussian white noise to the input signal. This noise is added to the signal before the input to the ADC. As a result, a signal that might fall somewhere in the smallest voltage difference that the board can detect (known as code width) now randomly bounces above and below the boundaries of that code. When sampled, points now appear on both the top and bottom boundaries, and the numbers of points on either the top or bottom of the code width are weighted based on the location of the actual signal. You can then use averaging to essentially zoom in past the specified resolution of the board, providing more accurate measurements that are less influenced by wide band noise. For instance, a 12-bit board can perform with 14-bit resolution with dithering enabled. You can also disable dithering for high-speed applications that do not use averaging.

Figure 14. Decreasing quantization error on 12-bit devices using dithering

### 7. Relevant NI products

Customers interested in this topic were also interested in the following NI products:

For the complete list of tutorials, return to the NI Measurement Fundamentals Main page.

### Ratings

Rate this document