BME BME 4 4 52 52 Bio Bio medi medi cal Signal cal Signal Processing
Processing Lecture 2 Lecture 2
Discrete Time Signals and Discrete Time Signals and Systems
Systems
Lecture 2 Outline
In this lecture, we’ll study the following
Analogue to digital conversion
Sampling, quantisation, coding, aliasing
Digital to analogue conversion (in brief)
Classification of systems
Basic operations of systems
Analogue to digital conversion
Recorded biological signals are analogue signals
To process analogue signals by digital means (like using a PC), we need to convert them to digital form
I.e. to convert them to a sequence of numbers having finite precision
This process is known as analogue to digital (A/D) conversion, which involves
i) Sampling
ii) Quantisation
iii) Coding
Sampler Quantiser Coder
Discrete-time signal Quantised signal Digital signal
x(t) x(n) 0 1 0 11 ...
Analog to digital converter
The Sampling Process
Often, a discrete time sequence x[n] is developed by uniformly sampling an analogue signal x(t) as indicated below
I.e. conversion of a continuous-time, continuous amplitude signal into discrete-time signal (i.e. continuous-amplitude, discrete-time)
Done by taking samples at specific uniform intervals of time
The sampling interval is the time of one of these uniform intervals
Sampling frequency is the number of uniform time intervals in one second
The relation between the two signals are
Discrete-time signal
Analogue signal
Aliasing
Aliasing
Aliasing causes ambiguities in reconstruction, i.e. distorts the sampled signal
To avoid aliasing, the sampling frequency has to be more than twice of the highest frequency contained in x(t)
This is known as Nyquist theorem and the minimum frequency known as Nyquist frequency(rate)
Example – Nyquist rate computation
Consider the analog signal
x(t)=3 cos 50t + 10 sin 300 t – cos 100 t
What is the Nyquist frequency (rate)?
Answer
Use the generic term, A cos 2ft (or A sin 2ft) to compute the frequencies present in the signal => which are 25 Hz, 150 Hz and 50 Hz
So, Nyquist frequency is 2* highest frequency= 2*150 Hz=300 Hz
In practise, we normally sample at a much higher rate than
Nyquist frequency
Quantisation and Coding
Quantisation
This is the conversion of discrete-time continuous amplitude signal (after sampling) into discrete-time discrete amplitude signal
Quantisation levels
The value of each sample is represented by a value selected from a finite set of possible values
Quantisation width= (xmax-xmin)/(No of levels -1)
Quantisation error is the error in the quantisation process by rounding to the nearest level
Coding
In the coding process, each discrete value is represented by a certain number of bits
2
number of bitsno of levels
Example of performing quantisation and coding
Example of quantisation and coding
Eg: Assume after sampling, we have the 5
thsample, x(5)=1.66 volts
Assume 9 levels are used to represent amplitude values of 0 V (min) to 2 V (max)
Quantisation width= (xmax-xmin)/(No of levels -1) =0.25 V
The possible quantised values are 0, 0.25, 0.5, 0.75, 1.00, 1.25, 1.50, 1.75, 2.00
So, x(5) =1.75 volts (rounded to nearest level) = 7th quantised level
2number of bits no of levels, so we need at least 4 bits
After coding, it is 0111
Quantisation error
1.66 V is represented as 1.75 V, so there is an error of 0.09 V, this is the quantisation error
This error can be reduced by using more bits in coding thereby increasing the number of quantisation levels
In some hardware, the quantisation is done to the nearest lower level, so it would 1.50 instead of 1.75
Quantisation and coding – further example
For the same example in the previous,
what would be the code and quantisation error if 17 levels were used?
17 levels in the range 0 V (min) to 2 V (max)
Quantisation width= (xmax-xmin)/(No of levels -1) =0.125 V
The possible quantised values are 0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.00, 1.125, 1.25, 1.375, 1.50, 1.625, 1.75, 1.875, 2.00
So, x(5) =1.625 volts (rounded to nearest level) = 13th quantised level
2number of bits no of levels, so we need at least 5 bits
After coding, it is 01101
Quantisation error
1.66 V is represented as 1.625 V, so there is an error of 0.035 V, this is the quantisation error
This error is reduced by the increase of bits/quantisation levels
Digital to analog (D/A) conversion
This is not important for this course
Converts digital to analogue signals by performing some kind of interpolation to
‘connect the dots’
Eg: zero-order hold/staircase
approximation A/D converter (the
simplest)
Sequences
Sometimes, a discrete-time signal is known as a sequence and vice versa
A discrete-time signal may be a finite length or an infinite-length sequence
Eg: x[n]=3+4n
3, -5n 4 is a finite length sequence with length 4-(-5)+1=10
x[n]=sin(0.1n) is an infinite-length sequence
An N length sequence can be increased by padding with zeros
Eg: length 3 changed to length 5 4 1
, ]
[ n n
3 n x
5 4
, 0
4 1
{ , ] [
3
n n n n
xpad
Discrete-time systems
Discrete-time systems operates on an input sequence, according to some prescribed transfer function and produces another output sequence
Example, the input sequence could be a noisy ECG signal that we studied in Quiz 1 and the system outputs a noise reduced ECG signal
In this case, the discrete-time system is a band-pass filter
There are some classifications and basic operations for discrete- time systems, which we will study next
x[n] Discrete time system y[n]
Discrete time system
0 100 200 300 400 500 600 700
-0.4 -0.2 0 0.2 0.4 0.6 0.8 1 1.2
Amplitude (microV)
Sampling points Real ECG signal from MGH database
0 100 200 300 400 500 600 700
-0.4 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4
0.5Real ECG signal from MGH database (after noise reduction)
Sampling points
Amplitude (arbitrary units)
Classifications of Discrete-time Systems
As with signals, systems can also be classified as:
Static and dynamic systems
Linear and non-linear systems
Time-variant and time-invariant systems
Causal and non-causal systems
Stable and non-stable systems
Static and dynamic systems
Static
The output of a static system at any time depends only on the input values at that particular time (not on past or future input values)
It has no memory or energy storage elements
A resistive network is an example
Eg: y[n]=4x[n]+(x[n])3
Dynamic
The output of a dynamic system depends on the inputs at the specific time and at other previous times.
Have memory or energy storage elements (eg: capacitive/inductive network)
It always contains a difference equation
Eg: y[n]=4x[n]-x[n-1]
Linear and non-linear systems
Linear
A linear system is one in which the principle of superposition holds
For eg, if the system has two inputs, x[n] and y[n], the superposition is defined as follows
H is the transfer function of the system
Nonlinear
If the system does not satisfy the superposition principle, it is non- linear
+ H
a
b x(n)
y(n)
H[ax(n)+by(n)]
)]
( [ )]
( [ )]
( )
(
[ax n by n aH x n bH y n
H
+ H
a
b x(n)
y(n)
aH[x(n)]+bH[y(n)]
H
Time-variant and time-invariant systems
Time invariant or shift-invariant system
Also known as fixed system
Input-output relationship does not vary with time
Eg: H[x(n-k)]=y(n-k) where k is an integer
In other words, if y[n] is the response of the system to any input x[n], then the response of the system to the time shifted input is the
response of the system to x[n] shifted by the same amount
Time-variant (shift-variant)
If the system does not satisfy the above property, it is time- variant/shift-variant.
Causal and non-causal systems
Causal system
A causal system is non-anticipatory
The response depends only on the present and/or past value of the input, not future values
Eg: y[n]=0.5x[n]-x[n-2]
Non-causal system
The response depends on some future values of the input
Not realisable in practise
Eg: y[n]=0.1x[n-1]+x[n]-0.8x[n+1]
Stable and non-stable systems
Stable system
A stable system produces bounded output for bounded input
In other words, for a bounded (i.e. limited) input, the output does not grow unreasonably large
Eg: y[n]=H(x[n])
The energy of x is bounded, |x[n]|Mx for all n
=> the energy of y is also bounded, |y[n]|My for all n
Non-stable system
The response can be unreasonably large for a bounded input
Basic system operations
Product (modulation)
y[n]=x[n].w[n]
Normally used in windowing – where a discrete time finite signal is obtained from a discrete time infinite signal
Addition
y[n]=x[n] + w[n]
Multiplication
y[n]=A.x[n]
X
x[n]
w[n]
y[n]
modulator
+
x[n]
w[n]
y[n]
adder
x[n] y[n]
multiplier
A
This is the system!
Basic system operations (cont)
Time reversal (folding)
y[n]=x[-n]
Important operation in filtering
Arrow points to n=0
Branching
Used to provide multiple copies of the signal
Time shifting
y[n]=x[n-N] (delay)
y[n]=x[n+N] (advance)
x[n] x[n]
x[n]
x[n] z-N y[n]
x[n] zN y[n]
Basic system operations (cont)
Time scaling (downsampling/upsampling)
Downsampling, y[n]=x[nM]
In downsampling, every Mth sample of the input sequence is kept and M-1 in between samples are removed
No. of samples is reduced
Eg: y[n]=x[3n]
Figure from S.K.Mitra, DSP 3rd ed.
Basic system operations (cont)
Upsampling, y[n]=x[n/N]
In upsampling, N-1 equidistant zero-values samples are inserted by the upsampler between each consecutive samples of the input sequence
No. of samples is increased
Eg: y[n]=x[n/3]
Figure from S.K.Mitra, DSP 3rd ed.
Combination of basic operations
Often, a system includes a combination of operations
Example - figure shows a discrete time system block diagram
Example – sequence computation
For the following sequences, defined for 0 n 4 (length=5),
a[n]={3 4 6 -9 0}
b[n]={2 -1 4 5 -3}
obtain the new sequences
c[n]={a[n].b[n]}
d[n]={a[n]+b[n]}
e[n]=1.5{a[n]}
Ans
c[n]={6 -4 24 -45 0}
d[n]={5 3 10 -4 -3}
e[n]={4.5 6 9 -13.5 0}
These are easy as both a[n] and b[n] have same length. What if
their lengths differ?
Example – differing sequence lengths
If the lengths of sequences differ, then pad with zeros (in front or end or in between) to obtain same length sequences and same defined ranges BEFORE applying the operations
Example, for the following sequence
f[n]={-2 1 -3} defined for 0 n 2
what would be g[n]=a[n]+f[n]?
Hint: f[n] has length 3, while a[n] has length five, so pad f[n] with 2 zeros
Sometimes, making a table will make it easier
Answer
a[n]={3 4 6 -9 0} defined for 0 n 4
fpad[n]={-2 1 -3 0 0} defined for 0 n 4
f[n] is padded with 2 zeros at the end as to make the defined ranges of a[n] and fpad[n] equal.
So, g[n]={1 5 3 -9 0}
Advanced example
Consider the following sequences:
x[n]={-4 5 1 -2 -3 0 2}, -3 n 3
y[n]={6 -3 -1 0 8 7 -2}, -1 n 5
w[n]={3 2 2 -1 0 -2 5}, 2 n 8
The sample values of each of the above sequences outside ranges specified are all zeros. Generate the following sequences (put an arrow at n=0):
(a) c[n]=x[-n+2]
(b) d[n]=y[-n-3]
(c) e[n]=w[-n]
(d) u[n]=x[n]+y[n-2]
Hint: x(n+k) signal moves k
x(n-k) signal moves k
x(-n+k) signal moves k
x(-n-k) signal moves k
Answer
c[n]={2 0 -3 -2 1 5 -4}
d[n]={-2 7 8 0 -1 -3 6 0 0}
e[n]={5 -2 0 -1 2 2 3 0 0}
u[n]={-4 5 1 -2 3 -3 1 0 8 7 -2}
Continued in next slide
Solution
Prepare tables
Min range, n=-3
Max range, n=8
(a) c[n]=x[-n+2]
(b) d[n]=y[-n-3]
(c) e[n]=w[-n]
(d) u[n]=x[n]+y[n-2]