Z-Transforms

You are not logged in.

Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.
Big Picture

After reading these notes, you should be able to:

  • Recognize the transform of variables x[n] \rightarrow \mathcal{X}(z), v[n] \rightarrow \mathcal{V}(z)
  • Use scaling and shifting identities to convert difference equations into polynomials in z or z^{-1}.
  • Recognize that the abstract 'K' and 'H' operators can be represented as rational functions of z.
  • Use Black's formula to compute closed loop transfer functions!!!!
  • Use pattern matching to convert back to the time domain:
    • Generate system difference equations
    • Determine natural frequencies
    • Compute specific outputs using the partial fraction expansion.
    • Compute steady-state behavior directly from the closed-loop transfer function!!

The z transform gives us a way to specify input-output behavior in a way that allows us to make very concrete use of Black's formula, and to analyze feedback systems. Don't miss that!!!!

Our system model

Relations between position, velocity, acceleration and force

Change in velocity (acceleration) is proportional to force:

v[n]\cong v[n-1] + \Delta T f[n-1]

Change in position is proportional to velocity:

p[n]\cong p[n-1] + \Delta T v[n-1]

Change in force is proportional to control input (inductor L\frac{di_L}{dt} = v_{L}):

f[n] \cong f[n-1] + \Delta T \gamma c[n-1]

Notice the reappearance of \gamma, our generic proportionality factor usually calibrated by measurement.

The Controller

If p_d[n] is the desired position at sample time n and p[n] is the actual location, we define the error at time n to be:

e[n] = p_d[n] - p[n]

Our control input c[n] is:

c[n] = k_p e[n] + \frac{k_d}{\Delta T} (e[n] - e[n-1])

The Z-Transform

The Z-transform of a time-series x[n] is given by the summation:

\mathcal{X}(z) = \sum_{n=-\infty}^{\infty} x[n] z^{-n}

The unilateral Z transform Frequently, x[n]=0 for n<0, and under these conditions we can simplify the doubly infinite sum to a sum from zero to \infty. If we just assume any sequence is zero for n < 0 , then we are really using the unilateral Z transform:

\mathcal{X}(z) = \sum_{n=0}^{\infty} x[n] z^{-n}.

There are some subtleties about the unilateral Z transform, and almost all of them have to do with the meaning of shift relationships like

y[n] = x[n-5].
If we want to relate the unilateral transform of x to the unilateral transform of y, then we are implicitly assuming x[n] = 0, \;\;\; n < 0, and therefore
y[n] = 0, \;\;\; n < 5.
If we start by defining a sequence y, we can easily define a sequence for which there is no corresponding unilateral x. We will just have to avoid doing that.

Example 1

Consider a time sequence in the form of a geometric series. That is,

x[n] = a^n,\;\;\; n \geq 0
x[n]=0,\;\;\; n<0
for some a.

The Z-transform of the time sequence in the form of a geometric series is easily calculated using infinite summation formulas as in

\mathcal{X}(z) = \sum_{n=0}^{\infty} a^n z^{-n} = \sum_{n=0}^{\infty} (a z^{-1})^n.

For values of z>a, meaning az^{-1}<1, the summation has a finite value given by

= \frac{1}{1-az^{-1}}.

Example 2 Consider the unit sample, that is the time series where x[n]=1 for n=0 and x[n]=0 for every other n. In this case, there is only one non-zero term in the summation, corresponding to x[0]z^0, and thus we get that:

\mathcal{X}(z) = 1

1st Key Identity - Scaling and Shifting

If w[n] = \alpha x[n-1], a scaled and shifted version of x[n], the Z-transform of w[n] is related to the Z-transform of x[n] as:

\mathcal{W}(z) = \alpha z^{-1} \mathcal{X}(z)

We can see this by writing out the Z-transform of w[n] explicitly:

\mathcal{W}(z) = \sum_{n=0}^{\infty} w[n] z^{-n} = \sum_{n=0}^{\infty} \alpha x[n-1] z^{-(n-1)}z^{-1}

Where we used the fact that z^{-(n-1)}z^{-1} = z^{-n}.

\mathcal{W}(z) = \alpha z^{-1} \sum_{n=1}^{\infty} x[n-1] z^{-(n-1)}

