0% found this document useful (0 votes)
4 views

Lab 3

Uploaded by

Mahsa Sorouri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Lab 3

Uploaded by

Mahsa Sorouri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Lab 3: Using STM32F7 to View Frequency Response of Different Sampling Rates of the DSP

In this lab, the frequency response of the STM32F7 Microcontroller will be observed by viewing the
aliasing effect of the 48 kHz sampling rate and the 32 kHz sampling rate of the microcontroller. The
code that determines the sampling rate is shown below and the uncommented code is the sampling
rate that was executed by the microcontroller. Firstly, I uploaded the pictures then explain whole
parts of the lab.

Then I will show which part of the code we used.


* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
// Uncomment the desired sample rate
//#define USE_FREQ AUDIO_FREQUENCY_48K
#define USE_FREQ AUDIO_FREQUENCY_32K

In these pictures, we settle down the oscilloscope, then how we do it, I will explain it here. The setup
is shown in Figure 1 and the splitter was connected to the output channel of the function generator
which splits the output of the function generator into two channels. One channel was connected to
the audio right or red channel which is to be read by the STM32F7 and produced to be sent out at the
audio right output of the STM32F7 which is connected to the channel 2 input of the oscilloscope.
Channel 2 corresponds to the blue line on the oscilloscope. The splitter splits the other channel to
read directly by the oscilloscope and is connected to the channel 1 input and the channel 1
corresponds to the yellow line on the display of the oscilloscope. The STM32F7 was programmed to
have the sampling rate of 48 kHz and the frequency response was recorded as frequency was
increased by the function generator. The function generator was set to 1V peak-to-peak and
recordings started at 1 kHz. The intervals of the reading decreased as the function generator
approached the cutoff frequency of the sampling rate. The magnitude of the wave was recorded
using the ‘Measure’ function of the oscilloscope to display peak-to-peak voltage values of each
reading taken at the corresponding frequency. The initial values of the voltage readings were
observed to have a peak-to-peak voltage of more than what was made by the original voltage output
of the function generator. The phase difference was also recorded at each frequency and this was
recorded by using the ‘Cursor’ functions to track cursors along the signal lines and the phase
difference was recorded in microseconds as the cursors were placed at the peak of their
corresponding signals. In this picture,

This ‘Cursor’ function is shown in this picture, The distance was given as the ΔX which indicated the
time difference of the two peaks. The phase difference also oscillated in a behavior as the frequency
response was plotted. The code for the interrupt service routine was used from Lab 1 to produce an
identical signal as the input as long as the input frequency was maintained below half the sampling
rate frequency.

void PUT_YOUR_LAB_CODE_HERE(int16_t input_left, int16_t input_right, int16_t&


output_left, int16_t& output_right) {
output_right = input_right; //red cable
//output_left = input_left; //white cable
}
In this picture, he values of the phase shift and the magnitude were plotted on a spreadsheet to
demonstrate the behavior of the two in relation to the frequency. A plot was made for the 48 kHz
sampling rate and the procedure was completed a second time for the 32 kHz sampling rate.
The phase difference of the 48 kHz and the 32 kHz sampling rates are shown in pictures. The behavior
of the plots illustrates the aliasing effect as the sampling rate becomes too slow take accurate
readings of signals that have frequencies of more than half value of the sampling rate.
The phase difference became more difficult to pinpoint and measure as the aliasing effect became
more apparent. That made it more difficult to pinpoint the peaks of the signals and that is why the
phase response has different ranges of frequency as opposed to magnitude readings. The cutoff
frequencies were viewed to be 24.1 kHz for the 48 kHz sampling rate and 16.1 kHz for the 32 kHz
sampling rate.
Another method of estimating the cutoff frequency is setting the function generator to make 10 micro
second bursts at a frequency of 10 Hz. And a screenshot was taken from the record function to be
set to record as a single impulse was detected. A screenshot was taken from the oscilloscope
observing the behavior of the 48 kHz and 32 kHz sampling rates and the Fast Fourier Transform (FFT)
function was used the estimate the cutoff frequency of each sampling rate as it had values already
displayed in decibel units (dB). The screenshots of these impulse responses for the 48 kHz and 32
kHz sampling rates are shown.

In these pictures, The cursor function was used on the FFT so the cursor could be dragged along the
values of the FFT plot and the points would not have to be done manually for the X and Y coordinates.
One cursor was set any point on the passband which indicated the gain of the lower frequencies and
the other cursor was traced along the FFT line until the ΔY was the smallest value it could be closest
to -3 dB. The cursor functions of these are shown here.
The results of the impulse response method showed that 23.97 kHz was the cutoff frequency of the
48 kHz sampling rate and is close in terms of the order of magnitude. The plotting method showed
that the cutoff frequency for 48 kHz is 24.1 kHz, which is approximately 200 Hz higher than the what
the impulse response had showed. The plotting method showed that the cutoff frequency is 16.1 kHz
and it is shown to be the same in the impulse response method.

You might also like