Salta al contenuto
Note per Studenti Discrete-Time Modeling and Difference Equations Report

Discrete-Time Modeling and Difference Equations

In questa pagina 7

This note reviews discrete-time modeling, the counterpart of the continuous-time modeling seen before (see Continuous-Time Modeling of Dynamic SystemsWhy control engineers need a model, white-box versus black-box modeling, the assumptions behind linear time-invariant lumped models, linear ODEs with constant coefficients, and the classification of lumped elements as passive or active.Continuous-Time Modeling of Dynamic Systems → and System ModelingA mathematical model (parameters, variables, relations) describes a system quantitatively; models are classified as static or dynamic, causal, linear, time-invariant, SISO or MIMO, and the course focuses on SISO continuous-time causal dynamic LTI systems described by a constant-coefficient input-output ODE.System Modeling →). The mathematical background is in Difference EquationsRecursive constant-coefficient linear difference equations (ARMA models) are the discrete-time counterpart of ODEs: the delay operator replaces the derivative, the modes are k^m lambda^k with lambda a root of the characteristic polynomial, and the solution splits into a natural and a forced response.Difference Equations → and Bilateral Z-TransformThe bilateral Z-transform X_B(z) = sum x(k) z^{-k} is the discrete-time counterpart of the Laplace transform; it converges only on a region of convergence (an annulus-type region), extends the DTFT when the unit circle is in the ROC, has an inversion formula and properties such as linearity, shift, time reversal and convolution.Bilateral Z-Transform → of the Signals and Systems course; the transform properties and tables used below are collected in Z-Transform Properties and Elementary Signalsdefinition of the unilateral Z-transform for causal LTI models, its ten properties, and the table of transforms of elementary signals (impulse, step, ramps, exponentials, sinusoids).Z-Transform Properties and Elementary Signals →.

1. Modeling assumptions

As in the continuous-time case, the models are:

  • dynamic;
  • single-input single-output (SISO);
  • discrete-time;
  • linear;
  • time-invariant;
  • causal;

and are based on linear difference equations with constant coefficients.

2. Difference equations

A linear difference equation (DE) with constant coefficients is

  ∑n=0Nan y[k−n]=∑m=0Mbm u[k−m]  ,an,bm∈R,aN,a0,bM≠0.\boxed{\;\sum_{n=0}^{N} a_n\, y[k-n] = \sum_{m=0}^{M} b_m\, u[k-m]\;}, \qquad a_n, b_m \in \mathbb{R},\quad a_N, a_0, b_M \ne 0 .

  • ana_n, bmb_m are the model parameters;
  • NN is the model order;
  • u[k]u[k] is the input signal (k∈Zk \in \mathbb{Z});
  • y[k]y[k] is the output signal.

Note: if a0≠0a_0 \ne 0 the model is causal, because the current output y[k]y[k] depends only on the past values of yy and uu (and on the current input).

Moving-average (MA) model

If N=0N = 0:

y[k]=∑m=0Mbma0 u[k−m].y[k] = \sum_{m=0}^{M} \frac{b_m}{a_0}\, u[k-m] .

The output is a weighted combination of present and past inputs only.

Autoregressive (AR) model

If M=0M = 0:

∑n=0Nan y[k−n]=b0 u[k].\sum_{n=0}^{N} a_n\, y[k-n] = b_0\, u[k] .

ARMA model

A model based on a difference equation is also called an ARMA (Auto Regressive - Moving Average) model, because it can be implemented as the cascade of an MA model and an AR model:

          MA model                        AR model
 u[k] --> z[k] = sum_{m=0}^{M} b_m u[k-m] --> z[k] --> sum_{n=0}^{N} a_n y[k-n] = z[k] --> y[k]

that is, first z[k]=∑m=0Mbmu[k−m]z[k] = \sum_{m=0}^{M} b_m u[k-m], then ∑n=0Nany[k−n]=z[k]\sum_{n=0}^{N} a_n y[k-n] = z[k].

Solving an ARMA model

Solving means finding the signal y[k]y[k] that satisfies the difference equation, given:

  • the input signal u[k]u[k] for k≥0k \ge 0 (the input is causal, i.e. equal to zero for k<0k < 0);
  • the initial conditions (i.c.) y[−1],y[−2],…,y[−N]y[-1], y[-2], \dots, y[-N].

