You are on page 1of 131

Digital Signal Processing

DESD June 2015

M.Kumar
C-DAC, Hyderabad

Agenda

Signal basics

Types of signals, signal classification

Discrete signals, systems, spectrum

LTI system, convolution

ADC(sampling, aliasing, quantization)

Signal processing operations

Basic filters

Introduction

And many more!

GPP Versus DSP

General Purpose Processors(GPP) are primarily designed for data


processing

Primary burden is data read/write

Digital Signal Processors are specifically designed for signal


processing

Handling many tasks at once, controlling huge amounts of memory and


data, controlling a wide variety of computer peripherals (disk drive, modem
etc..)

DSPs are more dedicated, work on smaller range of functions at lightning


speed, yet less costly and requiring much less space (size) and power
Primary burden is mathematical operations

So, DSP architectures incorporate certain features not found in


GPP

Overview of DSP

Signal Processing

Signal processing refers to the science of


analyzing time varying physical processes
Signal Processing

Analog
Before 1970s

Digital

Mixed

1970 to 2000

Current trend

Analog Signal Processing

All real world signals are analog

Uses R,L,C & transistors for signal processing

Analog
Input

Analog
Output

Limitations of ASP

More sensitive to componenet tolerances &


environmental changes
Changes in L, C or power changes system
characteristics
Analog systems take more space

Advantages of DSP over ASP

Ageing has no effect


Flexibility in developing new digital techniques
with minimal hardware changes

Programmable

Uses standard circuits for implementation

Multiplexing is possible

FDM

TDM

Why DSP?

Stability

Programmability and hence flexibility

One H/W can perform several tasks

Upgradeability

More reliable as components are less sensitive


to variations in ambient variables(temp..etc)

Easy to debug, hence short development time

Low cost as independent of H/W complexity

DSP Applications

DSP systems must work in real time, capturing


and processing information as it happens.
Otherwise, information is lost and the signal
gets distorted
Calculations should be done as fast as the
signal data is received from the ADC

DSP in Real World

DSP-based VoIP gateway makes a shift to data


networks possible, serving as the bridge between
PSTN and the packet network

Speech compression & transmission in mobile phones

Image, audio, video processing

Medical Imaging

Weather forcasting

Seismic data processing

Control of industrial processes

DSP Processors

TMS 320 from texas Instruments

Motorola DSP 56000

SHARC processors from Analog Devices

Recent Advancements in DSPs

Run at horse speeds

Smaller footprint

Reduction in power dissipation

DSP Application

Source:
1. http://news.bbc.co.uk/2/hi/health/8521067.stm
2. http://www.matchboxmobile.com/

What's Inside a DSP?

Signal Basics

What is a signal?

A signal is a function of one or more independent


variables such as time, distance, temparature etc
signal = function(x1,x2,x3...)

Why signals?

Signals carry useful information

Why signal processing?

To extract useful information carried by the signal

Speech Signal

Biological Signals

Biological signals are time series signals


generated by some biological mechanism
ECG(Electrocardiography) signals are electrical
potentials recorded from the chest(mainly),
arms, legs

EEG(Electroencephalography) signals are


oscillating electrical potentials recorded from
the scalf surface
They are generated by neuronal activities in the
brain

Example

Research

'Mind-reading machine' can convert thoughts


into speech

Source: http://mashable.com/2011/01/02/real-sci-fi-tech/#6643MindReading-Machine
http://www.eurekalert.org/pub_releases/2010-09/uou-tbs090110.php

Mind Reading Machine

This photo shows two kinds of electrodes


sitting atop a severely epileptic patient's
brain after part of his skull was removed
temporarily

An array of 16 microelectrodes known as a


microECoG grid is arranged in a four-by-four
array and shown next to a US quarter-dollar coin
with a Utah state

This magnetic resonance image (MRI) of an epileptic patient's


brain is superimposed with the locations of two kinds of
electrodes: conventional ECoG electrodes (yellow) to help locate
the source of...

i-Brain

Image Signal

Light intensity as a function of 2D coordinates

B&W(0 or 1) or grey scale images(I=0-255)

