An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136...

136
Page 1 of 136 An Illustration of Digital Signal Processing using mentorDSP Etienne Sicard October 2008 http://www.etienne-sicard.fr/mentordsp http://www.mentordsp.com

Transcript of An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136...

Page 1: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 1 of 136

An Illustration of Digital Signal Processing using

mentorDSP

Etienne Sicard

October 2008

http://www.etienne-sicard.fr/mentordsp

http://www.mentordsp.com

Page 2: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 2 of 136

About the Author

Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical Engineering from the University of Toulouse, France, in 1987. He stayed 18 months at Osaka University, Japan, and one year as an invited professor at the University of Balearic Islands, Spain. Etienne SICARD is currently a professor at INSA of Toulouse, Department of Electrical and Computer Engineering, part of the University of Toulouse, France. He was a visiting professor at the electronic department of Carleton University, Ottawa, Canada in 2004. His research interests include several aspects of CAD tools for the design and electromagnetic compatibility of integrated circuits, as well as signal processing applied to speech therapy. He is the author of 15 books, 10 commercial software and more than 100 technical papers in these areas. Etienne is a member of the SEE society and a senior member of the IEEE. He was elected for 2006 -2007 distinguished IEEE lecturer for EMC of ICs. About ni2designs, India Ni2designs is a recognized name in EDA software solution providing fraternity. Empowered by the state-of-the-art technologies and a team of highly qualified professionals, ni2designs offers best-of-breed EDA solutions that enable designers to fully realize their job. Mentor DSP package has been envisioned and developed by technical wizards of ni2designs, in joint collaboration with research from Prof. Etienne Sicard, INSA, University of Toulouse, France. ni logic Pvt. Ltd., 21/22, Bandal Dhankude Plaza, Opp. PMT Depot, Paud Road, Kothrud, Pune - 411 038, Maharashtra, India. Tele-Fax: +91 - 20 - 2528 6947 /48 E-mail: [email protected] Website : www.mentordsp.com About ni2designs, India © Copyright 2007-2008 by INSA, University of Toulouse, FRANCE ISBN 978-2-87649-054-3 Dépot legal: Décembre 2008 Edited by INSA Toulouse, France, University of Toulouse, 135 Av de Rangueil, 31077 Toulouse - France

Page 3: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 3 of 136

Table of Contents 1 Getting Started......................................................................................................................................3

1.1 Install MentorDSP .........................................................................................................................3 1.2 Starting MentorDSP ......................................................................................................................3 1.3 Getting Started - Sinusoidal Wave ................................................................................................3 1.4 Real-Time Spectrogram ................................................................................................................3 1.5 Getting Started - Real-Time Filtering .............................................................................................3

2 Basic Theory.........................................................................................................................................3 2.1 Illustration of Sampling theorem....................................................................................................3

2.1.1 User’s Interface .....................................................................................................................3 2.1.2 Short-cut................................................................................................................................3 2.1.3 Step-by-step procedure .........................................................................................................3

2.2 Illustration of ADC/DAC.................................................................................................................3 2.2.1 User’s Interface .....................................................................................................................3 2.2.2 Short-cut................................................................................................................................3 2.2.3 Step-by-step procedure .........................................................................................................3

2.3 Aliasing and its effects...................................................................................................................3 2.3.1 User’s Interface .....................................................................................................................3 2.3.2 Short-cut................................................................................................................................3 2.3.3 Step-by-step procedure .........................................................................................................3

2.4 Illustration of coding schemes .......................................................................................................3 2.4.1 Main Screen ..........................................................................................................................3 2.4.2 Main features:........................................................................................................................3 2.4.3 Theory...................................................................................................................................3 2.4.4 Integer Format.......................................................................................................................3 2.4.5 Fixed Point Format ................................................................................................................3 2.4.6 Float Point Format.................................................................................................................3 2.4.7 Short-cut................................................................................................................................3 2.4.8 Step-by-step procedure .........................................................................................................3

2.5 Reference: ....................................................................................................................................3 3 Fourier Transform .................................................................................................................................3

3.1 Illustrate the energy/power on a periodic signal.............................................................................3 3.1.1 Theory...................................................................................................................................3 3.1.2 User’s Interface .....................................................................................................................3 3.1.3 Shortcut.................................................................................................................................3 3.1.4 Step-by-step procedure .........................................................................................................3

3.2 Speech and formants. Periodicity in vowels ..................................................................................3 3.2.1 Theory...................................................................................................................................3 3.2.2 User’s Interface .....................................................................................................................3 3.2.3 Shortcut.................................................................................................................................3 3.2.4 Step-by-step procedure .........................................................................................................3 3.2.5 Reference:.............................................................................................................................3

3.3 Illustration of basic signals ............................................................................................................3 3.3.1 User’s Interface .....................................................................................................................3 3.3.2 Short Cut ...............................................................................................................................3 3.3.3 Practical Training:..................................................................................................................3 3.3.4 Other examples: ....................................................................................................................3

3.4 Random signals properties............................................................................................................3 3.4.1 Theory...................................................................................................................................3 3.4.2 User’s Interface .....................................................................................................................3 3.4.3 Short-Cut...............................................................................................................................3 3.4.4 Step-by-Step Procedure ........................................................................................................3

3.5 Random signals properties............................................................................................................3 3.5.1 Theory...................................................................................................................................3 3.5.2 Short-Cut...............................................................................................................................3 3.5.3 Step-by-Step Procedure ........................................................................................................3

4 Convolution...........................................................................................................................................3 4.1 Illustrate the convolution principles................................................................................................3

4.1.1 Theory...................................................................................................................................3

Page 4: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 4 of 136

4.1.2 Main features:........................................................................................................................3 4.1.3 Short-cut................................................................................................................................3 4.1.4 Step-by-step procedure .........................................................................................................3

4.2 Illustrate auto-correlation with sound for fundamental freq. extraction ...........................................3 4.2.1 Theory...................................................................................................................................3 4.2.2 Features ................................................................................................................................3 4.2.3 Short-Cut...............................................................................................................................3 4.2.4 Step-by-step procedure .........................................................................................................3

4.3 Illustrate correlation on image recognition .....................................................................................3 4.3.1 Theory...................................................................................................................................3 4.3.2 User’s Interface .....................................................................................................................3 4.3.3 Main Features .......................................................................................................................3 4.3.4 Short-cut................................................................................................................................3 4.3.5 Step-by-step procedure .........................................................................................................3

4.4 Illustrate Correlation on Noisy signal .............................................................................................3 4.4.1 Theory...................................................................................................................................3 4.4.2 Features ................................................................................................................................3 4.4.3 Short-Cut...............................................................................................................................3 4.4.4 Practical Training:..................................................................................................................3

5 Fourier Transform .................................................................................................................................3 5.1 Tutorial on Fourier series ..............................................................................................................3

Theory ..................................................................................................................................................3 User’s Interface.....................................................................................................................................3 Short-cut ...............................................................................................................................................3 Step-by-step procedure ........................................................................................................................3

5.2 Tutorial on invert Fourier transform, reconstruction .......................................................................3 Theory ..................................................................................................................................................3 User’s Interface.....................................................................................................................................3 Short-Cut ..............................................................................................................................................3 5.2.1 Step-by-step procedure .........................................................................................................3

5.3 Tutorial on Windowing...................................................................................................................3 5.3.1 Theory...................................................................................................................................3 5.3.2 User’s Interface .....................................................................................................................3 5.3.3 Features ................................................................................................................................3 5.3.4 Short Cut ...............................................................................................................................3 5.3.5 Step-by-step procedure .........................................................................................................3

5.4 Performance of FFT : real time, change parameters .....................................................................3 5.4.1 User’s Interface .....................................................................................................................3 5.4.2 Features ................................................................................................................................3 5.4.3 Short Cut ...............................................................................................................................3 5.4.4 Step-by-step procedure .........................................................................................................3

6 Filtering.................................................................................................................................................3 6.1 Fundaments on Discrete systems .................................................................................................3

Theory ..................................................................................................................................................3 User’s Interface.....................................................................................................................................3 Features ...............................................................................................................................................3 Short Cut ..............................................................................................................................................3 Step-by-step procedure ........................................................................................................................3

6.2 Finite Response Filter Design .......................................................................................................3 6.2.1 Theory...................................................................................................................................3 6.2.2 User’s Interface .....................................................................................................................3 6.2.3 Features ................................................................................................................................3 6.2.4 Short Cut ...............................................................................................................................3 6.2.5 Step-by-step procedure .........................................................................................................3

6.3 Infinite Response Filter Design......................................................................................................3 6.3.1 Theory...................................................................................................................................3 6.3.2 User’s Interface .....................................................................................................................3 6.3.3 Features ................................................................................................................................3 6.3.4 Short Cut ...............................................................................................................................3 6.3.5 Step-by-step procedure .........................................................................................................3

Page 5: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 5 of 136

6.3.6 References............................................................................................................................3 6.4 Illustrate FIR on low-pass filter ......................................................................................................3

6.4.1 Theory...................................................................................................................................3 6.4.2 User’s Interface .....................................................................................................................3 6.4.3 Features ................................................................................................................................3 6.4.4 Short Cut ...............................................................................................................................3 6.4.5 Step-by-step procedure .........................................................................................................3

6.5 Illustrate IIR on Speech filtering.....................................................................................................3 6.5.1 Theory...................................................................................................................................3 6.5.2 User’s Interface .....................................................................................................................3 6.5.3 Shortcut.................................................................................................................................3 6.5.4 Practical Training:..................................................................................................................3 6.5.5 Reference:.............................................................................................................................3

6.6 Echo Generation ...........................................................................................................................3 6.6.1 Theory: ..................................................................................................................................3

