# DFT, 1 Sinusoid and related functions, Range and Resolution.

Cuthbert Nyack
In this applet a section of a sinusoid from T1 to T2 is sampled and the DTFT and DFT calculated. An important property of the DFT is the relation between the spectrum and the beginning and end of the sample interval of a periodic signal. The variation of the spectra as T1, T2 are changed is illustrated by the applet. The real and imaginary parts and the magnitude of the DFT are also shown.

eg parameters:-
(3.0, 0.5, 4.21, 6.2, 20, 0, 15, 10.0, 15.0, 0.5) in this case one period is sampled and the DFT contains 1 line at the sinusoid frequency. The sampling frequency is ~ 60rad/s so there are 20 samples per period and the line in the DFT spectrum corresponds to m = 1.
(3.0, 0.5, 2.11, 6.19, 40, 0, 15, 10.0, 15.0, 0.25) in this case two periods are sampled and the DFT contains 1 line at the sinusoid frequency. The sampling frequency is ~ 60rad/s so there are 40 samples in 2 periods and the line in the DFT spectrum corresponds to m = 2.
(3.0, 0.5, 2.11, 10.27, 40, 0, 15, 10.0, 20.0, 0.25) in this case four periods are sampled and the DFT contains 1 line at the sinusoid frequency. The sampling frequency is ~ 30rad/s so there are 40 samples in 4 periods and the line in the DFT spectrum corresponds to m = 4.

(6.0, 0.5, 0.01, 8.49, 10, 0, 10, 10.0, 15.0, 1.0) in this case the Nyquist rate is violated since the sampling frequency(6.668rad/s) is less than twice the sinusoid frequency(12rad/s). The DFT spectrum between 0 and ws/2 contains 1 line at 0.668rad/s (ie ws - w). In this case the samples appear to trace out a sinusoid whose period is equal to 9 periods of the sinusoid at 6rad/s ie with a frequency of 6/9 = 0.667rad/s.

When an integral number of periods are sampled the DFT frequencies outside of the main peak falls on the zeros of the DTFT. When (n + ½) periods are sampled, the DFT frequencies fall near the maxima of the DTFT and the spectrum contains contains several lines. The effect is illustrated by the eg parameters below:-
(3.0, 0.5, 2.11, 5.12, 30, 0, 20, 10.0, 15.0, 0.5) in this case 1.5 periods are sampled and the DFT spectrum contains several lines. The sampling frequency is ~ 60.53rad/s, the DFT line separation is 2.017rad/s so the sinusoid frequency of 3rad/s corresponds to m ~ 1.5. Whenever the sinusoid frequency does not correspond to one of the DFT frequencies, then the spectrum is spread out among all the values of m. In this case the 2 largest frequency components correspond to m = 1 and m = 2.
(3.0, 0.5, 0.01, 11.32, 60, 0, 12, 10.0, 30.0, 0.2) in this case 5.5 periods are sampled and the DFT spectrum is a PSK spectrum rather than a sinusoid spectrum.

When n periods are sampled starting from the zero of the sine, the spectrum is imaginary. For (n + ½) periods, it is real and is an almost mixture for (n + ¼) and (n + ¾) periods. When Sampling starts from the peak of the sinusoid, this is equivalent to sampling a cosine and the opposite applies. eg (3.0, 0.5, 2.61, 6.65, 25, 0, 16, 10.0, 15.0, 0.4). For (n + ½) periods, it is not completely imaginary.

Range and Resolution.
When using the DFT it is necessary to know how to control the range and resolution of the spectrum. The range is determined by the sampling time and is equal to ws/2. The resolution is determined by the length of the sampling interval ~ 2p/NTs = ws/N .
eg parameters (3.0, 1.0, 0.01, 62.2, 100, 0, 100, 225.0, 65.5, 0.1)
The sampling frequency is 10.0rad/s (2p(Ns - 1)/(T2 - T1) and the range is from 0 to 5.0rad/s. The Resolution is shown on the applet as the Line Sep = 0.1rad/s(ws/Ns = 10.0/100). There is only 1 line in the spectrum of significance with magnitude ~50 which corresponds to a sinusoid of amplitude 50 * (2/100) = 1. The frequency of the spectral line is 3.0rad/s.

Reducing the sampling interval while keeping the number of samples constant increases both the range and the resolution.
eg parameters (3.0, 1.0, 0.01, 24.89, 100, 0, 100, 90.0, 65.5, 0.1)

eg parameters (3.0, 1.0, 0.01, 30.79, 50, 0, 50, 225.0, 65.5, 0.2)

Bad choice of parameters can result in a range which is less than the frequency of interest.
eg parameters (3.0, 1.0, 0.01, 63.32, 40, 0, 40, 168.0, 65.5, 0.2)
show the range is 1.935rad/s and the resolution is 0.096rad/s. The frequency shown in the range between 0 and ws/2 is at the aliased frequency 3.87 - 3.0 ~ 0.87rad/s. The correct frequency of 3rad/s occurs in the range ws/2 to ws

## The applet also allows the DFT spectra of other functions to be examined by varying the Wfm parameter.

Some of the options available are:-
Wfm = 1, a half wave rectified sinusoid.
Wfm = 2, a full wave rectified sinusoid.
Wfm = 3, a saturated sinusoid, saturation level set by a.
Wfm = 4, a half wave saturated sinusoid, saturation level set by a.
Wfm = 5, a full wave rectified saturated sinusoid, saturation level set by a.
Wfm = 6, an SCR controlled waveform, set by a.
Wfm = 7, a Triac controlled waveform, set by a.
Wfm = 8, a parabolic approximation to a sinusoid.
Wfm = 9, a cubic approximation to a sinusoid.