The memory of an ARMA model is the number of past samples required to compute y[k]y[k].

3. Why the Z\mathcal{Z}-transform

The Z\mathcal{Z}-transform converts time-shift operations applied to the samples of a sequence v[k]v[k] (advance and delay) into algebraic operations (multiplication and division by the variable zz) applied to its transform V(z)V(z): a unit advance of the sequence becomes a multiplication by zz.

Together with linearity, this turns a linear difference equation with constant coefficients (difficult to "solve") into an algebraic equation in the complex variable z∈Cz \in \mathbb{C} (easy to solve).

Solution procedure:

  1. apply the Z\mathcal{Z}-transform to the DE in the unknown y[k]y[k], obtaining an algebraic equation in zz with unknown Y(z)Y(z);
  2. solve it algebraically for Y(z)Y(z);
  3. apply the inverse transform Z−1\mathcal{Z}^{-1} to the "transformed" solution Y(z)Y(z) to get the solution y[k]y[k] of the original DE.

Only algebraic manipulations and tables of Z\mathcal{Z}-transforms of elementary signals are needed.

4. Solving the difference equation with the Z\mathcal{Z}-transform

Start from the DE and transform both sides:

Z{∑n=0Nany[k−n]}(z)=Z{∑m=0Mbmu[k−m]}(z).\mathcal{Z}\left\{\sum_{n=0}^{N} a_n y[k-n]\right\}(z) = \mathcal{Z}\left\{\sum_{m=0}^{M} b_m u[k-m]\right\}(z) .

By linearity:

∑n=0Nan Z{y[k−n]}(z)=∑m=0Mbm Z{u[k−m]}(z).\sum_{n=0}^{N} a_n\,\mathcal{Z}\{y[k-n]\}(z) = \sum_{m=0}^{M} b_m\,\mathcal{Z}\{u[k-m]\}(z) .

Use the time-delay property (the samples y[−1],…,y[−N]y[-1], \dots, y[-N] are the initial conditions and appear in the formula; the input is causal, so its extra sum vanishes):

Z{y[k−n]}(z)=z−nY(z)+∑i=−n−1y[i] z−i−n=z−nY(z)+∑j=0n−1y[j−n] z−j,Z{u[k−m]}(z)=z−mU(z).\mathcal{Z}\{y[k-n]\}(z) = z^{-n}Y(z) + \sum_{i=-n}^{-1} y[i]\,z^{-i-n} = z^{-n}Y(z) + \sum_{j=0}^{n-1} y[j-n]\,z^{-j}, \qquad \mathcal{Z}\{u[k-m]\}(z) = z^{-m}U(z) .

(The slides print v[⋅]v[\cdot] for the samples in the first formula; they are the samples of yy.) Substituting,

∑n=0Nan(z−nY(z)+∑j=0n−1y[j−n] z−j)=∑m=0Mbm z−m U(z),\sum_{n=0}^{N} a_n\left(z^{-n}Y(z) + \sum_{j=0}^{n-1} y[j-n]\,z^{-j}\right) = \sum_{m=0}^{M} b_m\, z^{-m}\,U(z),

(∑n=0Nanz−n)Y(z)=(−∑n=0N∑j=0n−1an y[j−n] z−j)+(∑m=0Mbmz−m)U(z).\left(\sum_{n=0}^{N} a_n z^{-n}\right)Y(z) = \left(-\sum_{n=0}^{N}\sum_{j=0}^{n-1} a_n\,y[j-n]\,z^{-j}\right) + \left(\sum_{m=0}^{M} b_m z^{-m}\right)U(z) .

Multiply both sides by zNz^N (assuming N≥MN \ge M; if M>NM > N multiply by zMz^M):

(∑n=0NanzN−n)⏟≜ A(z)Y(z)=(−∑n=0N∑j=0n−1an y[j−n] zN−j)⏟≜ C(z)+(∑m=0MbmzN−m)⏟≜ B(z)U(z).\underbrace{\left(\sum_{n=0}^{N} a_n z^{N-n}\right)}_{\triangleq\, A(z)}Y(z) = \underbrace{\left(-\sum_{n=0}^{N}\sum_{j=0}^{n-1} a_n\,y[j-n]\,z^{N-j}\right)}_{\triangleq\, C(z)} + \underbrace{\left(\sum_{m=0}^{M} b_m z^{N-m}\right)}_{\triangleq\, B(z)}U(z) .

