Sie sind auf Seite 1von 63

RDS

Chapter 04
Digital Signal Processing
Methods
Version 3.0 English
October 2014

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-1


Prof. Dr.-Ing. Gangolf Hirtz
Content
Methoden der Digitalen
Chapter 4 Digital Signal Processing Methods Signalverarbeitung

Content Inhalt 2

4.1 Discrete Fourier Transformation Diskrete Fouriertransformation 4


4.1.1 Overview Überblick 5
4.1.1.2 Motivation Motivation 5
4.1.1.2 Various signal forms Verschiedene Eingangssignale 6
4.1.1.3 Signal representation with sine- and cosine terms Signaldarstellung mit Sinus- und Cosinus-Termen 7
4.1.2 Mathematical description of DFT Mathematische Beschreibung der DFT 11
4.1.2.1 DFT DFT 11
4.1.2.2 Inverse DFT Inverse DFT 12
4.1.2.3 Graphical representation of DFT Graphiosche Darstellung der DFT 13
4.1.2.4 DFT coefficients DFT Koeffizienten 14
4.1.3 DFT as correlation DFT als Korrelation 16
4.1.4 DFT as matrix operation Darstellung der DFT als Matrix 17
4.1.5 Fast Fourier transformation (FFT) Schnelle Fourier Transformation (FFT) 20
4.1.5.1 Complexity of the DFT Komplexität der DFT 20
4.1.5.2 FFT implementation Implementierung der FFT 21
4.1.6 Goerzel algorithm Goerzel Algorithmus 29
4.1.7 Windowing Fensterung 32
4.1.4.1 The window length corresponds to multiples of the input frequency
Fenster entspricht Vielfachem des Eingangssignals 32
4.1.7.2 Leakage Leakage 33
4.1.7.3 Rectangle window Rechteckfenster 35
4.1.7.4 Continuous windowing functions Kontinuierliche Fenster 38
4.1.8 Properties of the Discrete Fourier Transformation Eigenschaften der Diskreten Fourier Transformation 41
4.1.8.1 Overview Übersicht 41
4.1.8.2 Cyclic shifting Zyklische Verschiebung 42
4.1.8.3 Example DFT Beispiel DFT 44
4.1.8.4 Real- und imaginary part of DFT Real- und Imaginärteil der DFT 45
4.1.9 Practical DFT applications Praktische Anwendung der DFT 50
4.1.9.1 Definition of DFT parameters Festlegung der DFT 50
4.1.9.2 Example 1 Beispiel 1 54
4.1.9.3 Example 2 Beispiel 2 55
4.1.10 Convolution of two signals using the FFT Faltung von Signalen mittels FFT 56
4.1.10.1
Professur Digital- und Schaltungstechnik
Principle Prinzipielle Vorgehensweise Realization of Digital
56 Systems 4-2
Prof. Dr.-Ing. Gangolf Hirtz
4.1.10.2 Overlap-Save technique Overlap Save Technik 57
4.1.9 Practical DFT applications Praktische Anwendung der DFT 50
Content
4.1.9.1
4.1.9.2
Definition of DFT parameters
Example 1
Festlegung der DFT
Beispiel 1
50
54
4.1.9.3 Example 2 Beispiel 2 55
4.1.10 Convolution of two signals using the FFT Faltung von Signalen mittels FFT 56
4.1.10.1 Principle Prinzipielle Vorgehensweise 56
4.1.10.2 Overlap-Save technique Overlap Save Technik 57
4.1.10.3 Overlap-Add technique Overlap Add Technik 58
4.1.11 Short Time Fourier Transformation (STFT) Short Time Fourier Transformation 59
4.1.11.1 Welch algorithm Welch Algorithmus 59
4.1.11.2 Example Cirp function Bsp Cirp-Funktion 61
4.1.11.3 Wavelet Transformation Wavelet Transformation 62

4.2 Signal generators Signalgeneratoren 63


4.2.1 Sawtooth generator Sägezahngenerator 64
4.2.2 Rectangle generator Rechteckgenerator 67
4.2.3 Triangle signal generator Dreieckgenerator 68
4.2.4 Sine wave generator Erzeugung von Sinusschwingungen 69
4.2.4.1 Filtering Filterung 69
4.2.4.2 Direct Digital Synthesis DDS Direkte Digitale Synthese (DDS) 70
4.2.5 Polynomial approximation Polynomapproximation 71
4.2.5.1 Principle Polynomapproximation der Sinusfunktion 71
4.2.5.2 Methodology polynomial approximation Polynomapproximation der Quadratwurzel 72
4.2.5.3 Polynomial approximation of the sine-wave Polynom Approximation einer Sinus Funktion 73
4.2.5.4 Approximation of square root function Approximation einer Wurzelfunktion 74
4.2.6 Instable digital filter as sine wave generator Instabiler Digitalfilter als Sinusoszillator 76
4.2.6.1 Implementation Implementierung 76
4.2.6.2 Quadrature oscillator Quadraturoszllator 79
4.2.7 Noise generators Rauschgeneratoren 80
4.2.7.1 Noise generator for equally distributed noise Rauschgeerator für gleichverteiltes Rauschen 81
4.2.7.2 Normal distributed noise Rauschgeerator für normalverteiltes Rauschen 82
4.2.7.3 Color noise Rauschgeerator für farbiges Rauschen 83

4.3 Annex Anhang 84


4.3.1 Bibliography Literatur 84
4.3.1 Exercises Übungen 85

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-3


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation

Baptiste Joseph Fourier, french mathematican und physicist 1768-1830

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-4


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
4.1.1 Overview

4.1.1.1 Motivation
• Beside digital filters the discrete Fourier transformation (DFT) is the mostly implemented DSP algorithm at all.
• The DFT is the equivalent to the Fourier transformation for continuous signals.
• The DFT is applied in the following areas:
– Determination of frequency behavior of signals
– Determination of spectral components of machines in order to detect signs of wear
– Detection of specific frequency spectrums (e.g. breakage of glass …)
– Determination of spectral distribution of audio signals as basis for frequency equalization
– General measurement applications (spectrum analyzer)

• Digital filtering:
– In case of large number of filter coefficients it May be more economic to transfer the input as well as the filter
impulse response into the frequency domain (DFT) multiply the two DFT converted signals and transform the result
back into the time domain.
.

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-5


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
4.1.1.2 Various signal forms
• In principle it‘s possible to distinguish four different kinds
of signals:
– Signals can be continuous or discrete.
– Signals can be periodic or a periodic.

… …
1. Continuous periodic signals
– Sine-wave, rectangular, sawtooth signals with periodic
repetition t

–  Fourier series.

2. Continuous a periodic signals


– Decaying exponential functions, Gaussian curves,
signals tending to ±infinity, without repetition. t
– Fourier transformation

3. Discrete periodic signals … …


