Monday, April 15, 2013

Introduction

The figure below shows the typical continuous feedback system that we have been considering so far in this tutorial. Almost all of the continuous controllers can be built using analog electronics.

The continuous controller, enclosed in the dashed square, can be replaced by a digital controller, shown below, that performs same control task as the continuous controller. The basic difference between these controllers is that the digital system operates on discrete signals (or samples of the sensed signal) rather than on continuous signals.

Different types of signals in the above digital schematic can be represented by the following plots.
undefined
The purpose of this Digital Control Tutorial is to show you how to use MATLAB to work with discrete functions either in transfer function or state-space form to design digital control systems.

Zero-Hold Equivalence

In the above schematic of the digital control system, we see that the digital control system contains both discrete and the continuous portions. When designing a digital control system, we need to find the discrete equivalent of the continuous portion so that we only need to deal with discrete functions.
For this technique, we will consider the following portion of the digital control system and rearrange as follows.
undefined

The clock connected to the D/A and A/D converters supplies a pulse every T seconds and each D/A and A/D sends a signal only when the pulse arrives. The purpose of having this pulse is to require that Hzoh(z) have only samples u(k) to work on and produce only samples of output y(k); thus, Hzoh(z) can be realized as a discrete function.
The philosophy of the design is the following. We want to find a discrete function Hzoh(z) so that for a piecewise constant input to the continuous system H(s), the sampled output of the continuous system equals the discrete output. Suppose the signal u(k) represents a sample of the input signal. There are techniques for taking this sample u(k) and holding it to produce a continuous signal uhat(t). The sketch below shows that the uhat(t) is held constant at u(k) over the interval kT to (k+1)T. This operation of holding uhat(t) constant over the sampling time is called zero-order hold.

The zero-order held signal uhat(t) goes through H2(s) and A/D to produce the output y(k) that will be the piecewise same signal as if the discrete signal u(k) goes through Hzoh(z) to produce the discrete output y(k).
undefined
Now we will redraw the schematic, placing Hzoh(z) in place of the continuous portion.

By placing Hzoh(z), we can design digital control systems dealing with only discrete functions.
Note: There are certain cases where the discrete response does not match the continuous response due to a hold circuit implemented in digital control systems. For information, see Lagging effect associated with the hold.

Conversion Using c2d

There is a MATLAB function called c2d that converts a given continuous system (either in transfer function or state-space form) to a discrete system using the zero-order hold operation explained above. The basic command for this in MATLAB is sys_d = c2d(sys,Ts,'zoh')
The sampling time (Ts in sec/sample) should be smaller than 1/(30*BW), where BW is the closed-loop bandwidth frequency.

Example: Mass-Spring-Damper

Transfer Function
Suppose you have the following continuous transfer function
(1)$$
\frac{X(s)}{F(s)} = \frac{1}{Ms^2+bs+k}
$$
Assuming the closed-loop bandwidth frequency is greater than 1 rad/sec, we will choose the sampling time (Ts) equal to 1/100 sec. Now, create an new m-file and enter the following commands.
M = 1;
b = 10;
k = 20;

s = tf('s');
sys = 1/(M*s^2+b*s+k);

Ts = 1/100;
sys_d = c2d(sys,Ts,'zoh')
sys_d =
 
  4.837e-05 z + 4.678e-05
  -----------------------
  z^2 - 1.903 z + 0.9048
 
Sample time: 0.01 seconds
Discrete-time transfer function.

State-Space
The continuous time state-space model is as follows:
(2)$$
\mathbf{\dot{x}} = \left[ \begin{array}{c} \dot{x} \\ \ddot{x} \end{array} \right] = \left[ \begin{array}{cc} 0 & 1 \\ -\frac{k}{m}  & -\frac{b}{m} \end{array} \right] \left[ \begin{array}{c} x \\ \dot{x} \end{array} \right] + \left[ \begin{array}{c} 0 \\ \frac{1}{m} \end{array} \right] F(t)
$$
(3)$$
y = \left[ \begin{array}{cc} 1 & 0 \end{array} \right] \left[
\begin{array}{c} x \\ \dot{x} \end{array} \right]
$$
All constants are the same as before. The following m-file converts the above continuous state-space to discrete state-space.
A = [0       1;
    -k/M   -b/M];

B = [  0;
    1/M];

C = [1 0];

D = [0];

Ts = 1/100;

sys = ss(A,B,C,D);
sys_d = c2d(sys,Ts,'zoh')
sys_d =
 
  a = 
             x1        x2
   x1     0.999  0.009513
   x2   -0.1903    0.9039
 
  b = 
              u1
   x1  4.837e-05
   x2   0.009513
 
  c = 
       x1  x2
   y1   1   0
 
  d = 
       u1
   y1   0
 
