You are on page 1of 5

Physics 209: Wave Phenomena with Biophysical Applications

Fall Semester, 2006

Week 3: Background Notes for Lab 2 (also useful for Lab1)-


Digital Signal Processing

Digital signal processing (DSP) is now a ubiquitous part of our lives, most obviously in the
entertainment industry (CDs, DVDs etc), but also in many other areas such as communica-
tions technology, science, and medicine. The essential feature of DSP is that a continuous
signal (music, voice, etc), instead of being recorded continuously as it would be on an audio
tape, is “discretely sampled.” This means that one obtains a data points that are a set of
instantaneous measurements of the signal at different times. If sufficient points are measured
per period of the signal, a very good approximation to its spectrum can be obtained. This
handout explains a bit about how one adapts Fourier methods to deal with this kind of data.

Additional information is available in Hobbie Sections 11.4 and 11.5

A typical discretely sampled data set (for a function of time f (t)) consists of N data points
measured with equal time spacing ∆t between each point. We will index each point by j so
that the data points are f (tj ) = fj with tj = j∆t for 0 ≤ j ≤ N − 1

Δt

t0 t1 t2 ………. tj ………. tN-2 tN-1

SKETCH OF DISCRETE DATA

This defines a total measurement time T = N ∆t. The trick with discrete Fourier transform
methods is to deal with the fact that one doesn’t have information about the function for
all times −∞ < t + ∞. One therefore effectively assumes that the signal is periodic with
period T , and does a Fourier Series analysis based on that.

1
Measured
signal

t0 tN t2N

NΔt

SKETCH OF SIGNAL MADE ”PERIODIC”

This yields a set of discrete frequencies in the spectrum, which is of course what one wants
for digital handling of data.

Here’s how it goes:

If the signal were truly periodic with period T = N ∆t, it would have a fundamental frequency
ν1 = N1∆t . Thus the frequencies we access in our spectrum are the harmonics of this (indexed
by k) : νk = kν1 = Nk∆t .

0 1 2 3 ………. ………. 1
ν
NΔt NΔt NΔt 2Δt

€ € € €

SKETCH OF FREQS SAMPLED

One might think that one will get information at N frequencies up to νS = N ν1 = NN∆t = ∆t 1

(the “sampling frequency”) but this is not the case. This is because one must sample a
sine wave at least twice per period to measure it properly (see discussion of aliasing below).
Also, if one thinks about information content, we have N data points, and so can only get
N pieces of information out of the signal. These are the an and bn coefficients, and we get
N/2 of each, extending up to the so-called Nyquist Frequency νN y = ν2S .

Here are the expicit formulae for the fourier series that are now known as the discrete Fourier
Transform.

Note that integrals get replaced by sums

2
2ZT
ak = f (t) cos(2πkν1 t)dt (1)
T 0
−1
2 NX j
= f (tj ) cos(2π j∆t)∆t (2)
N ∆t j=0 N ∆t
−1
2 NX
= fj cos(2πj k/N ) (3)
N j=0

and similarly

−1
2 NX
bk = fj sin(2πj k/N ) (4)
N j=0

The function f (t) is then given by the inverse

n
X
fj = (ak cos(2πj k/N ) + bk sin(2πj k/N )) (5)
k=1

where n = (N − 1)/2 (Nyquist condition).

As discussed briefly in Hobbie, a straight forward computer implementation of these equa-


tions is very costly in computer time, with the time required for the computation scaling
like N 2 . Fortunately there is a technique known as the Fast Fourier Transform (FFT) that
reduces the computation to something like (N/2) log2 (N ), which is enormously smaller that
N 2 for large N . This approach is now universally used, and indeed is used in the LoggerPro
software we’ll use in the lab. Explaination of it is beyond the scope of this course but a good
reference is Numerical Recipies by Press et. al..

One thing to point out about the FFT is that it works best on data sets where N = 2m .
Thus most implementations will “pad” data sets with extra data points set to zero to get N
to numbers such as 256, 512, 1024, 2048, etc.... You will see this in the lab, where the set of
frequencies you get are not quite what you’d expect from the sampling rate you choose.

Aliasing

As described in the handout on DFTs, you can only get spectral information for frequencies
below the Nyquist frequency νN y = 1/(2∆t), ie half your inverse sampling rate. Crudely,
you must measure a sine wave at least twice per period to resolve it.

However, it is worse than this. As a consequence of the digitization of the data, signals
with frequencies greater than νN y appear spuriously in the interval 0 < ν < νN y . This is the

3
phenomenon known as aliasing. This is a very nasty pitfall of digital signal processing, and if
you are ever doing this kind of work, YOU MUST BE AWARE OF THE POSSIBILITY OF
ALIASING!! You should also be acquainted with the ways of dealing with it. Best is simply
not to have noise or spurious signals above the Nyquist frequency. Another popular approach
is a low-pass anti-aliasing filter that suppresses all signals above the Nyquist frequency,
without (one hopes) affecting the signals of interest.

1.5
Signal at f = 1250 Hz; sampled at 2 KHz; Aliased signal at f = 750 Hz

1.0

0.5
Signal

0.0

-0.5

-1.0
-3
0 1 2 3 4 5 6 7 8 9 10x10
Time (sec)

PLOT OF ALIASING EXAMPLE


Signal at 1250 Hz is sampled at 2 KHz (∆t = 0.0005 sec). Thus νN y = 1000 Hz. At this
sampling rate, you can’t distinguish the 1250 Hz signal from another signal at 750 Hz.
In this example, the “measurement window” only extends up to 1000 Hz. Thus your mea-
surement would indicate the presence of a spurious signal at 750 Hz.

Here’s the mathematics of aliasing:

Briefly, a signal at ν = νN y + δν appears below the Nyquist frequency at νA = νN y − δν.


This is a consequence of the discrete sampling. To see this, call νA = νk and note that
ν = 2νN y − νk

4
νk δν δν νk

0 νA νNy ν 2νNy
ν
= νk

SKETCH OF ALIASING FREQUENCIES

cos(2πνtj ) = cos(2π(2νN y − νk )tj ) (6)


2 k
= cos(2π( − )j∆t) (7)
2∆t N ∆t
= cos(2π(j − jk/N ) (8)
= cos(2πj) cos(2πjk/N ) − sin(2πj) sin(2πjk/N ) (9)
= cos(2πjk/N ) (10)
= cos(2πνk tj ) (11)

And so the sampling process can’t tell the difference between signals at these two frequencies.
We will see this in the lab!!

You might also like