– Sampled continuous periodic signals
–  Discrete Fourier Transformation
t

4. Discrete a periodic signals


– Sampled continuous a periodic signals.
–  Discrete Time Fourier Transformation
t

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-6


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
4.1.1.3 Signal representation with sine- and cosine terms a  cos 0  t   b  sin 0  t   A  sin 0  t   
A  a 2  b2
b
  tan
a
cos sin DFT 6d
1 1

xq[n]
xi[n]

0 0

-1 -1
0 2 4 6 8 10 12 14 16 0 2 4 6 8 10 12 14 16
n n
0 30 60 90
1 1 1 1
z[n]

z[n]

z[n]

z[n]
0 0 0 0

-1 -1 -1 -1
0 5 10 15 0 5 10 15 0 5 10 15 0 5 10 15
n n n n
120 150 180 210
1 1 1 1
z[n]

z[n]

z[n]

z[n]
0 0 0 0

-1 -1 -1 -1
0 5 10 15 0 5 10 15 0 5 10 15 0 5 10 15
n n n n

Phase shift by differenmt weigthing of sine- and cosine terms

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-7


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation

50 50 50

0 0 0
0

2
-50 -50 -50
0 5 10 15 0 5 10 15 0 5 10 15
n n n

50 50 50

0 0 0
3

5
-50 -50 -50
0 5 10 15 0 5 10 15 0 5 10 15
n n n

50 50 50

0 0 0
6

8
-50 -50 -50
0 5 10 15 0 5 10 15 0 5 10 15
n n n

Cosine terms of input sequence x[n]

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-8


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation

50 50 50

0 0 0
0

2
-50 -50 -50
0 5 10 15 0 5 10 15 0 5 10 15
n n n

50 50 50

0 0 0
3

5
-50 -50 -50
0 5 10 15 0 5 10 15 0 5 10 15
n n n

50 50 50

0 0 0
6

8
-50 -50 -50
0 5 10 15 0 5 10 15 0 5 10 15
n n n

Sine terms of input sequence x[n]

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-9


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
4.1.2 Mathematical description
4.1.2.1 DFT
• Starting point for the DFT is the Fourier transformation of time-continuous signals:

 j 2  f t
X(f )   x(t )  e

dt

• The time-continuous signal x(t) is sampled at equidistant points n∙T ; the integral is approximated by a sum.
– An infinite number of samples is obtained.

X(f )   x(nT )  e j2  f nT T
n 

– We limit the DFT on an finite sample number. This way a kind of windowing of the sampled input signal takes
place, index w.
f
N 1  j 2 n
X w ( f )   x(nT )  e
fS
n0

– Furthermore the sample period T is considered to be 1, by means T can be omitted:


• The function Xw(f) is a periodic function with frequency f S= 1/T and N independent, equidistant values:

fS f f fS
f  0, , 2  S 3 S ,  N  1 
N N N N
• The DTF can be expressed as:
fS
k
N 1  j 2 n N N 1  j 2 n k
f
X w (k S )   x(nT )  e  X k   
fS
x[n]  e N; k  0,1, 2 N 1
N n0 n0

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-10


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
4.1.2.3 Inverse DFT
• The inverse discrete Fourier transformation (IDTF) we describe as:

1 N 1  j 2 k 
n
x[n]    X [ f ] e N
; n  0,1, 2 N 1
N k 0

• The equations for the DFT are also called analysis equations while the DFT ones are called synthesis equations.

x[n]  X [k ]
The values X[k] are complex ; they are also designated as DFT-coefficients.
The DFT is an unambiguous (eindeutige) image between complex input sequence x[n] and complex spectrum X[k].

• The DFT base functions are:

 j2 k  n  n  n
e N  cos  2    k    j  sin  2    k   n  0,1, 2 N 1
 N  N
cRe [ k ] cIm [ k ]

 The parameter k indicates how many sine or cosine-periods are within the range of N samples.
– K=1 means 1 period.
– K=N means N periods.
– K=0 corresponds to the DC value.

• The coefficients cIm[0] and cIm[N] are always zero, why?

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-11


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
• The DFT coefficients are repeated with respect to N/2 (Example:16/2)
• The imaginary coefficients k=0 and k=N/2 are always zero.
• That means that N samples always result in N coefficients.

50
x[n]
x[n]

0
0 N-1
N samples

-50
0 5 10 15
n Time domain

50
ReX[k]

0
Frequency domain
-50
0 2 4 6 8 10 12 14 16 Re  X []
k

50 0 N/2 N-1
ImX[k]

0 Im  X []

-50
0 N/2 N-1
0 2 4 6 8 10 12 14 16
k

DFT of an input sequence x[n]

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-12


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
4.1.5 Fast Fourier transformation (FFT)

4.1.5.1 Complexity of the DFT


• The complexity of the DFT algorithm is an elementary bottleneck.
N 1 j2k n

X[k]   x[n]  e N
n 0

– The following processing steps have to be done:


o To execute a DFT with N coefficients N multiplications and N-1 summations are necessary (FLOPS = floating point
operations).
RDFT , direct  c  N 2 FLOPS

o The processing effort increases squared with the transformation length. The factor c indicates how many single
floating point operations are necessary for one summation and multiplication; best case c=1.
• Applying the fast Fourier transformation (FFT) the computational effort can drastically be decreased to:
RFFT  c  N  log 2  N 

DFT FFT
N K FLOPS K FLOPS
4 16 8
8 64 24
16 256 64
64 4.096 384
256 65.536 2.048
1024 1.048.576 10.240
4096 16.774.216 49.152

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-13


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
4.1.5.2 FFT implementation
• Several implementations of the FFT are known, but all of them are based on the same principle.
• It’s essential that the length N must be a power of two

N  2p
• The FFT divides the DFT of length N in two DFTs of half length; one with only the even samples and the other one with the
odd samples:

N 1 j2k n N2 j2k n N 1 j2k n


  
X[k]   x[n]  e N   x[n]  e N   x[n]  e N
n 0 n  0,2 n 1,3

N / 2 1
j2k  2n  N / 2 1
j2k  2n 1
 
  x[2n]  e
n 0
N   x[2n  1]  e
n 0
N

N / 2 1
j2k  2n  j2k N / 2 1
j2k  2n 
  
  x[2n]  e
n 0
N e N   x[2n  1]  e
n 0
N

U[k] V[k]

• Summarizing the even samples and summarizing the odd samples


• .
0, 1, 2, 3, N  2, N 1

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-14


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
• The principle is explained in the following example with N = 8.
j2k n j2k  2n  j2k j2k  2n 
7  3   3 
X[k]   x[n]  e 8   x[2n]  e 8 e 8   x[2n  1]  e 8
n 0 n 0 n 0

