Problem with a discrete notch filter design

6 views (last 30 days)
Hi,
I'm new to matlab and simulink programming and I now have to design and test a notch filter. The sampling frequency is 40kHz and I want to filter a frequency of 120Hz. I have this transfer function in S domaine :
s^2 + 5.685e05
------------------------
s^2 + 125.7 s + 5.685e05
I used c2d to get the Z domain tranfer function and got this :
z^2 - 2 z + 1
----------------------
z^2 - 1.997 z + 0.9969
I tried to use this tranfer function in a discrete transfer function block of simulink to filter my signal and only got an asymptotic result meaning nothing. I also got the recurrence equation out of the transfer function to implement it in a M file and got the same result. The input/reference signal on which I'm testing my filter is a 120Hz sinus.
I don't understand what I'm missing here. If I check the bodeplot of the Z domain transfer function, I can clearly see the notch effect.
Can somebody help me find out what's going on?
Thanks a lot

Accepted Answer

Ryan G
Ryan G on 24 Aug 2012
The issue sounds like roundoff error. You can utilize the system in your workspace directly by utilizing the LTI system block which is part of the control system toolbox in the Simulink library browser. This should show you the right answer. Set the frequency of your sin wave in rad/s not hz (120hz ~= 754 rad/s).
What I noticed is that if I use the discrete transfer function block with the values shown, the result is exponential. The reason this happens is the discrete transfer function is almost unstable and by rounding off you now have created an unstable transfer function. To see this, do the following:
format long
num = sysd.num;
den = sysd.den;
num{1}
den{1}
Where sysd is the discrete transfer function object.
You will see how different the actual numerator and denominator are from what the rounded tf shows. Plug these long form values into the discrete transfer function block running at 1/40000 seconds and you will see proper results.
  1 Comment
Simon
Simon on 24 Aug 2012
Hi Ryan,
Thank you very much for your answer. I got this as the tf :
ans =
1.000000000000000 -1.999645076531685 0.999999814257592
ans =
1.000000000000000 -1.996508599259047 0.996863336984954
When put in a discrete transfer function block, it worked. From what I understand, the stability of the filter is quite fragile... I'm not sure it will be when I implement it in a microcontroller... Is there something I can do to improve the stability?
Thanks

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!