We changed the starting value of n in the summation because we know that x[0-1]=0 which means the n=0 term is 0. We can relabel the index of the sum using n'=n-1.

\mathcal{W}(z) = \alpha z^{-1} \sum_{n'=0}^{\infty} x[n'] z^{-n'} = \alpha z^{-1} \mathcal{X}(z)

Application to the Example System

Remember our system model from section 2. We can rewrite our difference equation for velocity using Z-transforms as:

\mathcal{V}(z) = z^{-1} \mathcal{V}(z) + \Delta T z^{-1} \mathcal{F}(z)

where \mathcal{V} denotes the Z transform of the sequence v.

Solving for \mathcal{V}(z), we get:

(1-z^{-1})\mathcal{V}(z) = \Delta T z^{-1} \mathcal{F}(z)

\mathcal{V}(z) = \frac{ \Delta T z^{-1} }{(1-z^{-1})}\mathcal{F}(z)

We had a similar difference equation for the position p[n] so we can write that its Z-transform is:

\mathcal{P}(z) = \frac{ \Delta T z^{-1} }{(1-z^{-1})}\mathcal{V}(z)

And likewise we can relate the Z-transforms for the force and control input:

\mathcal{F}(z) = \frac{ \Delta T \gamma z^{-1} }{(1-z^{-1})}\mathcal{C}(z)

Combining these we get:

\mathcal{P}(z) = \frac{ \Delta T^2 z^{-2} }{(1-z^{-1})^2}\mathcal{F}(z) = \frac{ \Delta T^3 \gamma z^{-3} }{(1-z^{-1})^3}\mathcal{C}(z)

This describes how we go from an input control to an output of position, which we draw schematically as:

2nd Key Identity - General Linearity
If \;\;\;v[n] = c_1x[n] + c_2 w[n] \;\;\;\; Then \;\;\;\mathcal{V}(z) = c_1 \mathcal{X}(z) + c_2 \mathcal{W}(z).


We can see this by distributing the sum:

\sum v[n] z^{-n} = \sum(c_1 x[n] + c_2 w[n]) z^{-n} = c_1 \sum x[n] z^{-n} + c_2 \sum w[n] z^{-n}

Application to our model problem

From the control input difference equation:

c[n] = K_p e[n] + \frac{K_d}{\Delta T} (e[n] - e[n-1])

We get the Z-transform:

\mathcal{C}(z) = K_p \mathcal{E}(z) + \frac{K_d}{\Delta T} (\mathcal{E}(z) - z^{-1}\mathcal{E}(z))

\mathcal{C}(z) = (K_p + \frac{K_d}{\Delta T} (1- z^{-1})) \mathcal{E}(z)

We call the system that gives the control input from the error K(z) and add it to the schematic of our system. (The image below shows E(z) as an output of the K(z) block but should be viewed as an input multiplied by K(z))

Black is the new Black

We described our "plant" as

\mathcal{P}(z) = \frac{ \Delta T^3 \gamma z^{-3} }{(1-z^{-1})^3}\mathcal{C}(z) = \mathcal{H}(z)\mathcal{C}(z),
and we described our controller as

\mathcal{C}(z) = (K_p + \frac{K_d}{\Delta T} (1- z^{-1})) \mathcal{E}(z) = \mathcal{K}(z)\left(\mathcal{P_d}(z)-\mathcal{P}(z)\right).

We can use Black's formula to combine the K and H operators to get:

\mathcal{P}(z) = \frac{\mathcal{K}(z) \mathcal{H}(z)}{1+ \mathcal{K}(z) \mathcal{H}(z)} \mathcal{P}_{d}(z)

We define

\mathcal{G}(z) \equiv \frac{\mathcal{K}(z) \mathcal{H}(z)}{1+ \mathcal{K}(z) \mathcal{H}(z)},
and refer to \mathcal{G}(z) as the closed loop transfer function.

We can expand out \mathcal{G}(z) using the definitions of \mathcal{K} and \mathcal{H},

\mathcal{G}(z) = \frac{\frac{\Delta T^3 \gamma z^{-3}}{(1-z^{-1})^3} \cdot (K_p + \frac{K_d}{\Delta T}(1-z^{-1}))}{1+ \frac{\Delta T^3 \gamma z^{-3}}{(1-z^{-1})^3} \cdot (K_p + \frac{K_d}{\Delta T}(1-z^{-1}))}

\mathcal{G}(z) = \frac{\Delta T^3 \gamma z^{-3} \cdot (K_p + \frac{K_d}{\Delta T}(1-z^{-1}))}{(1-z^{-1})^3+ \Delta T^3 \gamma z^{-3} \cdot (K_p + \frac{K_d}{\Delta T}(1-z^{-1}))}

If we define \alpha \equiv \Delta T^3 \gamma (K_p + \frac{K_d}{\Delta T}) and \beta \equiv \Delta T^3 \gamma \frac{K_d}{\Delta T}, we can rewrite the numerator and the second term in the denominator to get:

\mathcal{G}(z) = \frac{\alpha z^{-3} + \beta z^{-4}}{(1-z^{-1})^3+ \alpha z^{-3} + \beta z^{-4}}

Expanding the (1-z^{-1})^3 term:

\mathcal{G}(z) = \frac{\alpha z^{-3} + \beta z^{-4}}{(1-3z^{-1} + 3 z^{-2} -z^{-3})+ \alpha z^{-3} + \beta z^{-4}}

\mathcal{G}(z) = \frac{\alpha z^{-3} + \beta z^{-4}}{1-3z^{-1} + 3 z^{-2} - (1+\alpha)z^{-3} + \beta z^{-4}}

3rd Key Identity - Rational Function in z to Difference Equation

If: \mathcal{P}(z) = \mathcal{H}(z) \mathcal{P}_d(x) and \mathcal{H}(z) = \frac{\sum_{l=0}^{L'} b_l z^{-l}}{1-\sum_{l=1}^{L} a_l z^{-l}}, that is \mathcal{H}(z) is a rational function in z

Then: The difference equation is:

p[n] - \sum_{l=1}^L a_l p[n-l] = \sum_{l=0}^{L'} b_l p_d[n-l]

Alternatively, we can isolate p[n] to one side to get the equation in "update form",

p[n] = \sum_{l=1}^L a_l p[n-l] + \sum_{l=0}^{L'} b_l p_d[n-l]
or
p[n] = a_1 p[n-1] + a_2 p[n-2] +....+ b_0 p_d[n] + b_1 p_d[n-1] + ...

The natural frequencies of the difference equation are all the \lambda's such that

(1-\sum_{l=1}^L a_l \lambda ^{-l}) = 0.

That is, the \lambda's are the roots of the polynomial, the solutions to the polynomial equation

\lambda^L - a_1 \lambda ^{L-1} - a_{L-1} \lambda - a_L = 0.

For polynomials above order three, the natural frequencies are usually impossible to calculate analytically. So either one guesses or uses an iterative numerical procedure. Almost every programming language has a math package with such an iterative numerical procedure, also called a "root-finder". For example, in matlab, the command

\mathrm{roots}([1, -a_1,...,-a_L])
will return the roots.

Stability and \mathcal{H}(z)

We say that \mathcal{H}(z) represents a difference equation if it has a rational function representation, that is, \mathcal{H}(z) can be represented as the ratio of numerator and denominator polynomials in z.

If \mathcal{H}(z) has a rational function representation, and the roots of the denominator polynomial are all less or equal to one in magnitude, \mathcal{H}(z) represents a stable difference equation. And if the roots of the denominator polynomial are strictly less than 1 in magnitude, then the difference equation is strictly stable.

Applying to the Plant

We had found that:

\mathcal{P}(z) = \frac{\Delta T ^2 z^{-2}}{1- 2z^{-1} + z^{-2}} \mathcal{F}(z) = \mathcal{H}(z) \mathcal{F}(z)

\mathcal{P}(z) = \frac{\Delta T ^2}{z^2- 2z + 1} \mathcal{F}(z)

So:

(1-2z^{-1} + z^{-2}) \mathcal{P}(z) = \Delta T^2 z^{-2} \mathcal{F}(z),

p[n] - 2p[n-1] + p[n-2] = \Delta T^2 f[n-2],

or we could write it as

(z^2 - 2z + 1) \mathcal{P}(z) = \Delta T^2\mathcal{F}(z),
p[n+2] - 2p[n+1] + p[n] = \Delta T^2 f[n].

When using unilateral transforms, one should be careful to write equations in terms of delays, n-1, n-2,... because it is easy to violate the assumption that variables are zero for n < 0 when writing advances. For example, if x[n] = 0 for n < 0, and x[n] = 1 , n \ge 0 (x is the unit step), and y is related to x by

y[n] = x[n+1]
then y[-1] = x[0] = 1 \ne 0 , violating the y[n] = 0 for n < 0 assumption in the unilateral transform.

Avoiding writing advances is why we usually write \mathcal{H}(z) as rational functions in NEGATIVE powers of z.

Applying to the Controller

If we have a system where the force applied at time n is proportional to the error we have:

f[n] = K_p (p_d[n] - p[n])
\mathcal{F}(z) = K_p (\mathcal{P}_d(z) - \mathcal{P}(z))

The Closed-Loop System

\mathcal{K}(z) = K_p
\mathcal{H}(z) = \frac{\Delta T^2 z^{-2}}{1- 2z^{-1} + z^{-2}}
\mathcal{G}(z) = \frac{K_p \Delta T^2 z^{-2}}{1- 2z^{-1} + z^{-2} + K_p \Delta T^2 z^{-2}} = \frac{K_p \Delta T^2}{1-2z^{-1} + (1+K_p \Delta T^2) z^{-2}}

Since \mathcal{P}(z) = \mathcal{G}(z) \mathcal{P}_d(z), we get the difference equation:

p[n] - 2p[n-1] + (1+K+p \Delta T^2) p[n-2] = K_p \Delta T^2 p_d[n-2]

The natural frequencies \lambda will be the roots of the equation \lambda ^2 -2 \lambda + (1+ K_p\Delta T^2), which we already know are larger than one in magnitude for all K_p > 0.

The proportion feedback closed-loop system is always unstable.

Converting back from z to n.

Assume that we have the system:

\mathcal{P}(z) = \mathcal{G}(z) \mathcal{P}_d(z)

\mathcal{G}(z) = \frac{K_p \Delta T^2 z^{-2}}{1-2z^{-1} + (1+ K_p \Delta T^2) z^{-2}}

Suppose p_d[n] =1 for n\geq 0 and p[n] = 0 for n<0.

Since we recognize that p_d[n] = a^n where a=1, we know its Z-transform is:

\mathcal{P}_d(z) = \frac{1}{1-z^{-1}}

Thus the Z-transform for p[n] is:

\mathcal{P}(z) = \frac{K_p \Delta T^2 z^{-2}}{1-2z^{-1} + (1+K_p \Delta T^2) z^{-2}} \frac{1}{1-z^{-1}}

From this, can we recover p[n]?

If \lambda_1 and \lambda_2 are the natural frequencies, \lambda_1 is NOT EQUAL to \lambda_2, and neither is equal to 1, then

\mathcal{P}(z) = \frac{K_p \Delta T^2 z^{-2}}{(1-\lambda_1 z^{-1})(1-\lambda_2 z^{-1})(1-z^{-1})}= \frac{A}{1-\lambda_1 z^{-1}} + \frac{B}{1-\lambda_2 z^{-1}} + \frac{C}{1-z^{-1}},
which is referred to as the partial fraction expansion.

By linearity and pattern matching, this suggests that:

p[n] = A \lambda_1^n + B \lambda_2 ^n + C\; 1^n = A \lambda_1^n + B \lambda_2 ^n + C, \;\;\; n\geq 0

By cross-multiplying, and exploiting the fact that the roots of the denominator polynomial of \mathcal{P}(z) are unique (that is \lambda_1, \lambda_2, and 1 are unique values), you should be able to find that,

A= (1-\lambda_1 z^{-1}) \mathcal{P}(z)|_{z=\lambda_1}, B=(1-\lambda_2 z^{-1})\mathcal{P}(z)|_{z=\lambda_2}, C= (1- z^{-1})\mathcal{P}(z)|_{z=1}

Again note that this is only true with \lambda_1,\lambda_2, and 1 are distinct. It is possible analyze the case of repeated roots, but the resulting formulas do not lend much insight.

The steady-state behavior

If a system is strictly stable, and the input to the system is a unit step, then eventually the output of the system will be

C= (1- z^{-1})\mathcal{P}(z)|_{z=1} = \mathcal{G}(z) |_{z=1}
.

That is, we can compute the steady-state step response by evaluating the closed-loop transfer function at z = 1.