1000]-x[nx[n]*0.51000]-y[n*-0.5Y[n] ++= .................................................................................3 6.6.2 User’s Interface .....................................................................................................................3 6.6.3 Short-Cut...............................................................................................................................3 6.6.4 Practical Training:..................................................................................................................3 6.6.5 Step-by-step procedure .........................................................................................................3

6.7 Dual-tone multi-frequency (DTMF) identification............................................................................3 6.7.1 Theory: ..................................................................................................................................3 User’s Interface.....................................................................................................................................3 Short Cut ..............................................................................................................................................3 Step-by-step procedure ........................................................................................................................3

7 Image ...................................................................................................................................................3 7.1 Play with image properties ............................................................................................................3

7.1.1 Theory...................................................................................................................................3 7.1.2 Short-Cut...............................................................................................................................3 7.1.3 User’s Interface .....................................................................................................................3 7.1.4 Practical Training:..................................................................................................................3 7.1.5 Step-by-step procedure .........................................................................................................3 7.1.6 Reference:.............................................................................................................................3

7.2 Image Histograms.........................................................................................................................3 7.2.1 Theory: ..................................................................................................................................3 7.2.2 User’s Interface .....................................................................................................................3 7.2.3 Short-Cut...............................................................................................................................3 7.2.4 Practical Training:..................................................................................................................3 7.2.5 Step-by-step procedure .........................................................................................................3 7.2.6 References............................................................................................................................3

7.3 Discrete Cosine Transform............................................................................................................3 7.3.1 Theory...................................................................................................................................3 7.3.2 User’s Interface .....................................................................................................................3 7.3.3 Short-cut................................................................................................................................3 7.3.4 Practical Training:..................................................................................................................3 7.3.5 Step-by-step procedure .........................................................................................................3

7.4 Free picture transform...................................................................................................................3 7.4.1 Theory...................................................................................................................................3 7.4.2 Proposed GUI........................................................................................................................3 7.4.3 Features ................................................................................................................................3 7.4.4 Short-cut................................................................................................................................3 7.4.5 Practical Training:..................................................................................................................3 7.4.6 Reference:.............................................................................................................................3

7.5 Image Noise..................................................................................................................................3 7.5.1 Theory: ..................................................................................................................................3 7.5.2 User’s Interface .....................................................................................................................3 7.5.3 Short-Cut...............................................................................................................................3 7.5.4 Practical Training:..................................................................................................................3 7.5.5 Step-by-step procedure .........................................................................................................3

8 Modulation ............................................................................................................................................3

Page 6: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 6 of 136

8.1 Illustrate Amplitude Modulation .....................................................................................................3 8.1.1 Theory...................................................................................................................................3 8.1.2 User’s Interface .....................................................................................................................3 8.1.3 Short-Cut...............................................................................................................................3 8.1.4 Practical Training:..................................................................................................................3 8.1.5 Step-by-step procedure .........................................................................................................3

8.2 Illustrate Frequency Modulation ....................................................................................................3 8.2.1 Theory...................................................................................................................................3 8.2.2 User’s Interface .....................................................................................................................3 8.2.3 Short-Cut...............................................................................................................................3 8.2.4 Practical Training:..................................................................................................................3 8.2.5 Step-by-step procedure .........................................................................................................3 8.2.6 References: ...........................................................................................................................3

8.3 Illustrate Quadrature Phase Shift Keying.......................................................................................3 8.3.1 Theory...................................................................................................................................3 8.3.2 User’s Interface .....................................................................................................................3 8.3.3 Short-Cut...............................................................................................................................3 8.3.4 Practical Training:..................................................................................................................3 8.3.5 Step-by-step procedure .........................................................................................................3 8.3.6 References: ...........................................................................................................................3

8.4 Illustrate Gaussian Modulated Shift Keying ...................................................................................3 Theory ..................................................................................................................................................3 User’s Interface.....................................................................................................................................3 Short-Cut ..............................................................................................................................................3 Practical Training: .................................................................................................................................3 Step-by-step procedure ........................................................................................................................3 References: ..........................................................................................................................................3

8.5 Illustrate Code-Division-Multiple-Access (CDMA)..........................................................................3 8.5.1 Theory...................................................................................................................................3 8.5.2 8-bit codes example ..............................................................................................................3 8.5.3 User’s Interface .....................................................................................................................3 8.5.4 Short-Cut...............................................................................................................................3 8.5.5 Practical Training:..................................................................................................................3 8.5.6 Step-by-step procedure .........................................................................................................3 8.5.7 References: ...........................................................................................................................3

8.6 Illustrate Orthogonal Frequency-Division Multiplexing (OFDM) .....................................................3 8.6.1 Theory...................................................................................................................................3 8.6.2 User’s Interface .....................................................................................................................3 8.6.3 Short-Cut...............................................................................................................................3 8.6.4 Practical Training:..................................................................................................................3 8.6.5 Step-by-step procedure .........................................................................................................3 8.6.6 References: ...........................................................................................................................3

9 Questions and Answers ........................................................................................................................3 9.1 Exercise : Fourier Transform – Resolution ....................................................................................3 9.2 Fourier Transform – 2 pics ............................................................................................................3 9.3 Exercise : Fourier Transform – Square Signal...............................................................................3

10 Appendix...........................................................................................................................................3 10.1 Signal Processing Fundaments used in MentorDSP .....................................................................3

Page 7: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 7 of 136

1 Getting Started

1.1 Install MentorDSP

The MentorDSP software is available for download from www.mentordsp.com .

1.2 Starting MentorDSP

Double click the MentorDSP icon or click “MentorDSP.EXE”.

The following screen appears:

Fig. 1 : Information screen

Click “Here to Start”. The following screen appears. The main tools of MentorDSP are accessible on the left part of the screen (SigGen, DSPpro, Numpro, DSPbase, MathStat, ImageSee and ComPro). A list of chapters is proposed on the right part of the screen. It includes topics such as “Basic Theory”, “Fourier Transform”, “Convolution”, “Filtering”, “Modulation” and “Image Processing”. Double-Click “Getting Started”.

Fig. 2 : Main chapters

Page 8: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 8 of 136

1.3 Getting Started - Sinusoidal Wave

Click in “Getting Started”, and then double-Click “Sinusoidal Wave”. The screen is organized in two parts. The upper part includes the representation of a sinusoidal wave at a 1000 Hz default frequency. The lower part is the result of the Fourier Transform, in frequency domain. We observe a peak at 1000 Hz, as expected. Click “Close”.

Fig. 3 : Fourier Transform of a 1000 Hz Sinusoidal waveform

1.4 Real-Time Spectrogram

Double click “Real-Time Spectrogram”. Pronounce vowels likes [a] [i][u] [e] [o] and see in real time the distribution of the frequency-domain components (Y Axis) during the time (X Axis). The red-white color corresponds to a high energy. The blue-green color corresponds to a low energy.

Fig. 4 : Real-time spectrogram showing the time-domain evolution of voice properties vs. frequency (bottom)

Page 9: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 9 of 136

1.5 Getting Started - Real-Time Filtering

Double click “Getting Started - Real-Time Filtering”. The upper screen includes (Fig. 5) the sound as captured by the microphone. The lower screen is the Fourier Transform of that sound, with or without filtering. Click “Close”.

Fig. 5 : Sound capture (top) and Instant Fourier Transform (bottom)

Click on one of the icons “Low-Pass”, “High-pass”, “Band-pass” or “Band-stop” and click “Generate”. The coefficients corresponding to the IIR filter are computed and applied to the real-time sound. The resulting signal is converted in real-time in frequency domain by applying a Fourier Transform and displayed in the spectrogram.

Fig. 6 : Filter synthesis menu used for real-time filtering of sound

Page 10: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 10 of 136

2 Basic Theory

2.1 Illustration of Sampling theorem

Lab practical 2.1 Illustration of Sampling theorem Objectives Illustrate how change in sampling frequency affects the sampled signal

spectra and how the signals are reconstructed. Method Displays the original signal and a re-sampled signal. The user can change

the re-sampling frequency to see how the signal is reconstructed. Module dspBase

2.1.1 User’s Interface

2.1.2 Short-cut

2.1.3 Step-by-step procedure Step Description Comment 1 Click “Basic Theory”→ “Sampling Theorem”. The upper screen shows

a 100 Hz sinusoidal wave. The lower screen shows the same signal with around 4 samples per period. The vertical red bars in the upper window indicate the sampling intervals.

By default a sinusoidal wave appears (Frequency 100 Hz)

Page 11: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 11 of 136

2 Modify the cursor “Sampling Frequency” and ask for a higher

sampling rate.

This change the time step used to sample the upper signal into the lower signal.

3 Click “Capture Microphone”. See the real-time capture of the sound

and the effect of sampling on the lower curve. Suggestions : Find the maximum frequency in the audio signal and suggest the sampling frequency

4 Click “Spectrogram”. See how a low sampling rate induces numerical noise. The correct spectrogram is the one on the right, with the highest sampling rate and the lowest numerical noise.

5 Hear the difference between signals; Click “Play 1” to hear the original signal and “Play 2” to hear the low-sampling rate signal.

Page 12: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 12 of 136

2.2 Illustration of ADC/DAC

Lab practical 2.2 Illustration of ADC/DAC Objectives Illustrate how a change in resolution affects the sampled signal and how

the signals is degraded. Method The upper screen contains the orginal signal, the lower screen the lower-

resolution signal. Module DspBase

2.2.1 User’s Interface

2.2.2 Short-cut

2.2.3 Step-by-step procedure Step Description Comment 1 Click “Basic Theory”→ “Illustration of ADC/DAC”.

The lower signal is a 4-bit sampled version of the upper signal.

By default a sinusoidal wave appears (Frequency 440 Hz, duration 0,5 s)

2 In the time sub-menu, choose the dot version to see the curve as a set of sampled points. The lower curve is approximated in a 4-bit format, i.e 16 different values from -1.0 to +1.0.

Page 13: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 13 of 136

Shows the signal as a series of

sampled points

Shows the signal as a continuous

wave

3 Modify the resolution to 2 bits.

This changes the vertical resolution of the signal

4 Click “Play 1” to hear the original signal (32-bit resolution) and “Play 2” to hear its low-resolution version

5 Click “Capture Microphone”. See the real-time capture of the sound and the effect of sampling on the lower curve.

Page 14: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 14 of 136

2.3 Aliasing and its effects

Lab practical 2.3 Aliasing and its effects Objectives Illustrate in 2D the effect of chirp signals Method audio signal from 200 Hz to 11025 Hz, equal to the default sampling rate Module DSP Base

2.3.1 User’s Interface

2.3.2 Short-cut

2.3.3 Step-by-step procedure Step Description Comment 1 Click “Basic theory – Aliasing” 2 The generator window proposes a chirp signal

(200 -> 11025 Hz).

The end frequency is equal to the default sampling frequency

3 Click “Generate”. The time-domain aspect appears on the upper screen. The spectrogram is

The aliasing effect appears in the right part of the spectrogram

Page 15: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 15 of 136

computed in the lower part of the screen. : apparent frequency decreases rather than increasing

4 Hear the result. Click “Play 1”. The frequency increases and then decreases.

5 Observe the curve waveform around Fe/2.

Put in sample mode

Zoom at a large scale

Shift right or left

Here, each sample is equal to half the period

At half of the signal, the period is Fe/2 that is 5500 Hz. Each period is sampled using two points. The signal looks constant.

5 Click “Generate” in the tool menu; decrease the upper frequency of the chirp signal until aliasing disappears.

The end frequency should be up to half the default sampling frequency

Page 16: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 16 of 136

2.4 Illustration of coding schemes

Lab practical 2.4 Illustration of coding schemes Objectives Fixed point format, floating point format illustrat ion Method Dedicated screen for playing with these concepts Hardware Illustration of fixed point in DSP (rounding, satur ation, varying resolution

format); also illustrates floating point.

2.4.1 Main Screen

2.4.2 Main features:

• Generation of a real, binary, hexadecimal, fixed-point and floating-point number • Varying precision 4 to 16 bits • Saturation : on/off, see difference with and without

2.4.3 Theory The two classes of data formats are the integer and real numbers (Figure xxx). The integer type is separated into two formats: unsigned format and signed format. The real numbers are also sub-divided into fixed point and floating point descriptions. Each data is coded in 8,16 or 32 bits. In particular cases, other formats are used, such as the exotic 24 bit in some optimized applications, such as in application-specific digital signal processors.

Fixed point Floating point

Integer

8 bits 16 bits 32 bits

Real numbers

Unsigned Signed

8 bits 16 bits 32 bits

16 bits 24 bits 32 bits

32 bits

Figure 2-4-1: Most common data formats used in ASIC designs

2.4.4 Integer Format A summary of integer formats is reported in table 2-4-1. The signification of each bit is given in figure 2-4-2. The unsigned integer format is simply the series of power of 2. As an example, the number 01101011 corresponds to 107, as detailed in equation 2-4-1.

1071283264021232526201101011 =++++=++++= (Equ. 2-4-1)

Page 17: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 17 of 136

Type Size

(bit) Usual name Range

Unsigned integer 8 Byte 0..255 16 Word 0..65535 32 Long word 0..4294967295 Signed integer 8 Short integer -128..+127 16 Integer -32768..+ 32767 32 Long integer -2147483648..+ 2147483647

Table 2-4-1: Size and range of usual integer formats

26 25 24 23 20

20 = 1 21 = 2 22 = 4

23 = 8

24 = 16

25 = 32

26 = 64 27 = 128 …. 210 = 1024 215 = 32768 220 = 1048576 230 = 1073741824 231 = 2147483648

Unsigned integer, 8 bit

27 22 21

214 213 24 23 .... 20

Unsigned integer, 16 bit

215 22 21

230 229 24 23 .... 20

Unsigned integer, 32 bit

231 22 21 ..

Figure 2-4-2: Unsigned integer format

26 25 24 23 20

20 = 1 21 = 2 22 = 4

23 = 8

24 = 16

25 = 32

26 = 64 27 = 128 …. 210 = 1024 215 = 32768 220 = 1048576 230 = 1073741824 231 = 2147483648

Signed integer, 8 bit format

-27 22 21

214 213 24 23 .... 20

Signed integer, 16 bit format

-215 22 21

230 229 24 23 .... 20

Signed integer, 32 bit format

-231 22 21 ..

Figure 2-4-3: Signed integer format

The signed integer format uses the left-most bit for the sign. The coding of the data works as for the unsigned integer, except that the left-most bit accounts for a negative number. In 16 bit format, a 1 in the sign bit equals to -32768. As As an example, the 8-bit signed number 11101011 is detailed in equation 2-4-22. The sign bit appears in the sum as -128, all the other bit remaining positive.

21128326412802123252627211101011 −=+++++−=+++++−= (Equ. 2-4-2)

2.4.5 Fixed Point Format A second important class of numbers is the real format. In digital signal processing, real numbers are often implemented as fixed point numbers. The key idea is to restrict the real numbers within the range [-1.0..+1.0] and to use arithmetic hardware that is compatible with integer hardware. A summary of real formats is reported in table 2-4-3.

Page 18: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 18 of 136

Type Size (bit) Usual name Range Fixed point 16 Fixed -1.0..+1.0 (Minimum 0.00003) 32 Double

fixed - 1.0..+1.0 (Minimum 0.00000000046)

Table 2-4-3: Size and range of usual real formats

Fixed point

2-1 2-2 2-3 2-4 2-5 2-6 .. .. 2-15 -2-0

2-0 = 1.0 2-1 = 0.5 2-2 = 0.25

2-3 = 0.125

2-4 = 0.0625

2-5 = 0.03125

2-6 = 0.015625 …. 2-15 = 0.000030517578125 2-31 = 0.0000000004656

Fixed point, 16 bit

2-1 2-2 2-3 2-4 2-5 2-6 .. .. 2-31-2-0

Fixed point, 32 bit

2-30

Figure 2-4-4: Fixed point numbers in 16 and 32 bit format

In the case of fixed point arithmetic, we read bits as fractions in negative power of 2 (Example of equation 7-3). When the left-most bit is set to 1, it accounts for -1.0 in the addition (Equation 2-4-3). The main limitation of this format is its limited range from -1.0 to 1.0. Its main advantage is a hardware compatibility with integer circuits, leading to low power computing, a particularly attractive feature for embedded electronics. As an example, most digital signal processing of mobile phones work in fixed point arithmetic.

78125.003125.025.05.052221201100100 =++=−+−+−= (Equ. 2-4-3)

-0.2187503125.025.05.00.15222120211100100 =+++−=−+−+−+−= (Equ. 2-4-5) The DSP engine of the dsPIC33F works in a fixed-point 16-bit format.

2.4.6 Float Point Format IEEE Standard 754 floating point is the most common representation for real numbers on most Windows and Unix platforms. Floating-point representation basically represents reals in scientific notation. Scientific notation represents numbers as a base number and an exponent. Floating-point employs an exponent of precision appropriate to the scale of the number. This allows to represent very small numbers like -5.8e-39 and very large numbers, like 3.4e38. The floating point number x is composed of the sign (S=+/- 1), the exponent E and the fraction F. The general formulation of the real number format, according to IEEE 754 is as follows:

biasEFSx −××= 2).1(

12 1 −= −Nbias N=exponent size (8 for single-precision floating numbers)

Sign bit Fraction (23 bits)

20 2-1 2-2 2-3 2-4 2-5 .. 2-22 S .. 22 21 20 2N

E=Exponent (N=8 bit)

0 22 23 30 31

Figure 2-4-5: Floating point arithmetic format

Page 19: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 19 of 136

Exponents have to be signed values in order to be able to represent both tiny and huge values. In 32-bit format, the exponent is biased by 127 before being stored. Its value is adjusted to put it within an unsigned range suitable for comparison. For example, to represent a number which has exponent of 15, E is 15+127= 142. The summary table with some example 32-bit single-precision examples is reported in Table 2-4-4. Three special cases arise: - if Exponent is 0 and Fraction is 0, the number is ±0, depending on the sign bit - if Exponent = 255 and Fraction is 0, the number is ±infinity, noted “INF” in MentorDSP - if Exponent = 255 and Fraction is not 0, the number being represented is called “Not-A-Number” (NaN).

Value Sign (1 bit)

Exponent (8 bit)

Significand (23 bit)

0.0 0 0000 0000 000 0000 0000 0000 0000 0000

1.0 0 0111 1111 000 0000 0000 0000 0000 0000

-1.0 1 0111 1111 000 0000 0000 0000 0000 0000

10.0 0 1000 0010 010 0000 0000 0000 0000 0000

-10.0 1 1000 0010 010 0000 0000 0000 0000 0000

0.5 0 0111 1110 000 0000 0000 0000 0000 0000

Infinity Infinity 1111 1111 000 0000 0000 0000 0000 0000

NaN NaN 1111 1111 non zero

Table 2-4-4: Size and range of usual real formats The PIC24, dsPIC30F and dsPIC33FJ are 16-bit chips that do not have floating point in them. The floating point is emulated IEEE-754 and is represented by functions from the math library, libm, and helper functions called by the compiled C code, such as floating add, subtract, multiply and divide.

2.4.7 Short-cut

Page 20: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 20 of 136

2.4.8 Step-by-step procedure

Step Description Comment 1 Click “Basic theory – Data Coding” 2 The generator window proposes various versions of

number 1.0 The fixed-point value is out of the boundaries, which induces a small error.

3 In the upper menu, enter a new value for X “0.5”. Click “Real to Hexa”. The result is 0 as the hexadecimal format only works on integers. Click “Real to Fixed”. The result is 010000.. as the second most significant bit counts as 0.5. Click “Real to Float”.

The best exponent is -1 (coded with a bias of 127, which leads to 126, i.e 011111110). The fraction is 0, the mantissa is 1.0+0 that is 1.0. This leads to 1.0*2**(-1)

4 Double click in the bits of the hexa array and see the result in terms of value.

5 Double click in the bits of the fixed array to see the sign bit effect, and the fractions: 0.5 0.25 0.125 Try to get 0.78125 as detailed in the equation above.

6 Go through the examples shown in the table above (-1.0; -10.0; 10.0) and see how the IEEE 754 format operates.

7 Change the format to 4b, 8b, or 32b and see how the precision is affected.

IEEE 754 is fixed to single precision (8-bit for exponent, 23-bit for fraction, 1 bit for sign)

8 Verify that putting zero everywhere in the float array leads to 0. Try to generate “NaN” and “Infinity” according to table xxx. Click the desired bits in the Exponent and Mantissa, and observe the result.

2.5 Reference:

Page 21: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 21 of 136

- IEEE Computer Society (1985), IEEE Standard for Binary Floating-Point Arithmetic, IEEE Std 754-1985. http://standards.ieee.org

- RACFP, A training Tool to Work With Floating Point Representation, IEEE Trans Education, Vol 49, N°3 , Aug 2006

Page 22: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 22 of 136

3 Fourier Transform

3.1 Illustrate the energy/power on a periodic signa l

Lab practical 3.1 Illustrate the energy/power on a periodic signal Objectives Validate by examples the computation of average, energy and power Method Specify a window in which you want to compute the average, energy, and power. Verify

by theory the values extracted by the software. Validate the trigonometric equivalences used to compute the integrals.

Module DSPBase, SigGEN

3.1.1 Theory

Signal Average ∫≡0

00

1 Tdt).t(x

T)t(x

Signal Energy ∫+∞

∞−≡ dt)t(xE

2

Average Power ∫+

≡0 2

0

1 Tt

tdt)t(x

TP

3.1.2 User’s Interface

3.1.3 Shortcut

Page 23: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 23 of 136

3.1.4 Step-by-step procedure Step Description Comment 1 Click “Basic theory – Energy, Power” By default, a 1000 Hz

sinusoidal wave appears. 2 Click the mouse close to (0,0) and release the mouse near the

intersection between the X axis and the signal, corresponding to one period of sinusoidal wave.

(1) Click the mouse here, keep pressed

(2) Release the mouse here

Start marker Stop marker

One period

3 The evaluation of different basic parameters is given in the menu “Time”:

The small mismatch between theory and simulation is due to the small number of samples with which the sinusoidal wave is described. As the sampling frequency Fe is 11025 Hz, the sinusoidal wave is describe using 11 points.

In theory (see below) - the average should be 0.0 - the energy should be 5e-4 - the power should be 0.5 - the period should be 1.0 ms - the frequency should be 1 KHz

4 Check the formulation used in the integral.

2

)2cos(1)sin( 2 A

A−=

Click “Signal Generator”, click “Equation” and enter “sin(2*pi*100*t)* sin(2*pi*100*t) ” for example. Click “-> 1 – Up” and then “Generate”. The signal is displayed in the upper curve.

Page 24: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 24 of 136

5 Click “Signal Generator”, click “Equation” and enter “(1-cos(2*pi*200*t))/2 ”. Click “-> 2 – Down” and then “Generate”. The signal is displayed in the lower curve.

6 Use the X scale icons of the “time” sub-menu to verify that the two signals are identical.

Signal Energy :

∫∫ =≡TT

dttdttxE0

2

0

2)10002sin()( π

[ ] 0005.0)20002sin(20004

1

22

)20002cos(1 001.00

001.0

0

001.0

0=−

=−

= ∫ tt

dtt

E ππ

π

Signal Power

5.0001.0

1)(

10

2 ==≡ ∫ EdttxT

PT

Page 25: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 25 of 136

3.2 Speech and formants. Periodicity in vowels

Lab practical 3.2 Speech and formants. Periodicity in vowels. Objectives Illustrate speech contents. Periodicity of vowels, a-periodicity of consonant Illustrate

formants. Show the basics of vowel recognition. Method Real time data acquisition. Real-time FFT and spectrogram to show harmonic contents Modules DSPBase

3.2.1 Theory Formants results from the resonant frequencies of vocal tracts. Formants appear as a group of harmonics with relatively high energy, which identify vowels to the listener. The formant with the lowest frequency is called f1 and ranges from 300 to 800 Hz. The second formant f2 ranges from 800 to 2200 Hz. The two first formants f1 and f2 are linked mainly to the position of the tongue. The link between f1 and f2 values and the vowels is given in the following table. A third formant called f3 ranges from 2200 to 3500 Hz. Vowel formant frequencies

Vowel Formant F1 (Hz) Formant F2 (Hz)

u 320 800

o 500 1000

ǡ 700 1150

ø 500 1500

y 320 1650

æ 700 1800

e 500 2300

i 320 3200

3.2.2 User’s Interface

Page 26: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 26 of 136

3.2.3 Shortcut

3.2.4 Step-by-step procedure Step Description Comment 1 Click “Basic theory – Speech and Formants”. The upper screen displays

the real-time aspect of the sound captured by the microphone. The real-time spectrogram is computed and reported in real time on the lower part with an indication on the formant range. Pronounce vowels likes [a] [i][u] [e] [o] and see in real time the distribution of the frequency-domain components (Y Axis) during the time (X Axis).

The red-white color corresponds to a high energy. The blue-green color corresponds to a low energy.

2 You may download an existing WAV file by a click in “Signal Generator”, “Audio In” and then select the desired file. Upto 100,000 samples may be loaded. At 11025 Hz, this corresponds to 9 seconds of sound.

The spectrogram is recomputed accordingly.

3 Identify energy spread in formants, as listed in the section “Theory”.

Page 27: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 27 of 136

Confirm the energy patterns for [a] [i] [u] [e] [o].

[a] [i] [u] [e] [o]

4 Pronounce sounds such as [s] or [f] to see the spectral contents. Notice

that the [s] has a random but a significant amount of energy in the upper frequencies, while [f] is almost a white noise, with energy randomly spread over all frequencies.

5 Observe and hear the spectral contents of some sample WAV files proposed in MentorDSP: the airplane noise, musical instruments such as the flute or the piano, etc..

3.2.5 Reference: - http://en.wikipedia.org/wiki/Formant

Page 28: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 28 of 136

3.3 Illustration of basic signals

Lab practical 3.3 Illustration of basic signals Objectives Illustrate Dirac, step, pulse, Gaussian, sinc. Method Enter the equation and display the result. Module DSPBase, SigGen

3.3.1 User’s Interface

3.3.2 Short Cut

3.3.3 Practical Training: Unit Step Procedure

- Click « SIGgen” or “Signal Generator” from the DSPBase menu.

- Select the item « Basic » - Click the icon « Step » - Alternatively, click

“Equation” and enter “u(t)”

Cardinal Sine

t

)tsin()t(csin

ππ=

- Click « Signal Generator » and item « Equation »

- Enter the text: “sin(pi*t)(pi*t)” - Modify the range from -5.0 to 5.0

Page 29: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 29 of 136

Dirac Pulse

In theory, the pulse in infinitely narrow and infinitely tall. In MentorDSP, by default, the pulse width is equal to 1 sample (1/11025=90.7µs) and the height is 11025, so that the integral is 1.0.

- Click « Signal Generator » and item « Basic »

- Specify the delay and amplitude of the pulse.

- Alternatively, in “Equation”, use “DIRAC(<time>) ” where the time parameter is the delay.

You may verify that the integral is one by placing the DIRAC pulse in the upper window (for example dirac(0.01)) and by entering “int(dirac(0.01)) ” to compute the integral.

Normal

2

2

2

)(

2

1 σ

σπ

t

ef−

=

- Click « Signal Generator » and item « Equation »

- Enter “norm(0.1) ” for a Normal law with variance 0.1

- Alternatively, enter the equation corresponding to the formulation

- Modify the range from -0.5 to 0.5

3.3.4 Other examples: sin(2*pi*100*t)

Sinus frequency 100 Hz

cos(2*pi*1000*t)

Cosine frequency 100 Hz

Page 30: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 30 of 136

sin(1000*t)/(1000*t) Sinc function u(t)

Step function

-u(t)+u(t-0.02) 0.5*u(0.01-t)

Combinations of step functions

white(1)+sin(2*pi*1000*t)

Sinus frequency 1000 Hz with white noise from -1.0 to 1.0

sin(2*pi*100*t)+sin(2*pi*900*t)

Sinus 100 Hz added to sinus 900 Hz

sin(2*pi*100*t)*sin(2*pi*900*t)

Sinus 100 Hz multiplied by sinus 900 Hz

gauss(0.1)+0.1*sin(1000*t)

Gaussian noise, 0.1 variance, added to a 0.1 V, 1000 Hz sinus

pos(cos(2*pi*200*t))

Positive value of a cosine, 200 Hz

white(1)

White noise, -1.0 to +1.0

logic(0.01)

Random logic value generator, 0.01 s period

s1+s2 Upper signal s1 added to lower signal s2 s1*s2

Upper signal s1 Multiplied by lower signal s2

Page 31: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 31 of 136

3.4 Random signals properties

Lab practical 3.4 Random signals properties Module MathSTAT Objectives Illustrate mean of random signal, standard deviation, variance, probability

density function. Illustrate central limit theorem. Method Enter the random signal equation, display the results. Can repeat

automatically the random signal generation. Add white noise sources, see the distribution and show that its limit is a Gaussian distribution

Version April 29, 2008

3.4.1 Theory

3.4.1.1 Probability density function

3.4.1.2 ( )')()( xFxf XX = =derivative of the probability distribution function

3.4.1.3 3.4.1.4 Probability distribution

)xX(P)x(FX ≤=

3.4.2 User’s Interface

3.4.3 Short-Cut

3.4.4 Step-by-Step Procedure Step Description Comment 1 Click “Basic Theory – Probability Density” Generates a white noise,

opens MathStats to show

Page 32: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 32 of 136

the probability density, which has a rectangular shape

Release the button “Update”.

This stops the automatic generation of white noise and computation of the density.

2 Click “Signal Generator”

3 In “Equation”, type “white(1)+white(1)”. Click “Generate”, click “Update”. Adjust the Y scale

The probability density is now of triangular shape

4 Click “white(1)+white(1)+white(1)+white(1)”. Click “Generate”. Click “Update”.

The probability density tends to a normal law, which corresponds to the theorem of central limit

5 Click “Capture Micro.” and see the probability density of sounds. Investigate the PD of vowels, and random noise such as [f] and [s].

Page 33: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 33 of 136

Page 34: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 34 of 136

3.5 Random signals properties

Lab practical 3.5 Random signals properties Objectives Illustrate mean of random signal, standard deviation, variance, probability density

function. Method Enter the random signal equation, display the results. Can repeat automatically the

random signal generation. Compute the mean value, mean-square value and variance; compare with theory

Module Math Stat

3.5.1 Theory

3.5.1.1 Mean Value

∫+∞

∞−≡= dxxfxXEXm X ).(.][)(1

3.5.1.2 Mean-square value

∫+∞

∞−≡= dxxfxXEXm X ).(.][)( 22

2

3.5.1.3 Deviation 2

12X (X)m(X)mσ −≡

3.5.1.4 Probability density function

3.5.1.5 ( )')()( xFxf XX = =derivative of the probability distribution function

3.5.1.6 Probability distribution )xX(P)x(FX ≤=

3.5.1.7 Gaussian Function

2

2

2

)(

2

1 σ

σπ

mt

ef−−

=

σ=deviation m=mean value For a white noise [-1.0,+1.0], the PDF is as follows. The mean value is 0, the mean-square value is 0.333, and the variance is 0.577.

-1.0 1.0

0.5

x

fX(x)

02

5.0).(.)(0.1

0.1

2

1 =

==

∞+

∞−∫x

dxxfxXm X

3

1

35.0).(.)(

0.1

0.1

32

2 =

== ∫

∞+

∞−−

xdxxfxXm X

577.03

1(X)m(X)mσ

212X ==−≡

Page 35: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 35 of 136

3.5.2 Short-Cut

3.5.3 Step-by-Step Procedure Step Description Comment 1 Click “MathStat” in the main menu. By default, a white

noise [-1.0,+1.0] is proposed, with its probability density function in the MathStat window.

The probability density function of a white noise has a rectangular shape

2 Click “Update”. Each second, a new random signal is generated and the associated Mean and Deviation is computed. Notice that the mean is close to 0.0 and the deviation close to 0.57, according to the theory.

3 In “Equation”, type “white(1)+0.5 ”. Click “Generate”. The mean is now close to 0.5, while the deviation remain constant.

4 Click “gauss(0.5)”. Click “Generate”. The Gaussian noise has a Probability Density Function which tends to a Gaussian curve. The deviation given

Page 36: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 36 of 136

in parenthesis is confirmed by the computation.

Page 37: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 37 of 136

4 Convolution

4.1 Illustrate the convolution principles

Lab practical 4.1 Illustrate the convolution principles. Objectives Show how convolution works on very simple signals; Method Display signals X and Y (top) and bottom, sampled, and compute X*Y on a sub-window Module - DSPBase for time aspect of x[t] and y[t]

- MATHStat for convolution/correlation computation

4.1.1 Theory

∫+∞

∞−−= τττ dtyxtytx )()()(*)(

4.1.2 Main features:

• Computes the convolution between two signals • By default, a simple pulse is proposed for X[n] and Y[n] • The convolution is a triangle in this case • The use can see how the convolution is computed for each value of t • Any user’s-defined signal may be used as X[n] and Y[n] • Noisy signals are accessible through the Equation menu

4.1.3 Short-cut

4.1.4 Step-by-step procedure Step Description Comment 1 Click “Convolution – Convolution

Principles”. x[n] and y[n] are a simple pulse. The convolution appears to be a triangle.

By default, two identical pulses are displayed, with x[n]=1 for n [1..5]. y drawn as y[-n]. By default, the convolution is computed to 100 samples.

2 Click the offset cursor in the convolution window. This shows the value of x[offset]*y[offset]. See how y[offset-tau] is drawn on the bottom screen. The convolution is the result of multiplication of the upper signal by the bottom signal.

Page 38: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 38 of 136

3 Find the maximum of the convolution Maximum corresponds to the coincidence of the upper and lower signals (shift six samples).

This cursor changes the value of t (offset between

x[n] and y[n])

Changing the time offset moves the red dot

Page 39: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 39 of 136

4.2 Illustrate auto-correlation with sound for fund amental freq. extraction

Lab practical 4.2 Illustrate auto-correlation with sound for fundamental freq. extraction Objectives See the result of real-time auto-correlation and determine fundamental frequency. Method Sample microphone, compute the result of auto-correlation in real-time Modules - DSPBase for time aspect of x[t] and x[-t]

- MATHStat for convolution/correlation computation

4.2.1 Theory

∫+∞

∞−−=−≡ τττγ d)t(x)(x)t(x*)t(x)t(

4.2.2 Features - Correlation is executed between the two same information, that is the real-time sound captured from the

microphone - The length of the windowing may be adjusted in the convolution window - The first peak in the convolution window corresponds to the fundamental frequency of the voice

4.2.3 Short-Cut

4.2.4 Step-by-step procedure Step Description Comment 1 Click “Convolution – Sound Correlation”.

The real-time sound from the microphone appears in the upper and lower windows.

Page 40: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 40 of 136

Period corresponding to the fundamental frequency of the

voice F0 (approx. 200 Hz)

2 The autocorrelation of the real-time sound

is computed. There is a direct link between the period of the sound and the first peak in the correlation window.

The first peak also corresponds to the

period of F0 (approx. 200 Hz)

3 Using the microphone, pronounce a stable vowel like [a] or [you]. The autocorrelation is averaged on several samples and shows a figure that looks like below.

The autocorrelation is always maximum at t=0. In contrast to convolution, the autocorrelation do not change the sign of y[n].

4 After a certain amount of iterations, the first peak on the right is the fundamental frequency of the voice that pronounces the vowel.

This works only for a stable sound and stable frequency.

5 In the lower part of the window, place the marker at the first peak, which corresponding to a period of 4.5ms in this case, and a frequency of 220 Hz.

For male voices, the fundamental frequency F0 ranges from 100 to 200Hz. For females, it is between 200 and 350 Hz.

Page 41: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 41 of 136

Page 42: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 42 of 136

4.3 Illustrate correlation on image recognition

Lab practical 4.3 Illustrate correlation on image recognition. Objectives Explain how 2D correlation may be used for object recognition. Method Load a general image containing several objects. Load a reference image including one

object (a red square by default). Run the 2D correlation to locate the most probable position of the object in the general image.

Module ImageSee

4.3.1 Theory

ρτρτρτ ddyxJIyxJyxI ∫ ∫+∞

∞−

+∞

∞−−−= ],[],[],[*],[

4.3.2 User’s Interface

4.3.3 Main Features - By default, one general image is loaded on the upper screen, one reference image is loaded on the

lower screen - Red, Green, Blue plane selection for both image visualization and computing - Image size limitation : 400 x 300 pictures - Import picture from file (BMP format) - The 2D computation evaluates the matching between the general image top) and the reference image