Sample time: 0.01 seconds
Discrete-time state-space model.

From these matrices, the discrete state-space can be written as
(4)$$
\left[ \begin{array}{c} x(k) \\ v(k) \end{array} \right] =
\left[ \begin{array}{cc} 0.9990 & 0.0095 \\ -0.1903 & 0.9039  \end{array} \right] \left[ \begin{array}{c} x(k-1) \\ v(k-1) \end{array} \right] +
\left[ \begin{array}{c} 0 \\ 0.0095 \end{array} \right] F(k-1)
$$
(5)$$
y(k-1) = \left[ \begin{array}{cc} 1 & 0 \end{array} \right] \left[ \begin{array}{c} x(k-1) \\ v(k-1) \end{array} \right]
$$
Now you have the discrete time state-space model.

Stability and Transient Response

For continuous systems, we know that certain behaviors results from different pole locations in the s-plane. For instance, a system is unstable when any pole is located to the right of the imaginary axis. For discrete systems, we can analyze the system behaviors from different pole locations in the z-plane. The characteristics in the z-plane can be related to those in the s-plane by the expression
(6)$$
z = e^{sT}
$$
  • T = Sampling time (sec/sample)
  • s = Location in the s-plane
  • z = Location in the z-plane
The figure below shows the mapping of lines of constant damping ratio (zeta) and natural frequency (Wn) from the s-plane to the z-plane using the expression shown above.
undefined
If you noticed in the z-plane, the stability boundary is no longer imaginary axis, but is the unit circle z=1. The system is stable when all poles are located inside the unit circle and unstable when any pole is located outside.
For analyzing the transient response from pole locations in the z-plane, the following three equations used in continuous system designs are still applicable.
(7)$$
\zeta \omega_n \geq \frac{4.6}{Ts}
$$
(8)$$
\omega_n \geq \frac{1.8}{Tr}
$$
(9)$$
\zeta = \frac{-\ln(\%OS/100)}{\sqrt{\pi^2+\ln(\%OS/100)^2}}
$$
where,
  • zeta = Damping ratio
  • Wn = Natural frequency (rad/sec)
  • Ts = Settling time
  • Tr = Rise time
  • Mp = Maximum overshoot
Important: The natural frequency (Wn) in z-plane has the unit of rad/sample, but when you use the equations shown above, the Wn must be in the unit of rad/sec.
Suppose we have the following discrete transfer function
(10)$$
\frac{Y(z)}{F(z)} = \frac{1}{z^2-0.3z+0.5}
$$
Create an new m-file and enter the following commands. Running this m-file in the command window gives you the following plot with the lines of constant damping ratio and natural frequency.
numDz = 1;
denDz = [1 -0.3 0.5];
sys = tf(numDz,denDz,-1); % the -1 indicates that the sample time is undetermined

pzmap(sys)
axis([-1 1 -1 1])
zgrid
undefinedFrom this plot, we see poles are located approximately at the natural frequency of 9pi/20T (rad/sample) and the damping ratio of 0.25. Assuming that we have a sampling time of 1/20 sec (which leads to Wn = 28.2 rad/sec) and using three equations shown above, we can determine that this system should have the rise time of 0.06 sec, a settling time of 0.65 sec and a maximum overshoot of 45% (0.45 more than the steady-state value). Let's obtain the step response and see if these are correct. Add the following commands to the above m-file and rerun it in the command window. You should get the following step response.
sys = tf(numDz,denDz,1/20);
step(sys,2.5);
undefinedAs you can see from the plot, the rise time, settling time and overshoot came out to be what we expected. This shows how you can use the locations of poles and the above three equations to analyze the transient response of the system.

Discrete Root Locus

The root-locus is the locus of points where roots of characteristic equation can be found as a single gain is varied from zero to infinity. The characteristic equation of an unity feedback system is
(11)$$
1+KG(z)Hzoh(z) = 0
$$
where G(z) is the compensator implemented in the digital controller and Hzoh(z) is the plant transfer function in z.
The mechanics of drawing the root-loci are exactly the same in the z-plane as in the s-plane. Recall from the continuous Root-Locus Tutorial, we used the MATLAB function called sgrid to find the root-locus region that gives an acceptable gain (K). For the discrete root-locus analysis, we will use the function zgrid that has the same characteristics as sgrid. The command zgrid(zeta, Wn) draws lines of constant damping ratio (zeta) and natural frequency (Wn).
Suppose we have the following discrete transfer function
(12)$$
\frac{Y(z)}{F(z)} = \frac{z-0.3}{z^2-1.6z+0.7}
$$
and the requirements are a damping ratio greater than 0.6 and a natural frequency greater than 0.4 rad/sample (these can be found from design requirements, sampling time (sec/sample) and three equations shown in the previous section). The following commands draw the root-locus with the lines of constant damping ratio and natural frequency. Create an new m-file and enter the following commands. Running this m-file should give you the following root-locus plot.
numDz = [1 -0.3];
denDz = [1 -1.6 0.7];
sys = tf(numDz,denDz,-1);