Color images(I=R(0-255),G(0-255),B(0-255))

Video Signal

Sequence of images called frames


Video is a function to three variables(2 spatial
coordinates and time)

Classification of Signals

Signals can be classified into various types by

Nature of independent variable

Value of the function defining the signal

Discrete/Analog(Continous)

Deterministic/Random

Periodic/Aperiodic

Depending on the dimensions

Even/Odd etc...

Classification based on Amplitude and Time


1.Analog
2.Discrete
3.Digital
4.Quantised boxcar

Amplitude- continuous
Time-continuous

Amplitude- continuous
Time-discrete

Amplitude- discrete

Amplitude- discrete

Time-discrete

Time-continuous

Discrete Vs Continous

Normally, independent variable is time

Continous time signal

Time is continous

Defined at every instant of time

Discrete time signal

Time is discrete
Defined at discrete instants of time- it is a sequence
of numbers

Random Vs Deterministic Signal

Deterministic

A signal can be predicted using some mathematical


expression, rule or look up table
Behavior is fixed and easy to analyse
Future values of the signal can be calculated from
past values

An example of a deterministic signal, the sine wave

Random (or stochastic)

A signal is generated randomly and can not be


predicted ahead of time
Future values can not be predicted and it is difficult
to analyse
Probability and statistics are used to analyse their
behavior
Because of their randomness, average values from
a collection of signals are usually studied rather
than analyzing one individual signal

An example of a Random signal, the sine wave with noise added

Periodic Vs Aperiodic

A continous time signal is periodic if it exhibits


periodicity, x(t+T)=x(t), -<t<, where T=period
A periodic signal has a definite pattern that
repeats over and over with a repetition period of
T0

Periodic signal (continuous-time)

For discrete time signal, x(n+N0) = x(n), -<n<

A signal, which does not have a repetitive pattern is aperiodic

Even/Odd Signal

Even

Signal exhibits symmetry in time domain


x(t) = x(-t) or x(n) = x(-n)

Odd

Signal exhibits anti-symmetry in the time domain


x(t) = -x(-t) or x(n)=-x(-n)

A signal can be expressed as sum of even and odd


components x(t) = xeven(t) + xodd(t)
where xeven(t) = 1/2[x(t)+x(-t)], xodd(t) = 1/2[x(t)-x(-t)]

Dimensions of a signal

A signal can have any number of dimensions


1D signal = function(x); where x = time, distance etc
2D signal = function(x,y); where x,y = spatial
positions
3D signal = function(x,y,z); where x,y,z = spatial
positions

Most signals are generated naturally but they


can also be generated artificially using a
computer simulation (Matlab/Octave)

Singular Functions

Important non-periodic functions


Delta or unit impluse function is the most basic
function
All other singular functions can be derived out
of it

t =0, t0 ; t dt=1

(n)=1, n=0
=0, n0

Unit step function

u(t)=0,t<0
=1,t>0

u(n)=0, n<0
=1,n>=0

Unit ramp function

r(t) = 0, t<0
= t, t>0

r(n) = 0,n<0
= n, n>=0

Unit pulse function

t =u t+

1
1
u t
2
2

Why Discrete Time Signals?

Most of the signals found in real world are


continous in nature
In order to process these signals, we need to
convert them to a convenient form so that we
can apply digital techniques

Analog is used to describe a waveform that's


continous in time and can take on a continous
range of amplitude values
Example

Voltage applied to oscilloscope

Discrete time signal is used to describe a signal


whose independent time variable is quantised
so that we know the value of the signal at
discrete instants of time

Discrete Time Signal

In addition to quantizing time, a discrete time


signal quantizes the signal amplitude
Example

Time Domain Signals

Discrete System

A discrete system is a collection of h/w or s/w


routines, that operate on discrete time signals

Example

If x[n] = {1,3,5,7,9} then y[n] = ?

How to measure frequency of continous


sinewave?
Ans: Apply it to an oscilloscope, spectrum
analyser or frequency counter

Given 20 signal samples, can we measure


frequency of discrete sinewave?

Answer

No, we can just plot the samples