U[k] V[k]
j2k 2 j2k 4 j2k 6 j2k  j2k 2 j2k 4 j2k 6 
       
 x[0]  1  x[2]  e 8  x[4]  e 8  x[6]  e 8 e 8   x[1]  1  x[3]  e 8  x[5]  e 8  x[7]  e 8 
U[k]  
V[k]
U [0]
x[0] u[0] 0
+ X [0]
U [1] W N
x[1] u[1] + X [1]
U [2] WN1
x[2] u[2] + X [2]
U [3] WN2
x[3] u[3] + X [3]
3 j2k
W N 
WNk e N

V [0]
x[4] v[0] WN4 + X [4]
V [1]
x[5] v[1] WN5 + X [5]
V [2]
x[6] v[2] WN6 + X [6]
V [3]
x[7] v[3] WN7 + X [7]

Example of a radix – 2FFT with N=8

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-15


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
• The decomposition is successively continued until only DFTs of length 2 remain. In total these are log 2(N) steps.
– In this example log2(8) = 3.
• For each step, there are N MAC operations (summation plus multiplication) required .

RFFT  c  N  log 2  N 
U[0]
x[0] + + X [0]
WN0 WN0
U[1]
x[4] + + X [1]
2
W N
V[0] WN1
x[2] WN4 + + X [2]

V[1] WN2
x[6] WN6 + + X [3]

Y[0] WN3
4
x[1] + W N + X [4]
WN0
Y[1]
x[5] + WN5 + X [5]
2
W N
Z[0]
x[3] WN4 + WN6 + X [6]

Z[1]
x[7] WN6 + WN7 + X [7]

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-16


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
• The factor c depends on the DSP architecture. For complex values and the complex twiddle factor each complex
multiplication can consist of 4 multiplications and 2 summations. Each complex summation again consists of two
summations  c = 8

RFFT  8  N  log 2  N 
U[0]
x[0] + + X [0]
WN0 WN0
U[1]
x[4] + + X [1]
2
WN
V[0] WN1
x[2] WN4 + + X [2]

V[1] WN2
x[6] WN6 + + X [3]

Y[0] WN3
4
x[1] + W N + X [4]
WN0
Y[1]
x[5] + WN5 + X [5]
2
W N
Z[0]
x[3] WN4 + WN6 + X [6]

Z[1]
x[7] WN6 + WN7 + X [7]

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-17


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation

j2k

WNk e N

x[0] + + + X [0]
0
W N WN0 WN0
x[4] WN4 + + + X [1]
2
WN
WN1
x[2] + WN4 + + X [2]
0
W N
WN2
x[6] WN4 + WN6 + + X [3]

4
WN3
x[1] + + W N + X [4]
0
W N WN0

x[5] WN4 + + WN5 + X [5]


2
W N

x[3] + WN4 + WN6 + X [6]


0
W N

x[7] WN4 + WN6 + WN7 + X [7]

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-18


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation

x[0] + + + X [0]
j20
 j20
4 
e e 8
j21
x[4] 
2 + j21
+ + X [1]
e 
4
e j21

8
j22
e
x[2] +  + + X [2]
4
e
j22

8
e
j21 j23
x[6] 
2 + 
4 + + X [3]
e e
j23

8
x[1] + + e + X [4]
j24
j20 
 8
e 4 e
j21 j25
x[5]  
e 2 + j21
+ e 8 + X [5]

4
e
j22 j26
x[3]  + 
+ e 4
e 8 + X [6]

j21 j23 j27


x[7]   
e 2 + e 4 + e 8 + X [7]

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-19


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
• As can be seen the decomposition consist of log2(N) steps. In this example 3 steps.
• Each step consist of N/2 so called Butterfly graphs.
– Each Butterfly graph requires 2 complex multiplications plus 2 complex
summations. +
i
– In total there are N MAC operations for each step necessary. WN

– Depending on the DSP architecture A complex MAC operation can be treated in


1 to max 8 single operations (c= 1…8)
WNi  N/2 +
• The total number of complex operations for a FFT is:

RFFT  c  N  log 2  N 
• In case of a direct DFT calculation N2 calculations are required.
– In case of N=1024  reduction of processing effort of 99%!

N  log 2  N  10
2
  1%
N 1024

• A further improvement is possible:


+
j2i j2i  N/2 j2i
  
WNi e N WNi  N / 2 e N e N  (1)
– This way the number of calculations can further be reduced (50%):
WNi -1 +

N
R FFT   log 2  N 
2

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-20


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
Bit reversed addressing

x[0] 000 000 x[0]

x[1] 001 100 x[4]

x[2] 010 010 x[2]

x[3] 011 110 x[6]

x[4] 100 001 x[1]

x[5] 101 101 x[5]

x[6] 110 011 x[3]

x[7] 111 111 x[7]

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-21


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
N=16
4.1.7 Windowing 1.5
4.1.7.1 The window length corresponds to multiples of 1
the input frequency 0.5
• From an infinite input sequence a section with N samples is

x[n]
0
cut out. -0.5
– In the example (fig. right top) exactly two periods of the -1
input signal fit into that window. -1.5
-30 -20 -10 0 10 20 30
• The DFT results in a spectral distribution according to the fi.
n
Right bottom.
2
• The frequency component is located at k=2 respectively
2 fS/N. 1.5

X[k] * 2 / N
– In this example the measurement interval N·T is equal to
multiples of the input signal period T0. 1

0.5
When the measurement interval is equal to multiples of the
input signal period T0 , then The DFT exactly provides a 0
0 1 2 3 4 5 6 7 8
correct spectrum analysis (assuming that the Nyquist k
criteria is fulfilled  no alias).
0 fs 2 fs 3 fs 4 fs 5 fs 6 fs 7 fs 8 fs
N N N N N N N N
– The blue line in the figure right bottom corresponds to
the magnitude of the Fourier transformation Xw(f) scaled f
to 1.
 t 
x(t )  rect    X w ( f )  X ( f )  Si   f  2  T0 
 0
2  T
• The frequency points (red dots) correspond to the
frequency points the DFT provides.

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-22


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
4.1.7.2 Leakage DCT1c
• In praxis the period of the input signals will barely 1.5
exactly fit into the DFT range. 1
– That’s shown in the figure right top with N = 18. 0.5
– The window length is 2,25 times the period of the

x[n]
0
input signal.
-0.5
• The frequency spectrum is no more unambiguous
(eindeutig) but spread of the whole frequency range. -1

• An unambiguous statement about the frequency of the -1.5


-30 -20 -10 0 10 20 30
input signal is no more possible. n

Leakage describes the effect that, due to the


windowing of the input signal, additional spectral 1
components beside the main lobe occur. 0.8

