Basics on Digital Signal Processing Introduction
Vassilis Anastassopoulos Electronics Laboratory, Physics Department, University of Patras
Outline of the Course 1. Intr tro oducti tio on (s (samplin ing g – quantization) 2. Signals and Sy Systems 3. Z-Transform 4. Th The e Dis Discr cree eett and and th the e Fas Fastt Fou Fouri rier er Tr Tran ansf sfor orm m 5. Linear Fi Filter De Design 6. Noise 7. Median Filters
2/36
Analog & digital signals Analog
Digital
Continuous function V function V of continuous continuous variable variable t (time, space etc) : V(t).
Discrete function V function Vk of discrete sampling variable tk, with k = integer: Vk = V(tk).
Sampled Signal
0.3
0.3
] V [ e 0.1 g a t 0 l o V
0.2
0.2 ] V [ e 0.1 g a t 0 l o V
-0.2
-0.2
-0.1
ts ts
-0.1
0
2
4 6 time [ms]
8
10
0
6 8 2 4 sampling time, tk [ms]
10
Uniform (periodic) sampling. Sampling frequency fS = 1/ tS 3/36
Analog & digital systems
4/36
Digital vs analog processing Digital Signal Processing (DSPing) Advantages
Limitations
• Often easier system upgrade.
• A/D & signal processors speed: wide-band signals still difficult to treat (real-time systems).
• Data easily stored -memory.
• Finite word-length effect.
• More flexible.
• Better control over accuracy requirements. • Reproducibility. • Linear phase • No drift with time and temperature
5/36
DSPing: aim & tools • Predicting a system’s output.
Applications
• Implementing a certain processing task. • Studying a certain signal.
• General purpose processors (GPP), -controllers.
Hardware
• Digital Signal Processors (DSP).
Fast
• Programmable logic ( PLD, FPGA ).
Faster
real-time DSPing
• Programming languages: Pascal, C / C++ ...
Software
• “High level” languages: Matlab, Mathcad, Mathematica… • Dedicated tools (ex: filter design s/w packages). 6/36
Related areas
7/36
Applications
8/36
Important digital signals Unit Impulse or Unit Sample. δ(nTs)
δ[(n-3)Τ s]
The most important signal for two reasons nΤs past
u(nTs)
δ(n)=1 for n=0
Unit Step u(n)=1 for n0 nΤs past
δ(n)=u(n)-u(n-1)
r(nTs)
Unit Ramp r(n)=nu(n) nΤs past
9/36
Digital system example V
General scheme
ms V
Sometimes steps missing - Filter + A/D
Antialiasing ms
A
(ex: economics); k
- D/A + filter (ex: digital output wanted).
A
k V
Topics of this lecture.
Filter Filter Antialiasing
ms V
A/D
A/D Digital Processing
Digital Processing D/A
Filter Reconstruction
ms
D A O N M A A L I O N G D D O I M G I A T I A N L D A O N M A A L I O N G 10/36
Digital system implementation ANALOG INPUT
Antialiasing Filter
A/D
KEY DECISION POINTS: Analysis bandwidth, Dynamic range • Pass / stop bands.
1 • Sampling rate. • No. of bits. Parameters.
Digital Processing
• Digital format.
2 3
What to use for processing?
DIGITAL OUTPUT 11/36
AD/DA Conversion – General Scheme
12/36
AD Conversion - Details
13/36
Sampling
14/36
Sampling
1
How fast must we sample a continuous signal to preserve its info content? Ex: train wheels in a movie. 25 frames (=samples) per second. Train starts
wheels ‘go’ clockwise.
Train accelerates
wheels ‘go’ counter -clockwise.
Why? Frequency misidentification due to low sampling frequency.
15/36
Rotating Disk
How fast do we have to instantly stare at the disk if it rotates with frequency 0.5 Hz?
16/36
1
The sampling theorem
A signal s(t) with maximum frequency f MAX can be Theo* recovered if sampled at frequency f > 2 f . S MAX *
Multiple proposers: Whittaker(s), Nyquist, Shannon, Kotel’nikov.
Naming gets Nyquist frequency (rate) f N = 2 f MAX or f MAX or f S,MIN or f S,MIN/2 confusing ! Example s(t) 3 cos(50π t) 10 sin(300π t) cos(100π t)
F1
F2
F1=25 Hz, F2 = 150 Hz, F3 = 50 Hz
Condition on f S?
F3 f S > 300 Hz
f MAX 17/36
Sampling and Spectrum
18/36
1
Sampling low-pass signals Continuous spectrum
(a)
(a)
Band-limited signal: frequencies in [-B, B] (f MAX = B).
-B
0
(b)
B
f
Discrete spectrum No aliasing
(b)
Time sampling repetition. f S > 2 B
-B
0
B f S/2
0
f S/2
no aliasing.
f
Discrete spectrum Aliasing & corruption
(c)
frequency
(c) f
f S
2B
aliasing !
Aliasing: signal ambiguity in frequency domain 19/36
Antialiasing filter
1 (a)
(a),(b) Out-of-band noise can aliase
Signal of interest
Out of band noise
Out of band noise
-B
0
B
(b)
f
into band of interest. Filter it before!
(c) Antialiasing filter Passband: depends on bandwidth of interest.
Attenuation AMIN : depends on (c)
-B
0
B f S/2
• ADC resolution ( number of bits N).
AMIN, dB ~ 6.02 N + 1.76 • Out-of-band noise magnitude. Other parameters: ripple, stopband frequency...
20/36
Under-sampling
1
Using spectral replications to reduce sampling frequency fS req’ments. 2 f C B m 1
m
f S
Bandpass signal centered on fC
0
2 f C B
B
f C
m
, selected so that f S > 2B -f S
0
f S
Example
Slower ADCs / electronics needed.
Simpler antialiasing filters.
With under-sampling f S = 22.5 MHz (m=1);
= 17.5 MHz (m=2); = 11.66 MHz (m=3).
f C
Advantages
f C = 20 MHz, B = 5MHz Without under-sampling f S > 40 MHz.
2f S
21/36
Quantization and Coding N Quantization Levels
q
Quantization Noise
22/36
SNR of ideal ADC
2
RMS input (1) SNRideal 20 log10 RMS(e q )
Also called SQNR (signal-to-quantisation-noise ratio)
Assumptions Ideal
(p(e) constant, no stuck bits…)
T
ADC: only quantisation error eq
eq uncorrelated with signal. ADC performance constant in time.
2
V V RMS input FSR sinωt dt FSR T 2 2 2 1
Input(t) = ½ V FSR sin( t).
0
p( e) quantisation error probability density q/2
RMS(e q )
eq2 p eq deq - q/2
q 12
VFSR 2N 12
(sampling frequency fS = 2 fMAX)
1 q
q 2
q 2
eq Error value 23/36
2
SNR of ideal ADC - 2 SNRideal 6.02 N 1.76 [dB]
Substituting in (1) :
One additional bit
(2)
SNR increased by 6 dB
Real SNR lower because: - Real signals have noise. - Forcing input to full scale unwise. - Real ADCs have additional noise (aperture jitter, non-linearities etc).
Actually (2) needs correction factor depending on ratio between sampling freq & Nyquist freq. Processing gain due to oversampling.
24/36
Coding - Conventional
25/36
Coding – Flash AD
26/36
DAC process
27/36
Oversampling – Noise shaping PSD
Nyquist Sampler
f f b
f N
The oversampling process takes apart the images of the signal band.
(a) Oversampling OSR=4
f
f s=4f N
(b) PSD Signal
Quantization noise in Nyquist converters Quantization noise in Oversampling converters
0
f N /2
PSD Signal
f s /2
Quantization noise Nyquist converters
Quantization noise Oversampling and noise shaping converters
Spectrum at the output of a noise shaping quantizer loop compared to those obtained from Nyquist and Oversampling converters.
Quantization noise Oversampling converters
0
F N/2
frequency
When the sampling rate increases (4 times) the quantization noise spreads over a larger region. The quantization noise power in the signal band is 4 times smaller.
Fs/2
28/36
Digital Systems A discreet-time system is a device or algorithm that operates on an input sequence according to some computational procedure It may be •A general purpose computer •A microprocessor •dedicated hardware •A combination of all these
29/36
Linear, Time Invariant Systems System Properties • linear •Time Invariant •Stable •Causal
y (n )
N
a x(n k ) k
k 0
Convolution
30/36
Linear Systems - Convolution
5+7-1=11 terms
31/36
Linear Systems - Convolution
5+7-1=11 terms
32/36
General Linear Structure
y (n )
M
L
a x(n k ) b y(n k ) k
k 0
k
k 1
33/36
Simple Examples
34/36
Linearity – Superposition – Frequency Preservation
Principle of Superposition x1(n)
y1(n) H ax1(n)+bx2(n)
ay1(n)+by 2(n) H
x2(n)
y2n) H
Principle of Superposition x1(n)
x2
x2
Preservation
x12(n) x1(n)+x2(n)
x2(n)
Frequency
x12(n)+x22(n)+2 x1(n) x2(n) x2
Non-linear
x22(n)
If y(n)=x2(n) then for x(n)=sin(nω) y(n)=sin2(nω)=0.5+0.5cos(2nω) 35/36