However, given sampling period ts, we can know


the frequency of discrete sinewave
Example: If ts = 0.05 ms/sample,
Period of sinewave = 20 samples/period x 0.05
ms/sample = 1 ms
Frequency = 1/period = 1/1ms = 1kHz

So, in discrete systems, absolute frequency


determination is dependent on sampling
frequency fs =1/ts

Frequency Domain Representation

Discrete sinewave x1(n) with an arbitrary


frequency f0 Hz can be represented as

The same x1(n) can be described by indicating


that it has a frequency of 1, measured in units
of f0 , and no other requency content

Example

Summary

A discrete time domain can be represented

Mathematically as x1(n)

Graphically

Discrete frequency domain X1(m)

Signal Amplitude

The amplitude of a variable is the measure of


how far, and in what direction, that variable
differs from zero
So, signal amplitude can be +ve or -ve

Signal Magnitude

The magnitude(absolute value) of a variable is


the measure of how far , regardless of
direction, its quantity differs from zero
So, magnitudes are always +ve

Signal Power

The power of a signal is proportional to its


amplitude or magnitude squared

Signal Processing Operations

Adder: element for element addition of two


different sequences, to produce a new
sequence

Subtractor

Summation

Multiplication

Unit Delay
Example: a(5) = b(4) etc...

Summary

Signal processing operations are always


performed on sequences of individual discrete
values
The elementary operations are very simple
Regardless of how complicated they appear to
be, most of the DSP algorithms can be
performed using the combinations of these
simple operations

LTI Systems

Why LTI Systems?

Answer

Linearity and time invariance are two important


system characteristics
Most of the real world systems are LTI
It is easy to predict performance of any DSP
scheme, as long as it is LTI

Linear

Linear defines a special class of systems where


the output is the superposition or sum of the
individual outputs had the individual inputs
been appplied separately to the system
If x1(n) -----------> y1(n),
x2(n) -------------> y2(n) then
x1(n) + x2(n) -------------> y1(n) + y2(n)

Proportionality Characteristic

If the inputs are scaled by constant factors c1


and c2 then the output sequence parts are also
scaled by those factors
c1x1(n) + c2x2(n) -------------> c1y1(n) + c2y2(n)
This is also known as homogeneity property
Input x(n)

Linear Discrete
System

Output y(n)

Example

Lets take a discrete system whose


y(n) = -x(n)/2
Input x(n)

Linear Discrete
System

Output y(n) = -x(n)/2

Let x1(n) represent 1Hz sinewave sampled at a


rate of 32 samples per cycle and x 2(n)
represent 3Hz sinewave

Non-Linear System

y(n) = [x(n)]2

Input x(n)

Linear Discrete
System

Output y(n) = [x(n)]2

Let x1(n) = 1 Hz sinewave and x2(n) = 3 Hz sinewave

x1(n) = sin(2f0nts) = sin(2.1.nts)


y1(n) = [x(n)]2 = sin(2.1.nts).sin(2.1.nts)
using

Therefore, y1(n) has 0Hz and 2Hz frequency components

Similarly, when x2(n) is applied, y2(n) will contain


0Hz and 6Hz components
When x3(n) = x1(n) + x2(n) is applied, we can
predict the freq content of y3(n) output sequence
by using (a+b)2 = a2 + 2ab +b2, where a and b
represent 1Hz and 3Hz sinewaves respectively
a2 generates 0 and 2 Hz sinusoids, b 2 generates
0 nd 6Hz sinusoids, and 2ab yields another 2Hz
and 4Hz sinusoids in y3(n)

These extra sinusoids were generated by an interaction of


the two input sinusoids due to the squaring operation. That's
Non-Linearity

Summary

The linear systems output is the sum of the


individual outputs
Also, the output y1(n) depends only on x1(n), not
on other input x2(n)
There is no interaction between inputs x 1(n) and
x2(n) at the output of linear systems

Time-Invariant Systems

A time-invariant system is one where a time


delay(or shift) in the input sequence causes a
equivalent time delay in the system's output
sequence
If x(n)---------> y(n) then
x'(n) = x(n+k) -------------> y(n+k)
where k is some integer representing k sample
period time delays

