- Problem 3.1:
A bandpass filter is commonly used in a communications
receiver to reduce noise and interference outside of the
transmission band.
The transmission band in this problem is from 3000 Hz to
4000 Hz, as could be used in an acoustic modem.
For the simulation of the narrowband interferer, please use a chirp signal from 1000 Hz to 1100 Hz. In improvesnr.m, replace the line

n=0.25*randn(1, time/Ts );

witht = Ts : Ts : time; f0 = 1000; chirpBW = 100; n = cos(2*pi*f0*t + pi*(chirpBW/time)*(t.^2));

By starting at t=Ts and ending at t=time, we ensure that signal n would have the same number of samples as signal x.In part (c), please design the second-order IIR notch filter by manually placing poles and zeros, and manually determining the gain. Explain how you made these choices. More information is below.

Here's how to connect the poles p0 and p1, zeros z0 and z1, and gain C of the transfer function with the feedback coefficients a1 and a2 and feedforward coefficients b0, b1 and b2:

-1 -1 -1 -2 (1 - z0 z )(1 - z1 z ) 1 - (z0 + z1) z + z0 z1 z H(z) = C ------------------------ = C ------------------------------ -1 -1 -1 -2 (1 - p0 z )(1 - p1 z ) 1 - (p0 + p1) z + p0 p1 z

So, using the notation of lecture slide 6-15 on biquads,b0 = C b1 = -C (z0 + z1) b2 = C z0 z1 a1 = p0 + p1 a2 = - p0 p1

Please note that the Matlab`filter`

and`freqz`

commands represent an infinite impulse response filter usinga1 = -(p0 + p1) a2 = p0 p1

