Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Hip2 2022

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Applied Signal Processing

Hand-In Problem 2 FIR Differentiator Design

October 15, 2023

This problem concerns estimating the speed of an object from noisy samples
of the position. The data file (hip2.mat) for the problem contains two variables:
true_position representing samples of the true position and noisy_position rep-
resenting the samples of the measured position which are noisy. The position is the
distance, in meters, traveled by a truck from the start point, and the sampling
interval ∆t is 1 second. By definition, the velocity is the derivative of the position,
so a very natural estimate of the velocity from sampled position data is:
p(n) − p(n − 1)
v̂(n) = , (1)
∆t
where ∆t is the sampling interval and p(n) is the sampled position. This is called
the Euler approximation of the derivative. From (1) it is clear that the derivative
approximation v̂(n) can be seen as the output after FIR filtering with the impulse
response 
1/∆t,
 n=0
hEuler (n) = −1/∆t, n = 1 (2)

0, otherwise

Apply this Euler approximation to the true and measured signals respectively (use
conv in Matlab), and plot the result. When plotting the output from the filter
disregard the last sample. (The last sample is extremely large compared to the oth-
ers. We will come back to this later on.) Apparently, differentiation using sampled
data is an extremely noise-sensitive task. To improve the estimator we can make
use of the fact that the position signal is slowly varying and hence has a low-pass
character, whereas the noise is fairly quickly changing and contain all frequencies.
Your task is to design a FIR filter that performs approximate differentiation for
low frequencies up to frequency 0.05 Hz, while blocking the frequency band above
0.1 Hz to reduce the influence of the noise. The continuous-time filter we wish to
approximate has frequency response (why?)

jω |ω| ≤ 2π · 0.05 rad/s
H(ω) = (3)
0 |ω| > 2π · 0.1 rad/s
Thus, the passband has an amplitude response which is increasing linearly with
frequency and a constant +90◦ phase shift. The latter is easily fixed by enforcing
odd symmetry in the FIR coefficients. Note that the Matlab function firpm can
force the filter’s phase to be +90◦ degreas automatically for you, by adding the string
’differentiator’ as the last argument to the function. For more information see
the help text, i.e. in Matlab type help firpm.
In Matlab the convention is that a FIR filter is said to be order M if it has
M + 1 filter coefficients. Numerical values of normalized frequencies are in Matlab
normalized relative to half the sampling frequency. Hence, normalized frequency of
1 corresponds half the sampling frequency fs /2.

1
Design task and questions Your task is to design a low-pass FIR differentiator
filter which has an amplitude function which deviates less than 0.01 from the desired
specification given in (3). The order of the filter should be such that it has 61
filter coefficients. It is advisable to make use of the command firpm (see Matlab’s
documentation for usage instructions). Remember that the width of the transition
region strongly influences the ripple magnitude.
See Canvas for the skeleton codebase, and follow the instructions in the code.
Remember to include the secret passphrase and the student_id parameter you’ve
used at the start of your report.

Questions When you have developed a filter which passes the self-test function,
provide motivated answers for the following questions.
1. Include the code you’ve written and briefly explain the chosen input arguments
to the firpm command.
2. Plot the resulting filter coefficients using the stem command and plot the
magnitude of the frequency function in linear scale. Mark the magnitude plot
with the specifications of the ideal filter.
3. The designed filter will introduce a delay. How long is the delay? Explain the
reason for the delay.
4. Filter the true_position and noisy_position signals through the designed
filter. Scale the output to obtain the unit km/h. Plot the signals in the same
graph. Compensate the plots for the delay introduced by the filter. At the
end of the filter output very large oscillations occur. Why? Hint: test filtering
with the signals

y1 = [noisy_position; flip(noisy_position)];
y2 = [noisy_position; zeros(length(noisy_position),1)];

Why do/don’t we get similar behavior? Make sure your plot shows the useful
part of the signal, e.g. using axis([0 600 0 220]).
5. Repeat the previous step using the trivial Euler filter defined in Equation (2).
Compare and comment on the results.
6. What is the maximum speed of the vehicle found using the observed signal
and ”true” signal?
Upload a pdf with your answers and the m-files producing the plots.

Good Luck!

You might also like