Example

Let x(n) is unit amplitude, 1Hz sinewave


sequence with y(n) as output
Input x(n)

Linear Discrete
System

Output y(n) = -x(n)/2

Let x'(n) = x(n+4), then x'(0) = x(4), x'(1)=x(5)...


then y'(n) = y(n+4)
i.e..y'(0) = y(4), y'(1) = y(5).....

Commutative Property of LTI system

Analyzing LTI Systems

LTI systems can be analysed to predict their


performance
If we know the unit impulse response of an LTI
system, we can calculate everything there is to
know about the system
The LTI system completely characterizes the
system
Input x(n)

LTI
Discrete System

Output y(n)

Impulse Response

Impulse response means system's time domain


output sequence when the input is a single
unity-valued sample(unit impulse) preceeded
and followed by zero valued samples

Adantages of LTI System

We can determine the output sequence for any


input sequence
output seq = convolution of input sequence and
system's impulse sequence

Also, we can find the system's frequency


response by taking the discrete fourier
transform of that impulse renponse

Analog to Digital Conversion


Analog to Digital Conversion

Analog

Analog
Digital to Analog Conversion

Periodic Sampling

Periodic sampling is the process of representing a


continous signal with a sequence of discrete data
values
Continous Signal

Analog to Digital
Converter

Digital Values

Question:How fast a given continous signal must be


sampled in order to preserve its information content?

Frequency Ambiquity

There is a frequency ambiquity associated with


dicrete time signal samples
Example
If we were given the following sequence of
values x(0) =0, x(1)=0.866, x(2) = 0.866,
x(3)=0, x(4)=-0.866, x(5)=-0.866, x(6)=0
Next, two people were asked to draw that
sinewave

Samples

Two sinewaves passing through the same


points

The key issue is, if data sequence represented


periodic samples of a sinewave, we can not
unambiguously determine the frequency of the
sinewave from those sample values alone
Let x(t) = sin(2f0t) and
x(n) = sin(2f0nts) where ts = 1/fs
Since

x(n) = sin(2f0nts) = sin(2f0nts + 2m)


= sin(2(f0 + m/nts))nts
If we let m be an integer multiple of n, m=kn, we
can replace m/n with k, so that
x(n) = sin(2f0nts) = sin(2(f0 + kfs)nts)

Here, the f0 and (f0 + kfs) are therefore equal

Important Points

x(n) sequence of digital sample values,


representing a sinewave of f0 Hz, also exactly
represent sinewaves at other frequencies
namely f0 + kfs
When sampling at a rate of fs samples, if k is
any positive or negative integer, we cannot
distinguish between the sample values of a
sinewave of f0 Hz and a sinewave of (f0 + kfs )
Hz

The sample nature of any sequence of discrete


values makes that sequence also represent an
infinite number of different sinusiods
Also, from equation-1, the spectrum of any
discrete series of sampled values contains
periodic replicas of the original continous
spectrum
The period between these replicated spectra in
the frequency domain will always be fs

These spectral replications repeat in both


directions of frequency spectrum. That's
because k can be any +ve or -ve integer
Also, equation-1 is the reason that all digital
filter frequency responses are periodic in the
frequency domain

Example

Consider the sampling of a 7kHz sinewave at a


sampling rate of 6kHz
Equation-1 is causing a sinusoid whose name
is 7kHz, to go by the alias of 1kHz

Notice that the sample values would not


change at all if, instead, we were sampling a 1
kHz sinewave
Here f0=7kHz, fs=6kHz and k=-1 such that
f0 + kfs = [7 + (-1).(6)]=1kHz
Our problem is that no processing scheme can
determine if the sequence of samped values,
whose amplitudes are represented by the dots
came from a 7kHz or a 1kHz sinusoid

Another Example

Here f0=4kHz, fs=6kHz and k=-1 such that


f0 + kfs = [4 + (-1).(6)]=-2kHz

Now, we restrict our spectral band of interest to


the frequency range of fs/2 Hz
In sampling theory, fs/2 is called by different
names as critical Nyquist, Half Nyquist and
folding frequency