(bottom)

4.3.4 Short-cut

4.3.5 Step-by-step procedure Step Description Comment 1 Click “Convolution – Image Correlation”

or “Image – Image Correlation” By default, the upper image contains a set of objects, the

Page 43: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 43 of 136

bottom image one single object.

2 Click “Compute correlation”

3 The peak of correlation corresponds to the best (X,Y) offset to match Image 1 and Image2

Highest probability is here

Lowest probability is here

The highest score corresponds to color white. The yellow area is also meaning a high score, which means that the red square matches other places.

4 Unselect the Green and Blue planes of image 1. Notice that the red is contained in almost all the image.

5 Click “Load BMP 2”. Choose an other reference image like “image_correlation_blue_circle.bmp ». Click «Compute correlation ». The peak is moved to the best (X,Y) match

Page 44: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 44 of 136

Best match is located here

6 Load “image_Correlation_can1.bmp » as the general image and “image_Correlation_can2.bmp » as the reference image.

Click « Compute correlation ». The result is shown below.

Page 45: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 45 of 136

4.4 Illustrate Correlation on Noisy signal

Lab practical 4.4 Illustrate Correlation on Noisy signal Objectives Add noise and deterministic signal. See how correlation can find signal in

noise. Method Enter the random signal + deterministic equation. Display the correlation

