# Rectangular Pulse Response of RC Circuit via Difference Equation.

Cuthbert Nyack
The RC Circuit response to an input sequence can be obtained by deriving a discrete transfer function for the RC circuit starting from the continuous transfer function G(s) = 1/(Ts + 1) (T = RC). If this discrete transfer function G(z) = Y(z)/X(z) is converted to a difference equation (y(n) = f(y(n - m) + x(n - p))) then the output can be obtained. In this page, the input is assumed to be a sampled rectangular pulse and the output obtained using transfer functions obtained from different approximations are compared.
The approximations used are, Bilinear, Back Difference, Forward Difference, Impulse Invariant, Step Invariant and the Matched Z.
The Bilinear Approximation replaces s with (2/T)(z - 1)/(z + 1) and the discrete transfer function obtained is shown below. The Back difference approximation replaces s with (1 - z-1)/T and the resulting discrete transfer function is shown below. The Forward approximation replaces s by (z - 1)/T and the resulting discrete transfer function is shown below. The Impulse Invariant replaces a 1/(s + a) factor with aT/(1 - e-aTz-1) resulting in the following transfer function. The Step Invariant derives a Discrete t/f which has the same step response as the continuous transfer function. The Matched Z approximation assumes that a continuous pole at a produces a discrete pole at eaT. The transfer function arising is shown below. The applet below shows the responses for the different approximations. The DTFT of the input and output as well as the location of the discrete pole are also shown.
Fn = 0 , Bilinear Approximation.
Fn = 1 , Back Difference Approximation.
Fn = 2 , Forward Differencer Approximation.
Fn = 3 , Impulse Invariant Approximation.
Fn = 4 , Step Invariant Approximation.
Fn = 5 , Matched Z Approximation.

eg Parameters:-(1.0, 1.0, 1.0, 1.0, 80, 1.0, 0, na, 0.15, 0.05) show the Bilinear approximation giving very close agreement with the continuous result.
eg Parameters:-(1.0, 1.0, 1.0, 1.0, 80, 0.1, 0, na, 0.2, 0.05) show the Bilinear approximation having a pole at the origin Tc = Ts/2 and the output reaches the input after one sample time. Furthur reduction in Tc to 0.01 brings the pole to -0.818 and the output displays the oscillatory behaviour characteristic of poles on the negative real axis.

eg Parameters:-(1.0, 1.0, 1.0, 1.0, 80, 1.0, 1, na, 0.15, 0.05) show the Back Difference approximation giving very close agreement with the continuous result with the pole remaining on the +ve z axis as Tc and Ts are varied.

eg Parameters:-(1.0, 1.0, 1.0, 1.0, 80, 1.0, 2, na, 0.15, 0.05) show the Forward Difference approximation already showing noticeable differences from the continuous result. Reducing Tc to 0.15 (Tc = Ts) places the pole at the origin. When Tc = Ts/2 (eg 0.1, 0.2) the pole moves to -1 and the output is oscillatory. Furthur reduction in Tc produces an unstable output as the pole moves out of the unit circle. Because of the possibility of instability the Forward Difference approximation is not used to derive discrete transfer functions.

eg Parameters:-(1.0, 1.0, 1.0, 1.0, 80, 1.0, 3, na, 0.15, 0.05) show the Impulse Invariant approximation showing good agreement with the continuous case. However to get the correct numerical result, the output must be multiplied by the factor shown at the bottom. The pole remains on the +ve real axis and inside the unit circle as Tc, Ts are varied.

eg Parameters:-(1.0, 1.0, 1.0, 1.0, 80, 1.0, 4, na, 0.15, 0.05) show the Step Invariant approximation showing good agreement with the continuous case. The pole remains on the +ve real axis and inside the unit circle as Tc, Ts are varied.

eg Parameters:-(1.0, 1.0, 1.0, 1.0, 80, 1.0, 5, na, 0.15, 0.05) show the Matched Z approximation showing good agreement with the continuous case. However to get the correct numerical result, the output must be multiplied by the factor shown at the bottom. The pole remains on the +ve real axis and inside the unit circle as Tc, Ts are varied.