Within the spectral band of interest(3Hz


because fs=6Hz), there is energy at -2 kHz and
+1 kHz, aliased from 4kHz and 7kHz
respectively
Note, here that the vertical positions of the dots
in the figure have no amplitude significance
Only, horizontal positions indicate which
frequencies are related through aliasing

Sampling Low Pass Signals

A band limited signal implies that any signal


energy outside the range of BHz is below the
sensitivity of our system
This continous spectrum can't be represented
in a digital machine in its current band limited
form

If we change fs through decimation or


interpolation, the spectrum replicas will shift up
or down right in the middle of the frequency
range of interest fs/2, which causes problems
How can we control the locations of those
spectral replications?
Answer: Using Nyquist Criteria

Nyquist Criteria

In practical ADC, the fs 2B is used to separate


spectral replications at the folding frequencies
of fs/2
Lets take fs = 1.5B, which results in
undersampling
Here the spectral replications are now
overlapping the original baseband spectrum
centered about zero Hz

Observation-1

Limiting our attention to the band of fs/2 Hz,


we see two important points
The lower edge and the upper edge of the
spectral replicas centered at +f s and -fs now lie
in our band of interest
Portions of spectral replications now combine
with the original spectrum which results in
aliasing errors

Aliasing

Now, the discrete sampled values associated


with the spectrum of fig-3 no longer truly
represent the original input signal
The spectral information between -B to -B/2
and B/2 to B Hz has been corrupted
We can not know the exact amplitude in the
aliased region

Observation-2

The entire spectral content of the original


continous signal is now residing in the band of
interest between -fs/2 and +fs/2
Also, any signal energy located above +B Hz
and -B Hz in the original continous spectrum
will always end up in the band of interest after
sampling, regardless of the sampling rate
This property is true regardless of the original
signal or the sample rate

Anti Aliasing Filter

That's the reason why all the continous signals


are band limited by passing through analog low
pass filters before applying to ADC

Example

Consider a continous signal of bandwidth B


accompanied by noise energy

Sampling the continous signal with fs>2B


prevents replications of the signal of interest
from overlapping each other, but all of the noise
energy still ends up in the range of -f s/2 and
+fs/2 of our discrete spectrum

So, use anti-aliasing filter prior to ADC


conversion to attenuate any unwanted signal
energy above +B and below -B Hz

Original
Continous
Signal

Analog Anti
Aliasing Filter
(cutoff freq=BHz)

Filtered
Continous
Signal

Discrete
Samples
ADC

Binary Quantization

To process a sampled signal in a computer,


samples must be converted to binary numbers
using a finite number of bits per sample
N bits per sample gives 2N quantization levels

More bits per sample(larger N) means better


resolution, but the digital data becomes larger
and results in complex DSP architecture
Quantization involves rounding operations.
Therefore the accuracy of the quantized signal is
limited
The round off error induced by quantization is
called Quantization Noise
The maximun quantization error per sample is
equal to the half the binary Step Size

Difference between quantized and original


value is called quantization error or noise
Spacing between two quantization levels is
called quantization width or resolution
For quantization to N bits, the quantization error
Qe of each digital sample can be viewed as the
uniformly distributed random variable in the
range of -2-N < Qe < 2N

For a B bit quantizer, SQNR = 6B dB


For every additional bit, SQNR has a gain of
6dB
More bits per sample(larger N), gives smaller
quantization error
However, a DSP system with more bits per
sample becomes expensive

Example

Resolution = Range/Number of Levels(2 N)


For a signal varying between 0 to 5V with a 8
bit ADC has a resolution of ____and SQNR___

Summary

Basic Concepts

Types of Signals

Classification of Signals

Discrete Signals,
Systems, Spectrum

LTI Systems
ADC, Sampling, Aliasing

Signal

Analog

Continuous
Time

Digital

Discrete
Time
ADC

How to process a signal?

Depends on the type of the signal and the


information being carried by the signal
Type of the signal can be in terms of basis
functions in the domain of original independent
variable(s) or the transformed domain
Also, Information extraction process may be
carried out in the original domain of the signal
or the transformed domain