X[f]
0.6
– The Leakage effect is not a wrong interpretation of 0.4
the sampled signal. 0.2
– The frequency spectrum in the figure right bottom is
0
absolutely correct! 0 1 2 3 4 5 6 7 8
– Due to the windowing (N=18) and the periodic k
repetition, due to the phase jumps, high frequency 0 fs 2 fs 3 fs 4 fs 5 fs 6 fs 7 fs 8 fs
components occur which can be seen in the N N N N N N N N
spectrum  Leakage.
• These abrupt transition can be avoided by using more f
continuous window-functions.
N fS f
f    2, 29  S
7 N 16

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-23


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
DFT2a

• As can be seen in the figure right top, the input 1


sequence is weighted with a continuous, 0.8

cosine- shaped windowing function and no

w[n]
0.6

more abrupt cut. 0.4


0.2
• This way the windowed input series smoothly 0
ends and a continuous transition of the -30 -20 -10 0
n
10 20 30

windowed input signal of length N to the


1.5
periodic repeated input signal is achieved.
1
• Abrupt phase jumps are avoided. 0.5

• This has the effect that in frequency domain

x[n]
0
-0.5
unwanted spectral components are
-1
attenuated.
-1.5
• . -30 -20 -10 0
n
10 20 30

0.5
xw[n]
0

-0.5

-1
-5 0 5 10 15 20
n

0.8

0.6
Xw[f]

0.4

0.2

0
0 1 2 3 4 5 6 7 8
k

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-24


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
4.1.7.3 Rectangular window
1
• The rectangular window is the most easiest window applied.
Only the number of samples used for the DFT is restricted to
N. 0.8

• The frequency magnitude has a main lobe and several side


0.6

w[n]
lobes.
0.4
– The main lobe should be small, so that neighboring
frequency components of the input signal still can be 0.2
distinguished.
– The side lobes should have a high attenuation (compared 0
0 5 10 15 20
to the main lobe) in order to suppress the Leakage effect n
as much as possible.
.
• From the main lobe the spectral resolution of the DFT can
be derived. 0
10
– The spectral resolution is important in case that frequency
components which are quite close together and even
more with different amplitudes should be analyzed. -1
10

W[f]
 Spectral resolution is the frequency distance that two
frequency components must have that they can be -2
10
distinguished by then DFT Main lobe
In average the frequency resolution is half of the main lobe
width.
-3
10
. -0.25 -0.2 -0.15 -0.1 -0.05 0 0.05 0.1 0.15 0.2 0.25
fs/N

Rectangular window in time-and frequency domain

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-25


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
• In frequency domain the rectangular window is a Sinc-
function with the following properties: 1

1 0  n  N 1
Window function wR (n)   0.8

0 else
0.6

w[n]
wR (n)
0.4

N 1  j  2  
N 1
f sin   f  N 
WR ( f )   e  j  2   n  f
e 2
 0.2
n0 sin(  f )
0
0 5 10 15 20
n
• The main lobe has a width of:

4  2  fS
or
N N
0
10
• The resulting spectral resolution is:

fS 10
-1

W[f]
N

-2
10

-3
10
-0.25 -0.2 -0.15 -0.1 -0.05 0 0.05 0.1 0.15 0.2 0.25
fs/N

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-26


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
1 1

0.8 0.8

0.6 0.6
w[n]

w[n]
0.4 0.4

0.2 0.2

0 0
0 5 10 15 20 0 5 10 15 20 25 30 35
n n

0 0
10 10

-1
10 -1
10
W[f]

W[f]
-2
10 10
-2

-3
10 10
-3
-0.25 -0.2 -0.15 -0.1 -0.05 0 0.05 0.1 0.15 0.2 0.25 -0.25 -0.2 -0.15 -0.1 -0.05 0 0.05 0.1 0.15 0.2 0.25
fs/N
fs/N

Rectangular window, N=16 Rectangular window, N=32

1 1
Spectral resolution: fS   f S  0,0625 Spectral resolution: fS   f S  0,03125
16 32

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-27


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
4.1.7.4 Continuous windows
1
• Beside the rectangular widow a lot of other windows
are commonly used. These windows have a more or
0.8
less continuous frequency shape.
• The behavior is explained by means of the Hann 0.6

w[n]
window:
   2n   0.4
0,5  1  cos   n  0,1, 2 N 1
w[n]     N  1 
0 0.2
 sonst
0
• The main lobe of the Hann window has a width of: 0 5 10 15 20 25 30 35
n
4  fS
B
N
• As result the spectral resolution is:
2  fS 0
 0, 0625  f S 10
N

• The attenuation of the first side lobe is 32dB, those 10


-1

W[f]
of the following side lobes are 18dB each
• The spectral resolution is two times worse than that
of the rectangular window. 10
-2

• The Leakage effect suppression is about 20dB Main lobe


better
-3
10
-0.25 -0.2 -0.15 -0.1 -0.05 0 0.05 0.1 0.15 0.2 0.25
fs/N

Hann window, N=32

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-28


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
1 1

0.8 0.8

0.6 0.6
w[n]

w[n]
0.4 0.4

0.2 0.2

0 0
0 5 10 15 20 25 30 35 0 5 10 15 20 25 30 35
n n

0 0
10 10

-1 -1
10 10

-2 -2
10 10
W[f]

W[f]
-3 -3
10 10

-4 -4
10 10

-5 -5
10 10
-0.25 -0.2 -0.15 -0.1 -0.05 0 0.05 0.1 0.15 0.2 0.25 -0.25 -0.2 -0.15 -0.1 -0.05 0 0.05 0.1 0.15 0.2 0.25
fs/N fs/N

Kaiser window ß=1 Kaiser window ß=10

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-29


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
Overview over the windowing functions

Relative
Definition Main Lobe Sideband Rolloff
Window Bandwidth [-3dB] Attenuation [dB/Octave]

w[n]  1
Rectangular 1,8 / N -13,0dB -6,0dB
 2   n 
w[n]  0,54  0, 46  cos  
Hamming  N 1  6,6 /N -43dB -6,0dB
 2   n 
w[n]  0,5  0,5  cos  
Hanning  N 1  6,2 / N -31dB -18dB
 2   n   4   n 
w[n]  0, 42  0,5  cos    0,08  cos  
Blackman  N 1   N 1  11 / N -58dB -18dB

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-30


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
4.1.8 Properties of the Discrete Fourier Transformation

4.1.8.1 Overview

• Linearity
DFT
 a  x [n]
i
i i   ai  X i [k ]
i

DFT a1  x1[n]  a2  x2 [n]  a1  DFT  x1[n]  a2  DFT  x2 [n]

• Mirror
DFT
x[n]  X [k ]

• Symmetry
DFT DFT
x[n]  X [k ]  x [n]  X *[k ]
*

X [ k ]  X *[  k ]  X [ N  k ]

• Parseval’s law
N 1
1 N 1
DFT
 x[n]    X [k ] The energy of a signal in time domain is equal to the energy
2 2

n 0 N k 0 in the frequency domain

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-31


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
4.1.8.2 Cyclic shifting x[n]  x[n  2]
j 2 j 
j  2  2k  k
DFT   m k X [k ]  X [k ]*  X [k ]  e 32
 X [k ]  e 8
