A Script for Symbolic and Numerical Solution of System Time Response for a Simple Closed Loop Discrete Time System

by Nasser Abbasi
May 11, 2005.


This is a simple Mathematica script which takes as input the reference signal R(s), the plant transfer function G(s), and the sample time T, and generate the sampled output c[kT]. The intermediate computation of G(z) and the closed loop transfer function T(z) and C(z) and c[KT] are all shown both in symbolic format and in numerical format.

This script solves only for this system configuration, for arbitrary G(s), T, and R(s).

[Graphics:HTMLFiles/nma001_1.gif]

To illustrate, the script is run to solve examples 6.1 and example 6.4 in the text book Digital Control System Analysis and Design, 3rd edition by Phillips and Nagle. The result generated matches the text book result with the additional advantage of being able to see the analytical steps taken during the solution steps.
Next I need to add the ability to generate the solution c(t) to the sampled input.

Data Input section

Here type in the input for the system (this could also be done via an Input statement if needed) for now, simply edit these lines to change the input as needed.

Example 6.1 output

process[T61, inputS, plantS61] ; (*solves example 6.1*)

********** Symbolic solution is *************

Input R(z) = z/(-1 + z)

Plant  G  (z) =  (4 z)/(-^(-2 T) + z)         p

G(z) =  (2 ^(-2 T) (-1 + ^(2 T)))/(-^(-2 T) + z)

Closed loop transfer function T(z) =  (2 ^(-2 T) (-1 + ^(2 T)))/(2 - 3 ^(-2 T) + z)

Output C(z) =  (2 ^(-2 T) (-1 + ^(2 T)) z)/(-2 + 3 ^(-2 T) + z - 3 ^(-2 T) z + z^2)

Output c[k] =  -2/3 (-1 + (-2 + 3 ^(-2 T))^k)

********* Numerical solution is  *************

Input R(z) = z/(-1. + z)

Plant  G  (z) =  (4. z)/(-0.818731 + 1. z)         p

G(z) = 0.362538/(-0.818731 + 1. z)

Closed loop transfer function T(z) = 0.362538/(-0.456192 + 1. z)

Output C(z) =  (0.362538 z)/(0.456192 - 1.45619 z + 1. z^2)

Output c[k] = 0.666667 - 0.666667 0.456192^k

[Graphics:HTMLFiles/nma001_20.gif]

Example 6.4 output

process[T64, inputS, plantS64] ; (*solves example 6.4*)

********** Symbolic solution is *************

Input R(z) = z/(-1 + z)

Plant  G  (z) = z/(-1 + z) - (^T z)/(-1 + ^T z)         p

G(z) =  (^(-T) (-1 - T + z + ^T (1 + (-1 + T) z)))/(^(-T) - z - ^(-T) z + z^2)

Closed loop transfer function T(z) =  (^(-T) (-1 - T + z + ^T (1 + (-1 + T) z)))/(1 - ^(-T) T - 2 z + T z + z^2)

Output C(z) =  (^(-T) z (-1 - T + z + ^T (1 + (-1 + T) z)))/(-1 + ^(-T) T + 3 z - T z - ^(-T) T z - 3 z^2 + T z^2 + z^3)

********* Numerical solution is  *************

Input R(z) = z/(-1. + z)

Plant  G  (z) = z/(-1. + z) - (2.71828 z)/(-1. + 2.71828 z)         p

G(z) =  (0.367879 (0.718282 + z))/(0.367879 - 1.36788 z + 1. z^2)

Closed loop transfer function T(z) =  (0.367879 (0.718282 + z))/(0.632121 - 1. z + 1. z^2)

Output C(z) =  (0.367879 z (0.718282 + z))/(-0.632121 + 1.63212 z - 2. z^2 + 1. z^3)

[Graphics:HTMLFiles/nma001_38.gif]

Code section


Created by Mathematica  (March 4, 2006) Valid XHTML 1.1!