Signal processing Operations

Analog processing

Discrete processing

Mostly time domain operations


Both time & frequency domain operations

Filtering is a widely used signal processing


operation

Simple Time Domain Operations

Scaling: Multiplication of signal with +ve or -ve


constant, y(t) = kx(t)
Where amplification if k>1, attenuation if k<1

Delay: Delayed replica of original signal


y(t) = x(t-t0)

Addition: Two or more signals combine to


generate a new signal, y(t) = x 1(t) + x2(t)
Multiplication, Integration, Differenciation etc...

Signal Processing Examples

Filtering

Removing unwanted signal from the desired signal

Multiplexing

More signals are combined and transmitted over


the same channel

Filtering

An important frequency domain operation


A filter passes certain frequency components
with minimal distortion and blocks all other
frequency components
Basic filters are

LPF

HPF

BPF

BSF

Thank you
mkumar@cdac.in

FDM Vs FMDA

FDM is a technique that is used in many other


technologies. A multiplexer modulates all the
signals that is going to use the channel into a
single signal
FDMA foregoes the use of a multiplexer, since it
acts on the data link layer. All the information is
combined prior to generating a signal, making
the use of a physical layer multiplexer
unnecessary

Network Layers

Case Study

Low Pass Filter


1.5

1.5
1

LPF
3KHz

0.5

2KHz

0
-0.5

0
-0.5

-1

-1

-1.5

-1.5

200

400

600

800

1000

200

400

600

800

1000

800

1000

0.5
0

0
-1

-0.5

-2

-1

-3

-1.5

Only 2 Hz signal
remains

1.5

5KHz

0.5

0
0

200

400

600

800

200

400

600

800

1000

1000

3
2
1

1.5

LPF
8KHz

1
0.5

11KHz

-2
-3
0

-0.5
-1
-1.5

0
-1

200

400

600

800

1000

200

400

600

Only 2 Hz and 5 Hz
signals remain

High Pass Filter


1.5

0.5

2KHz

HPF
3KHz

0
-0.5
-1
-1.5
0

200

400

600

800

-2

1000

200

400

600

800

1000

Only 5 Hz and 11 Hz
signals remain

1.5

0.5

-1

-0.5

-2

-1

-3

-1.5
0

0
-1

-3

5KHz

0
200

400

600

800

1000

200

400

600

800

1000

Combined signal

1.5
1

1.5

HPF
8KHz

1
0.5

11KHz

0.5
0
-0.5

-1
-0.5

-1.5
-1
-1.5
0

200

400

600

800

1000

200

400

600

800

1000

Only 11 Hz signal remains

Band Pass Filter


1.5
1
0.5

2KHz

0
-0.5
-1
-1.5
0

200

400

600

800

1000

1.5

+
1.5
1

0.5

BPF

-1
-2

-1

-3

200

400

200

400

600

800

1000

600

800

1000

1
0.5
0
-0.5
-1

-0.5
-1
-1.5

1.5

-1.5
0

-0.5

-1.5
0

11KHz

0.5

5KHz

200

400

600

800

Combined signal

1000

fp1=4 Hz,
fp2=6 Hz,
fs1=3 Hz,
fs2=7 Hz

200

400

600

800

Only 5 Hz signal
remains

1000

Band Stop Filter


1.5
1
0.5

2KHz

0
-0.5
-1
-1.5

200

400

600

800

1000

1.5

+
1.5
1

0.5

BSF

-1

-0.5

-2

-1

-3

0
-0.5
-1

-1.5

200

400

600

800

1000

1
0.5
0
-0.5
-1
-1.5

-1.5

0
0

1.5

11KHz

0.5

5KHz

200

400

600

800

1000

200

400

600

800

Combined signal

1000

fp1=4 Hz,
fp2=6 Hz,
fs1=3 Hz,
fs2=7 Hz

200

400

600

800

1000

5 Hz signal is filtered
out, only 2 Hz and 11
Hz signals remain

Case Study

Shoot

Capture

Play Back

Edit

Serve

Encode

Integrate

You might also like