`
`Digital Control
`of Dynamic Systems
`
`Gene F. Franklin
`Stanford University
`J. David Powell
`Stanford University
`Michael L. Workman
`IBM Corporation
`
`.f... ADDISON-WESLEY PUBLISHING COMPANY
`Reading, Massachusetts· Menlo Park, California • New York
`Don Mills, Ontario· Wokingham, England • Amsterdam
`Bonn· Sydney· Singapore· Tokyo· Madrid· San Juan
`
` Micro Motion 1037
`
`1
`
`
`
`Moder
`Richar
`Digital
`Gene I
`Compl
`lohnC
`Feedb.
`Gene I
`Adapti
`JohnJ
`Moder
`Stanle
`
`Many of the designations used by manufacturers and sellers to distinguish their products
`are claimed as trademarks. Where those designations appear in this book, and Addison(cid:173)
`Wesley was aware of a trademark claim, the designations have been printed in initial caps
`or all caps.
`
`The programs and applications presented in this book have been included for their instruc(cid:173)
`tional value. They have been tested with care, but are not guaranteed for any particular
`purpose. The publisher does not offer any warranties or representations, nor does it accept
`any liabilities with respect to the programs or applications.
`
`Library of Congress Cataloging-in-Publication Data
`Franklin, Gene F.
`Digital control of dynamic systems / Gene F. Franklin, J. David
`Powell, Michael L. Workman. 2nd ed.
`p. cm.
`Bibliography: p.
`Includes index.
`ISBN 0-201-11938-2
`1. Digital control systems. 2. Dynamics. I. Powell, J. David.
`II. Workman, Michael L. III. Title.
`TJ223.M53F731990
`629.8-dc20
`
`89-32967
`CIP
`
`Reprinled with corrections June, 1990
`
`Copyright © 1990, 1980 by Addison-Wesley Publishing Company, Inc. All rights reserved.
`No part of this publication may be reproduced, stored in a retrieval system, or transmit(cid:173)
`ted, in any form or by any means, electronic, mechanical, photocopying,
`recording, or
`otherwise, without the prior written permission of the publisher. Printed in the United
`States of America.
`
`BCDEFGHIJ-DO-943210
`
`2
`
`
`
`CHAPTER 1
`
`Introduction
`
`1.1 PROBLEM DEFINITION
`The control of physical systems with a digital computer is becoming more
`and more common. Aircraft autopilots, mass-transit vehicles, oil refineries,
`paper-making machines, and countless electromechanical servomechanisms
`are among the many existing examples. Furthermore, many new digital
`control applications are being stimulated by microprocessor technology in(cid:173)
`cluding control of various aspects of automobiles and household appliances.
`Among the advantages of digital logic for control are the increased flexibility
`of the control programs and the decision-making or logic capability of digital
`systems, which can be combined with the dynamic control function to meet
`other system requirements.
`The digital controls studied in this book are for closed-loop (feedback)
`systems in which the dynamic response of the process being controlled ~s a
`major consideration in the design. A typical topology of the elementary type
`of system that will occupy most of our attention is sketched schematically in
`Fig. 1.1. This figure will help to define our basic notation and to introduce
`several features that distinguish digital controls from those implemented
`with analog devices. The process to be controlled is called the plant and
`may be any of the physical processes mentioned above whose satisfactory
`response requires control action.
`By "satisfactory response" we mean that the plant output, y(t), is to be
`forced to follow or track the reference input, r(t), despite the presence of
`disturbance inputs to the plant [w(t) in Fig. 1.1] and despite errors in the
`sensor [represented by v(t) in Fig. 1.1]. It is also essential that the tracking
`succeed even if the dynamics of the plant should change somewhat during
`
`1
`
`3
`
`
`
`2
`
`CHAPTER 1 INTRODUCTION
`
`r(kD +
`--+ !; }-----~
`
`y(kD
`
`w(t)
`
`y(t)
`
`v(t)
`
`Notation:
`r = reference or command inputs
`u = control or actuator input signal
`controlled or output signal
`y
`y = instrument or sensor output, usually an approximation to or estimate
`of y. (For any' variable, say e, the notation & is now commonly taken
`from statistics to mean an estimate of e.)
`e = r-y
`indicated error
`r-y = system error
`e
`= disturbance input to the plant
`w
`= disturbance or noise in the sensor
`v
`A/D
`analog-to-digital converter
`0/ A = digital-to-analog converter
`
`Figure 1.1 Block diagram of a basic control system.
`
`the operation. The process of holding y(t) close to r(t), including the case
`where r == 0, is referred to generally as the process of regulation. A system
`that has good regulation in the presence of disturbance signals is said to
`have good disturbance rejection. A system that has good regulation in the
`face of changes in the plant parameters is said to have low sensitivity to
`these parameters. A system that has both good disturbance rejection and
`low sensitivity we call robust.
`The means by which robust regulation is to be accomplished is through
`the control inputs to the plant [u(t) in Fig. 1.1]. It was discovered long agol
`that a scheme offeedback wherein the plant output is measured (or sensed)
`and compared directly with the reference input has many advantages in the
`effort to design robust controls over systems that do not use such feedback.
`Much of our effort in later parts of this book will be devoted to illustrating
`this discovery and demonstrating how to exploit the advantages of feedback.
`However, the problem of control as discussed thus far is in no way restricted
`
`1 See especially the book by Bode (1945).
`
`sari
`
`als(
`At
`of,
`(i.e
`rep
`the
`wit
`thE
`WE
`qu,
`0.1
`is i
`
`4
`
`
`
`1.1 PROBLEM DEFINITION
`
`3
`
`to digital controL For that we must consider the unique features of Fig. 1.1
`introduced by the use of a digital device to generate the control action.
`We consider first the action of the analog-to-digital (A/D) converter on a
`signal. This device acts on a physical variable, most commonly an electrical
`voltage, and converts it into a stream of numbers. In Fig. 1.1, the A/D
`converter acts on the sensor output and supplies numbers to the digital
`computer. It is common for the sensor output, y, to be sampled and to have
`the error formed in the computer. We need to know the times at which these
`numbers arrive if we are to analyze the dynamics of this system.
`In this book we will make the assumption that all the numbers arrive
`with the same fixed period T, called the sampling period. In practice, digi(cid:173)
`tal control systems sometimes have varying sample periods and/or different
`periods in different feedback paths. Usually there is a clock as part of the
`computer logic which supplies a pulse or interrupt every T seconds, and
`the A/D converter sends a number to the computer each time the interrupt
`arrives. An alternative implementation is simply to access the A/D upon
`completion of each cycle of the code execution, a scheme often referred to
`as free running. In the first case the sample period is precisely fixed; in the
`latter case the sample period is essentially fixed by the length of the code,
`providing no logic branches are present that could vary the amount of code
`executed. Thus in Fig. 1.1 we identify the sequence of numbers into the com(cid:173)
`puter as e{kT). We conclude from the periodic sampling action of the A/D
`converter that some of the signals in the digital control system, like e(kT),
`are variable only at discrete times. We call these variables discrete signals
`to distinguish them from variables like wand y, which change continuously
`in time. A system having both discrete and continuous signals is called a
`sampled-data system.
`. In addition to generating a discrete signal, however, the A/D converter
`also provides a quantized signal. By this we mean that the output of the
`A/D converter must be stored in digital. logic composed of a finite number
`of digits. Most commonly, of course, the logic is based on binary digits
`(Le., bits) composed of O's and l's, but the essential feature is that the
`representation has a finite number of digits. A common situation is that
`the conversion of y to Y is done so that y can be thought of as a number
`with a fixed number of places of accuracy. If we plot the values of y versus
`the resulting values of y we can obtain a plot like that shown in Fig. 1.2.
`We would say that y has been truncated to one decimal place, or that y is
`quantized with a q of 0.1, since y changes only in fixed quanta of, in this case,
`0.1 units. (We will use q for quantum size, in general.) Note that quantization
`is a nonlinear function. A signal that is both discrete and quantized is called
`
`le case
`5ystem
`laid to
`in the
`vity to
`In and
`
`trough
`~ ago1
`msed)
`in the
`[back.
`~ating
`lback.
`dcted
`
`5
`
`
`
`4
`
`CHAPTER 1 INTRODUCTION
`
`y
`0.5
`0.4
`0.3
`0.2
`
`-0.4
`-0.5
`
`Figure 1.2 Plot of output versus input characteristics of the AID converter.
`
`a digital signal. Not surprisingly, digital computers in this book process
`digital signals.
`In a real sense the problems of analysis and design of digital controls
`are concerned with taking account of the effects of the sampling period T
`and the quantization size q. If both T and q are extremely small (sampling
`frequency 50 or more times the system bandwidth with a 16-bit word size),
`digital signals are nearly continuous, and continuous methods of analysis and
`design can be used. The resulting design could be converted to the digital
`format for implementation by using the emulation method described in
`Chapter 5. We will be interested in this text in gaining an understanding of
`the effects of all sample rates, fast and slow, and the effects of quantization
`for large and small word sizes. Many systems are originally conceived with
`fast sample rates, and the computer is specified and frozen early in the
`design cycle; however, as the designs evolve, more demands are placed on the
`system, and the only way to accommodate the increased computer load is to
`slow down the sample rate. Furthermore, for cost-sensitive digital systems,
`the best design is the one with the lowest cost computer that will do the
`required job. That translates into being the computer with the slowest speed
`and the smallest word size. We will, however, treat the problems of varying
`T and q separately. We first consider q to be zero and study discrete and
`sampled-data (combined discrete and continuous) systems that are linear.
`In Chapter 7 we will analyze in more detail the source and the effects of
`quantization, and we will discuss in Chapters 5 and 10 specific effects of
`sample-rate selection.
`It is worthy to note that the single most important impact of imple(cid:173)
`menting a control system digitally is the delay associated with the D / A
`
`converteJ
`the next
`u(t) com
`as shown
`. delay in;
`for man~
`Chapterl
`Our
`in conti!
`continuo
`ginning,
`experien
`viewpoiI
`ingful tl:
`review t
`
`1.2 EJ
`In order
`models
`is a satE
`the dou
`
`This ex
`transfel
`
`6
`
`
`
`1.2 EXAMPLE SYSTEMS FOR STUDY
`
`5
`
`u
`
`3
`
`4
`
`5
`
`6
`
`7
`
`8
`
`kT
`
`Figure 1.3 The delay due to the hold operation.
`
`converter. Each value of u(kT) in Fig. 1.1 is typically held constant2 until
`the next value is available from the computer. Thus the continuous value of
`u(t) consists of steps (see Fig. 1.3) that, on the average, lag u(kT) by T/2,
`as shown by the dashed line in the figure. If one simply incorporates this T /2
`delay in a continuous analysis of a digital system, excellent agreement results
`for many reasonable sample rates. This point will be explained further in
`Chapters 3 and 5.
`Our approach to the design of digital controls is to assume a background
`in continuous systems and to relate the comparable digital problem to its
`continuous counterpart. We will develop the essential results, from the be(cid:173)
`ginning, in the domain of discrete systems, but we will call upon previous
`experience in' continuous-system analysis and in design to give alternative
`viewpoints and deeper understa!lding of the results. In order to make mean(cid:173)
`ingful these references to a background in continuous-system design, we will
`review the concepts and define our notation as required .
`
`1.2 ~EXAMPLE SYSTEMS FOR STUDY
`In order to guide the discussion in the following chapters we have developed
`models for six example control problems in Appendix A. The first of these
`is a satellite attitude control problem in which the plant transfer function is
`the double integrator
`
`This example is simple, but with two poles on the stability boundary, this
`transfer function must be controlled with care. The second example is a
`
`2Called a Zero Order Hold or ZOH.
`
`(1.1)
`
`;er.
`
`ocess
`
`ltrols
`3d T
`pIing
`,ize) ,
`; and
`gital
`~d in
`llg of
`ttion
`with
`. the
`1 the
`is to
`ems,
`• the
`peed
`ying
`and
`lear.
`es of
`;s of
`
`lple(cid:173)
`)/A
`
`7
`
`
`
`222 CHAPTER 5 DESIGN USING TRANSFORM TECHNIQUES
`
`in the fact that the control response is determined from
`
`ll(z)
`[T(z)
`1)
`R(z) = 1 + 1)G = G(z)'
`
`which for this example is
`
`[T(z)
`R(z) = 13.06 z2
`
`~---
`
`z - 0.0793
`0.7859z + 0.3679
`
`(z - l)(z - 0.9048)
`z + 0.9672
`
`There is a root at z = -0.9672!. This is the source of the oscillation in the
`control response, but it did not show up in the output response because it
`was exactly canceled by a zero. The control oscillation causes the "intersam(cid:173)
`pIe ripple" in the output response, and the designer should be alert to this
`if poorly behaved roots arise in the control response. An actual prediction
`of the output intersample ripple based on linear analysis was not possible
`with the z-transform method described so far; rather, one would need to
`apply the "modified z-transform," which is beyond the scope of this text.
`Alternatively, one can use a CAD simulation to find such oscillations quite
`easily, as was done here. To avoid this oscillation, we could introduce another
`term in ll(z), b3z-3, and require that ll(z) be zero at z = -0.9672, so this
`zero of G(z) is not canceled by 1)(z). The result will be a simpler 1)(z) with
`a slightly more complicated 1l (z). However, rather than pursue this method
`further, we will wait until the more powerful method of pole assignment
`by state-variable analysis is developed in the next chapter, where computer
`algorithms are more readily provided.
`
`5.8 PID CONTROL
`Just as in continuous systems, there are three basic types of control: Propor(cid:173)
`tional, Integral, and Derivative, hence the name, PID. In the design exam(cid:173)
`ples so far, we have been using the discrete equivalent of lead compensation,
`which is essentially a combination of proportional and derivative controL Let
`us now review these three controls as they pertain to a discrete implementa(cid:173)
`tion. The term PID is widely used because there are commercially available
`modules that have knobs for the user to turn that set the values of each of
`the three control types.
`
`5.8.1
`A dis(
`that i
`
`the di
`
`where
`
`5.8.2
`For cc
`
`where
`in the
`
`u(k) ==
`
`In
`tive co
`
`or, eqt
`
`which
`in the
`the pc
`for th,
`repres(
`the dL
`pole IT
`
`8
`
`
`
`5.8 PID CONTROL
`
`223
`
`5.8.1 Proportional Control
`
`A discrete implementation of proportional control is identical to continuous;
`that is, where the continuous is
`
`the discrete is
`
`u(k) = Kpe(k) ~ I D(z) = Kp I
`where e(t) is the error signal as shown in Fig 5.2.
`
`5.8.2 Derivative Control
`
`For continuous systems, derivative or rate control has the form
`
`where TD is called the derivative time. Differentiation can be approximated
`in the discrete domain as the first difference, that is,
`
`u(k) = KpTD (e(k) - e(k - 1))
`T
`
`In many designs, the compensation is a sum of proportional and deriva(cid:173)
`tive control (or PD control). In this case, we have
`
`or, equivalently,
`
`ID(Z)=Kz-al
`I
`z
`
`which is similar to the lead ~pmpensations that have been used in the designs
`in the previous sections. The difference is that the pole is at z = 0, whereas
`the pole has been placed at various locations along the z-plane real axis
`for the previous designs. In the continuous case, pure derivative control
`represents the ideal situation in that there is no destabilizing phase lag from
`the differentiation, or, equivalently, the pole is at s = -00. This s-plane
`
`pole maps into z = ° for discrete rate control; however, the z = 0 pole does
`
`9
`
`
`
`224 CHAPTER 5 DESIGN USING TRANSFORM TECHNIQUES
`
`add some phase lag because of the necessity to wait for one cycle in order
`to compute the first difference. Any other stable pole location, whether on
`the positive or negative real axis, would also have some delay or phase lag
`associated with it for the same reason.
`
`5.8.3 Integral Control
`
`For continuous systems, we integrate the error to arrive at the control,
`
`K it
`
`u(t) = J..
`TI
`
`to
`
`.
`
`e(t)dt =} D(s)
`
`where TI is called the integral, or reset time. The discrete equivalent is to
`sum all previous errors, yielding
`
`u(k) = u(k 1)+ ;1 e(k) =} D(z) =
`KT
`
`Just as for continuous systems, the primary reason for integral control is to
`reduce or eliminate steady-state errors, but this typically occurs at the cost
`of reduced stability.
`
`5.8.4 PID Control
`
`Combining all the above yields the PID controller
`
`D(z) Kp (1 + Tz + TD(Z -1)) .
`
`TI(Z - 1)
`
`Tz
`
`(5.61)
`
`This form of control law is able satisfactorily to meet the specifications for
`a large portion of control problems and is therefore paclG:tged commercially
`and sold for general use. The user simply has to determine the best values
`of K p , TD, and TI.
`
`5.8.5 Ziegler-Nichols PID Tuning
`
`The parameters in the PID controller could be selected by any of the design
`methods previously discussed. However, these methods require a dynamic
`model of the process which is not always readily available. Ziegler-Nichols
`tuning is a method for picking the parameters based on fairly simple exper(cid:173)
`iments on the process and thus bypasses the need to determine a complete
`dynamic model.
`
`t
`I
`
`f
`c
`a
`t
`
`c
`t:
`p
`d
`r.
`Ie
`
`10
`
`
`
`654
`CHAPTER 12 APPLICATION OF DIGITAL CONTROL
`
`
`
`
`
`Referred to as analog I/O, A/D’s and D/A’s form a basic part of the
`digital control system. In almost all applications of A/D converters, the
`
`
`sample and hold device allows the analog signal to be held at a constant value
`
`
`(sampled) while the A/ D converts the signal to a binary representation. Once
`the conversion is complete, the sample and hold circuit is taken out of the
`
`
`hold mode and allowed to track or follow the input signal. It is for this reason
`that sample and,hold devices are often referred to as track-and-holds. When
`
`
`switched from sample to hold (via a logic or control signal), the value of the
`analog input is represented as charge stored on a capacitor, and the charge
`
`
`is held as constant as possible while in the hold ‘mode (see Chapter 3).
`
`
`As long as a number remains at the input of a D/ A converter, the output
`voltage will remain at the corresponding value. If the number is changed,
`
`
`the output changes accordingly. Thus, if the D / A contains an input register
`or latch, once the register is loaded the output signal will correspond to that
`
`
`number until the register is changed. D/ A converters with latches are often
`referred to as latching D/A’s. Latching D/A converters are very common
`in small microprocessor systems.
`In the rest of this section, we will discuss some additional characteristics
`of analog I/O devices which are of import to the control system designer.
`
`
`
`
`
`
`
`
`A/D Converter Specifications. A brief description of the features and
`characteristics of an A /D converter will provide the reader with basic un-
`derstanding of the nature of obtaining digitized representations of analog
`
`
`signals. An abreviated data sheet for an A/D converter is contained in Ap-
`pendix B of this chapter.
`
`
`
`
`
`2. Analo
`accept
`(bipolt
`3. Code:
`in ofl's
`
`‘QPCI‘at
`straigl
`by con
`
`4. Offset:
`code is
`from 0
`The of
`transit
`
`5. Linear
`
`from it
`words,
`lution
`drawn
`deviati
`
`6. Begin .
`conver:
`
`7. Convei
`
`to-digii
`after re
`
`8. Convei
`Faster
`of resoi
`calcula
`
`Many II]
`above ShOUL
`converters.
`
`D /A Conv
`definitions a
`of conversior
`time it take:
`
`correspondir
`the settling 1
`
`
`
`
`1. Resolution: The quantity representing the smallest difference that can
`be discerned. Although the units are incorrect, it is usually quoted in
`bits (N), and the resolution is calculated as
`
`
`
`
`Resolution = 1 part in 2N parts.
`
`Usually (but not necessarily) A/ D converters accept analog voltages as
`
`
`input, within a total signal range of Us = lvmaxl + lumin|, in which case
`
`the resolution is
`
`
`
`
`
`.
`t
`R s l
`eouion
`
`Us
`= — olt
`(2N_1)v s,
`
`,
`
`
`
`which is‘also refered to as the quantization level q, or sometimes as the
`code width. For the example in Fig. 12.3, the resolution is three bits
`and was set to correspond to q = 0.250 volts.
`
`
`
`
`
`11
`
`11
`
`
`
`
`
`12.2 DIGITAL CONTROL SYSTEM HARDWARE
`655
`
`
` of the
`
`Analog Input Range: Refers to the type of input signals that can be
`accepted, either both positive and negative with respect to ground
`(bipolar), or positive or negative with respect to ground (unipolar).
`
`12
`
`:rs, the
`it value
`1. Once
`3 of the
`Lreason
`
`. When
`e of the
`
`charge
`3).
`output
`
`nanged,
`register
`to that
`re often
`ommon
`
`teristics
`
`Ligner.
`
`ree bits
`
`; as the
`
`res and
`lSiC un—
`
`‘ analog
`. in Ap-
`
`hat can
`loted in
`
`ages as
`ch case
`
`Code: The digital code used to represent the analog number. Usually
`in offset binary or two’s complement (see Section 12.3.7) for bipolar
`operation. For unipolar Operation no sign bit is needed, so the code is
`straight magnitude. Offset binary can be converted to two’s conplement
`by'complementing the MSB.
`
`Oflsetz The midpoint input for the zero code. In offset binary, the zero
`code is 1000 .
`. .0000. The major carry transition point, or the transition
`from 0111 .
`.
`. 1111 to 1000...0000, should occur at an input of —q/2.
`The offset is the analog value that corresponds to the true major carry
`transition point plus q/ 2.
`
`Linearity Error. Refers to the deviation of each possible digital result
`from its correct transition point relative to the analog input. In other
`words, if the digital output code measured is multiplied by the reso-
`lution and plotted against the analog input along with a straight line
`drawn from zero through full scale, the linearity error refers to the
`deviation of the center point of each code from the straight line.
`
`Begin Conversion: Logic signal input that initiates an analog-to-digital
`conversion.
`
`Conversion Complete: Logic signal (coc) input that indicates an analog—
`to-digital conversion has been completed. This signal is usually reset
`after reciept of a begin conversion command.
`
`Conversion time (Tc): The time it takes to complete a conversion cycle.
`Faster conversion is always more expensive for a given number of bits
`of resolution. The conversion time puts a lower bound on the control
`calculation delay A for a control system.
`
`Many more terms and definitions could be reviewed, but the ones given
`above should give a feel for the basic issues involved when considering A /D
`converters.
`
`D/A Converter Specifications. D/A converters have most of the same
`definitions and specifications as the A /D converters described above. Instead
`of conversion time, the D / A has a. settling time associated with the maximum
`time it takes its analog output to change from any voltage to the voltage
`corresponding to a newly applied digital input. For small output changes,
`the settling time is dominated by the linear amplifier bandwidth in the D /A
`
`12
`
`