Here's the code for a notch filter at notch frequency of pi/4 rad/sample from Lecture 6:zeroAngle = pi/4; z0 = exp(j*zeroAngle); z1 = exp(-j*zeroAngle); numer = [1 -(z0+z1) z0*z1]; r = 0.9; poleAngle = pi/4; p0 = r * exp(j*poleAngle); p1 = r * exp(-j*poleAngle); denom = [1 -(p0+p1) p0*p1]; %%% Normalize the DC response to 1 in linear units %%% by setting H(z) evaluated at z = 1 to be 1 C = (denom * [1 1 1]') / (numer * [1 1 1]'); freqz(C*numer, denom);

You'll need to connect continuous-time notch frequency fnotch and the sampling rate fs to the discrete-time frequency wnotch. Then, setzeroAngle = wnotch; poleAngle = wnotch;

Notes on the notch filter for this problem from fall 2019.

- Problem 3.2:
Quadrature Amplitude Modulation (QAM) uses transmission bandwidth
efficiently by combining two amplitude modulated signals in the
same transmission bandwidth.
One signal is modulated by a cosine and the other signal is
modulated by a sine in a QAM transmitter.
Please see lecture slide 1-15 on QAM transmission, which is based
on lecture slides 1-6 to 1-9 on sinusoidal modulation.
A QAM receiver must track the carrier frequency and carrier phase to recover the transmitted messages. This problem asks you to explore the degradation in the received messages if the carrier frequency has been perfectly tracked in the receiver but the carrier phase tracking has a slight error in it.

In this problem, there are two baseband message signals

*m*_{1}(*t*) and*m*_{2}(*t*). Please use different baseband message signals.The second message signal should have about the same average power as the first message signal. To compute the average power, one can compute the instantaneous power by squaring the absolute value of each amplitude and then computing the average of the instantaneous power calculations. The Matlab code would be

averagePower = sum(abs(signal) .^ 2) / length(signal);

To create the second message signal, you could take the first message signal and change a parameter value of the ramp component or the sinusoidal component.

It simplifies the solution if you use the same linear phase lowpass FIR filter for the two demodulating filters in the receiver. The demodulating filters are designed to give a passband frequency of 500 Hz and a stopband frequency of 1000 Hz.

With phase error, energy in transmitted message signal #1 will leak into received message signal #2, and vice-versa, which is known as cross-interference.

*Let's do the math. Assuming that there is a phase error of theta at the receiver, we can derive the upper output**s*_{1}(*t*)*using the trigonometric identities in JSK on page 404.**s*_{1}(*t*) = LPF{*m*_{1}(*t*) cos(2 pi*f*_{c}*t*) cos(2 pi*f*_{c}*t*+ theta) -*m*_{2}(*t*) sin(2 pi*f*_{c}*t*) cos(2 pi*f*_{c}*t*+ theta) }*s*_{1}(*t*) = LPF{ 1/2*m*_{1}(*t*) ( cos(theta) + cos(4 pi*f*_{c}*t*+ theta ) ) - 1/2*m*_{2}(*t*) ( sin(-theta) + sin(4 pi*f*_{c}*t*+ theta ) ) }*s*_{1}(*t*) = 1/2 cos(theta)*m*_{1}(*t*) + 1/2 sin(theta)*m*_{2}(*t*)*When theta = 0, i.e. when there is no phase error,**s*_{1}(*t*) = 1/2*m*_{1}(*t*)*which recovers the in-phase component up to a scalar gain*.The lowpass filter in the equations above was assumed to be ideal with no delay. In practice, the input signal experiences delay through the filter by the time it reaches the output. The code in AM.m uses an FIR filter of order 100, which has 101 coefficients and a group delay of 50 samples.

Implement the lowpass filter by using the convolution command

`conv`

. Then, discard the first 50 samples and the last 50 samples from the result to remove the leading and trailing effects due to convolving two finite length signals. We had seen these effects during the convolution demo.In the receiver in Figure 5.10, the term sin(2 pi f

_{c}t) should be -sin(2 pi f_{c}t) to match the negation of the lower path in the transmitter.**Connections to lecture**. We discussed sinusoidal modulation and demodulation on lecture slides 1-6 through 1-9 for two-sided signals. Consider a two-sided baseband signal x_{1}(t) with bandwidth w_{1}modulated by cos(w_{c}t) which gives y(t) = x_{1}(t) cos(w_{c}t) as a two-sided signal. The spectrum Y(w) is bandpass over w in [w_{c}- w_{1}, w_{c}+ w_{1}] and [-w_{c}- w_{1}, -w_{c}+ w_{1}] and has bandwidth 2 w_{1}as shown on lecture slide 1-6. For demodulation back to baseband, we'll multiply y(t) by cos(w_{c}t) and apply a lowpass filter. In modulating y(t) by cos(w_{c}t), we’ll get a combination of a baseband component for w in [-w_{1}, w_{1}] and a bandpass component for w in [2w_{c}- w_{1}, 2w_{c}+ w_{1}] and [-2w_{c}- w_{1}, -2w_{c}+ w_{1}] as shown on lecture slide 1-7.Applying a lowpass filter with a passband frequency of w

_{1}will extract the baseband component and attenuate/reduce the bandpass component. Here are several lowpass filtering approaches. Lecture slide 1-7 applies an ideal IIR filter whose frequency response is a rectangular pulse for w in [-w_{1}, w_{1}] and whose impulse response is a two-sided sinc pulse. Although not implementable, it is useful as a starting point. A practical demodulating filter could be an FIR or IIR filter with a stopband frequency between 1.1 w_{1}and 2w_{c}- w_{1}.**Message bandwidth**. The message bandwidth is not explicitly given. By using plotspec(m1, Ts) in Matlab, the magnitude of the frequency content of message #1 using contains one large DC component plus a smaller peak at 20 Hz plus slowly decaying magnitude values that follow a 1/f shape. The carrier frequency is 1000 Hz. The demodulating filter is a linear phase FIR filter designed using the Parks-McCellan algorithm (firpm command) using a passband frequency of 500 Hz and stopband frequency of 1000 Hz. From the demodulating filter specifications, one can infer the message bandwidth to be 500 Hz, and the stopband frequency is twice the message bandwidth. - Problem 3.3:
For a demonstration of using filterDesigner, formerly known as the filter
design and analysis tool (fdatool), in Matlab to design IIR filters,
please view the video for
Spring 2014 Lecture 6 Part 5,
at the 17:15 mark.
In the pull-down menu in filterDesigner (formerly fdatool) for choosing a filter structure, SOS means second-order sections, i.e. a cascade of biquads.

IIR filter design algorithms return poles, zeros, and gain(s). The design algorithms are based on closed-form formulas and are incredibly accurate, including determining the minimum filter order. Even so, the IIR filter structure chosen for the implementation of the filter can alter the pole locations, which can sometimes lead to a bounded-input bounded-output unstable filter or otherwise cause the filter implementation to miss the original specifications.

Please check the filter design and implementation to make sure that it meets specifications.

- Increase the plotting resolution for magnitude and group delay plots vs. frequency for the filter by going to the Analysis menu ... Analysis Parameters ... and setting the number of points to 65536.
- Display the magnitude response in filterDesigner by choosing "Magnitude Response" under the "Analysis" menu or the appropriate icon shortcut.
- Zoom into the passbands and stopband by using the zoom tool, which is available as the icon of the magnifying glass with a plus sign in the middle of it.
- Hit CONTROL-Z to undo the most recent zoom.

Once you've designed your filter in filterDesigner (formerly fdatool) in Matlab, you can export the filter coefficients to use in Matlab commands. In the Design Filter View of filterDesigner, the upper left window has the text "Current Filter Information". Below this text, you can right click on the text "Structure" and pick either cascade of biquads or single section.

*Cascade of biquads.*If you leave the filter as a cascade of biquads, then for each biquad, expand the factored form of the transfer function and report the feedforward coefficients (b0, b1 and b2) and the feedback coefficients (a1 and a2). Here's how to connect the poles, zeros and gain with the coefficients using the transfer function using the notation on lecture slide 6-15 for the unfactored form (on the right):-1 -1 -1 -2 (1 - z0 z )(1 - z1 z ) 1 - (z0 + z1) z + z0 z1 z H(z) = C ------------------------ = C ------------------------------ -1 -1 -1 -2 (1 - p0 z )(1 - p1 z ) 1 - (p0 + p1) z + p0 p1 z

So,b0 = C b1 = -C (z0 + z1) b2 = C z0 z1 a1 = p0 + p1 a2 = - p0 p1

Please note that the Matlab`filter`

and`freqz`

commands represent an infinite impulse response filter usinga1 = -(p0 + p1) a2 = p0 p1

One could also use a cascade of first-order sections. In each first-order section, the pole and zero would be complex-valued, which increases the computational complexity for addition and multiplication over real-valued coefficients and data. Multiplication of two complex numbers takes 4 real multiplications and 2 real additions, and the addition of two complex numbers of 2 real additions. That is, a cascade of two first-order sections with complex-valued coefficients would have four times the computational complexity and twice the memory usage vs. a second-order section (biquad) with real-valued coefficients and data.

*Single section.*Under the "Edit" menu, you can convert an IIR filter design to a single section by choosing "Convert to Single Section". Then, under the File menu, you can click "Export". The "Export" command will by default export the filter coefficients to the Matlab workspace. The numerator coefficients will be in the Num vector, and the denominator coefficients will be in the Den vector. Then, in Matlab, you can type Num to see the numerator coefficients, and type Den to see the denominator coefficients. Moreover, you can apply the filter to a signal in Matlab usingoutputSignal = filter(Num, Den, inputSignal);

When converting an IIR filter design from a cascade of biquads to a single section, the IIR filter might become BIBO unstable: IIR Filter Structure. For example, if you convert the Butterworth filter design from part (a) into a single section, many of the poles will move outside of the unit circle. You can see this by choosing "Pole/Zero Plot" under the "Analysis" menu. One pole located on or outside of the unit circle is enough to have BIBO instability.(c) The total number of instruction cycles for an IIR filter on a particular processor would depend on the IIR filter structure. Appendix N Computational Complexity of Implementing a Tapped Delay Line on the C6700 DSP explains the number of instruction cycles on the TMS320C6748 processor in lab. For an FIR filter of N coefficients, it takes N+28 instruction cycles. An IIR filter of order M has M feedback coefficients and M+1 feedforward coefficients, for a total of 2M+1 coefficients. Hence, an IIR filter would take 2M+29 instruction cycles, and a IIR biquad filter (second-order section) would take 33 instruction cycles. The top of the handout has a link to a video presentation for the handout.

Last updated 02/25/24. Send comments to bevans@ece.utexas.edu