Assignment #5: Due Friday May 6, 2016
Assignment #5: Due Friday May 6, 2016
0
–1
H f dB
– 70
f
0 3.5k 4k 8k 8.5k 24k
b.) Provide Python design information, including magnitude and phase response
plots. Your plots should use a digital frequency axis scaled to the actual sam-
pling frequency.
c.) Verify the filter real-time frequency response by placing the coefficients in a
working cascade of biquads IIR filtering program such as described in notes
Chapter 7.
d.) For verification all you need to obtain is the frequency response magnitude in
dB. The best approach is probably to use the vector network analyzer, but
optionally you can drive the filter routine with the software noise generator
or the noise source in the Analog Discovery. Once you have experimental
data in a file, import it into your Jupyter notebook (again see the Chapter 7
sample notebook) to overlay with the theoretical response.
e.) Time your code with -o3 optimization using the GPIO IRQ timing pulse.
Estimate the maximum sampling rate possible without loss of real-time per-
formance? Switch to the ARM SOS routine to see how much faster it is.
2. Using the GUI parameter slider control for he Cypress FM to implement a variable center fre-
quency notch filter of the form
–1 –2
j 1 – 2 cos 0 z + z
H e = --------------------------------------------------------
–1 2 –2
- , 0 0
1 – 2r cos 0 z + r z
with r = 0.9 . The parameter the GUI adjusts will be 0 or have some relation to it. Use
float32_t for your design. Test the filter with a sampling frequency of 48 kHz, and verify
using the network analyzer the ability to tune the notch around the interval f 0 0 f s 2 Hz.
What is the notch depth in dB when tuned to about 1 kHz? I will expect a sound demo of this
in the lab. A nice test of this system is to sum an audio music source together with a single
tone jammer from a function generator, and then see how well the tone can be suppressed
from the music without coloration. With a second slider you can use r to adjust the filter
bandwidth. As an audio source you can use an MP3 player/iPod, portable CD player, or Web
radio.
Note: The notch filter above is really just a single biquad section. So create an SOS coeffi-
cients array as described in notes Chapter 7, such that you can change values in the array
according to the needed 0 and r values. Then you can use the filter functions found in
IIR_filters.c/IIR_filters.h, i.e., IIR_sos_filt_float32() or use the
CMSIS-DSP functions arm_biquad_cascade_df2T_f32()/arm_biquad_cas-
cade_df2T_init_f32(). As globals include
// Create (instantiate) GUI slider data structure
struct FM4_slider_struct FM4_GUI;
In main initialize the GUI slider accordingly and the one only section biquad as
init_slider_interface(&FM4_GUI,460800, 1.0, 1.0, 0.0, 0.0, 12000.0, 0.9);
...
//Initialize IIR notch to the f0 and r values
ba_coeff1[0] = 1.0;
ba_coeff1[1] = -2.0*cosf(2*PI*f0/fs); // or use FM4_GUI.P_vals[4] for f0
ba_coeff1[2] = 1.0;
ba_coeff1[3] = -r*ba_coeff1[1]; // or use FM4_GUI.P_vals[5] for r
ba_coeff1[4] = -r*r; // or use FM4_GUI.P_vals[5] for r
I recommend updating the filter coefficients only when the parameter slider of interest
changes. That means putting an if() code block inside the main while()loop where fol-
Notch BW
f s = 48 kHz