Академический Документы
Профессиональный Документы
Культура Документы
NITTE
(An Autonomous Institute under VTU, Belgaum)
NITTE - 574110
Department
Of
Electrical and Electronics
Embedded Systems
Task Report - 2
Implementation of FIR low pass filter
In STM32f4 Discovery Board
By
1. Kiran B V
2. Prajwal B V
3. Vidya M C
(4NM11EE019)
(4NM11EE035)
(4NM11EE065)
Overview: This document is a brief report on our second task for embedded
systems. The Overview summarizes the content of this document. Our second task
was to implement a FIR low pass filter in STM32F4 Discovery Board. For more
information about the task please refer to the task details.
The STM32f4 Discovery board comes with an internal 12 bit ADC which is used to
sample the analog signal. The samples are then processed using the FIR algorithm
and the result is converted back to the analog form with the internal DAC. The
sampling frequency fs determines the processing bandwidth. The microcontroller
has to convolute 2*M+1 samples every 1/fs seconds.
As suggested by its name, A FIR or finite impulse response filter is characterized by
the finite length of its impulse response. The impulse response of an ideal low pass
filter is of infinite length and it takes the form of
sin( n)
n
Task Details: Use cortex m4 stm32 board to demonstrate low pass fir filter with a cutoff frequency of 200 Hz.
Principle: As explained in the overview the working of FIR filter relies on convolution
of sampled data with a finite length impulse response of a low pass filter. The
impulse response of a low pass filter has the form
sin( (nM))
(nM)
where
represents the digital cut-off frequency. " is proportional to the analog cut-off
y[p] =
[] [ ]
=2
The frequency response of the Digital FIR filter is shown below. It is a plot of
magnitude of transfer function in decibels as a function of frequency (rad/sec). The
characteristics repeat every 2* intervals.
The next picture is a closer view of the response characteristics. The small
deviations from ideal characteristics are due to the restriction imposed on the length
of filter impulse response.
Development of FIR algorithm: The principle was initially tested in matlab. A set of
100 samples of input was convoluted with the impulse response of a FIR low pass
filter. Here the input was a sinusoidal signal of two different frequencies. One was in
pass band while the other in the stop band. The convoluted output for two
frequencies are provided below. In both plots the first and last 100 samples should
be discarded since the computation of these samples relied on x[n] being 0 which is
not true.
This code was modified so that it operated on a real time input rather than on a
stored input signal. Here the input to the FIR filter was provided one by one in a
sequential manner. The output was also updated in the sequential manner. The
picture shows the output of FIR filter for two inputs where one is in pass band and
another in stop band.
Finally the code was developed in keil IDE. We tested the code in the keil debugger
by verifying the output array y_virt for inputs of various frequencies. As in the
previous cases, the two inputs was chosen so that one of them was in the pass band
and another in the stop band.
Aliasing: The next set of pictures show the output for input frequencies above the
sampling frequency (4 KHz). Since the anti-aliasing filter is not used, all higher
frequencies appear as lower frequency signals at output. These pictures were taken
to verify the repeating nature of the filter response characteristics.
Testing results: The FIR low pass filter was tested by verifying its output for input of
various frequencies. Input to the filter was given from AFO which was a 2.5Vp-p
sinusoidal signal with a suitable DC offset. The DC offset is required since the input
range of ADC is limited to 0 to 3V. The output was recorded on a digital oscilloscope.
Channel 1 of the oscilloscope is connected to the AFO output and channel 2 is
connected to the output of the FIR filter. In the pictures shown below the bottom
trace represents the signal in channel 1 while the upper trace represents the signal
in channel 2.
The first picture shows the output of FIR filter for a 30 Hz sinusoidal signal. Since the
cut-off frequency is at 200Hz the output is not attenuated
This picture shows the output when the frequency of the input sinusoidal signal is
closer to the cut-off frequency.
Further increasing the input frequency will reduce the output amplitude to almost
zero.