result. Can repeat automatically the random signal generation and cumulate the correlation in order to find the small signal in noise.

Hardware - DSPBase for time aspect of x[t] and x[-t] - MATHStat for convolution/correlation computation

4.4.1 Theory

∫+∞

∞−−=−≡ τττγ d)t(x)(x)t(x*)t(x)t(

4.4.2 Features - Displays time (left) and correlation (right). - Display the auto-correlation window - Can enter variety of noises by changing the equation (Generator Menu) - Can change the vertical scale of the correlation window - By default, the signal generation is repeated automatically (Button “Do Again”)

4.4.3 Short-Cut

4.4.4 Practical Training: - Investigate correlation ability to find a period in a strong noise. By default, a white noise of 1.0 V

amplitude peak-to-peak is superimposed to a sinusoidal wave of 0.2 V amplitude. - The cumulated auto-correlation finds the period, after averaging 100’s of samples.

1 Click “Convolution – Extract Signal from noise”.

By default, a sinusoidal wave with additive white noise is generated.

The convolution starts by very noisy results

Page 46: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 46 of 136

2 The button “Update” is down by default, which

automatically generates a new series of data each second.

The convolution do not stabilizes to a specific result as the noise is very important.

3 Select the mode “Autocorrelation with average”. Now, the auto-correlation result is cumulated with others and an averaging is computed, that extracts signal from noise.

The convolution stabilizes to a sinusoidal wave. The first peak corresponds to the deterministic sinusoidal wave that wave generated at start (250 Hz frequency by default).

4 Change the Y scale to see the cumulated correlation result.

The auto-correlation is cumulated for a large series of samples

The Y scale is increased to see the

correlation amplitude This button enables the

« auto » mode that continously generate new series of samples (one per second)

The first maxium corresponds to 4ms,

i.e 250 Hz.

The default sinusoidal wave has a very small amplitude.

5 Click “Generator” of the tool menu. In “Equation”, The convolution shows the

Page 47: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 47 of 136

modify the noise amplitude by changing the parameter in the white function (White noise generator).

period even if the white noise becomes very important, but a large series of data is required.

Page 48: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 48 of 136

5 Fourier Transform

5.1 Tutorial on Fourier series

Lab practical L5.1 Tutorial on Fourier series Objectives Establish the link between basic signals and their Fourier series. Method Use predefined signals with window fitted with one period to ease the

interpretation of An and Bn series. Module DSPBase

Theory

Any signal can be represented as : )2sin][2cos][()(10 T

tnnB

T

tnnAAtx

nππ∑

=++=

Where :

∫=T

dttxT

A00 )(

1 (mean value of x(t) in the interval T)

∫=T

dtT

tntx

TnA

0)2cos()(

2][ π (n>0)

∫=T

dtT

tntx

TnB

0)2sin()(

2][ π (n>0)

User’s Interface

Fourier Coefficients Predefined

signals

Short-cut

Page 49: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 49 of 136

Step-by-step procedure Step Description Comment 1 Click “Fourier Transform – Introduction To Fourier

Transform”.

The default Fourier window size n=512 pts

As the sampling frequency Fe is 11025 Hz, the sinusoidal wave matching the

window is Fe/n=21.53 Hz

A sinusoidal wave of frequency 21.5 Hz with frequency exactly fitted with the Fourier Window is generated.

2 The Fourier transform gives the following results: B[1] is the only non-null coefficient. Its value is 1.0, according to the sinus amplitude.

3 Click “Signal Generator”. Change the frequency to 43.0 Hz (twice the initial one). Change the amplitude to 0.5. Click “Generate” and select again “Fourier Coefficients” in the bottom screen.

2 periods fit almost exactly in the 512-pts Fourier

Window

3 Check the coefficient values. This time, B[1]=0, because there is no 22 Hz component in the signal. But there is a 0.5 V component at 43 Hz.

Page 50: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 50 of 136

4 Select various basic signals and verify the link between theory and computed A[n] and B[n].

For example, the clock signal should have even An equal to 0 and odd An amplitude reduced by approximately SQRT(2).

5 Change the window from “Rectangular” to “Blackman”. The Blackman window modifies the values for A [1], B [1] but reduces the numerical noise.

Page 51: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 51 of 136

5.2 Tutorial on invert Fourier transform, reconstru ction

Lab practical L5.2 Tutorial on invert Fourier transform, reconstruction Objectives Understand how a signal can be built from sinus waves Method Superimpose the iFFT of the signal and the signal, where the user selects

harmonics one by one (or all) Module DSPBase

Theory

Signal is reconstructed by : )T

tnsinb

T

tncosa(a)t(x nn n ππ 22

10 ∑∞

=++=

User’s Interface

Short-Cut

5.2.1 Step-by-step procedure Step Description Comment 1 Click “Fourier Transform – Invert Fourier

Transform” A sinusoidal wave with frequency exactly fitted with the Fourier Window is generated. The invert-Fourier transform is also computed from coefficients A[n] and B[n] (In Red).

Page 52: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 52 of 136

Original signal (blue)

Reconstructed signal (red)

2 Modify the B[1] cursor and see how the iFFT

signal is impacted. B[1] influences the amplitude of the sinusoidal wave at 21.3 Hz.

3 Click the icon “Cosine”. This generates a cosine wave, with its corresponding Fourier Coefficients.

Sine wave

Cosine wave Rectified

Sine wave

Clock wave Triangle

wave

Saw Tooth wave

Change A[1] value by modifying the cursor position and see the effect on the reconstructed curbe.

This time, all B[n] values are equal to 0.0, and A[1] is the only non-nul coefficient.

4 Click the icon “Clock”. See the effect of A[n] Only cosine coefficients are

Page 53: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 53 of 136

coefficients, as well as B[n] coefficients.

affected because the clock is symmetrically generated vs. the Y axis.

5 Click again the icon “Clock” and click “Unselect All”. The iFFT signal is equal to 0.0.

6 Click “a[0]”. The iFFT signal is constant, equal to 0.5.

Page 54: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 54 of 136

7 Click A[1], A[2], A[3], etc.. in order to reconstruct

step-by-step the square wave.

Page 55: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 55 of 136

5.3 Tutorial on Windowing

Lab practical 5.3 Tutorial on Windowing Objectives Understand the windowing mechanism (rectangular, Blackman, hamming

windows) Method Display the windowing shapes, the result of multiplication of signals by

windows and the corresponding result in time domain and frequency domain.

Module DSPBase

5.3.1 Theory Different types of windows are used to improve the quality of Fourier Transform and the synthesis of Digital Filters. The most popular windows are :

• Rectangular

• Hanning

• Hamming

• Blackman

The series of original data x[n] (n from 1 to N) is multiplied by the window W[n] to produce the result y[n]. ][].[][ nxnWny =

5.3.1.1 Rectangular window:

The Rectangular window function is given by,

elsewhere 0,

0 ,1)(

=≤<= NnnWREC

where N is the number of original data.

5.3.1.2 Hanning window function:

NnM

nnWHAN ≤<

+= 0 cos5.05.0)(π

5.3.1.3 Hamming window function:

NnM

nnWHAM ≤<

+= 0 cos46.054.0)(π

5.3.1.4 Blackman window function:

NnMM

nnWBLA ≤<

+

−= 0 n2

cos 0.08 cos5.042.0)(ππ

5.3.2 User’s Interface - The tool SIGGen can be used to generate the windows - The tool DSPBase is used to plot the windows and the windowing result

Page 56: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 56 of 136

5.3.3 Features - Generate windows by entering the equation or using predefined keywords - See the result of multiplying a basic waveform to the window - See the FFT result and the added value of windowing - Keywords ‘RECT, HAMMING, HANNING or BLACKMAN give a direct access to the window in the signal

generator - The user can also write the full equation using combinations of sine and cosine functions

5.3.4 Short Cut

5.3.5 Step-by-step procedure Step Description Comment 1 Click “Fourier

Transform – Windowing”

A sinusoidal wave is displayed on the top window, and the Blackman window is displayed on the bottom window.

Page 57: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 57 of 136

2 Click “ 1 x 2”. The sinusoidal wave is multiplied by the Blackman window as shown above.

3 Click “Signal

Generator” and select “Hamming(0.1)”. Click “Operations” and again “1 x 2”. The new result appears.

4 Click “Signal

Generator” and select “Rect(0.1)”. Click “Operations” and again “1 x 2”. The new result appears.

5 Click “Fourier

Transform” on bottom of signal 2. A peak at 1000 Hz is displayed, but a large amount of noise is also present. This is due to the use of the rectangular window.

Peak at 1000 Hz

Numerical noise

Note: the default window size is 512 points. Consequently, the windows are computed for n ranging from 1 to 512. Changing the FFT resolution will change the windowing size accordingly.

Page 58: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 58 of 136

6 Select a new window (Hamming in this case) and observe the new FFT result.

Little attenuation of

the 1000 Hz peak

The numerical noise is strongly attenuated

Page 59: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 59 of 136

5.4 Performance of FFT : real time, change paramete rs

Lab practical 5.4 Performance of FFT : real time, change parameters Objectives Understand FFT’ parameters, see how FFT can help in speech characterization. See

the correspondence between time-domain waveform and frequency domain waveform. Method Applies FFT on live input, or a file. Place real-time sound on top, real-time spectrogram

on bottom window. Give immediate access to critical parameters. Module DSPBase

5.4.1 User’s Interface

5.4.2 Features - Choose input from WAV file, or from microphone in real time - Access to FFT parameters - Change windowing (rectangular, hamming...) - Change Y scale (0-500, 0-1000, 0-2500) - Modify the color palette through cursor “Energy Scale”

5.4.3 Short Cut

Page 60: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 60 of 136

5.4.4 Step-by-step procedure Step Description Comment 1 Click “Fourier Transform

– Real-Time Spectrogram”

The time-domain aspect of the sound appears in the upper window and the spectrogram is displayed in the lower window

2 Pronounce vowels. See how the frequency contents of vowels is clearly different?.

3 Zoom at low frequency

by changing (Range parameter set to 500 Hz) and see the evolution of the first harmonic (the fundamental frequency)

4 See [s], [ch], [f] high freq

contents (Range parameter set to 5000 Hz)

5 Generate a pure sound

(whistle)

Page 61: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 61 of 136

6 Filtering

6.1 Fundaments on Discrete systems

Lab practical L6.1 Fundaments on Discrete systems Objectives Understand the mechanisms of recurrence equations. Method See the discrete aspect of signals and how it is delayed, added and

amplified. Select predefined equations in the list and see step by step the response.

Theory

[ ] [ ] [ ]∑∑==

−+−=M

ii

N

ii inxbinyany

01

User’s Interface

Features - User can enter its own recurrence equation - See the block diagram of Recursive and Non-recursive filters (several examples given) - Step by step computation of Y[n] (“Compute y[i]’) - Can play with several X[n] through the signal generator menu - See the input X[n] and output Y[n] as discrete values

Page 62: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 62 of 136

Short Cut

Step-by-step procedure Step

Description Comment

1 Click “Filtering – Basics of Discrete Systems”. A low-pass filter with the recurrence equation reported below is proposed: Y[n]= 0.32*x[n]+0.34*x[n-1]+0.32*x[n-2]

A pulse is generated as X[n] (upper window), and Y[n] is set to 0 (lower window)

2 Click “Compute y[0]” in the filter menu.

The response Y[0] to X[0] is computed and the result appears. As x[0]=0.0, x[-1]=0.0 and x[-2]=0.0, the result is 0.0

The response Y[0] to X[0] is computed and the result appears. The corresponding value is also added in the array.

3 Click several times “Compute y[i]” and see how Y[n] is constructed step-by-step.

The Y[n] signal is as shown below.

Page 63: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 63 of 136

4 Click “FIR Diagram”. See the structure of the filter

according to the recurrence equation.

4 Change the recurrence equation. Click “n=0” to reset time.

5 Click “Signal Generator”. Choose “Chirp signal”. Modify f1 to 100 Hz and f2 to 5000 Hz.

Also change the duration of the signal as follows:

The chirp signal varies from low frequencies (f1=100 Hz) to high frequencies (f2=5000 Hz) to cover the whole range of frequencies and see the filtering effect.

6 Click “Compute Y[n]”. The response is computed and displayed.

Page 64: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 64 of 136

Low frequencies are not attenuated

Cut-off frequency here

High frequencies strongly attenuated

Gibbs effect of FIR filters

7 Click “Import Coefficients” and select for example

“HiPass_11.CSV”. This corresponds to a 11-coefficient FIR high-pass filter.

8 Click again “Signal Generator”, choose the “Chirp” signal and click “Generate”. Click “Compute Y[n]”. This time, low frequencies are strongly attenuated, while high frequencies are not filtered.

Page 65: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 65 of 136

6.2 Finite Response Filter Design

Lab practical 6.2 Finite Response Filter Design Objectives Design and analyze frequency performances of FIR digital filters Method Specify the type of filter, generate the filter coefficients, see the frequency response

6.2.1 Theory

Frequency

fe/2 fc

Amplitude

0.0

1.0

Invert Fourier Transform

Time

Amplitude

Truncate and shift

Time

Amplitude

B0 B1 Bn

6.2.2 User’s Interface

6.2.3 Features - The user selects the type of filter (low pass, high pass, band pass, notch) - The cut-off frequency and filter parameter numbers may be changed - The coefficients are then automatically computed - The result on a chirp signal may be observed (variation of the amplitude of the Y[n] signal depending on

frequency

Page 66: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 66 of 136

6.2.4 Short Cut

6.2.5 Step-by-step procedure Step Description Comment 1 Click “Filtering – FIR Filter Synthesis” A chirp signal is

generated as X[n] (upper window), and its spectrogram is computed (lower window)

2 The default filter is the Low Pass Filter, the cut-off frequency by default is around 1000 Hz.

3 Click “Generate Filter”

The coefficients are computed and listed in the table

6 Click “Compute y[n]”. The response of the filter to the chirp signal appears.

The low frequency contents are not attenuated, while the frequencies above 1000 Hz are reduced.

Page 67: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 67 of 136

7 In the “FIR Synthesis” menu, enter more coefficients.

Generate again the filter and compute y[n]. The y[n] result is attenuated very significantly.

8 Click “Play 1” and “Play 2” to hear the difference between the original signal x[n] and the output signal y[n]

The frequencies above the cut-off frequency are strongly attenuated.

9 You can download an existing filter (several examples provided) in “Equation”, by a press at “Import Coefs”.

10 Investigate other types of filters such as high-pass, band-pass or notch filters.

The major drawback of this type of filter is the needs for a huge number of coefficients in order to achieve the desired function.

11 Investigate the role of the windowing function on the quality of the digital filtering.

12 Enter your own equation and see how the filter reacts. Note: the text is limited to 128 characters.

Page 68: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 68 of 136

6.3 Infinite Response Filter Design

Lab practical 6.3 Infinite Response Filter Design Objectives Design and analyze frequency performances of IIR digital filters Method Specify the type of filter, generate the filter coefficients, see the frequency response

6.3.1 Theory The advantage of infinite-impulse response (IIR) filters over finite-impulse response (FIR) ones is that the former require a much lower order (much fewer multipliers and adders) to obtain the desired response specifications. However, in contrast with FIR synthesis theory, which is quite simple, the methodology for IIR synthesis relies on “analog prototypes”, which require delicate transforms detailed below. MentorDSP illustrates the steps for 2nd order IIR synthesis and the associated mathematical approach. 6.3.1.1 IIR filter general form: The general form of a 2nd order IIR filter is given below:

22

110

22

110)( −−

−−

++++=

zazaa

zbzbbzH

From this general form, the recurrence equation can be written as:

]2[]1[]1[]1[][][0

2

0

1

0

2

0

1

0

0 −−−−−+−+= nya

any

a

anx

a

bnx

a

bnx

a

bny

6.3.1.2 From Analog to Sampled Domain The synthesis method is derived from analog prototypes with a transfer function described in p-form. An example of 2nd order prototype for analog low-pass filtering is :

1

1)(

2 ++=

Q

pp

pH

For IIR filter synthesis, frequencies are “normalized” to ease computation and equalivalences between the analog world and sampled world. The normalized frequency Ω, is linked by frequency f (Hz) with the relation below, where the sampling frequency is fs (Hz).

sf

fπ2=Ω

As the signal frequency f is supposed to be less than fs / 2 (Nyquist theorem), Ω ranges between 0 and π. The Bilinear Transform (BLT) is applied by replacing p by its z-domain equivalence, given below.

p-domain Z domain p

1

1

1

1

)2

tan(

1−

+−

Ω z

z

In the particular case of 2nd order IIR filters, a set of trigonometric formulation and simplifications may be conducted (See details in R. Bristow-Johnson’s reference paper). As a result, the direct conversion from p-domain transfer function to z-domain filter transfer function is done according to the equations below.

p-domain Z domain 1 )cos1)(21( 21 Ω−++ −− zz p Ω− − sin)1( 2z p2

)cos1)(21( 21 Ω++− −− zz

6.3.1.3 Low-pass filter general form:

Page 69: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 69 of 136

1

1)(

2 ++=

Q

pp

pH

The mathematical expression for the 2nd order IIR filter coefficients is given below:

2

cos10

Ω−=b

Ω−= cos11b

2

cos12

Ω−=b

alfaa += 10

Ω−= cos21a

alfaa −= 12 Where

Qalfa

2

)sin(Ω=

Consequently, the coefficients of the recurrence equation may be computed as follows:

]2[11

]1[1

cos2]1[

)1(2cos1

]1[1

cos1][

)1(2cos1

][ −+−−−

+Ω−−−

+Ω−+−

+Ω−+

+Ω−= ny

alfa

alfany

alfanx

alfanx

alfanx

alfany

6.3.1.4 High-Pass filter general form

1)(

2

2

++=

Q

pp

ppH

2

cos10

Ω+=b

)cos1(1 Ω+−=b

2

cos12

Ω+=b

a0, a1 and a2 are same as above. 6.3.1.5 Band-Pass filter general form

1)(

2 ++=

Q

pp

ppH

2

sin0

Ω=b

01 =b

2

sin2

Ω−=b

a0, a1 and a2 are same as above. 6.3.1.6 Band-Stop filter general form

1

1)(

2

2

++

+=

Q

pp

ppH

10 =b

Ω−= cos21b

12 =b a0 ,a1 and a2 are same as above.

Page 70: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 70 of 136

6.3.2 User’s Interface

6.3.3 Features - The user selects the type of filter (low pass, high pass, band-pass, band-stop) - The cut-off frequency and filter parameters may be changed - The synthesis method is derived uses biquad coefficients derived from analog transfer functions - The coefficients are then automatically computed - The result on a chirp signal may be observed (variation of the amplitude of the Y[n] signal depending on

frequency

6.3.4 Short Cut

6.3.5 Step-by-step procedure Step Description Comment 1 Click “Filtering – IIR Filter Synthesis” A chirp signal is

generated as X[n] (upper window), and its spectrogram is computed (lower window)

Page 71: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 71 of 136

2 Select the type of filter. By default the filter is Low pass 3 Select the cut-off frequency by modifying the cursor

position.

By default around 1000 Hz.

4 The proposed method is based on bi-quad prototypes (order 2). The user parameter is the quality factor. For example, change it to “2.0”.

5 A set of intermediate values is computed by a click on “Update”. These values are used in the coefficient equations as described above (theory section).

6 Click “Generate”. The coefficients are computed and listed in the table. The recurrence equation is updated.

7 Click “IIR Diagram”. The coefficients are updated as follows:

8 Click “Compute y[n]”. The response of the filter to the chirp signal appears.

The low frequency contents are not attenuated, while the frequencies above 1000 Hz are strongly

Page 72: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 72 of 136

reduced. Notice the quality factor (Q=2.0) as defined by the user.

9 Now select the band-pass filter, modify the quality factor to 10.0.

The frequencies around the cut-off frequency are amplified

9 Now select the band-pass filter, modify the quality factor to 10.0.

The frequencies around the cut-off frequency are amplified

10 Click “Generate” and “Compute y[n]”. The response shows a very strong amplification of the central frequency, and attenuation on both ends.

11 Click “Play 1” and “Play 2” to hear the difference between the original signal x[n] and the output signal y[n]

The sound around the user’s frequency is strongly amplified

6.3.6 References - R. Bristow-Johnson “Cookbook formulae for audio EQ biquad filter coefficients”, http://www.musicdsp.org - Digital Signal Processing concept & applications, CH: 5 & 6 Bernard Mulgrew, Peter Grant, John Thompson

(Macmillan press ltd.)

Page 73: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 73 of 136

6.4 Illustrate FIR on low-pass filter

Lab practical L6.4 - Illustrate FIR on low-pass filter. Objectives See Finite Impulse Response Filter at work and the influence of the number of

coefficients on a filter efficiency. Method Generate a chirp signal, load predefined filter coefficients and observe the filtering

efficiency on spectrogram; Hear filtering effect Module DSPBase

6.4.1 Theory

y n[ ] = bix n − i[ ]i =0

N

6.4.2 User’s Interface

6.4.3 Features - User can load pre-computed filters (Import/Export) - Can play with several X[n] (chirp signal, WAV file) - See time domain aspect of X[n] and Y[n] - See spectrogram of X[n] and Y[n] - Hear the filtered WAV file

Page 74: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 74 of 136

6.4.4 Short Cut

6.4.5 Step-by-step procedure Step Description Comment 1 Click “Filtering – FIR Application : Low Pass

Filtering” A chirp signal is generated as X[n] (upper window), and also in Y[n] (lower window)

2 Select the desired filter. Choose “LowPass_3.csv” in the list.

This corresponds to a low pass filter with 3 coefficients.

3 Click “Compute Y[n]” The response to the 3-coefficients filter appears.

The attenuation is quite small.

4 Click “Import Coefs” and choose “LowPass_11.csv” in the list. Click “Compute Y[n]”. The response to the 11-coefficients filter appears.

The attenuation is significant.

5 Click “Import Coefs” and choose “LowPass_101.csv” in the list. Click “Compute Y[n]”. The response to the 101-

The filtering effect is very demonstrative.

Page 75: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 75 of 136

coefficients filter appears.

6 Click “Spectrogram” to see the same result in time, frequency and amplitude.

The attenuation is very clear.

Page 76: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 76 of 136

6.5 Illustrate IIR on Speech filtering

Lab practical 6.5 Illustrate IIR on Speech filtering Objectives Illustrate Infinite Impulse Response band-stop filter on a WAV file. Method Load the WAV file, see the spectral contents. Hear the sound and a 440

Hz noise superimposed to the desired signal. Synthesize a 440 Hz band-stop filter, remove the noise and see the result;

Tool DSP-Pro

6.5.1 Theory The band-stop analog transfer function is

1

1)(

2

2

++

+=

Q

pp

ppH

A 2nd order IIR filter which reproduces the above analog model can be extracted from the bi-linear transform from p-domain to z-domain as follows [1]:

]2[1

1]1[

1

cos2]1[

)1(2

1]1[

1

cos2][

)1(2

1][ −

+−−−

+Ω−−−

++−

+Ω−+

+= ny

alfa

alfany

alfanx

alfanx

alfanx

alfany

Where:

sf

fπ2=Ω

Qalfa

2

)sin(Ω=

6.5.2 User’s Interface

Page 77: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 77 of 136

6.5.3 Shortcut

6.5.4 Practical Training: 0 Click “Filtering” and “IIR example – remove 440 Hz”. The

“AIUEO-A440.wav” signal spectrogram appears on the top; the filtered version with a 440 Hz notch filter appears on the bottom.

1 Alternatively, enter DSPpro. The left screen shows by default a chirp signal (signal from low to high frequency) and its spectrogram. The screen on the right gives access to filter synthesis.

2 Click “Signal Generator”, “Audio In” and Load “AIUEO-A440.wav”. This corresponds to vowels with noise.

440 Hz noise

Vowels

Noise stops here

A 440Hz noise appears in a significant portion of the signal.

3 Click “Band Stop”, tune the cut-off frequency to 440 Hz using the cursor (low-high). Click “Generate”. This completes the design of a band-stop infinite-response 2nd order filter tuned to reject the 440 Hz.

4 Click “Compute y[n]”. Observe the result. The 440 Hz noise is a little attenuated; the quality factor of the filter is “1.0” by default, which is too low.

5 Put 10 for the quality factor Q. Click “Generate”. The coefficients are updated. Click “Compute y[n]”.

Page 78: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 78 of 136

Signal before applying bandstop filter

440 Hz noise dominant

Signal after applying bandstop filter

Very small 440 Hz noise

6 Observe the result. Almost all the 440 Hz noise is suppressed.

7 Draw the spectrogram of the signals before and after filtering and see how the 440Hz noise is attenuated.

6.5.5 Reference: - Digital Signal Processing concept & applications, CH: 5 & 6 Bernard Mulgrew, Peter Grant, John Thompson

(Macmillan press ltd.) - R. Bristow-Johnson “Cookbook formulae for audio EQ biquad filter coefficients”, http://www.musicdsp.org

Page 79: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 79 of 136

6.6 Echo Generation

Lab practical L6.6 Generate echo Objectives Understand the effect of large delay on sound reverberating effects Method Use IIR filter structure and delay cells with very large numbers Module DSPBase, DSPPro

6.6.1 Theory:

1000]-x[nx[n]*0.51000]-y[n*-0.5Y[n] ++=

6.6.2 User’s Interface

6.6.3 Short-Cut

6.6.4 Practical Training: - Enter basic recurrence formulas like Y[n]=-0.5*y[n-1000]+0.5*x[n]+x[n-1000] - See echo effect on a WAV file - See echo effect on a pulse - Hear initial WAV and resulting wave - Change the echo parameters (delay, reflection amplitude) and hear the result

Page 80: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 80 of 136

6.6.5 Step-by-step procedure Step Description Comment 1 Click “Filtering – Echo Generation”. A WAV signal

including a set of vowels pronounced by a male adult is loaded as X[n] (upper window), and the version with echo is computed as Y[n].

(a) original signal

(b) signal with echo

2 Change the recurrence equation coefficients - Echo amplitude (-0.5 initially changed for example

to -0.2, which reduces the echo effect) - Delay (-1000 initially changed to 500 which

reduces the delay)

3 Click “Update Coefficients” The new parameters of the recurrence equation are updated.

4 Click “Generate Y[n]” The new response is computed 5 Click “Play 1” and “Play 2” to compare the result The echo effect appears quite

clearly in signal 2 (Y[n]) 6 Click “Signal Generator”. Select “Pulse” in the “Basic”

menu. Compute the response. The pulse response is a set of delayed pulse with opposite sign and damped amplitude

Page 81: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 81 of 136

Page 82: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 82 of 136

6.7 Dual-tone multi-frequency (DTMF) identification

Lab practical L6.7 Dual-tone multi-frequency (DTMF) identification Objectives Detect tone frequency by selected filters Method Synthesize band pass filters tuned to the desired frequencies. Module - DSPBase

- DSPpro

6.7.1 Theory: Dual-tone multi-frequency (DTMF) is used for telephone signaling over the line in the voice-frequency band to the call switching center, by combining two sinusoidal waves, one called f1 ranging from 697 to 941 Hz, and the second called f2 ranging from 1209 to 1477 Hz. Its specification is illustrated below.

y n[ ] = bix n − i[ ]i =0

N

∑ with coefficients tuned to the following frequencies

'1', '2', '3': f1 := 697 Hz

'4', '5', '6': f1 := 770 Hz

'7', '8', '9': f1 := 852 Hz

'*', '0', '#': f1 := 941 Hz

'1', '4', '7', '*': f2 := 1209 Hz

'2', '5', '8', '0': f2 := 1336 Hz

'3', '6', '9', '#': f2 := 1477 Hz

User’s Interface

Main Features - Create a sound with DTMF tone using the signal generator - Load band pass filter by use of FIR/IIR filter design - See how the filter isolates the energy at the desired time

Page 83: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 83 of 136

Short Cut

Step-by-step procedure Step Description Comment 1 Click “Filtering – DTMF Phone Key Identification” A DTFM signal is generated

that includes all possible phone keys

2 Use the FIR design windows to generate a band-pass filters tuned to important bands. For example, specify a band-pass filter close to 941 Hz. Reduce the window width and increase the filter order for highest selectivity.

Select band-pass filter

Tune to 941 Hz

As narrow as possible for high selectivity

High order for high selectivity

Generate filter..

..and compute y[n]

For example, “0” is a combination of f1=941 Hz and f2= 1336 Hz.

3 Click “Compute Y[n]” The response to the filter appears.

The filter should isolate the energy at the desired bandwidth.

4 Try to isolate other

Page 84: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 84 of 136

7 Image

7.1 Play with image properties

Lab practical L7.1 Play with image properties Objectives Understand basic principles of image coding Method Give access to pixel R,G,B and H,S,V values. Highlight pixel environment.

Illustrate the link between the two systems. Illustrate noise. Module ImageSEE

7.1.1 Theory

7.1.1.1 RGB and HSV definition In computer graphics, each parameter composing the RGB coding system is usually represented by an integer from 0 to 255 (one byte). R=red, G=green, B=blue ]255..0[,, ∈BGR The HSV (Hue, Saturation, Value) model defines a color space in terms of three constituent components: - H=Hue=color type (red, blue.. yellow): ]360..0[ °∈H

- S=saturation=color intensity ]255..0[∈S 0=white, 255=no saturation

- V=value=brightness of the color ]255..0[∈V

7.1.1.2 Link between RGB and HSV ),,max( BGRV =

),,min( BGRm =

)1(255V

mS −=

if V=R

mV

BGH

−−= 60 if G>B

36060 +−−=

mV

BGH if G<B

if V=G

12060 +−−=

mV

RBH

if V=B

24060 +−−=

mV

GRH

Page 85: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 85 of 136

7.1.2 Short-Cut

7.1.3 User’s Interface

7.1.4 Practical Training: - Understand the link between pixel and RGB values - Discover the HSV (Hue, Saturation, Value) coding - Illustrate the correspondence in the palette - Modify the HSV value parameter

7.1.5 Step-by-step procedure Step Description Comment 1 Click “Image – Image Properties”.

No image is present.

2 Click “Load Image”. Select “Tautou64.bmp”. Move the cursor in the image situated on the main image. The R,G,B values and corresponding H,S,V values are updated. The integer and hex values are also displayed. In the palette, the H and S points are plotted. In the right upper window, a zoom at the (5 x 5) nearest pixels is proposed.

3 Click “Load Image”. Select “India64.bmp”. Notice that in this black and white picture, the Hue is undefined.

The R,G,B values are identical (gray scale).

Page 86: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 86 of 136

4 Load the file “ColorPalette.bmp”. Investigate the Hue

variation (X Axis).

7.1.6 Reference: - http://en.wikipedia.org/wiki/HSV_color_space - Raphael Gonzalez, Richard E. Woods (2002) Digital Image Processing, 2nd ed. Prentice Hall Press,

ISBN 0-201-18075-8, p. 295.

Page 87: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 87 of 136

7.2 Image Histograms

Lab practical L7.2 Image Histograms Objectives Histograms reveal if image has been properly exposed, characterizes the lighting and

what adjustments will work best. Method Perform probability distribution, density function, average, standard deviation etc on

brightness, color… Module ImageSEE

7.2.1 Theory: Histogram provides the frequency of one given property on a portion or the complete image.

1. Assign zero values to all elements of the array h. 2. For all pixels (x,y) of the image, increment h[f(x,y)] by one, where f() is the given property.

The region where most of the values are present is the tonal range.

1500

1000

500

0 255

Value

Pixel count

Tonal range

7.2.2 User’s Interface

Page 88: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 88 of 136

7.2.3 Short-Cut

7.2.4 Practical Training: - Understand the decomposition of a picture into Red, Green, Blue planes - Understand the link between the picture and Hue, Saturation, Value maps - Understand brightness range and the link to the histogram (mid-tones, highlights) - Illustrate “Low-key” and “High-key” images - Understand low-contrast and high-contrast images

7.2.5 Step-by-step procedure Step Description Comment 1 Click “Image – Image Statistics”. No image is present. The

histogram is empty. 2 Click “Load Image”. Select “tango. bmp”. The

histogram shows the hue, that is the spread of colors over the whole palette (0 to 360°). Primary colors correspond to narrow peaks.

Yellow peak

Blue peak

Red peak

3 Click “Evalue → Red” and “Transfer to Image2”. The red color is spread in various tones, as seen in the figure on the right and on the histogram. Click “Evaluate → Green” and “Evaluate → Blue” to compare the spread of tones.

4 Select “sunflower.bmp”. The histogram of the values shows a wide spread from low to high brightness. This is equivalent to a large contrat.

Wide value variation = large contrast

Page 89: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 89 of 136

5 Select “sunflower-lowcontrast.bmp”

Reduced variation of values = low contrast

6 Investigate images with low saturation such as

“GridGarden.bmp”.

7 Compare with high saturation image such as

“SunFlower.bmp”.

7.2.6 References - http://www.icaen.uiowa.edu/~dip - http://www.cambridgeincolour.com/tutorials

Page 90: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 90 of 136

7.3 Discrete Cosine Transform

Lab practical L7.3 Discrete Cosine Transform Objectives Illustrate the image conversion from raw pixel to frequency coefficients and image

reconstruction. Also illustrate the coefficients quantization for image compression. Method Control the main DCT parameters; apply the DCT to some simple images to understand

the link between image pixels and frequency. Change the quantization resolution; observe the image quality reduction and image compression factor.

Module ImageSEE

7.3.1 Theory

7.3.1.1 DCT transform

+

+= ∑ ∑−

=

= N

vy

N

uxyxfvCuC

NvuF

N

x

N

y 2

)12(cos

2

)12(cos),()()(

2),(

1

0

1

0

ππ

7.3.1.2 Invert DCT transform

+

+= ∑ ∑−

=

= N

vy

N

uxvuFvCuC

Nyxf

N

u

N

v 2

)12(cos

2

)12(cos),()()(

2),(

1

0

1

0

ππ

With

2)( =iC if i=0

1)( =iC otherwise f(x,y)= pixel value at (x,y) coordinates F(u,v)= DCT value at (u,v) frequencies N = number of points (8 points in MentorDSP, as for JPG images) 7.3.1.3 Quantization

qq

vuFvuF ).

),(((int)),( =′

onquantizativuq *)1(1 +++= With F(u,v)’=low resolution DCT value at (u,v) frequencies Quantization = quantization factor (0= minimum quantization, 30=maximum quantization) Using maximum quantization, the F(u,v)’ , the value of q is high and the rounding of F(u,v)/q leads three possible values are -1, 0 and +1, that can be coded using 2 bits only. This corresponds to maximum compaction. Using minimum quantization, the DCT values are coded using 16 bits. For N= 8, DCT coefficients computed by MentorDSP vary from -800 to 2100 approximately.

7.3.2 User’s Interface

Page 91: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 91 of 136

7.3.3 Short-cut

7.3.4 Practical Training: - Select a predefined picture, select an area in the picture, visualize its his frequency contents. - Understand the 2D computation of coefficients by selected clicks in original images. - Understand the concept of high-frequency in image using fuzzy squares. - Alter the resolution of the quantification coefficients in the F(u,v) matrix. See the effects on the result.

7.3.5 Step-by-step procedure Step Description Comment 1 Click “Image – Discrete Cosine Transform”. A set of

predefined images is proposed on the left menu. By default, the black square is selected. Its DCT and invert DCT (DCT-1) are displayed. The DCT is applied to squares with fixed size 8x8 pixels. The quantization factor is zero, so that no compression is effective.

DCT coefs computed at this location

The DCT-1perfectly matches the original picture. The 8x8 pixels correspond to JPG images.

2 Click “Erase” in the window “DCT Values”. At location (0,0), the DCT-1 corresponds to a black box, 8x8 pixels.

Cl

Page 92: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 92 of 136

3 Double click in the DCT array to investigate the link between DCT values and DCT-1 image. The location close the upper left corner corresponds to low frequency.

4 Click the predefined shape situated on the right lower corner. An image with increased pixel frequency is generated. The DCT is almost 0 except for one single point, appearing in white in the DCT window.

5 Click “Load Image” and select “India64.bmp”. Click on the image and locate high-frequency regions (i.e locations with fast variation from white to black).

6 Modify the cursor “Quantization factor”. This acts on coefficient resolution which affects the picture quality. The quantization induces 0 values for several coefficients, as seen in the array “DCT Values”.

Page 93: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 93 of 136

7.4 Free picture transform

Lab practical L7.4 Free picture transform Objectives Reshape picture by arithmetic operation Method Enter an expression for the matrix transform, see the result; presets the operation and

alter its coefficients (shift, size increase, rotate, stretch..) Module ImageSEE

7.4.1 Theory

7.4.1.1 General equation

1++++=

hygx

cbyaxX

1++++=

hygx

feydxY

Where (x,y) is the original pixel coordinate and (X,Y) is the final pixel coordinate. 7.4.1.2 Particular cases Stretch axX = ; eyY = Rotation ;)sin(-)xcos( yX θθ= ;)cos()xsin( yY θθ += Translation cxX += ; fyY +=

7.4.1.3 General Transform knowing 4 points origin (x,y) and 4 end points (X,Y) [ ][ ] [ ]BA =λ

=

−−−−

−−−−−−−−

Yn

Xn

Y

X

Y

X

h

g

f

ed

c

b

a

YnynYnxn

XnynXnxn

xn

ynxn

yYxYy

yXxX

yYxYy

yXxX

x

yx

x

yx

..

..2

2

1

1

00

........

........

000

01

........

........222212

222200

111111

111100

2000

0122

1000

0111

[ ] [ ] [ ] [ ] [ ]BAAA TT 1)( −=λ

7.4.2 Proposed GUI

Page 94: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 94 of 136

7.4.3 Features - basic presets available (translate, rotate, stretch, perspective…) - user’s defined modification of (X,Y) from (x,y) initial coordinates - reshaping coefficients automatically calculated given start and stop window

7.4.4 Short-cut

7.4.5 Practical Training: Step Description Comment 1 Click “Image-Image Transform”. Click “Load Image”

and select for example “India64.bmp”. By default, the (x,y) to (X,Y) transform corresponds to the rotation 45° (π/4).

Using low resolution images speeds up the process

Page 95: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 95 of 136

2 Click “Compute Transform”. The matrix transform is applied to the whole picture. The result is shown below.

3 Investigate the effect of other transforms using presets (Stretch in X or Y).

4 Select “Camel.bmp”. Click “Anchors for perspective”. Click on the anchors as shown below.

Initial coordinates in white

Final coordinates in green

5 In real-time, the matrix coefficients are updated according to the initial and final coordinates. The computation algorithm is detailed in the part “Theory” and makes an extensive use of matrix computation.

6 Click “Transform”. The initial image is large and the result image even more.

Note the size of the final image in this case : 1500 x 1200 pixels!

Page 96: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 96 of 136

7.4.6 Reference: http://alumni.media.mit.edu/~cwren/interpolator Nicolas SCHULCZ Design of software prototypes for signal processing training, the MentorDSP project, INSA Toulouse, France, Engineering report, June 2007 (in French)

Page 97: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 97 of 136

7.5 Image Noise

Lab practical L7.5 Image Noise Objectives Illustrate noise in images and filtering techniques. Method Create additive noise to user’s defined images. Define a pixel filter and apply to the

noisy image Module ImageSEE

7.5.1 Theory: Random noise is characterized by intensity and color fluctuations above and below the actual image intensity.

- MentorDSP produces a White noise which is randomly selected from 0 to n, the later is defined by the user. The white noise has constant power spectrum. The white noise is a very crude approximation of image noise

- The Gaussian noise is a very good approximation of noise that occurs in many practical cases. The density distribution follows the formulation:

2

2

2

)(

2

1 σ

σπ

mt

ef−−

=

- Additive noise : ),(],[1],[2 yxyxIyxI ν+=

- Image Filtering :

yx

yxIyxI

∂∂= ],[1

],[2

]1,1[1).3,3(]1,1[1).3,1(

]1,1[1).3,3(]1,1[1).1,1(],[1).2,2(],[2

++++−++++−−+=

yxIwyxIw

yxIwyxIwyxIwyxI

x-1 x x+1

y-1 w(1,1) w(1,3) y w(2,2)

y+1 w(3,1) w(3,3)

7.5.2 User’s Interface

Page 98: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 98 of 136

7.5.3 Short-Cut

7.5.4 Practical Training: - Understand the noise addition in Red, Green, Blue planes - Understand the link between the noise amplitude and picture quality - Apply filter to recover from noise - Investigate other filter effects (contour extraction)

7.5.5 Step-by-step procedure Step Description Comment 1 Click “Image – Image Noise and Filtering”. No image is present. The

three color planes are selected. Default noise amplitude is 10.

2 Click “Load Image”. Select “sunflower.bmp”. Click “Add Noise”. No significant decrease in picture quality is observed.

3 Modify the noise cursor until the quality is seriously affected (Above: maximum level of 255).

4 Enter the following values for the filter, which

correspond to averaging of near-by coordinates. The weight of the pixel is 4, equal to the sum of weights of the nearby pixels.

Page 99: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 99 of 136

5 Click “Apply Filter”. A smoothing effect is observed.

Click several times. Although the noise disappears, the pictures looses in precision.

6 Load “india64.bmp”. The filter values shown below are

used for contour extraction. Apply the filter and see the result. Dark regions correspond to low variation of color, while bright regions correspond to fast color change.

Page 100: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 100 of 136

8 Modulation

8.1 Illustrate Amplitude Modulation

Lab practical 8.1 Illustrate Amplitude Modulation Objectives Illustrate amplitude modulation and demodulation Method Change the Amplitude Modulation parameters, see its instant spectrum as well as

spectrogram; understand AM demodulation through rectification and filtering. Module DspBase and ComPRO

8.1.1 Theory

)sin().1()( tAmtS cω+=

Where ωc is the carrier pulse m is the modulation coefficient A is the modulation signal When

)sin( tA mω=

And knowing that

2

)cos()cos(sinsin

BABABA

+−−=

)sin())sin(.1()( ttmtS cm ωω+=

))cos((.2

1))cos((.

2

1)sin()( tmtmttS cmcmc ωωωωω +−−+= (equ 8-1)

8.1.2 User’s Interface

8.1.3 Short-Cut

Page 101: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 101 of 136

8.1.4 Practical Training: - Change the modulation coefficient - See the time-domain aspect of the modulation - See the instant FFT. Three harmonics are observed in application to equation 8-1 : the carrier frequency

and two harmonics at f0+fc and f0-fc. - Demodulate the signal through a rectification and a filtering

8.1.5 Step-by-step procedure Step Description Comment 1 Click “Modulation – Amplitude Modulation”. The time-domain

waveform appears in the upper window. The corresponding Fourier Transform is displayed in the lower window. The ComPRO menu gives access to the modulation coefficient without the need to open the Signal Generator window.

A 1000Hz carrier modulated by a 200 Hz sinusoidal wave is generated. The coefficient is 0.7

2 In the ComPRO window, modify the modulation coefficient (for example 1.5). Either use the arrows (step 0.1) or change the value and click “Update”. See how sub-harmonic amplitude rises with AM coefficient.

The new wave and corresponding spectrum appear.

3 Click “Spectrogram”. At time t=0.1s, the signal ends and returns to a default value 0.0. This creates a discontinuity and generates a “dirac-like” series of harmonics in the whole spectrum.

Carrier f0+fc

f0-fc End of signal generating a discontinuity and a huge amout of harmonics

Notice the two harmonics at f0+fc and f0-fc (1200 Hz and 800 Hz).

Page 102: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 102 of 136

4 Change the modulation frequency (now 100 Hz). See the modification in the Spectrogram : the carrier remains but the distance with sub-harmonics is now 100 Hz.

5 The demodulation first consists of a rectification, which is usually performed by a diode with a threshold voltage of several hundred millivolt. The default threshold voltage proposed in ComPRO is 0.1V. Click “Apply -> 2 ” in “AM rectification”.

The result shown in the lower screen only contains voltage values above the threshold voltage.

6 Change the threshold voltage and see the effect on the amplitude.

Threshold voltage

Usually, diodes with very low threshold voltages are used for this rectification.

7 Once rectified, the signal is filtered to extract the AM modulation. By default, the carrier signal is at 1000 Hz, and the information is at 200 Hz. An appropriate low-pass filtering frequency would be above 200 Hz and below 1000 Hz. Investigate the effect of changing the filtering frequency.

In practice, the low-pass filtering may be a R-C filter of a FIR filter (see corresponding lab-practical)

Page 103: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 103 of 136

Filtering frequency: 100 Hz : the 200 Hz signal is also filtered

Filtering frequency: 800 Hz : the 200 Hz signal appears clearly

Page 104: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 104 of 136

8.2 Illustrate Frequency Modulation

Lab practical 8.2 Illustrate Frequency Modulation Objectives Illustrate Frequency Modulation (FM) impact in frequency domain and the

parameter influence Method Modify the parameters of the Frequency Modulation, see its instant

spectrum as well as spectrogram Module ComPro

8.2.1 Theory

).sin()( AmttS c += ω

Where ωc is the carrier pulse m is the modulation coefficient A is the modulation signal Considering

)sin( tA mω=

))sin(.sin()( tmttS mc ωω +=

))sin(()()( tnmJtS mcn n ωω +=∑+∞

−∞= (equ 8-2)

Where Jn(m) are the Bessel coefficients usually provided by dedicated tables The FM wave contains an infinite number of sidebands at (fc+fm), (fc+ 2fm), ( fc+ 3fm), etc, symmetrical at fc.

8.2.2 User’s Interface

8.2.3 Short-Cut

Page 105: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 105 of 136

8.2.4 Practical Training: - Change the modulation coefficient - See the time-domain aspect of the modulation - See the instant FFT. A series of harmonics is observed in application to equation 8-2 : the carrier

frequency and harmonics at f0+n.fc and f0-n.fc. The amplitude of each harmonic strongly depends on the modulation accessible in the “Tool” menu. It follows Bessel functions.

- The student may also enter his own FM equation ; see the result in time domain

8.2.5 Step-by-step procedure Step Description Comment 1 Click “Modulation – Frequency Modulation”. The time

domain waveform and instant spectrum appear. A 1000 Hz carrier modulated by a 200 Hz sinusoidal wave is generated. The coefficient is 1.0 by default.

2 In the ComPRO sub-window, change the modulation coefficient by using the arrows of by entering a new value.

The new wave appears.

3 Click “Spectrogram”. At time t=0.1s, the signal ends and returns to a default value 0.0. This creates a discontinuity and generates a “dirac-like” series of harmonics in the whole spectrum.

Carrier f0+fc

f0-fc End of signal generating a discontinuity and a huge amout of harmonics

f0+2fc

f0+3fc

f0-2fc

As m increases, each sideband harmonic follows its own path of increasing and decreasing amplitude called a Bessel function. - For m = 0 (i.e. no modulation), the carrier is at full

strength. - As m increases, the carrier loses strength; each

additional order of sideband pairs begins to appear.

Notice the harmonics at f0+n.fc and f0-n.fc (1200, 1400, 1600 Hz, etc. and 800, 600, 400 Hz, etc.

Page 106: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 106 of 136

4 Click “Signal Generator”. Click “Equation” and enter

the equation of the Frequency Modulation, for example: sin(2*pi*1000*t+0.7*sin(2*pi*200*t))

8.2.6 References: Learn more about BESSEL functions at http://www.indiana.edu/~emusic/fm/fm.htm

Page 107: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 107 of 136

8.3 Illustrate Quadrature Phase Shift Keying

Lab practical 8.3 Illustrate Quadrature Phase Shift Keying (QPSK) Objectives Illustrate QPSK modulation, its link to digital data, and bit extraction Method Enter the data to be phase-modulated, see time-domain result, see

spectrogram. Make step-by-step demodulation and see how bits appear as DC levels

Module DSPBase and ComPRO

8.3.1 Theory

)sin()cos()()()( tststQtItS cqci ωω +=+= Equ. 1

Where I(t) = “In phase” component Q(t) = “Quadrature” component ωc is the carrier pulse si is the sign of I(t) sq is the sign of Q(t) The correspondence between data symbols and signs is given below, which corresponds to the constellation diagram shown below:

Data si sq 00 -1 -1 01 -1 1 10 1 -1 11 1 1

si

sq

1 -1

-1

1

ϕ

11 01

00 10

The signal can also be written:

)sin(2)( ϕω += ttS c Equ. 2

ϕ is the phase, with the following correspondence:

Data ϕ 00 5π/4 01 3π/4 10 7π/4 11 π/4

Demodulation is performed by multiplying the signal by cos and sin, with the same frequency. For the cosine channel:

))sin()cos()(cos()( tststtID cqcic ωωω += Equ. 3

which can be arranged as a function of the phase and a high-frequency term:

Page 108: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 108 of 136

)2cos()cos()( tAtID cωϕ += Equ. 4

))sin()cos()(sin()( tststtQD cqcic ωωω += Equ. 5

which can be arranged as a function of the phase and a high-frequency term: )2sin()sin()( tAtQD cωϕ += Equ. 6

The high frequency is removed by averaging. The cosine channel gives back the information si and the sine channel the information sq.

8.3.2 User’s Interface

Figure 1 : QPSK signal generator window

Figure 2 : QPSK signal waveform and spectrogram

8.3.3 Short-Cut

Page 109: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 109 of 136

8.3.4 Practical Training: - Student enters the data to be phase-modulated - See time-domain result, compute spectrogram. Spectrum can show discontinuities when phase

changing: high frequency - View of constellation – Link between data and phase of the signal - Make step-by-step demodulation and see how bits appear as DC levels - Student can demodulate signal modulated by other student - Possibility to add noise

8.3.5 Step-by-step procedure Step Description Comment 1 Click “Modulation – QPSK Modulation”. The time

domain waveform and corresponding spectrogram appear. Each phase change generates a discontinuity that produces harmonics in the whole spectrum.

Carrier

“00”

The phase changes introduce discontinuities

“01” “10” “11”

A 900 Hz carrier modulated by “00-01-10-11” data sequence is generated.

2 Illustrate the correspondence between Equations 1 and 2 (equivalence between I+Q and sinus). Click “Signal Generator”, “Equation” and enter the following formulation which corresponds to the angle 5π/4 for a symbol “00” (from table above). Click “->2” to place the signal on the bottom screen for comparison purpose. sqrt(2)*sin(2*pi*900*t+(5*pi/4))

The two signals are identical.

Page 110: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 110 of 136

3 Click “Signal Generator”, “Equation” and enter the following formulation. Click “->2” to place the signal on the bottom screen for comparison purpose. -cos(2*pi*900*t)-sin(2*pi*900*t)

Again the signals are identical

4 Demodulation. Click “Signal Generator”, “Basic”, “Sine” at 900 Hz frequency. Click “->2” and “Generate”.

A sinusoidal wave is generated on the bottom screen.

4 In the tool menu, Click “1x2”. The QPSK is multiplied the sinusoidal wave.

The result of the multiplication of S(t) by a sine wave is the LSB of the data, that is “.0”, “.1”, “.0”, “.1”.

Page 111: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 111 of 136

Negative average corresponds to “0”

Positive average corresponds to “1”

5 Click “Signal Generator”, “Basic”, “Cosine” at 900 Hz

frequency. Click “->2” and “Generate”.

Negative average corresponds to “0”

Positive average corresponds to “1”

The result of the multiplication of S(t) by a sine wave is the MSB of the data, that is “0.”, “0.”, “1.”, “1.”.

6 The ComPRO module features the same operation with all controls in a single sub-menu.

Enter data here (8 bit format, eq. 4 symbols)

Modify the carrier frequency (900 Hz by default)

Add noise to the existing signal

Multiply by cos(wt), see the result on the upper screen

Extract cosine channel data through averaging

Extract sine channel data through averaging

Multiply by sin(wt), see the result on the upper screen

7 Click “Apply”. The data is modulated using QPSK.

8 Add a large noise to the data (1.6 V here) and click ‘apply’.

9 Multiply by cosine and sine waves. The following results appear.

The noise almost covers the wave.

Page 112: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 112 of 136

10 Click “Extract”. The average is computed for each

symbol and a decision is taken as follows: - if the average is above 0, the data is “1”. - If the average is below 0, the data is “0”

“0” “0”

“1” “1”

“0”

“1”

“0”

“1”

Even with a high noise (twice larger than the signal), the average value clearly indicates the “0” or the “1”.

11 See how the binary information is recovered even with high noise: each channel extracts one part of the symbol. The cos channel extracts the left bit, the sin channel the right bit.

12 Increase the noise to 12 V (More than 10 times the signal). The bit error rate is significant. An example of erroneous demodulation is given below.

Page 113: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 113 of 136

Should be 0011 Should be 0101

12.8 V white noise

8.3.6 References: Learn more about QPSK from http://en.wikipedia.org/wiki/Phase-shift_keying

Page 114: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 114 of 136

8.4 Illustrate Gaussian Modulated Shift Keying

Lab practical L8.4 Illustrate Gaussian Modulated Shift Keying (GMSK) Objectives Illustrate GMSK modulation, its link to digital data, and bit extraction Method Enter the data to be phase-modulated, see time-domain result, see

spectrogram. Make step-by-step demodulation and see how bits appear as DC levels

Module DSPBase for signal visualization ComPro for modulation/demodulation

Theory

(See L8.3 QPSK for basic information on phase modulation) The transition between two symbols is done using smoothing curves to avoid time-domain discontinuities as follows:

time

Phase

π/4

3π/4

-3π/4

-π/4

“00” “01” “10” “11”

(or 7π/4)

(or 5π/4)

QPSK

GMSK

User’s Interface

Figure 2 : GMSK signal waveform and spectrogram

Page 115: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 115 of 136

Short-Cut

Practical Training: - Student enters the data to be phase-modulated - See time-domain result, compute spectrogram. The spectrum shows almost no discontinuity when

phase changes due to Gaussian smoothing. - Possibility to add noise

Step-by-step procedure Step Description Comment 1 Click “Modulation – GMSK Modulation”. The time

domain waveform and corresponding spectrogram appear. In contrast to what has been observed in QPSK modulation, phase change almost generates no discontinuity except at the signal termination.

Almost invisible phase change

A 900 Hz carrier modulated by “00-01-10-11” data sequence is generated.

2 Use ComPRO module to demodulate the signal.

Page 116: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 116 of 136

Enter data here (8 bit format, eq. 4 symbols)

Modify the carrier frequency (900 Hz by default)

Add noise to the existing signal

Multiply by cos(wt), see the result on the upper screen

Extract cosine channel data through averaging

Extract sine channel data through averaging

Multiply by sin(wt), see the result on the upper screen

3 Multiply by cosine and sine waves. The following

results appear.

Note the smooth waveform obtained through the GMSK phase change.

4 Click “Extract”. The average is computed for each symbol and a decision is taken as follows: - if the average is above 0, the data is “1”. - If the average is below 0, the data is “0”

“0”

“0” “1”

“1”

“0”

“1” “0”

“1”

The initial data is recovered.

References: Learn more about QPSK from http://en.wikipedia.org/wiki/Phase-shift_keying

Page 117: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 117 of 136

8.5 Illustrate Code-Division-Multiple-Access (CDMA)

Lab practical 8.5 Illustrate Code-Division-Multiple-Access (CDMA) Objectives Illustrate CDMA modulation and demodulation, the code effect, the link to

digital data, and bit extraction. Method Enter the data to be phase-modulated, multiply by the code, see time-

domain result, see spectrogram. Make step-by-step demodulation and see how bits appear. See the effect of correct and erroneous code on result, as well as noise.

Modules SigGen, DSPbase & ComPRO

8.5.1 Theory In radio CDMA, each group of emitter/receiver is given a shared code. Many codes occupy the same channel, but only users associated with a particular code can understand each other. Codes are said to be orthogonal to each other if the sum of elementary multiplication is zero, which is close to the concept of correlation. Mutually orthogonal vectors can be obtained from Walsh matrix (See [1]). Examples of 8-bit codes are proposed in fig. 1.

Code 1

-1

+1

Code 1

-1

+1

Code 1

-1

+1

Code 1

-1

+1

Figure 1 : examples of 8-bit orthogonal codes used for CDMA communications

8.5.2 8-bit codes example - <-1,-1,1,1, -1,-1,1,1> is orthogonal to <-1,1,1,-1, -1,1,1,-1> as (-1x-1)+(-1x1)+(1x1)+(1x-1)…=0 - <-1,-1,1,1, -1,-1,1,1> is not orthogonal to <1,1,-1,-1, 1,1,-1,-1> as (-1x1)+(-1x1)+(1x-1)+(1x-1)…=-8

8.5.3 User’s Interface

Figure 1 : CDMA modulation in SigGEN

Page 118: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 118 of 136

Digital data modulated using Binary phase

shift keying

Code impacting the sign of the signal (“0” multiplies by -1, “1”

by +1)

Add noise, define its amplitude

Add another CDMA signal, same data but different code

Receiver: multiply by the code

Demodulate BPSK

Average on each symbol to extract the “0” or “1”

Adjust decision threshold VT: average>VT : 1 average <Vt : 0

Otherwise undefined (X)

Display one data duration

Display one code duration

Figure 2 : CDMA modulation and demodulation menu in ComPRO

8.5.4 Short-Cut

8.5.5 Practical Training: - Student enters the data to be emitted, choose the code - See time-domain result, compute spectrogram. The spectrum shows data discontinuities - The CDMA signal is multiplied by the good code : data is restored. - The CDMA signal is multiplied by the wrong code : data is wrong - The CDMA signal is multiplied by noise : data can still be recovered - The CDMA signal is added to another CDMA signal, same frequency, different code : data can still be

recovered

8.5.6 Step-by-step procedure Step Description Comment 1 Click “Modulation – CDMA Modulation”. The time

domain waveform and corresponding spectrogram appear. The ComPRO module is also proposed on the right side of the screen.

A 1900 Hz carrier modulated by “00011011” data sequence is generated. The spectrogram shows

Page 119: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 119 of 136

important harmonic contents due to numerous discontinuities

2 Click “Zoom 1 code”. Phase changes are observed at regular intervals, which correspond to the code (01010101).

“0” (multiply by -1) “1” (multiply by +1) “0” (multiply by -1)

3 Demodulation. In the CDMA receiver menu, multiply the signal by the code by a click on “->1”. The result appears on the upper window. The phase shifts due to the code have disappeared, only remain the phase change due to symbol change.

(1) Multiply by the same code as for emitter

4 Now, multiply the cosine with the same frequency by a click on “->1”.

(2) Multiply by cosine at same

frequency

“0” “0” “0”

“1” “1”

“0”

“1” “1”

The data sequence clearly appears in the result “00011011”.

5 Extract data: Click “Average channel 1”. The data is

Page 120: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 120 of 136

averaged for each symbol. The threshold is 0.3V. If the average is above 0.3V, the data is “1”. If the average is below -0.3V, the data is “0”. Else the data is undefined (“x”).

(3) Click Average channel 1

(4) The digital data appears

-0.3

“0”

“x”

“1”

+0.3

6 Demodulation with noise. Select the desired level of

noise, and click “apply”.

(1) Increase the noise

(2) Generate the CDMA signal with

noise

The noise density is quite high in the corresponding spectrogram.

7 As in steps 3 to 5, multiply by the code and by the cosine. Then compute the average. The data sequence is correct.

8 Increase the noise furthermore until a wrong code is produced. Using 12 V noise, the 3rd data should be 0 (less than -0.3V) but is considered as “x” as the average is around -0.1.

A noise with a variance nearly 10 times higher that the signal is required to induce frequent failures (high bit error rate).

Page 121: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 121 of 136

9 Demodulation with a wrong code. Select another code such as 00110011. The average is close to 0 for each symbol, which appear as “x”.

The data sequence is lost. Orthogonal codes lead to average close to 0.0V.

10 Demodulate with a non-orthogonal code. Type for example 01010110, which is very close to the code used for modulation. In this case, the receiver interprets some symbols.

Non-orthogonal codes lead to average higher than 0.0V, which may lead to interference between symbols.

11 You may add not only noise but also a modulation on the same frequency, almost same amplitude, but different code.

(1) Select the other code

(2) Add the CDMA modulation using this code to the initial CDMA signal

Notice the important amplitude changes due to conflicting situation of two added sinusoidal waves. In some cases, the signal might be almost 0 (fading effect).

12 Signal is recovered even with a CDMA signal with the

Page 122: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 122 of 136

other code, which proves that CDMA is robust to interference.

8.5.7 References: Learn more about QPSK from http://en.wikipedia.org/wiki/Code_division_multiple_access

Page 123: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 123 of 136

8.6 Illustrate Orthogonal Frequency-Division Multip lexing (OFDM)

Lab practical 8.6 Illustrate Orthogonal Frequency-Division Multiplexing (OFDM) Objectives Illustrate OFDM modulation Method Enter the data to be modulated. Understand the role of each sub-carrier.

Understand how data is split and modulated. Module DSPBase, ComPRO

8.6.1 Theory OFDM transmits data through a large number of narrow-band carriers, closely spaced in the frequency domain. Invert-FFT avoids the use of a large number of modulators and filters at the transmitter. FFT does the same for the receiver. 8.6.1.1 Transmitter The OFDM symbol s(t) is the sum of N sinusoidal carriers with increased frequency, modulated by symbols m containing the data as written in Equ. 1 :

∑ == N

k

knN

jekmns

1

2

][][π

Equ. 1

Where N is the number of carriers (a power of 2 for FFT and iFFT implementation) m[k] is the kth symbol which contains the data 8.6.1.2 Receiver The symbol m is estimated using equation 2.

∑ =

−= N

n

inN

jens

Nim

1

2

][1

][π

Equ. 2

8.6.2 User’s Interface

Figure 1 : OFDM signal waveform with data and FFT information

Page 124: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 124 of 136

8.6.3 Short-Cut

8.6.4 Practical Training: - Student enters the data to be emitted, choose the sub-carrier number and FFT size - See time-domain result, compute spectrogram. The spectrum shows sub-carriers

8.6.5 Step-by-step procedure Step Description Comment 1 Click “Modulation – OFDM Modulation”. The time

domain waveform and corresponding spectrogram appear.

The data “0101”

2 Click “Signal Generator”. In the menu “Transmit Data”, choose “0xxx”. The sub-carrier corresponding to 86 Hz is applied a negative sign corresponding to “0”.

3 Select “1xxx”. The sign is inverted. The sub-carrier at 86 Hz is assigned the MSB using a BPSK modulation.

Page 125: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 125 of 136

4 Enter “01xx”. The 2nd sub-carrier at 172 Hz codes the

“1”. The result is the sum of the two sub-carriers.

5 Select a 4-bit data. Click “Generate”. On the bottom screen, click “Fourier Transform”.

OFDM bandwidth

Frequency

Amplitude

Sub-carrier 1 x fscs

Sub-carrier 2 x fscs

Sub-carrier 4 x fscs

8.6.6 References: Learn more about OFDM from http://en.wikipedia.org/wiki/OFDM Bahai, A. R. S., Saltzberg, B. R., Ergen, M. (2004)., Multi Carrier Digital Communications: Theory and Applications of OFDM, Springer, 2004

Page 126: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 126 of 136

9 Questions and Answers

9.1 Exercise : Fourier Transform – Resolution

Question : When we compute the Fourier transform of a 1000 Hz clock, and if we select the range 5000 Hz and a FFT resolution of 256 points, the following FFT result appears. Why don’t we observe sharp peaks, instead of these smooth peaks?

Answer: Click the icon below to see the spectrum as a discrete series of harmonics. The result appears as shown below. The energy is distributed among not only one but many successive harmonics. This is usual when computing the FFT using a low number of points, and without any correspondence between the FFT window (here 256 points, each point equal to 1/11025 s, total 23.22 ms). The separation between two harmonics is 43 Hz.

The result is much better when you modify the frequency to 1102 Hz, which corresponds to the sampling frequency 11025 Hz divided by 10. In that case, the FFT applies to an exact number of harmonics which cancels all the noise observed between the peaks.

Page 127: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 127 of 136

No more noise

Energy distributed on 4 harmonics

Also notice the effect of FFT resolution. Using more points (1024 instead of 512) leads to a higher resolution, meaning a smaller distance between two adjacent harmonics.

Narrow peaks

9.2 Fourier Transform – 2 pics

Question : When we compute the Fourier transform of a 1000 Hz sine wave, and if we select the range 20000 Hz, the following FFT result appears. One peak appears at 1000 Hz, which seems correct, an other appears at 10,034 Hz, which seems a mistake. Why?

Page 128: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 128 of 136

Answer: the second peak is normal. By default, MentorDSP uses 512 points. The FFT result has 512 harmonics. However, only the 256 ones are important, as the next 256 are identical, and folded (symmetry as shown below).

256 harmonics

256 harmonics

Frequency

Amplitude

Only this part is important Default sampling freq: 11025 Hz

Default sample number: 512 1000Hz

5512 Hz 11025 Hz

By default, MentorDSP uses a sampling freq. of 11025 Hz, which means that if you display from 0 to 5000 Hz you do not see this effect. If you display from 0 to 20000 Hz, you will see the “spectrum” copying effect. The theoretical frequency of the second peak is 11025-1000, that is 10025 Hz.

9.3 Exercise : Fourier Transform – Square Signal

Question : Is there a way to illustrate with MentorDSP the theoretical value of the Fourier Series of a clock, which states that the harmonics decrease by 1/3, 1/5, 1/7, etc.. ?

0=na

))1(1(2

)cos1(2

sin)(2 2/

2/

nT

T

n n

An

n

Atdtntf

Tb −−=−== ∫

− ππ

πω

++= tttA

tf ωωωπ

5sin5

13sin

3

1sin

4)(

Time

value

T

A

-A

Page 129: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 129 of 136

ω

value

4A/π

4A/3π

4A/5π

ω

Answer: Generate a clock with a frequency equal to 21,53 Hz, that is exactly the distance ∆f between two harmonics when using the default sampling frequency 11025 Hz and FFT resolution of 512 points.

n

fsf =∆

Where ∆f is the spacing between adjacent harmonics (Hz) fs is the sampling frequency (11025 Hz by default) n is the FFT resolution (512 points at initialization)

In this case, the FFT window exactly fits one period of the clock. Unfortunately, the Fourier series do not show the expected result. Harmonics 2, 4, 6, 8 should be 0.

Page 130: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 130 of 136

The explanation here comes from the windowing (Blackman by default). Distortion is a side effect of the Blackman or Hamming window. However, these windowing gives significant advantages in other cases such as numerical noise reduction. Choose “Rectangular”. At last, the result corresponds to the theory.

Click “Fourier Coefficients” and look at the list of harmonics. Notice that bn series are null and an series are the expected ones. These is because the clock is phase-shifted and correspond to cosine series instead of sine waves, as was stated previously in the theoretical section.

Theoretical value Computed value

6366.05,04 =π

0.637

2122,05,03

4 =π

0.212

Page 131: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 131 of 136

127.05.05

4 =π

0.127

Page 132: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 132 of 136

10 Appendix

10.1 Signal Processing Fundaments used in MentorDSP

10.1.1.1 Autocorrelation:

∫+∞

∞−−=−≡ τττγ d)t(x)(x)t(x*)t(x)t(

10.1.1.2 Autocorrelation in the case of random signals: [ ]ττγ −≡ ttXX xxE)(

10.1.1.3 Convolution

∫+∞

∞−−= τττ d)t(y)(x)t(y*)t(x

10.1.1.4 Convolution 2D

ρτρτρτ ddyxJIyxJyxI ∫ ∫+∞

∞−

+∞

∞−−−= ],[],[],[*],[

10.1.1.5 Correlation coefficient

[ ] [ ][ ]YX

XY

YXEXYE

σσρ −= avec σ=écart type

10.1.1.6 10.1.1.7 Energy Conservation in time and frequency domain

∫ ∫= df)f(Xdt)t(x22

10.1.1.8 Gaussian Minimum Shift Keying )),(2cos(),( 0 απα ttfAts Φ+=

∑+∞=

−∞=−=Φ i

i i iTtqt )(),( αα

))cos(1()( 21 tkktq −=

10.1.1.9 10.1.1.10 Probability density function

10.1.1.11 ( )')()( xFxf XX = =derivative of the probability distribution function

10.1.1.12 Power Spectral Density

2))(()( txTFfPSD ≡

10.1.1.13 Power Spectral Density for random signals

=

+∞→

2

T

)f(XElim)f(DSP T

T

20 Xm)(DSP =

10.1.1.14 Variance

212

22X (X)m(X)mariance)(σ −== v

10.1.1.15 Signal Energy

Page 133: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 133 of 136

∫+∞

∞−≡ dt)t(xE

2

10.1.1.16 Mean Value The mean of a random process is the average of all realizations of that process

∫+∞

∞−== dxxfxXEXm X ).(.][)(1

10.1.1.17 10.1.1.18 Probability distribution

)xX(P)x(FX ≤= 10.1.1.19 Gaussian Function

2

2

2

)(

2

1 σ

σπ

mt

ef−−

=

σ=variance (0.683 à -σ ou +σ) m=mean value 10.1.1.20 Moments Mean-square value

∫+∞

∞−== dxxfxXEXm X ).(.][)( 22

2

∫+∞

∞−== dxxfxXEXm X

nnn ).(.][)(

10.1.1.21 10.1.1.22 Signal Average

∫≡0

00

1 Tdt).t(x

T)t(x

10.1.1.23 Average Power

∫+

≡0 2

0

1 Tt

tdt)t(x

TP

10.1.1.24 Signal Power

∫+∞

∞−

= df)f(DSPP

10.1.1.25 Fourier Series

)T

tnsinb

T

tncosa(a)t(x nn n ππ 22

10 ∑∞

=++=

∫=T

dt)t(xT

a00

1 (mean value of x(t) in the interval T)

∫=T

n dt)T

tncos()t(x

Ta

02

2 π (n>0)

∫=T

n dt)T

tnsin()t(x

Tb

02

2 π (n>0)

10.1.1.26 Fourier Series in complex form

Page 134: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 134 of 136

)eS(a)t(xn

ntjn∑

−∞=+= ω

0

∫=T

dt)t(xT

a00

1

∫−=

T tjnn dte)t(x

TS

0

1 ω

2nn

n

jbaS

−=

2nn

n

jbaS

+=−

T

πω 2=

10.1.1.27 Fourier Transfrom

))t(x(TF)f(X =

∫+∞

∞−

−= dte)t(x)f(X ftjπ2

10.1.1.28 Fourier Transform of a convolution product

)t(y*)t(x)f(Y).f(X ↔ 10.1.1.29 Invert Fourier Transform

∫+∞

∞−= dfe)f(X)t(x ftjπ2

10.1.1.30 Z-Transform

∑∞

−∞=

−=n

nznxzX ].[)(

10.1.1.31 Z-Transform properties

)()(][][ 2121 zbXzaXnbxnax +→+

1][ →nδ

)().(][][ 2121 zXzXnxnx →∗ 10.1.1.32 Finite-Impulse-Filter

y n[ ] = bix n − i[ ]i =0

N

Impulse response [ ] [ ] [ ] [ ] [ ] [ ]∑=

−=−++−+−+=N

iiN inbNnbnbnbnbnh

0210 ...21 δδδδδ

Harmonic Response H( jf ) = bie− j 2πifTe

i =0

N

10.1.1.33 Infinite-Impulse-Filter

y n[ ] = bix n − i[ ]i =0

N

∑ + aiy n − i[ ]i =1

M

10.1.1.34 Trigonometry

BABABA sincoscossin)sin( −=−

BABABA sincoscossin)sin( +=+

Page 135: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 135 of 136

BABABA sinsincoscos)cos( +=−

BABABA sinsincoscos)cos( −=+

2

)cos()cos(sinsin

BABABA

+−−=

2

)cos()cos(coscos

BABABA

++−=

2

)sin()sin(sincos

BABABA

−−+=

2

)2cos(1)sin( 2 A

A−=

Page 136: An Illustration of Digital Signal Processingsrv-sicard/mentordsp/labpracticals.pdfPage 2 of 136 About the Author Etienne SICARD received the B.S degree in 1984 and the PhD in Electrical

Page 136 of 136

ISBN 978-2-87649-054-3