Professional Documents
Culture Documents
Digital Communications
in Practice
Aldebaro - UFPA
September 13th , 2014
Contents
Listings
1 Analog and Digital Signals
1.1 Review Exercises . . . . . .
1.2 Exercises . . . . . . . . . .
1.3 Solutions: Review Exercises
1.4 Solutions: Exercises . . . .
iii
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
1
1
3
9
11
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
23
23
28
30
38
39
Listings
1.1
1.2
1.3
1.4
1.5
1.7
1.8
1.9
MatlabOctaveCodeSnippets/snip_signals_2Drandom.m
3
MatlabOctaveCodeSnippets/snip_signals_sampling_inequality.m
Matlab/Octave code for this dB exercise . . . . . . . . .
9
Matlab/Octave code this dBm exercise . . . . . . . . . . 10
Matlab/Octave code for this exercise about digital interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Matlab/Octave code for this exercise about signal generation and analysis . . . . . . . . . . . . . . . . . . . . . 12
Matlab/Octave code this uniform quantization exercise . 13
Matlab/Octave code for this quantization exercise . . . 14
Matlab/Octave code for this sampling theorem exercise
15
2.1
MatlabOctaveCodeSnippets/snip_transforms_KLT.m .
19
3.1
MatlabOctaveCodeSnippets/snip_systems_buttord.m .
28
1.6
1.1.
1.2.
1.3.
1.4.
E[X] =
V
X
p i xi ,
i=1
1.5.
1.6.
ber of samples, sampling frequency, etc.) of the following companion files: tidigits_saa7.wav, timit_testdr8mpam0sx199.raw and
timit_testdr8mpam0sx199.wav. These are files that store speech waveforms (TIDIGITS and TIMIT are famous corpora distributed by LDC
[url1ldc]). Choose one of these files and analyze the corresponding
signal via plots (i. e., show the waveform with the abscissa and ordinate
properly labeled, and other graphs of interest such as the histogram
and PSD).
Using your favorite programming language, list the code for reading raw (without header) files storing two kinds of data: a) floats (4
bytes) in little-endian format and b) shorts (2 bytes) in big-endian
format.
1.7.
1.8.
1.9.
from a PDF fX1 ,X2 (x1 , x2 ) with mean = (2, 3)T . Use the Matlab/Octaves function mvnrnd or, if you do not have Matlabs Statistics Toolbox
1.2 Exercises
10
0
0.5
0
1
0.5
a) C = 2 I =
, 2 = 0.5. b) C =
. c) C =
.
0 2
0 4
0.5 1
1.2 Exercises
Unless specified otherwise, assume that the signals are in Volts and
were obtained over a resistor of 1 Ohm. Always indicate the units in
your answers and graphs.
Depict in plots the even and odd parts of x[n] = n2 (u[n 3]
u[n 7]).
1.1.
You do not know much about a signal x[n], but it is given that
x[0] = 3. Can x[n] be an odd signal? Why?
1.2.
1.3.
1.4.
1.5.
2.5
x(t) (V)
1.5
0.5
0
2
2
t (s)
1.6.
1.7.
Get familiar with digitizing systems and boards, which are sometimes called DAQ (data acquisition) boards. Calculate the storage space
and transfer rate for digitized signals (visit [url1bww] for extra information). a) Calculate the total space in megabytes (MB) for storing 30
1.8.
1.2 Exercises
b) Assume you need to use a 16-bits A/D process to achieve the desired
SNR, what is the maximum sampling rate that needs to be supported
for each interface above? c) Describe in high-level a digitizer system
to sustain a sampling rate of 40 MHz and store 3 hours of a signal.
Choose the data transfer technology, total hard disk space, etc.). d)
Considering you must use USB 2.0: what is the maximum sampling
rate the system could achieve in this case? e) Evaluate a Signatec
[url1sig] waveform recording product and indicate what is the maximum
throughput that Signatec offers (indicate sampling rate and number of
bits per sample) for recording some hours of signal into a hard disk.
Note that when operating at maximum sampling rate, most acquisition
boards and digital oscilloscopes store the ADC samples in a limited
amount of onboard RAM, which is typically capable of storing only
few seconds of signal. The discussed recording system must take into
account the data transfer from onboard RAM to hard disk.
For the following signals, calculate the energy E and power
P . Do they have a finite total energy or a finite average power? a)
x(t) = 5 cos(2300t + /4), b) x(t) = 3e2t u(t) and c) x(t) = t.
1.9.
1.10. What can be said about the total energy and average power of
explain the reason? How could you obtain the proper result? Compare
this result with Application ??. Why in this case autocorrelation seems
to be periodic and match the theoretical result?
1.14. A sinc function sinc( ) (see Section ??) centered in = 0 can
1.15. A signal x[n] was obtained using the randn function in Matlab/Oc-
tave, such that it has zero mean and unity variance. What is the power
of this signal? How x[n] can be transformed in a signal y[n] with mean
equal to four and variance equal to nine? What is the Matlab/Octave
command to generate 100 samples of y[n] using randn? What is the
average power of y[n]? Plot the following graphs: autocorrelation and
probability density function of both x[n] and y[n].
1.19. In case you have access to the required equipments, estimate and
1.2 Exercises
personal computer (describe the stairs: dynamic range and step size).
Try to model the DC offset.
1.20. Consider you want to quantize a sinusoid with peak amplitude
1.21. The sampling theorem is a strict inequality Fs > 2fmax but some
(1.1)
10
and evaluate their histograms. Were the signals properly digitized? All
(or most) quantizer levels were used? In case you find a CDA file, note
that these files (of just 44 bytes) are not the actual audio files. They
are just pointers to the audio data (similar to shortcut files). In order
to copy the files, you need to use a rip software such as, e. g. [url1rip].
% % global configs
size_x = 1000; % samples
samp_freq = 100; % samples per second
t = [0: size_x -1] '/ samp_freq ; % column - vector of time
indices
5
10
15
20
25
30
35
10
40
45
1.2.
To be done.
1.3.
10
1.4.
To be done.
1.5.
To be done.
1.6.
To be done.
1.7.
To be done.
1.8.
To be done.
1.9.
To be done.
1.10. To be done.
1.11. To be done.
1.12. To be done.
To be done.
1.2.
To be done.
1.3.
To be done.
1.4.
To be done.
1.5.
To be done.
1.6.
To be done.
1.7.
To be done.
1.8.
Listing 1.5: Matlab/Octave code for this exercise about digital interfaces
% global configs
bandwidths = [2133 3000 480 0.2304]; % Mbits / s
interfaces = { ' pci ' , ' sata ' , ' usb2 .0 ' , ' rs232 ' };
record_time = 30; % minutes
5
10
15
1.9.
To be done.
1.10. To be done.
1.11. To be done.
1.12. To be done.
1.13. To be done.
11
12
1.14. To be done.
1.15. See Listing 1.6.
Listing 1.6: Matlab/Octave code for this exercise about signal generation and
analysis
% % global configs
size_x = 100; % samples
bins = 500; % bins for histogram
5
10
15
25
% % plot autocorrelations
% DEPENDS on MATLAB ' s Signal Processing Toolbox
% DEPENDS on Octave - Forge ' s packages
plot ( xcorr ( x ) ) , title ( ' Autocorrelation of x ') ;
figure ;
plot ( xcorr ( y ) ) , title ( ' Autocorrelation of y ') ;
figure ;
30
figure ;
[ counts_y , bins_y ] = hist (y , bins ) ;
bar ( bins_y , counts_y ) , title ( ' Histogram of y ') ;
40
% % display info
disp ( ' Power : ') ;
10
15
20
25
13
14
30
1.17. To be done.
1.18. To be done.
1.19. To be done.
1.20. See Listing 1.8.
Listing 1.8: Matlab/Octave code for this quantization exercise
% % global configs
b = 10; % bits
10
15
20
25
15
30
% configs
mean_x2 = 3;
std_x2 = 2;
40
45
50
55
10
16
1.22. To be done.
2.1.
Given two vectors x = [4, 0] and y = [5, 2], find the projections
pyx and pxy and the respective error vectors eyx and exy .
2.2.
"
1 5
2.3. Is the matrix A =
unitary? Design a unitary matrix B
3 4
that is similar to A in the sense that its first basis (column) is a vector
in the same direction as [1, 3]T .
Assume a 2-d vector space has non orthogonal basis given by
i = [2, 1] and j = [0, 3]. Find the coefficients and that allow to
represent the vector x = [4, 1] as the linear combination x = i + j.
2.4.
2.5.
Find the inner product between the signals: a) u(t) and e0.9t , b)
cos(0.5n) and [n], c) u[n 1] and u[n].
2.6.
2.2 Exercises
A segment of an ECG signal x[n] with six samples
[1, 0.6, 0.5, 1, 2.5, 2] must be encoded using a 3-points DCT (i. e.,
using two frames with three samples each). Find the DCT coefficients
of these two vectors. Then, reconstruct an approximation of the two
vectors assuming that only the first coefficient can be used while
the other two are discarded (assumed to be zero). Confirm Eq. (??)
calculating the norms of both error vectors et and ef .
2.1.
2.2.
18
2.3. Consider that a block of pixels C = 124 220 120 was ex114 130 122
tracted from an image. Calculate the bi-dimensional DCT and DFT
first processing each row and organizing the result of this intermediate
step as a matrix T, then apply the transforms to each column of T to
generate the final matrix. Follow this procedure to obtain a matrix with
the DCT coefficients and then repeat it to obtain the DFT coefficients.
Design a DCT-based image coding system that is capable of
handling 24 bits/pixel color images and 8 bits/pixel black and white
(B&W, also called gray) images, all with a size of 512 512 pixels. The
system should operate using: a) 3 bits/pixel, b) 1 bit/pixel or c) 0.25
bit/pixel. For the three cases, provide the average peak SNR (PSNR),
i. e., the SNR when assuming the signal in the numerator is an image
with all pixels at the peak value of 255 and the denominator is the
mean squared-error. The test sequence should be the colorful and B&W
versions of the images Lenna, Peppers, Baboon, Splash and Tiffany,
available from [url2us2]. Do not download B&W versions of the five
mentioned images, but make the conversion from color to B&W yourself
and describe the conversion method you used. Hence, the test set will
have 5 images. You can use as many images you want to compose your
training set (distinct from the test set images). Provide the source code
and a short report of your results that includes the average PSNR.
2.4.
2.5.
2.6.
PCA assumes the signal is zero mean. This exercise uses this fact
2.2 Exercises
19
Note that the KLT does not have info about the mean. Therefore, in
practice, one needs to keep the mean and, eventually, normalize the
variances to be unitary (this normalization is called in statistics to
z-transform the data, but this term should not be confused with the
Z transform).
Generate N = 10, 000 samples from a bidimensional Gaussian
= (30, 20)T and covariance matrix
fX1 ,X"2 (x1 , x2 ) with
mean
#
2.7.
10 0.99
. Obtain two transforms: Ag using Gram-Schmidt
0.99 40
orthonormalization and Ap using PCA. You can remove means if useful.
Using each transform, project the data into the new space and compute
the variance of the coefficients in each dimension. Which transform you
expect to lead to smaller variances of the transformed vectors?
C=
2.8.
2.9.
2.10. What are the forward A and inverse AH matrices for a 3-points
orthonormal DFT?
20
2.11. Consider that s[n] was obtained by sampling with Fs = 100 kHz
an analog and periodic signal s(t). The sampling theorem was obeyed.
The 8-DFT of s[n] was calculated in Matlab/Octave with fft(s)/N and
is shown in Figure 2.1. The value N was chosen to be an exact multiple
of the fundamental period of s(t) such that the problem of spurious
components illustrated in Figure ?? did not occur. a) What is the
frequency of each component of s(t)? What is the resolution f in Hz
of this DFT? c) Find a reasonable expression for s(t).
mal DFT, find its inverse x. For the same spectrum, assuming that
Fs = 10 Hz, to which frequencies correspond the elements of X?
2.14. Using the orthogonality condition of the basis functions derive the
2.15. What are the Fourier series coefficients for the signal x(t) =
2.16. The bilateral Fourier series of a signal x(t) with period T0 = 0.01 s
21
2.2 Exercises
k= 2(
2.20. Prove the cited properties of the Fourier tools for the case of the
Fourier transform.
2.21. Prove the cited Fourier pairs for the case of the DTFT.
2.22. A right-sided signal has Laplace transform X(s) = 5/(s2 +2s+10),
2.25. Find the Z transform and associated ROC of the signal x[n] =
What are the values of X(z) for z = 0, 1 and z = 8ej ? If the DTFT
of x[n] exists, what are its values for = 0, and 2 rad?
3.1.
When the input x1 [n] = [n] is applied to a LTI system, the output
is y1 [n] = 3[n] + 2[n 1] + [n 2]. What is the output y2 [n] when
the input is x2 [n] = 5[n] + 2[n 1]?
3.2.
3.3.
3.4.
3.5.
3.6.
3.7.
3.8.
24
3.9.
3.15. Assume the DUT in the circuit of Figure ?? is the SAW filter
3.1 Exercises
25
3.18. A FIR filter with linear phase has an impulse response h[n] =
factor = 0.707 (such filter could be used by, e. g., the PLL discussed in
Section ??). a) find H(s) when the settling time must be approximately
3 ms (you may use Table ??). b) Perform a similar project but for the
SOS described by Eq. (??). c) Show the graphs of the outputs of both
systems to the step function u(t).
3.20. For the filter H(z) obtained with [b, a]=butter(3,1/3): a) find
the values of H(z) for z = 0.5 + 0.5j, 3 + 2j, 0, 1, 3 and 0.5 + 0.5j. b)
Using freqz.m, find the maximum value of the magnitude response and
in which frequency this maximum occurs. c) What are the first five
samples of the impulse response h[n]? d) Is this a FIR or IIR? e) Is
this a lowpass or highpass?
3.21. For
100
26
3.23. The filter H(s) = s3 +2s21+2s+1 was obtained with the command [b,
0.4s + 0.13) into H(z) assuming Ts = 0.1 s and compare their frequency
responses with the original one (in continuous-time) b) Repeat the
procedure for Ts = 1 s. c) Discuss what methods were most impacted
by the increase of Ts .
3.26. Given a filter H(s) = (0.1s2 + 71)/(s2 + 11s + 71) and assuming
3.1 Exercises
27
3.28. The filter Hs (s) = (0.1s2 + 71)/(s2 + 11s + 71) should be converted
to Hz (z) using the bilinear such that the value of Hs (j) at = 10 rad/s
is the same value Hz (ej ) will have at = /4 rad. a) find the
value of Fs that allows to directly convert Hs (s) into Hz (z) without
the traditional pre-warping step, b) assuming an arbitrary value of
Fs0 = 0.5 Hz, find the pre-warped version of Hs (s) that will generate
the correct Hz (z) via bilinear with Fs0 .
3.30. Design a causal FIR H(z) using the windowing method. The
filter must have 5 coefficients, cutoff frequency /6 rad and the adopted
window must be Hanns. The gain at DC must be unitary. The
command hanning(5) in Matlab/Octave, returns [0.25, 0.75, 1.00, 0.75,
0.25].
3.31. A filter was obtained with [b, a]=butter(3,1/3). a) Draw the block
10
main ( ) {
int x , y ;
...
while (1) { // eternal loop
x = readAD ( ) ;
...
writeDA ( y ) ;
}
...
}
28
3.1.
3.2.
Design a digital Butterworth filter H(z) using the bilinear transform. The cutoff and rejection filters are /4 and 2/3, respectively.
The linear gain at DC should be 1 and the minimum gain at the passband should be 0.95. The maximum gain at the rejection band is 0.01.
This filter can be obtained with the commands:
3.3.
a) What are the gain and phase at frequencies /4 and 2/3 rad? b)
What is the difference equation that corresponds to H(z)?
The bilinear transform Eq. (??) was obtained by expanding the
numerator and denominator of z = esTs /2 /esTs using a first order
Taylor expansion. Compare it with the expansion of z = esTs 1 + sTs .
What are the reasons for using the former expansion? An alternative
point of view is to calculate the series expansion of ln z for the matched
Z-transform s = ln(z)/Ts . Check the expansion for x > 0 at [url3iit].
3.4.
3.5.
29
Using the function fir1, compare the FIR filters with cutoff frequency /4 rad for the windows Hamming, Hann and rectangular. The
commands can be
3.6.
and freqz can help. How do they compare with respect to: attenuation,
decay, side lobe and width of the main lobe.
Observe that fir1 in Matlab uses a modified cutoff frequency fc .
Instead of fc being the frequency of half the power at passband, for
fir1 fc is the frequency of half the gain at passband. In other words,
considering a filter with gain |H(0)| = G at DC, fir1 provides a filter
with gain |H(fc )| 0.5G (which corresponds to 20 log10 0.5
6 dB),
instead of the commonly adopted 3 dB value of |H(fc )| G/ 2. For
the Hamming window, design an alternative to fir1 that allows theuser
to specify the cutoff frequency as the one in which |H(fc )| G/ 2.
3.7.
3.8.
3.9.
30
3.13. When cascading the 2nd order stages, why the stages with lower
3.14. Compare the MFB and Sallen-Key topologies. Can you find a
To be done. 1
3.2.
To be done. 2
3.3.
To be done. 3
3.4.
To be done. 4
3.5.
To be done. 5
3.6.
To be done. 6
3.7.
To be done. 7
3.8.
To be done. 8
3.9.
To be done. 9
3.10. To be done. 10
3.11. To be done. 11
3.12. To be done. 12
31
3.13. To be done. 13
3.14. To be done. 14
3.15. To be done. 15
3.16. In this case, f1 coincides with the nominal frequency fn = 455 kHz.
As the table indicates the actual center frequency fc of this device may
vary but it is assumed here that fc = fn and the gain is 0 dB (see the
figure associated to the table) or 1, in linear scale. The group delay at
this frequency is assumed to be 50 s, which corresponds to a phase of
6
ej5010 . Hence, the frequency response value H(1 ) at 1 = 2f1 is
3
6
1ej245510 5010 1ej142.9 (angle in rad). Converting the phase
to the range [, [ leads to H(1 ) = 1ej1.5708 .
instead of ej8t .
32
as componentes.
A magnitude das componentes dentro da banda de passagem
nao muda e soh a fase altera:
k=1 => w=1.5 rad/s => phase = -12 rad
k=2 => w=3 rad/s => phase = -24 rad
k=3 => w=4.5 rad/s => phase = -36 rad
Assim, a saida eh dada pela soma das parcelas acima:
y(t) = 0.5 sin(3/2t - 12) + 0.25 sin(3t - 24)
+ 1/8 sin(4.5t - 36)
3.18. A FIR filter with linear phase has an impulse response h[n] =
10
%a)
% Bz =[0.063856 0.191568 0.191568 0.063856];
% Az =[1 -0.96578 + 0.58264 -0.10602];
[ Bz , Az ]= butter (3 ,1/3) ;
z =[0.5+0.5* j 3+2* j 0 -1 3 0.5+0.5* j ]
Hz = polyval ( Bz , z ) ./ polyval ( Az , z )
magHz = abs ( Hz )
%b)
[H , w ]= freqz ( Bz , Az ) ;
% plot (w , abs ( H ) ) ;
indexMax = find ( abs ( H ) == max ( abs ( H ) ) )
freq_max = w ( indexMax )
15
33
%c)
h = impz ( Bz , Az , 5)
%d)
IIR
20
%e
freqz ( Bz , Az ) ; % lowpass
mand
[Bs,As]=butter(2,10,s). The pair of poles (roots of As) are
(10/ 2)(1 j), which have a natural frequency n = 10 rad/s. See
the details after the solution.
which indicates that magdB = -23 dB. Hence, the interferer has power
-22 dBm, corresponding to 1 dBm attenuated by 23 dB.
c)
34
10
15
20
25
main ( ) {
int x , y ;
int xnm1 , xnm2 , xnm3 , ynm1 , ynm2 , ynm3 ;
// initialize filter memory with zeros :
xnm1 =0;
xnm2 =0;
xnm3 =0;
ynm1 =0;
ynm2 =0;
ynm3 =0;
while (1) { // infinite loop
x = readAD ( ) ;
// implement zeros
y = 0.0181* x + 0.0543* xnm1 + 0.0543* xnm2 + 0.0181*
xnm3 ;
// implement poles
y = y + 1.7600* ynm1 - 1.1829* ynm2 + 0.2781* ynm3 ;
writeDA ( y ) ;
ymn3 = ynm2 ; % update for next iteration . Note order of
...
ynm2 = ynm1 ; % updates : avoid overwriting a value ...
ynm1 = yn ;
% that should be used later
xnm3 = xnm2 ;
xnm2 = xnm1 ;
xnm1 = xn ;
}
}
35
To obtain G(s) with new cutoff frequency of 1200 one can algebraically
do:
s
G(s) = H(s)|s 1200
and simplify the expression. Another alternative is to use Matlab/Octave:
[ bg , ag ]= butter (3 ,1200* pi , 's ') % obtain the filter
W = linspace (0 ,2000 ,100) ;
freqs ( bg , ag , W ) ;
Note that the cutoff frequencies have a linear gain of 0.70711, which
correspond to 3.01030 in dB.
3.24. It is convenient to first obtain a filter P (s) with cutoff frequency of
3.25. To be done. 25
36
H(z) =
For convenience, normalize by 11171 such that the denominator coefficient of highest order is 1:
H(z) =
10
15
Bs =[0.1 0 71]
As =[1 11 71]
Fs =50 % in Hz
N =20000; % number of points for freqs / freqz
[ Bz , Az ]= bilinear ( Bs , As , Fs )
[ Hz , Wd ]= freqz ( Bz , Az , N ) ;
w = Wd * Fs ; % from rad to rad / s
Hs = freqs ( Bs , As , w ) ; % H ( s ) at frequencies w
subplot (211)
plot (w ,20* log10 ( abs ( Hz ) ) )
hold on , plot (w ,20* log10 ( abs ( Hs ) ) , 'r ')
legend ( 'H ( z ) ' , 'H ( s ) ')
subplot (212)
magError = abs ( Hz ) - abs ( Hs ) ; % error
plot (w , magError ) , ylabel ( ' Error in magnitude ')
xlabel ( 'w ( rad / s ) ') ;
[m , i ]= min ( abs ( magError ) ) % find minimum
minFreq = w ( i ) % frequency of minimum abs error
By zooming the top plot, it can be seen that H(z) and H(s) have the
same magnitude ( 52.4 dB) for m 26.3 rad/s (besides at DC).
37
3.29. One can simply use the bilinear transform to get the digital filter
We could improve the design using pre-warping, such that the gains
at the cutoff frequencies of H(s) and H(z) match. From the previous
question, the cutoff frequency of H(s) is 1 rad/s (it was obtained with
[bg, ag]=butter(3,1,s)). Because the cutoff is 1 rad/s, the Matlab
command [Bz, Az]=bilinear(Bs,As,Fs,1), which uses pre-warping, does
not change the result. But pre-warping should be trained with other
questions.
3.30. To be done. 30
3.31. The coefficients b and a allow to draw the direct forms I, II and
38
10
15
main ( ) {
int x , y ;
int wn , wnm1 , wnm2 , wnm3 ;
wn =0; // initialize filter memory with zeros
wnm1 =0;
wnm2 =0;
wnm3 =0;
while (1) { // infinite loop
x = readAD ( ) ;
wn = x + 0.9658* wnm1 -0.5826* wnm2
+0.1060* wnm3 ;
y = 0.0639 * wn +
0.1916* wnm1 +
0.1916* wnm2 +
0.0639 * wnm3 ;
writeDA ( y ) ;
wnm3 = wnm2 ; // prepare for next iteration
wnm2 = wnm1 ;
wnm1 = wn ;
}
}
To be done. 1
3.2.
To be done. 2
3.3.
To be done. 4
3.5.
To be done. 5
To be done. 6
3.7.
To be done. 7
3.8.
To be done. 8
3.9.
To be done. 9
39
3.10. To be done. 10
3.11. To be done. 11
3.12. To be done. 12
When you apply a step function u(t) to the input of an opamp, you can
see that it takes some time until the output goes from 0 to 1. This is
related to the slew rate, which is faster for opamps that can deal with
higher frequencies.
8) Reproduce on Octave / Matlab figs. 13 and 15 of texas_sbfa001a.pdf
assuming a Butterworth response.
Fig 13 is approximated by the commands below. Note that the Bessel
filter is not the same as the one used by Texas because we are not
positioning the cutoff frequency as they did. Also, the other two filters
may be different.
cutoffFrequency = 20000; % in Hz
N = 5; % order
w = linspace (2* pi *200 ,2* pi *200000 ,1000) ;
40
10
15
20
clf
semilogx ( w /(2* pi ) ,20* log10 ( abs ( Hbu ) ) )
hold on
semilogx ( w /(2* pi ) ,20* log10 ( abs ( Hbe ) ) , 'k ')
semilogx ( w /(2* pi ) ,20* log10 ( abs ( Hch ) ) , 'r ')
axis ([200 200 e3 -90 10])
legend ( ' But ' , ' Bes ' , ' Che ') ;
grid
3.4.
41
b) The group delay shows how the frequency components of the input
signal get delayed. This delay is frequency-dependent. For example,
its peak is located at approximately 533.3 Hz, and at this frequency
the input component (the component at 533.3 Hz) gets delayed by 991
s. For components with frequency less than approximately 85 Hz, the
delay the filter imposes is 548 s.
Each SOS corresponds to a pair of poles with its own f0, BW and Q.
The combination of the 3 SOS compose the final transfer function.
42
The group delay for Chebyshev of Figure 3.3 can be compared to the
one with Bessel in Figure 3.2. It can be seen that the poles of Chebyshev
have higher Q (from approximately 1 to 4 is the last two SOS) and
the group delay is very different and worse for Chebyshev, which has a
peak of 2260 sat the frequency 642.2 Hz. More than twice the delay
imposed by the Bessel filter at the peak frequency.
Study the advantages and disadvantages when comparing Butterworth, Chebyshev and Bessel responses.
3.5.
In summary, Bessel has a good group delay behavior but a poor attenuation (gain) behavior. Chebyshev is the opposite while Butterworth is
a trade of between the two.
When cascading the 2nd order stages, why the stages with lower
Q are placed first by Filter Pro?
3.6.
3.7.
There are topologies better than Sallen-Key. For example, read: http:
//www.maxim-ic.com/app-notes/index.mvp/id/1762.
3.8.
3.9.
43
quency /4 rad for the windows Hamming, Hann and rectangular. The
commands can be
bham = fir1 (30 ,1/3 , hamming (31) ) ;
bhan = fir1 (30 ,1/3 , hanning (31) ) ;
bret = fir1 (30 ,1/3 , rectwin (31) ) ;
and freqz can help. How do they compare with respect to: attenuation,
decay, side lobe and width of the main lobe.
The following commands can be used
bham = fir1 (30 ,1/3 , hamming (31) ) ;
freqz ( bham ,1)
grpdelay ( transpose ( bham ) ) ;
3.12. The Kaiser window is very flexible. Study the project below
that uses Fs = 11025 Hz, passband [0, 1000] Hz, and rejection band
[1200, Fs /2]. The minimum attenuation at rejection band is 40 dB and
the maximum ripple at the passband is 5% (i. e., the filter can go from
1 to 0.95 at the passband).
[n , w , beta , ftype ] = kaiserord ([1000 ,1200] , [1 ,0] ,
[0.05 ,0.01] , 11025) ;
freqz ( fir1 (n ,w , ftype , kaiser ( n +1 , beta ) , ' noscale ')
,1 ,[] ,11025) ;
44
10
15
3.13. New question Can you generate random noise and filter it?
N =1000;
x = randn (1 , N ) ;
psd ( x )
pause
[B , A ]= butter (5 ,0.3 , ' high ') ; % high - pass filter
y = filter (B ,A , x ) ;
psd ( y )