rlocus(sys)
axis([-1 1 -1 1])

zeta = 0.4;
Wn = 0.3;
zgrid(zeta,Wn)
undefinedFrom this plot, you should realize that the system is stable because all poles are located inside the unit circle. Also, you see two dotted lines of constant damping ratio and natural frequency. The natural frequency is greater than 0.3 outside the constant-Wn line, and the damping ratio is greater than 0.4 inside the constant-zeta line. In this example, we do have the root-locus drawn in the desired region. Therefore, a gain (K) chosen from one of the loci in the desired region should give you the response that satisfies design requirements.

Introduction: Digital Controller Design

In this section we will discuss converting continuous time models into discrete time (or difference equation) models. We will also introduce the z-transform and show how to use it to analyze and design controllers for discrete time systems.
Key MATLAB commands used in this tutorial are: c2d , pzmap , zgrid , step , rlocus

Digital Controller Implementation

A digital controller is usually cascaded with the plant in a feedback system. The rest of the system can either be digital or analog.
Typically, a digital controller requires:
  • A/D conversion to convert analog inputs to machine readable (digital) format
  • D/A conversion to convert digital outputs to a form that can be input to a plant (analog)
  • A program that relates the outputs to the inputs

Output Program

  • Outputs from the digital controller are functions of current and past input samples, as well as past output samples - this can be implemented by storing relevant values of input and output in registers. The output can then be formed by a weighted sum of these stored values.
The programs can take numerous forms and perform many functions

Stability

Although a controller may be stable when implemented as an analog controller, it could be unstable when implemented as a digital controller due to a large sampling interval. During sampling the aliasing modifies the cutoff parameters. Thus the sample rate characterizes the transient response and stability of the compensated system, and must update the values at the controller input often enough so as to not cause instability.
When substituting the frequency into the z operator, regular stability criteria still apply to discrete control systems. Nyquist criteria apply to z-domain transfer functions as well as being general for complex valued functions. Bode stability criteria apply similarly. Jury criterion determines the discrete system stability about its characteristic polynomial.

Design of digital controller in s-domain

The digital controller can also be designed in the s-domain (continuous). The Tustin transformation can transform the continuous compensator to the respective digital compensator. The digital compensator will achieve an output which approaches the output of its respective analog controller as the sampling interval is decreased.
 s = \frac{2(z-1)}{T(z+1)}

Tustin transformation deduction

Tustin is the Padé(1,1) approximation of the exponential function  \begin{align} z &= e^{sT} \end{align}  :

\begin{align}
z &= e^{sT}   \\
  &= \frac{e^{sT/2}}{e^{-sT/2}} \\
  &\approx \frac{1 + s T / 2}{1 - s T / 2}
\end{align}
And its inverse

\begin{align}
s &= \frac{1}{T} \ln(z)  \\
  &= \frac{2}{T} \left[\frac{z-1}{z+1} + \frac{1}{3} \left( \frac{z-1}{z+1} \right)^3  + \frac{1}{5} \left( \frac{z-1}{z+1} \right)^5  + \frac{1}{7} \left( \frac{z-1}{z+1} \right)^7 + \cdots \right] \\
  &\approx  \frac{2}{T} \frac{z - 1}{z + 1} \\
  &=  \frac{2}{T} \frac{1 - z^{-1}}{1 + z^{-1}}
\end{align}
We must never forget that the digital control theory is the technique to design strategies in discrete time, (and/or) quantized amplitude (and/or) in (binary) coded form to be implemented in computer systems (microcontrollers, microprocessors) that will control the analog (continuous in time and amplitude) dynamics of analog systems. From this consideration many errors from classical digital control were identified and solved and new methods were proposed:
  • Marcelo Tredinnick and Marcelo Souza and their new type of analog-digital mapping
