Manually discretise a Second Order low pass filter

12 Ansichten (letzte 30 Tage)
Mike Scott
Mike Scott am 12 Nov. 2014
Bearbeitet: Piotr am 27 Mär. 2023
I need to manually create a second order digital filter for a set of data. I have carried out FFT on the data to identify the 4 sin waves the data is made up of and have identified the highest frequency sin wave as the one I wish to filter out.
So far I have understood that a second order filter can be represented as the transfer function:
y= wn^2/s^2+(2*zeta*wn*s)+wn^2
where wn = natural frequency of highest freq sin curve
zeta=damping ratio s=differential operator
I believe this equation can be used to identify the coefficients that can be input into Matlab's own bilinear function, although I also need to carry out manual bilinear transformation in order to provide a comparisons.
I have also read that to discretise, the transfer function should be in terms of z^-1 and the relationship between s and z^-1 is:
s=2(1-z^-1)/Ts(1+Z^-1)
At this stage, I have tried to substitute the equation for s back into my original second order equation and rearrange to get coefficients into a format that can be compared to the discrete time transfer function.
This is however proving difficult and I am not 100% on the methodology. Any advice, pointers of where to find additional information would be appreciated.
Thanks in advance,
Mike

Akzeptierte Antwort

Star Strider
Star Strider am 12 Nov. 2014
It’s just as straightforward as you describe it. It’s tedious algebra to do it manually, but if you have the Symbolic Math Toolbox, it’s easy:
syms wn s zeta Ts z
y= wn^2/s^2+(2*zeta*wn*s)+wn^2;
s2z=2*(1-1/z)/(Ts*(1+1/z)); % Bilinear Transform, ‘s’ To ‘z’
y = subs(y, s, s2z); % Convert Continuous To Discrete
[yn,yd] = numden(y); % Numerator, Denominator
yn = collect(yn, z) % Numerator Polynomial In ‘z’
yd = collect(yd, z) % Denominator Polynomial In ‘z’
yncf = coeffs(yn, z) % Numerator Coefficients
ydcf = coeffs(yd, z) % Denominator Coefficients

Weitere Antworten (1)

Mike Scott
Mike Scott am 12 Nov. 2014
Great thanks. Unfortunately I don't have the Toolbox, but I'll have a crack at it manually and see how I get on.
Thanks again
  3 Kommentare
Chiao-Ting Li
Chiao-Ting Li am 20 Mai 2019
Hi,
I recently have a similar question and stumbled into this post.
The original question posed the transfer function *without* brackets in the denominator (by an innecent mistake I think).
The correct formula for a second order filter should be:
y= wn^2/ ( s^2+(2*zeta*wn*s)+wn^2 )
And, therefore, the answer provided by @Star should be modified to be the following (the methodology is correct though):
yn =
Ts^2*wn^2*z^2 + 2*Ts^2*wn^2*z + Ts^2*wn^2
yd =
(Ts^2*wn^2 + 4*zeta*Ts*wn + 4)*z^2 + (2*Ts^2*wn^2 - 8)*z + Ts^2*wn^2 - 4*zeta*Ts*wn + 4
yncf =
[ Ts^2*wn^2, 2*Ts^2*wn^2, Ts^2*wn^2]
ydcf =
[ Ts^2*wn^2 - 4*zeta*Ts*wn + 4, 2*Ts^2*wn^2 - 8, Ts^2*wn^2 + 4*zeta*Ts*wn + 4]
thought I'd give an update on this post, in case someone just copy-and-paste the origial answer and get wiered results like I did.
Regards,
Chiao-Ting
Piotr
Piotr am 27 Mär. 2023
Bearbeitet: Piotr am 27 Mär. 2023
Hello Chiao-Ting,
thank you for the update. I have a question as I do not fully understand the units behind each of the parameters used in the main formulae.
In my problem I have information provided for the damped frequency which is in Hz and damping factor which is in Mneper/s. What units do you use? Is Ts a sampling rate [s]?
BR, Piotr

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by