0

I am very new to this forum, so excuse me if i do not write the equations properly. And I'm pretty new to DSP too, so this might be very basics for most of you, but it's pretty complicated to me.

I need to discretize a PT1 filter:

\$T\frac{dy(t)}{dt} + y(t) = u(t)\$

I need to discrtize this using ZOH, FOH and Tustins bilinear transformation. I need to apply this filter to my signal, using a for loop( yes i have Fc, Wn). I know this can be easily done in Matlab. but i wanna understand how it's done by hand.I could not understand anything from google.

Any leads would help me.

Edit1 @JonRB: Matlab Script:

% define a continuous-time first order low-pass filter in state-space
% notation. differential equation of the filter:
%  T * y'(t) + y(t) = u(t)
% -> State-space notation:
%  x'(t) = -1/T * x + 1/T * u
  % -3dB cutoff frequency: 100 Hz => omega_c = 2 * pi * 100 rad/s
% => T = 1 / omega_c
f_c = 10;
T = 1 / 2 / pi / f_c;
filt_cont = ss(-1/T, 1/T, 1, 0);
enter code here
% sampling period
Ts= 
% discretization of the filter 
filt_discr_zoh = c2d(filt_cont, Ts, 'zoh');
filt_discr_foh = c2d(filt_cont, Ts, 'foh');
filt_discr_tustin = c2d(filt_cont, Ts, 'tustin');
EpicUser
  • 1
  • 4

1 Answers1

1

There are a couple of steps that are required to realise a digital filter

Considering Bilinear transform

This will facilitate taking a continuous time domain equation & converting it into an appropriate discrete time domain equation.

Copying into EE.SE just for completness

\$ H(s) = \frac{1}{1+ RCs} \$

an s-domain to z-domain transformation can be realised by substituting the s terms for the equivalent z-domain

\$ s \leftarrow \frac{2}{\Delta_T}\frac{1-z^{-1}}{1+z^{-1}}\$

\$H(z) = \frac{1+z^{-1}}{(1+ \frac{2RC}{\Delta_T}) + (1- \frac{2RC}{\Delta_T})z^{-1}} \$

With the discrete time domain equation, the difference equation can be realised via refactoring to find the recurrence relation

\$y_n = y_{n-1} + \alpha (x_n - y_{n-1})\$

where \$\alpha = \frac{\Delta_T}{\Delta_T + \tau}\$ and \$\tau = RC\$ the time constant.

\$y_n \$ represents present output

\$y_{n-1} \$ represents last output

\$x_n\$ represents present input


If you now look at the equation (slightly re-ordered) in the question

\$u(t)= y(t) + T\frac{dy(t)}{dt} \$

w.r.t. the difference equation:

\$y_n = y_{n-1} + \alpha (x_n - y_{n-1})\$

It can be seen that there is a correlation. The \$\frac{dy(t)}{dt}\$ is represented by NEW - OLD and a scaling factor which has units of \$s^{-1}\$ : dy/dt


Realization in Matlab:Simulink

Looking at the difference equation: \$ y_n = y_{n-1} + \alpha (x_n - y_{n-1}) \$

there is a need for

  1. addition
  2. multiplication
  3. difference
  4. gain

This is using a 10kHz sin generator, sample time of 1us and an \$\alpha\$ of 0.059117397, which is a \$\tau\$ of 1.59155e-5, the equivalent of 10 kHz

enter image description here

enter image description here

  • Thanks for a detailed explanation! Matlab simulation wasn't required. Any chance you can demonstrate solving with ZOH or FOH, no need of Simulink though. – EpicUser May 13 '16 at 15:12
  • this include ZoH, that is what the unit delay is & what Z^(-1) represents –  May 13 '16 at 15:13
  • Ah in Matlab, but i want the derivation by hand. I want a final equation for ZOH filter using state space maybe?. – EpicUser May 13 '16 at 15:14
  • but that is what the difference equation shows. the y(n-1) is the output of a ZoH block –  May 13 '16 at 15:16
  • Ok clearly i am lacking some basics here. Did u implement all 3 in the same equation? if So, could you give me 3 different equation? – EpicUser May 13 '16 at 15:18
  • I will add my matlab script, which i wanna do it in hand. – EpicUser May 13 '16 at 15:18
  • I have added a eddit, if you could see my script. "filt_discr_zoh" "filt_discr_foh" "filt_discr_tustin". 3 different methods. I want 3 different equation for each of the methods. I hope I have explained it properly – EpicUser May 13 '16 at 15:27