# Control Systems/Digital Control Systems

## Digital Systems[edit]

Digital systems, expressed previously as difference equations or Z-Transform transfer functions can also be used with the state-space representation. Also, all the same techniques for dealing with analog systems can be applied to digital systems, with only minor changes.

## Digital Systems[edit]

For digital systems, we can write similar equations, using discrete data sets:

### Zero-Order Hold Derivation[edit]

If we have a continuous-time state equation:

We can derive the digital version of this equation that we discussed above. We take the Laplace transform of our equation:

Now, taking the inverse Laplace transform gives us our time-domain system, keeping in mind that the inverse Laplace transform of the *(sI - A)* term is our state-transition matrix, Φ:

Now, we apply a zero-order hold on our input, to make the system digital. Notice that we set our start time *t _{0} = kT*, because we are only interested in the behavior of our system during a single sample period:

We were able to remove *u(kT)* from the integral because it did not rely on τ. We now define a new function, Γ, as follows:

Inserting this new expression into our equation, and setting *t = (k + 1)T* gives us:

Now Φ(T) and Γ(T) are constant matrices, and we can give them new names. The *d* subscript denotes that they are digital versions of the coefficient matrices:

We can use these values in our state equation, converting to our bracket notation instead:

## Relating Continuous and Discrete Systems[edit]

Continuous and discrete systems that perform similarly can be related together through a set of relationships. It should come as no surprise that a discrete system and a continuous system will have different characteristics and different coefficient matrices. If we consider that a discrete system is the same as a continuous system, except that it is sampled with a sampling time T, then the relationships below will hold. The process of converting an analog system for use with digital hardware is called **discretization**. We've given a basic introduction to discretization already, but we will discuss it in more detail here.

### Discrete Coefficient Matrices[edit]

Of primary importance in discretization is the computation of the associated coefficient matrices from the continuous-time counterparts. If we have the continuous system *(A, B, C, D)*, we can use the relationship *t = kT* to transform the state-space solution into a sampled system:

Now, if we want to analyze the *k+1* term, we can solve the equation again:

Separating out the variables, and breaking the integral into two parts gives us:

If we substitute in a new variable *β = (k + 1)T + τ*, and if we see the following relationship:

We get our final result:

Comparing this equation to our regular solution gives us a set of relationships for converting the continuous-time system into a discrete-time system. Here, we will use "d" subscripts to denote the system matrices of a discrete system, and we will use a "c" subscript to denote the system matrices of a continuous system.

**Matrix Dimensions:**

A: *p* × *p*

B: *p* × *q*

C: *r* × *p*

D: *r* × *q*

If the A_{c} matrix is nonsingular, and we can find it's inverse, we can instead define B_{d} as:

The differences in the discrete and continuous matrices are due to the fact that the underlying equations that describe our systems are different. Continuous-time systems are represented by linear differential equations, while the digital systems are described by difference equations. High order terms in a difference equation are delayed copies of the signals, while high order terms in the differential equations are derivatives of the analog signal.

If we have a complicated analog system, and we would like to implement that system in a digital computer, we can use the above transformations to make our matrices conform to the new paradigm.

### Notation[edit]

Because the coefficent matrices for the discrete systems are computed differently from the continuous-time coefficient matrices, and because the matrices technically represent different things, it is not uncommon in the literature to denote these matrices with different variables. For instance, the following variables are used in place of *A* and *B* frequently:

These substitutions would give us a system defined by the ordered quadruple *(Ω, R, C, D)* for representing our equations.

As a matter of notational convenience, we will use the letters *A* and *B* to represent these matrices throughout the rest of this book.

## Converting Difference Equations[edit]

Now, let's say that we have a 3rd order difference equation, that describes a discrete-time system:

From here, we can define a set of discrete state variables x in the following manner:

Which in turn gives us 3 first-order difference equations:

Again, we say that matrix x is a vertical vector of the 3 state variables we have defined, and we can write our state equation in the same form as if it were a continuous-time system:

## Solving for x[n][edit]

We can find a general time-invariant solution for the discrete time difference equations. Let us start working up a pattern. We know the discrete state equation:

Starting from time *n = 0*, we can start to create a pattern:

With a little algebraic trickery, we can reduce this pattern to a single equation:

[General State Equation Solution]

Substituting this result into the output equation gives us:

[General Output Equation Solution]

## Time Variant Solutions[edit]

If the system is time-variant, we have a general solution that is similar to the continuous-time case:

Where φ, the **state transition matrix**, is defined in a similar manner to the state-transition matrix in the continuous case. However, some of the properties in the discrete time are different. For instance, the inverse of the state-transition matrix does not need to exist, and in many systems it does not exist.

### State Transition Matrix[edit]

The discrete time state transition matrix is the unique solution of the equation:

Where the following restriction must hold:

From this definition, an obvious way to calculate this state transition matrix presents itself:

Or,

## MATLAB Calculations[edit]

MATLAB is a computer program, and therefore calculates all systems using digital methods. The MATLAB function **lsim** is used to simulate a continuous system with a specified input. This function works by calling the **c2d**, which converts a system *(A, B, C, D)* into the equivalent discrete system. Once the system model is discretized, the function passes control to the **dlsim** function, which is used to simulate discrete-time systems with the specified input.

Because of this, simulation programs like MATLAB are subjected to round-off errors associated with the discretization process.

## Sampler Systems[edit]

Let's say that we introduce a sampler into our system:

Notice that after the sampler, we must introduce a reconstruction circuit (described elsewhere) so that we may continue to keep the input, output, and plant in the laplace domain. Notice that we denote the reconstruction circuit with the symbol: Gr(s).

Now, Let's show the transfer function of this equation:

Now, this is going to get a little tricky, so follow along:

And we convert into the star domain because each term on the right-hand side of this equation has a star-domain term:

And next we can change variables into the Z-domain:

And we can solve for Y(z):

The preceding was a particularly simple example. However, the reader is encouraged to solve for the transfer function for a system with a sampler (and it's associated reconstructor) in the following places:

- Before the feedback system
- In the forward path, after the plant
- In the reverse path
- After the feedback loop