That is A(z)Y(z)=C(z)+B(z)U(z)A(z)Y(z) = C(z) + B(z)U(z), so

Y(z)=C(z)A(z)⏟≜ Yn(z)+B(z)A(z) U(z)⏟≜ Yf(z).Y(z) = \underbrace{\frac{C(z)}{A(z)}}_{\triangleq\, Y_n(z)} + \underbrace{\frac{B(z)}{A(z)}\,U(z)}_{\triangleq\, Y_f(z)} .

Degrees (assuming aN,a0,bM≠0a_N, a_0, b_M \ne 0): deg⁡A(z)=N\deg A(z) = N, deg⁡C(z)≤N−1\deg C(z) \le N-1, and deg⁡B(z)=N\deg B(z) = N (the latter when b0≠0b_0 \ne 0).

  • Yn(z)Y_n(z) is the transform of the natural response: it depends on the initial conditions and is obtained with zero input.
  • Yf(z)Y_f(z) is the transform of the forced response: it depends on the input U(z)U(z) and is obtained with zero initial conditions.

5. Transfer function

The transform of the forced response is Yf(z)=B(z)A(z)U(z)Y_f(z) = \frac{B(z)}{A(z)}U(z). The quantity

  H(z)≜Yf(z)U(z)=B(z)A(z)=∑m=0MbmzN−m∑n=0NanzN−n  \boxed{\;H(z) \triangleq \frac{Y_f(z)}{U(z)} = \frac{B(z)}{A(z)} = \frac{\sum_{m=0}^{M} b_m z^{N-m}}{\sum_{n=0}^{N} a_n z^{N-n}}\;}

is the transfer function of the system. For systems described by linear DEs with constant coefficients it is always a rational function of the complex variable zz.

The transfer function completely characterises the forced response: Yf(z)=H(z)U(z)Y_f(z) = H(z)U(z).

6. Impulse response

For a unit impulse input u[k]=δ[k]u[k] = \delta[k] (the slide writes u(t)=δ(t)u(t) = \delta(t)), U(z)=Z{δ[k]}(z)=1U(z) = \mathcal{Z}\{\delta[k]\}(z) = 1 and therefore Yf(z)=H(z)Y_f(z) = H(z): the transfer function is the Z\mathcal{Z}-transform of the impulse response h[k]=Z−1{H(z)}(k)h[k] = \mathcal{Z}^{-1}\{H(z)\}(k).

The impulse response also completely characterises the forced response. From Yf(z)=H(z)U(z)Y_f(z) = H(z)U(z), transforming back and using the convolution property:

yf[k]=Z−1{H(z)U(z)}[k]=h[k]∗u[k]=∑n=0kh[k−n] u[n].y_f[k] = \mathcal{Z}^{-1}\{H(z)U(z)\}[k] = h[k] * u[k] = \sum_{n=0}^{k} h[k-n]\,u[n] .

 u[k] ---> [ h[k] ] ---> y_f[k] = sum_{n=0}^{k} h[k-n] u[n]

7. Inverse Z\mathcal{Z}-transform of rational functions

The "transformed" solution of the DE is

Y(z)=Yn(z)+Yf(z)=C(z)A(z)+B(z)A(z) U(z).Y(z) = Y_n(z) + Y_f(z) = \frac{C(z)}{A(z)} + \frac{B(z)}{A(z)}\,U(z) .

Y(z)Y(z) is a rational function, provided that U(z)U(z) is rational (true for all the elementary signals considered in practice, see the tables in Z-Transform Properties and Elementary Signalsdefinition of the unilateral Z-transform for causal LTI models, its ten properties, and the table of transforms of elementary signals (impulse, step, ramps, exponentials, sinusoids).Z-Transform Properties and Elementary Signals →). To compute the inverse transform, perform a partial fraction decomposition, then invert each term of the decomposition, whose inverse is known from the tables.