x[n  m]  X [k ]  e N

     
 X [k ]   cos   k   j  sin   k  
 8   8 
1 1

0.5 0.5

0 0
x

x
-0.5 x[n] x[n  2] -0.5

-1 -1
0 5 10 15 20 25 30 0 5 10 15 20 25 30
n n

10 10
real(X)

real(X)
0 0

-10 -10

0 5 10 15 20 25 30 0 5 10 15 20 25 30
k X [k ] X [k ]* k 

10 10
Imag(X)

Imag(X)
0 0

-10 -10

0 5 10 15 20 25 30 0 5 10 15 20 25 30
k k 

10 X [k ] X [k ]* 10
Abs(X)

Abs(X)

0 0

-10 -10

0 5 10 15 20 25 30 0 5 10 15 20 25 30
k k 

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-32


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
x[n]  x[n  4]
j 2 j 
 4k  k
X [k ]  X [k ]  X [k ]  e
* 32  X [k ]  e 4

     
X [2]*  X [2]   cos   2   j  sin   2    X [2]   0  j  1
 4   4 
j  2 
 30  k     
X [30]*  X [30]  e 32
 X [30]   cos   15   j  sin   15    X [30]   0  j  1
 4  4 
x[n  4] x[n  8]
1 1

0.5 0.5

0 0
x

x
-0.5 -0.5

-1 -1
0 5 10 15 20 25 30 0 5 10 15 20 25 30
n n

10 10
real(X)

real(X)
0 0

-10 -10

0 5 10 15 20 25 30 0 5 10 15 20 25 30
k  k 

10 10
Imag(X)

Imag(X)
0 0

-10 -10

0 5 10 15 20 25 30 0 5 10 15 20 25 30
k  k 

10 10
Abs(X)

Abs(X)

0 0

-10 -10

0 5 10 15 20 25 30 0 5 10 15 20 25 30
k  k 

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-33


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
4.1.8.3 Example DFT

0.5
x[n]

-0.5

-1
0 5 10 15 20 25 30
  n 1 1  
x[n]  1*cos   n  x[n]    cos   n 
 16  2 2  16 
15

10

5
ReX[k]

-5

-10

-15
0 5 10 15 20 25 30
k

X[k] X[k]

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-34


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
4.1.8.4 Real- und imaginary part of DFT

• The even real part of an series x[n] is represented by the DFT as even real-part of X[k].
• The odd real part of an series x[n] is represented by the DFT as odd imaginary part of X[k].

• The even imaginary part of an series x[n] is represented by the DFT as even imaginary part of X[k].
• The odd imaginary part of an series x[n] is represented by the DFT as odd real part of X[k].

x[n]  x e,r [n]  x o,r [n]  j  x e,i [n]  j  x o,i [n]

X[k]  X e,r [k]  j  X o,i [k]  j  X e,i [k]  x o,r [k]

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-35


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation

DFT 2b

2 2
1.5 1.5
1 1
0.5 0.5
xr[n]

xi[n]
0 0
-0.5 -0.5
-1 -1
-1.5 -1.5
-2 -2

0 5 10 15 20 25 30 0 5 10 15 20 25 30
n n

15 15

10 10

5 5
ReX[k]

ImX[k]
0 0

-5 -5

-10 -10

-15 -15
0 5 10 15 20 25 30 0 5 10 15 20 25 30
k k

 2  2   2  4   2  3   2  5 
x[n]  cos   n   sin   n   j  cos   n   j  sin  n
 32   32   32   32 

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-36


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
DFT 2c

1.5 1.5

1 1
DFT 2c
xrg[n] 0.5
1.5 0.5
1.5

xru[n]
0
1 0
1

-0.5
0.5 -0.5
0.5
xrg[n]

xru[n]
-1
0 -1
0

-1.5
-0.5 -1.5
-0.5
0 5 10 15 20 25 30 0 5 10 15 20 25 30
-1 n -1 n

even part x[n]


-1.5 -1.5
odd part x[n]
0 5 10 15 20  2  230 
25 0  25  4 10 15 20 25 30
15 nx[n]  cos  n  15 sin  n n
 32   32 
Re
10 X[k] 10 Im X[k]

15
5 15
5
ReX[k]

ImX[k]
10
0 10
0

5
-5 5
-5
ReX[k]

ImX[k]

0
-10 0
-10

-5
-15 -5
-15
0 5 10 15 20 25 30 0 5 10 15 20 25 30
-10 k -10 k

-15 -15
0 5 10 15 20 25 30 0 5 10 15 20 25 30
k k

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-37


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
DFT 2d

1.5 1.5

1 1
DFT 2d
0.5 0.5
xiu[n]

xig[n]
1.5
0 1.5
0
1
-0.5 1
-0.5
0.5
-1 0.5
-1
xiu[n]

xig[n]
0
-1.5 0
-1.5
-0.5 -0.5
0 5 10 15 20 25 30 0 5 10 15 20 25 30
-1 n -1 n
-1.5 -1.5
odd part Im x[n] even part Im{x[n]}
 2  5   2  3 
15 0 5 10 15 20  j 25
x[n] sin  30  n   15 0j  cos 5 n
10 15 20 25 30
n  32   32  n
10 Re X[k] 10 Im X[k]
5 5
15 15
ReX[k]

ImX[k]
0 0
10 10
-5 -5
5 5
ReX[k]

ImX[k]
-10 -10
0 0
-15 -15
-5 -5
0 5 10 15 20 25 30 0 5 10 15 20 25 30
k k
-10 -10

-15 -15
0 5 10 15 20 25 30 0 5 10 15 20 25 30
k k

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-38


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation

4.1.9 Practical DFT applications

4.1.9.1 Definition of DFT parameters


• Choice of sampling frequency
• The sampling frequency is chosen that way that the Nyquist criteria is fulfilled.

fs  2  B

• Number of sampling values


• The distance between two frequency components of the DFT is:
fS
f 
N
• For the number of sampling points:
fS
N
f

Spectral resolution of the DFT depends on the number of sampling values.


fS
f 
N
• Usage of FFT requires that N is a power of two
• In case that only Ns sampling values are available (Ns<N), the missing sample values are zero padded.
• Nevertheless the spectral resolution is only defined by Ns and not by N.
• fS
f 
Ns

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-39


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation

• In case of periodic signals, the number N is chosen that way that N∙T corresponds to multiples of the cycle duration of
the input signal.
• In case that N is not a power of two the FFT can’t be used.
• As already mentioned before, zero padding can be used to fill up the missing samples to carry out a FFT, but the
spectral resolution is not changed.

DCT3a
1 1

0.8 0.8

0.6 0.6
x1[n]

x2[n]
0.4 0.4

0.2 0.2
N=12 N=16
0 0
0 5 10 15 0 5 10 15
n n

