# Correlation: An overlooked oscilloscope measurement

The correlation function is a useful signal-analysis tool that engineers often overlook. Its formidable equation, which you have probably not thought about since your undergraduate signals and systems course, is:

where f_{1} and f_{2} are real functions of time (t) and τ represents a delay.

Sponsor video, mouseover for sound

You can forget the pain that this equation evoked in your earlier life because modern oscilloscopes and third-party math software easily perform all the computations and make this powerful function available to everyone. Correlation can be classified into either of two functions, auto-correlation or cross-correlation, depending on the number of inputs. In this article, we’ll show some common applications for both cross-correlation and auto-correlation.

**Correlation Functions
**Correlation functions were added to the available math functions in oscilloscopes to support two optional disk drive measurements, ACSN (auto-correlation signal to noise ratio) and NLST (non-linear transition shift). While these measurements may not be of general interest, their presence makes the correlation function available for more general applications.

Auto-correlation is the correlation of a signal with itself (single waveform). It provides a measure of the similarity between observations as a function of the time lag between them. It is an analysis tool for finding repeating patterns, like the presence of a periodic signal buried in noise.

Cross-correlation measures of the similarity of two waveforms as a function of a time delay between them. Cross-correlation is used to search for a known short signal in a longer signal (detection) or to measure a time delay between two signals with a common source.

**Auto-correlation example**

Auto-correlation is typically used to detect periodicity within a signal. In Figure 1, the top grid (channel 1) contains the input signal. It is a 10 Mbps, NRZ (non-return-to zero) PRBS (pseudorandom bit stream) with a PRBS7 pattern that repeats every 127 clocks. It is pretty obvious that there is a repetitive pattern. The next grid down contains the auto-correlation of that PRBS7 signal.

Figure 1. The auto-correlation of a PRBS7 in the upper trace shows the waveform with good SNR. The second trace from the top is the auto-correlation function showing peaks spaced 127 clock periods apart. The third trace is the same waveform with a greater level of additive vertical noise. Note the auto-correlation function of this input, shown in the bottom trace still shows the periodicity of the waveform as 127 clock periods even in the presence of noise.

The auto-correlation function takes a section of the input waveform and calculates how it correlates with an equal length section of itself, using different starting points. Visualize this as taking a section of input waveform (in this case the first five divisions of the channel 1 waveform), sliding it over the first five divisions of itself, and calculating the correlation value for the area that overlaps for each delay step. The bounds of the starting point are from the beginning of the waveform to its length, minus the section length (in this case five divisions). At the upper bound, the end of the first waveform section lies at the last sample point of the second waveform. Because the length of waveforms in this oscilloscope is limited to 10 divisions, the upper bound of the correlation function is 10 divisions minus the section length in divisions. This is why the auto-correlation function is limited to five horizontal divisions. The first half of the input signal contains two repetitions of the PRBS7 pattern. The auto-correlation function shows two peaks spaced 12.7 µs (127 – 100ns periods) apart as read in parameter P3, the difference between the peak locations.

The vertical scale of the correlation functions varies from +1 (Highly correlated) to -1 (inversely correlated) with 0 in the center indicating no correlation.

Consider the waveform in channel 2 (third grid from the top) in Figure 1. This is the same PRBS signal with a high level of additive vertical noise. Most people would be hard pressed to see the periodicity in this waveform. Note that the auto-correlation function in trace F2 (bottom trace) still reports the period as 12.7 µs (127 clock cycles) as read in parameter P6. This is an extremely useful characteristic of correlation function is that they work well in the presence of poor SNR (signal-to-noise ratio).

Compare the auto-correlation functions in Figure 1. Both have a value of 1 with zero delay. This is a characteristic of all non-zero amplitude signals.

The peak corresponding to a delay of one pattern period first repetition in F1 (second from the top) is also very close to one. This is because the waveform is nearly noise free and the second repetition is almost identical to the first. Look now at the auto-correlation function of the noisy signal (F2, bottom trace). The peak corresponding to the second repetition is much lower (approximately 0.5) because the noise in the second repetition is different and reduces the correlation. The difference in amplitude from the maximum of one is proportional to the noise level. This is the basis of the disk drive ACSN measurement:

where R is the value at zero delay (equal to 1) and r is the correlation value of the first repetition delay in a pattern period. Using the value of 0.5, we calculate an SNR of 2:1 and an ACSN value of 3 dB. These values match the generator setting for the noisy signal.

So, the auto-correlation function shows us periodicity in signals buried in noise and provides a measure of the SNR.

Cross-correlation example

Cross-correlation uses two input sources to measure delay between corresponding events even in the presence of high noise levels. A simple example is shown in Figure 2.

**Figure 2. Using cross-correlation to measure the time delay between a transmitted sine burst and a return signal in the presence of varying levels of noise. **

In this example, a sine burst is transmitted and a lower amplitude return echo occurs some time later. The cross-correlation of these two signals has a maximum value at the time corresponding with the delay between the two signals. In this example, the set of measurements on the left is made with a noise level low enough to still see the return echo. The set of waveforms on the right is made with a higher noise level. Even though it is almost impossible to see the return in the center grid the correlation function clearly indicates its presence and still reports the delay. The only difference is that the correlation amplitude is reduced due to the presence of additional noise. This example illustrates the noise immunity of correlation measurements making it ideal for the detection of known signals in the presence of noise. It tells you that the signal exists within the noise and where it is located in the record.

One of the more esoteric measurements that can be made with cross-correlation is the determination of a linear, time invariant systems impulse response. The source waveform for this measurement must be Gaussian, white noise. Figure 3 shows an example of the measurement and compares the resultant impulse response with that obtained by using an actual impulse function. The device under test in this example is a Butterworth band-pass filter with a center frequency of 5 MHz and a nominal bandwidth of 2 MHz.

Figure 3. Here’s an example of measuring the impulse response of a band pass filter using a white noise source and the cross-correlation function. The result is compared to a direct measurement using an impulse source.

The three grids on the left side of the figure show the use of cross-correlation. The top trace (C1) is the input to the filter, Gaussian white noise. The band-pass filter response, trace F1, is immediately below that. The bottom trace, F3, is the cross-correlation of the filter input and output and is the impulse response of the filter. The right side of the screen shows the direct impulse response measurement. The top trace is an impulse function applied to filter input. The output of the filter, in trace F2, is the impulse response. In the bottom right grid, the two results are compared (note, no attempt has been made to normalize the amplitude). It is plain that the resultant shapes are identical. Using cross-correlation to measure the impulse response is done in applications where it is difficult to generate an impulse. A typical example is in acoustic measurements.

If your oscilloscope does not offer the correlation function you can use a third party math software package like MATLAB (auto-correlation and cross-correlation) to perform these measurements. If your oscilloscope lets you run MATLAB internally, then you can perform the calculations as part of the processing chain. If not, you can make the calculations offline.