Versione ripasso

  • Models: dynamic, SISO, discrete-time, linear, time-invariant, causal, based on linear DEs with constant coefficients.
  • DE: ∑n=0Nany[k−n]=∑m=0Mbmu[k−m]\sum_{n=0}^{N} a_n y[k-n] = \sum_{m=0}^{M} b_m u[k-m], aN,a0,bM≠0a_N, a_0, b_M \ne 0; NN is the order; causal if a0≠0a_0 \ne 0.
  • MA (N=0N=0): y[k]=∑m(bm/a0) u[k−m]y[k] = \sum_m (b_m/a_0)\,u[k-m]. AR (M=0M=0): ∑nany[k−n]=b0u[k]\sum_n a_n y[k-n] = b_0 u[k]. ARMA = cascade of MA (z[k]=∑bmu[k−m]z[k] = \sum b_m u[k-m]) and AR (∑any[k−n]=z[k]\sum a_n y[k-n] = z[k]).
  • To solve: input u[k]u[k], k≥0k \ge 0, and i.c. y[−1],…,y[−N]y[-1], \dots, y[-N]. Memory = number of past samples needed for y[k]y[k].
  • Z\mathcal{Z}-transform turns shifts into multiplication by zz, so the DE becomes algebraic: transform, solve for Y(z)Y(z), invert.
  • With Z{y[k−n]}=z−nY(z)+∑j=0n−1y[j−n]z−j\mathcal{Z}\{y[k-n]\} = z^{-n}Y(z) + \sum_{j=0}^{n-1} y[j-n]z^{-j} and multiplying by zNz^N (N≥MN \ge M): A(z)Y(z)=C(z)+B(z)U(z),A=∑anzN−n, B=∑bmzN−m, C=−∑n∑j=0n−1any[j−n]zN−j.A(z)Y(z) = C(z) + B(z)U(z), \quad A = \sum a_n z^{N-n},\ B = \sum b_m z^{N-m},\ C = -\sum_n\sum_{j=0}^{n-1} a_n y[j-n]z^{N-j}.
  • Y(z)=CA+BAUY(z) = \dfrac{C}{A} + \dfrac{B}{A}U: natural response YnY_n (i.c., zero input) plus forced response YfY_f (input, zero i.c.). deg⁡A=N\deg A = N, deg⁡C≤N−1\deg C \le N-1.
  • Transfer function H(z)=Yf/U=B(z)/A(z)H(z) = Y_f/U = B(z)/A(z), always rational.
  • u=δ[k]u = \delta[k] gives Yf=H(z)Y_f = H(z): HH is the transform of the impulse response h[k]h[k]; yf[k]=h∗u=∑n=0kh[k−n]u[n]y_f[k] = h*u = \sum_{n=0}^{k} h[k-n]u[n].
  • Inverse transform of rational Y(z)Y(z): partial fractions, then table.

Procedura:

  1. Trasformare ambo i membri della DE usando linearità e proprietà del ritardo.
  2. Moltiplicare per zNz^N (o per zMz^M se M>NM > N) per ottenere A(z)A(z), B(z)B(z), C(z)C(z).
  3. Scrivere Y(z)=C(z)A(z)+B(z)A(z)U(z)Y(z) = \dfrac{C(z)}{A(z)} + \dfrac{B(z)}{A(z)}U(z).
  4. Antitrasformare con fratti semplici e tabella.

Dove compaiono le condizioni iniziali: y[−1],…,y[−N]y[-1],\dots,y[-N] entrano solo in C(z)C(z), quindi la risposta naturale YnY_n dipende solo da loro (con ingresso nullo). La forzata YfY_f dipende solo da uu con condizioni iniziali nulle.

Risposta impulsiva: con u[k]=δ[k]u[k] = \delta[k] si ha U(z)=1U(z) = 1, quindi Yf(z)=H(z)Y_f(z) = H(z) e h[k]=Z−1{H(z)}h[k] = \mathcal{Z}^{-1}\{H(z)\}. Per un ingresso generico yf[k]=∑n=0kh[k−n] u[n]y_f[k] = \sum_{n=0}^{k} h[k-n]\,u[n] (convoluzione).

Errori tipici:

  • Scambiare H(z)H(z) per Y(z)Y(z): HH descrive solo la risposta forzata.
  • Dimenticare C(z)C(z) e quindi le condizioni iniziali.
  • Moltiplicare per zNz^N quando M>NM > N (in quel caso serve zMz^M).

Teoria collegata