6 6

4 4
X1[k]

X2[k]

2 2

0 0
0 2 4 6 0 2 4 6 8 DFT with N=12 (left) and
k fS k fS
2 2 N=16 by zero padding (right)

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-40


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation

1 1
w[n]

w[n]
0.5 0.5

0 0
0 200 400 600 800 1000 0 200 400 600 800 1000
t t

2 2
1 1
xw[n]

xw[n]
0 0
-1 -1
-2 -2

0 200 400 600 800 1000 0 200 400 600 800 1000
t t

600
600
400
|X(f)|

|X(f)|

400
200
200

0 0
190 192 194 196 198 200 202 204 206 208 210 190 192 194 196 198 200 202 204 206 208 210
f [Hz] f [Hz]

fo=200Hz,f1=201Hz fs=1024Hz, N(FFT)=1024, 1024Samples, rect fo=200Hz,f1=201Hz fs=1024Hz, N(FFT)=1024, 900Samples, rect

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-41


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation

1 1
w[n]

w[n]
0.5 0.5

0 0
0 100 200 300 400 500 600 0 200 400 600 800 1000
t t
1
2
1 0.5
xw[n]

xw[n]
0 0
-1 -0.5
-2
-1
0 100 200 300 400 500 600 0 200 400 600 800 1000
t t

400
200
300
|X(f)| 150
|X(f)|

200
100
100 50
0 0
190 192 194 196 198 200 202 204 206 208 210 190 192 194 196 198 200 202 204 206 208 210
f [Hz] f [Hz]

fo=200Hz,f1=201Hz fs=1024Hz, N(FFT)=512, 512Samples, rect fo=200Hz,f1=201Hz fs=1024Hz, N(FFT)=1024 1024Samples, Hanning

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-42


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation

4.1.9.2 Example 1
• Assume a decaying sine-wave with period 1Hz, switched-on at time 0.
t DFT4a

x(t )  u (t )  sin  2    f 0  t   e ; f 0  1Hz;  1sec
 1

0.5
• The signal is decayed after 4 sec.

x(t)
0
• As sample frequency we chose 10Hz.
• This results in 40 sample values. -0.5

• For the FFT 64 sample values are needed (N=64) -1


0 1 2 3 4 5 6 7 8
 Zero padding (41…64) t [sec]

1
• The FFT result is multiplied with the sample period
0.5
• The frequency axis (right bottom) goes from
X[0]….X[32], or from 0Hz to 5Hz corresponding

x[n]
0
half of the sampling frequency
-0.5

-1
0 10 20 30 40 50 60 70 80
n

0.5

0.4

0.3
Xs(f)

0.2

0.1

0
0 5 10 15 20 25 30
k

0 1Hz 2Hz 3Hz 4Hz 5Hz

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-43


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation
DFT5a
4.1.9.3 Example 2
1
• Assuming two sine waves, quite close to each other:
0.5

x(t )  U 1  sin  2    f1  t   U 2  sin  2    f 2  t   unoise (t )

x[t]
0

-0.5
U 1  1V ; f1  990 Hz; -1

U 2  10mV ; f 2  1010 Hz; 0 0.5 1 1.5 2 2.5


t [s]
3 3.5 4 4.5
-3
x 10
5

 noise  10mV 1.5


1
• Choice of sampling frequency: fS= 4KHz 0.5

• Additional pre-filters are not used, since alias caused

xs[t]
0
-0.5
by the noise floor is neglectable small.
-1
• Choice of FFT-length: -1.5
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
t [s] -3
f S 4 KHz x 10
f    4 Hz 10
0

N 1024
-2
• FFT with normal rectangular window, N=1024  10