http://mtc-m18.sid.inpe.br/col/sid.inpe.br/mtc-m18@80/2008/03.17.15.17.24/doc/mirrorget.cgi?languagebutton=pt-BR&metadatarepository=sid.inpe.br/mtc-m18@80/2009/02.09.14.45.33&index=0&choice=full
http://mtc-m05.sid.inpe.br/col/sid.inpe.br/deise/1999/09.14.15.39/doc/homepage.pdf
http://www.sae.org/technical/papers/2002-01-3468
and

References

  1. ^ a b Samuel C. Sugarman (2004). HVAC Fundamentals. The Fairmont Press. ISBN 0-88173-489-6.
  2. ^ James R. Leigh (1987). Applied Control Theory. IET. ISBN 0-86341-089-8.

See also

In HVAC

DDC is often used to control HVAC (heating, ventilating, and air conditioning) devices such as valves via microprocessors using software to perform the control logic. Such systems receive analog and digital inputs from the sensors and devices installed in the HVAC system and, according to the control logic, provide analog or digital outputs to control the HVAC system devices.[1]
These systems may be mated with a software package that graphically allows operators to monitor, control, alarm and diagnose building equipment remotely.

Integration

When different DDC data networks are linked together they can be controlled from a shared platform. This platform can then share information from one language to another. For example, a LON controller could share a temperature value with a BACnet controller. The integration platform can not only make information shareable, but can interact with all the devices.
Most of the integration platforms are either a PC or a network appliance. In many cases, the HMI (human machine interface) or SCADA (Supervisory Control And Data Acquisition) are part of it. Integration platform examples, to name only a few, are the Tridium Niagara AX, Johnson FX40,TAC Vista, CAN2GO and the Unified Architecture i.e. OPC (Open Connectivity) server technology used when direct connectivity is not possible.

Data communication

When DDC controllers are networked together they can share information through a data bus. The control system may speak 'proprietary' or 'open protocol' language to communicate on the data bus. Examples of open protocol language are BACnet (Building Automation Control Network), LON (Echelon), Modbus.

Overview

Central controllers and most terminal unit controllers are programmable, meaning the direct digital control program code may be customized for the intended use. The program features include time schedules, setpoints, controllers, logic, timers, trend logs, and alarms.
The unit controllers typically have analog and digital inputs, that allow measurement of the variable (temperature, humidity, or pressure) and analog and digital outputs for control of the medium (hot/cold water and/or steam). Digital inputs are typically (dry) contacts from a control device, and analog inputs are typically a voltage or current measurement from a variable (temperature, humidity, velocity, or pressure) sensing device. Digital outputs are typically relay contacts used to start and stop equipment, and analog outputs are typically voltage or current signals to control the movement of the medium (air/water/steam) control devices. Usually abbreviated as "DDC".

Direct digital control

Direct digital control (DDC) is the automated control of a condition or process by a digital device (computer).[1][2]
A very early example of a DDC system meeting the above requirements was completed by the Australian business Midac in 1981-1982 using R-Tec Australian designed hardware. The system installed at the University of Melbourne used a serial communications network, connecting campus buildings back to a control room "front end" system in the basement of the Old Geology building. Each remote or Satellite Intelligence Unit (SIU) ran 2 Z80 microprocessors whilst the front end ran 11 in a Parallel Processing configuration with paged common memory. The z80 microprocessors shared the load by passing tasks to each other via the common memory and the communications network. This was possibly the first successful implementation of a distributed processing direct digital control system.

Tuesday, April 9, 2013

DIGITAL CONTROL

Download 

Download


undefined                                   Download





DIGITAL CONTROL
Kannan Moudgalya
Digital control systems are becoming increasingly prevalent and important within industry. In recent years significant progress has been made in their analysis and design - particularly within the areas of microprocessors and digital signal processors. The traditional approach to teaching digital control assumes an understanding of analog control theory; Digital Control, however, teaches the fundamentals of the topics, assuming no prior knowledge of control engineering. Organised into five sections, it discusses modelling, signal processing and identification of plants from measurements, as well as the transfer function approach to, and state space techniques for, control design.* Teaches the fundamentals of digital control, enabling the student to exploit the complete potential of digital systems.* Presents a number of control techniques including proportional-integral-derivative (PID), pole placement, internal model, minimum variance, model predictive and linear quadratic Gaussian control and their extensions.* Provides an extensive introduction to digital signal processing, an essential component to the understanding and implementation of digital controllers; and to the identification of plant models, an important topic in this information era.* Includes examples, problems and solutions as well as accompanying MatLAB code. Digital Control offers an advanced and self-contained textbook to senior undergraduates and postgraduates in chemical, electrical and mechanical engineering and computer science. It will also appeal to practicing systems engineers who need to learn digital control


Download      
                       .