|(X(f)|
-4
10

-6
10
900 920 940 960 980 1000 1020 1040 1060 1080 1100
f[Hz]

0
• FFT with Kaiser window, ß=7, N=1024  10

-2
10
|(X(f)|

• Input signal x(t) 10


-4

• Sampled input signal with fs=4KHz


• FFT mit N=1024, Rectangular window 10
-6

900 920 940 960 980 1000 1020 1040 1060 1080 1100
• FFT mit N=1024, Kaiser window, ß=7, f [Hz]

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-44


Prof. Dr.-Ing. Gangolf Hirtz
4.1 Discrete Fourier Transformation

4.1.10 Convolution of two signals using the FFT


x[n] N Point X [k ]
4.1.10.1 Principle
• Useful applications : FFT
– Convolution of input signals with large filters. Y [k ] N Point y[n]
x
– Spectrum calculation IFFT
y[n]  x[n]* h[n] h[n] N Point H [k ]
FFT
Y [ K ]  X [k ]  H [k ]

– Now 2 x FFT, 1 x IFFT and N complex multiplications are needed.


• For one convolution of two input signals, in total

 N 
4   3   log 2  N   N 
 2 

real multiplications are needed.


• In case of a conventional convolution for N output values out of Nx input values and Nh filter coefficients the number
of real multiplications is given by:
N x  Nh  1

– An implementation of the FFT and IFFT makes sense in case that:


 N 
4   3   log 2  N   N   N x  N h
 2 

– When the input signal is split to many blocks (see next page), the filter only has to be transformed once.
– The number of multiplications is reduced accordingly.

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-45


Prof. Dr.-Ing. Gangolf Hirtz
4.2 Signal generators

Signal generators

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-46


Prof. Dr.-Ing. Gangolf Hirtz
4.2 Signal generators
4.2.1 Sawtooth generator

• The sawtooth function is defined:


x
sawtooth( x)  1  , 0  x  2 

sawtooth( x)  sawtooth( x  2   )

• For a sawtooth function with frequency f0 :

y(t )  sawtooth(2    f 0  t )
• By sampling the time continuous signal at point t=n∙T, the time continuous signal in converted into a discrete signal.

y[n]  sawtooth(2    f 0  n  T )

• The figure below shows a time continuous sawtooth signal with frequency f 0=50Hz and as sampling frequency
fs=630Hz :

y (t ) y[n]

t[ms ] t[ms ]

20 20 20 T0 20

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-47


Prof. Dr.-Ing. Gangolf Hirtz
4.2 Signal generators

• Realization by discrete integrator:

y[n]  y[n  1]  b0  x[n  1]


1 1 Y ( z ) b0  z 1
Y ( z )  Y ( z )  z  b0  X ( z )  z  H ( z )  
X ( z ) 1  z 1

• When x[n] is a step function and the start conditions are y[0] = -1, for n≥0 we get:

 y[n]  1,  1  b0 ,  1  2  b0 ,  1  3  b0 
• The input signal continuously increases with step height b0 until the number range is exceeded.
• When the numbers are represented in fractional format, the upper limit is exceeded at the value +1.

• Step height b0
0,500
• Input period T0 0,375
• Sampling time T=1/fs 0,625
Y[4]
0,250 y[n]
0,750
• From the figure (previous page)
0,875 Y[5] 0,125
we can see: Y[3]

b0 2 f -1 Y[0] 0
  b0  2  0 n
T T0 fs -0,125
-0,875
Y[6] Y[2]
-0,750 -0,250
Y[1] Y[7]
20
-0,625 -0,375
-0,500

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-48


Prof. Dr.-Ing. Gangolf Hirtz
4.2 Signal generators

• b0 can only be implemented as quantized value bO,q.

b0,q
f 0,q   fs
2

• For an implementation of a 50Hz sawtooth frequency with a sampling frequency fs=1KHz on a 16 Bit DSP:

f0 50 Hz
b0  2   2  0,1
fs 1000 Hz
• The value 0,1 can be represented with a 16 Bit fix point DSP. The 16 Bit quantized value is:

b0,q  0,100.006.103.515.63
• For the resulting frequency we get:

f 0,q  50,003051757813

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-49


Prof. Dr.-Ing. Gangolf Hirtz
4.2 Signal generators
4.2.2 Rectangle generator
y[n] 1
• A rectangle signal with frequency f0 can be described
as:

y(t)  square(2    f 0  t, D)
t[ms ]
• The parameter D denotes the duty cycle (0 < D < 1).
• This time continuous signal can be transformed into a
time discrete rectangle signal: 1
T 1
y[n]  square(2    f 0  n  T, D) with D  1 T
T0 fs
• Such a rectangle signal can easily be derived from a y[n]
sawtooth signal x[n] with threshold S:

1 x[n]  S
y[n]  
1 x[n]  S
t[ms ]
• The threshold S can be defined by the sawtooth shape:

S  1 2  D
20 T0  (1  D)
• Possible applications are pulse wide modulation (PWM):
T1
D[m]  D0  k  x[m] T0

• The parameters D0 und k have to be chosen that way 20


that D[m] is in the range from 0 to 1.
Rectangle signal with fs=630Hz und T0=20ms
• x[m] is the modulating time discrete signal with
periodeT0.

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-50


Prof. Dr.-Ing. Gangolf Hirtz
4.2 Signal generators

4.2.3 Triangle signal generator x[n]


1
• A triangle signal generator can also be implemented
with help of a sawtooth generator.
– The integrator has to start with the initial condition
y[-1] = 0 t[ms ]
– Then the calculated output values are multiplied
with -1 in each second period.
• The period of the triangle signal is twice of the 1
sawtooth period.
• For the step height: y[n]
1
b0 2 f y (t )
  b0  4  0
T T0 fs
2
t[ms ]

1
1
T0 
f0

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-51


Prof. Dr.-Ing. Gangolf Hirtz
4.2 Signal generators
4.2.4 Sine wave generator

4.2.4.1 Filtering
• A sawtooth signal can be described as infinit5e series
8  1 1 
y[n]   sin  n  0   2 sin  3  n   0   2 sin  5  n   0  
2  
  3 5 

• This signal can easily be filtered, so that only the fundamental wave remains.

Y  e j 

H TP   

3  0 2  0 0 0 0 2  0 3 0 

Sine wave generation out of sawtooth signal

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-52


Prof. Dr.-Ing. Gangolf Hirtz
4.2 Signal generators
4.2.4.2 Direct Digital Synthesis DDS
• The functional values of the target function are
calculated and stored in a memory.
x[n]
• The values y[n] are directly read out from the
memory (Look-up table).
1

Address- Look-Up-
generation Table
t[ms ]

1

y[n]
1
y (t )

t[ms ]

1
1
T0 
f0

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-53


Prof. Dr.-Ing. Gangolf Hirtz
4.2 Signal generators
4.2.5 Polynomial approximation

• 4.2.5.1 Principle
• A lot of functions can be approximated by polynomials.

y  a 0  a1  x  a 2  x 2  aN  xN

The polynomial can be expressed as:

y  a N  x  a N 1   x  a N  2   x  a 0

N
 y   a i  xi
i 0

• The polynomial coefficients ai can be calculated with programs like MATLAB

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-54


Prof. Dr.-Ing. Gangolf Hirtz
4.2 Signal generators

• 4.2.5.2 Methodology polynomial approximation


• Data vector x
– The data vector x describes the values on the x-axis (abscissa).
– Since the fix point DSP calculates with finite number of digital values (e.g. 16 Bit) these x-values have to be
quantized.
o Example for a 4 Bit DSP and 5 x-values (basic values):
x  [1;  0,6;  0, 2; 0, 2; 0,6]
xq  [1;  0,625;  0, 250; 0250; 0,625]
• Calculation of functional vector
– The functional vector for the quantized x-vector is calculated as:
y  f ( xq )  sin(  xq ,i )  [0;  0,923879533;  0,707106781; 0,707106781; 0,923879533]

• Determination of polynomial coefficients on the exact theoretical values of the x-vector:


a  [a0 ; a1 ; a2 ; a3 ; a4 ; a5 ]

• Calculation of vector y1 and error vector e1:


y1  f ( xq )  sin(  xq ,i )
e1  y1  y

• Calculation of vector y2 which are the functional values calculated taking into account the quantization
effects of the target DSP and error vector e2:
y2  f ( xq ) q  sin(  xq ,i ) q
e2  y 2  y

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-55


Prof. Dr.-Ing. Gangolf Hirtz
4.2 Signal generators
Funktion an quantisierten Stützstellen Signal 2.m
4.2.5.3 Polynomial approximation of the sine-wave
1
function with 1000 basic values
• Processing steps as described: 0.5

y(xq)
 First, the polynomial to calculate the sine-wave function 0

is calculated (e.g with 8 coefficients N=7) -0.5

a  [0.4462;  0.0001; 2.4477; 0.0001; 5.1420;


-1
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1

0.0000; 3.1399; 0.0000]


xq pi
Approximierte Funktion
1

 As next step the error e1, which described the difference 0.5

between the target function (sine-wave) and the poly-

y1(xq)
0
nomial approximation is calculated: -0.5
o The errors e1 (also e2) are not sufficiently small -1
enough  more coefficients e.g. 12 (N=11) -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
xq pi
 The error e1 now with 12 coefficients is calculated again. -4
x 10 Fehler e1 mit 7 Koeffizienten x 10
-4
Fehler e2 auf DSP mit K=7
5 5
 Also the error e2 which describes the real error with
quantized values is acceptable small.
 The error e2 lies in the 16 Bit quantization noise

e1

e2
0 0

range, so that a further improvement by even more


coefficients is not possible anymore.
-5 -5
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
xq pi xq pi
-4 -4
x 10 Fehler e1 mit 11 Koeffizienten x 10 Fehler e2 auf DSP mit K=11
5 5
e1  [ 0.0060; 0.0000; 0.0804; 0.0001; 0.5983;  0.0001;
2.5499; 0.0000;  5.1677;  0.0000; 3.1416; 0.0000]
e1

e2
0 0

-5 -5
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
xq pi xq pi

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-56


Prof. Dr.-Ing. Gangolf Hirtz
4.2 Signal generators

4.2.5.4 Approximation of square root function Funktion an quantisierten Stützstellen Signal 3.m

y x x  [0;1[
1

0.8

y(xq)
0.6

0.4
• Processing of approximation method as
0.2
described:
0
– First an approximation with 6 basic values 0 0.1 0.2 0.3 0.4 0.5
xq pi
0.6 0.7 0.8 0.9 1

(N=5) doesn’t show sufficient results. Approximierte Funktion

1
– An coefficient increase to 11 coefficients does
0.8
also show no improvement as far as e1 and e2

y1(xq)
0.6
are concerned. 0.4

0.2

• Is there a possibility to describe the square root 0


0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
function by a polynomial approximation? xq pi
Fehler e1 mit 7 Koeffizienten Fehler e2 auf DSP mit K=7

0.04 0.04

e1

e2
0.02 0.02

0 0

0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1


xq pi xq pi
Fehler e1 mit 11 Koeffizienten Fehler e2 auf DSP mit K=11

0.04 0.04
e1

e2
0.02 0.02

0 0

0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1


xq pi xq pi

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-57


Prof. Dr.-Ing. Gangolf Hirtz
4.2 Signal generators

• A possibility is the limitation of the definition Funktion an quantisierten Stützstellen Signal 3.m

range: 1

y x x  [0, 25...1[ 0.8

0.6

y(xq)
0.4
• Such a limitation results in clearly improved
approximation results. 0.2

0
0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
• How can values, which are now excluded of xq pi

the definition range [0…0,25] , be calculated? Approximierte Funktion


 The answer is scaling of functional values: 1

y  x  2 L  22 L  x x  [0, 25...1] 0.8

y1(xq)
0.6

– The value under the square root is enlarged 0.4

by a value 22L (power of 2) while after 0.2


calculation of the root function the function
0
is de-scaled with 2-L. 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
xq pi
– Those functions cans easily be implemented
-4 -4
Fehler e1 mit 5 Koeffizienten Fehler e2 auf DSP mit K=5
by shift left and shift right operations. 5
x 10
5
x 10

• Now the value under the root can be


increases, so that it’s no more in the excludede
definition range.
e1

e2
0 0

-5 -5
0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.3 0.4 0.5 0.6 0.7 0.8 0.9
xq pi xq pi

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-58


Prof. Dr.-Ing. Gangolf Hirtz
4.2 Signal generators

4.2.6 Instable digital filter as sine wave generator Im  z 1


4.2.6.1 Implementation
• System function of a 2nd order IIR filter:
b0  b1  z 1
H ( z)  x
1  a1  z 1  a2  z 2
• With the coefficients: 1 0 1
o
b0  sin( ); b1  sin  0    0 Re  z
a1  2  cos  0 

– 0: circular frequency of oscillator normalized to the sampling


x
frequency.
– : Start phase of oscillator frequency
• A LTI system with two conjugate complex poles on the imaginary axis 1
oscillates stimulated with a Dirac input signal:
• The impulse response is (see next page):
b0
h[n]  u[n]  sin  0  n    +
 [ n] h[n]
1 1 1
b0  b1  z b b z 1 b0  b1  z 1 Z-1 Z-1
H ( z)   20 1  2   2
1
1  a1  z  a2  z 2
z  a1  z  a2 z  z  zP1    z  zP1  z
*
b1  a1
+
b0  b1  z 1 1
 2  2
z   z P1  z P1   z  z P1  z P1 z
* *

Z-1
b0  b1  z 1
b0  b1  z 1 1
 
1   zP1  zP* 1   z 1  z P1  z P* 1  z 2 1  2cos(0 )  z 1  1  z 2

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-59


Prof. Dr.-Ing. Gangolf Hirtz
4.2 Signal generators
• A LTI system with a sine-wave input signal answers with a sine-wave output signal with same frequency but different
magnitude and phase.
• LTI-system:

H  e j   H  e j   e
 
jH e j

• In and output signal:

f
x[n]  sin    n    2  
fS

 y[n]  H  e j   sin   n  H  e j  
• For a dirac input signal and a sine-wave output signal:
x[n]   [n]  y[n]  h[n]  u[n]  sin( 0  n   ) mit   0

sin  2    f 0  n  T   z 1 b0  b1  z 1
H z  
1  2  cos  2    f 0  n  T   z 1  z 2 1  a1  z 1  a2  z 2

h[n] H ( z) Konvergenz
sin  2    f 0  n  T   z 1
u[n]  sin  2    f 0  n  T  1  2  cos  2    f 0  n  T   z 1  z 2
z 1

u[n]  cos  2    f 0  n  T  1  cos  2    f 0  n  T   z 1


z 1
1  2  cos  2    f 0  n  T   z 1  z 2

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-60


Prof. Dr.-Ing. Gangolf Hirtz
4.2 Signal generators

• Considering the fractional number format of the DSP, then the magnitude of
the coefficients must be less than one. x[n]  b0Q   [n]  b1Q   [n  1]
– The coefficients b0 and b1 are less than one anyhow and just have to be
quantizedb0Q and b1Q .
+
– The coefficients a1 and a2 are scaled, since a1 normally is in the range y[n]
from -1 to -2. Z-1
– Therefore also a2 (-1) is scaled  a1Q and a2Q . 2L
a1Q  2 L
– The scaling factor chosen is normally a power of two.
+
• When as input signal, instead of a Dirac impulse, x[n] is chosen:
x[n]  b0Q   [n]  b1Q   [n  1]
Z-1

then the simplified diagram (figure right) is obtained.


• The difference equation (index aq means quantized): 1 2 L

y[0]  b0 q
y[1]  b1q  2 L   a1q  2 L   y[0]
y[n]  2 L   a1q  2 L   y[n  1]  2 L  y[n  2]; n  2

• The oscillator frequency is given by:

2    f0 arccos  a1q / 2 
0   f0  f S 
fS 2 

• To avoid two’s complement overflow, a saturation function must be


implemented in the DSP  nonlinear system.

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-61


Prof. Dr.-Ing. Gangolf Hirtz
4.3 Annex

4.3.2 Bibiography

[1] Daiel Ch. Von Grüningen. Digitale Signalverarbeitung.Fachbuchverlag Leipzig, 2004.


[2] Donal E. Knuth. The Art of Computer Programming, Seminumerical Algorithms. Addison-Weesly Publishing Co.
1998.

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-62


Prof. Dr.-Ing. Gangolf Hirtz
4.2 Signal generators

END

Professur Digital- und Schaltungstechnik Realization of Digital Systems 4-63


Prof. Dr.-Ing. Gangolf Hirtz