You are on page 1of 84

CONTROL SYSTEM DEMONSTRATOR PROJECT

Jake Sauer
ME 695
Western Michigan University
Department of Mechanical Engineering
CONTROL SYSTEM DEMONSTRATOR PROJECT

by

Jake Sauer

A project report submitted to the


Department of Mechanical Engineering
in partial fulfillment of the requirements for the degree of

Master of Science in Mechanical Engineering

WESTERN MICHIGAN UNIVERSITY


DEPARTMENT OF MECHANICAL ENGINEERING

March, 2002

i
ACKNOWLEDGMENT

I would like to thank my good friend Yei Dei Wang for generously lending his expertise
for the design and construction of the Control System Demonstrator. In spite of his busy
work and school schedule, Yei Dei donated a good deal of his free time helping me to
design and construct the circuitry needed to make this project a reality. The analog
circuits for this project (see the schematics presented in the appendices) were designed,
constructed, and documented by Yei Dei. His initial help in researching the control
hardware necessary to build this project was invaluable. Yei Dei deserves much credit
for his part in the design of the Control System Demonstrator, and I am sincerely grateful
for the time and effort which he devoted to helping me with this project.

Thanks Yei Dei!

iii
CONTENTS

List of Figures ................................................................................................................ vi

List of Tables ................................................................................................................. x

Abstract ......................................................................................................................... xi

Chapter 1: Introduction ................................................................................................ 1

Chapter 2: Background ................................................................................................ 2

2.1 Review of Conventional Process Control ......................................................... 2

2.1.1 Process Control Overview ....................................................................... 2

2.1.2 Dynamics and Mathematical Models ...................................................... 3

2.1.3 Types of Dynamic Processes ................................................................... 5

2.1.4 Basic Feedback Control .......................................................................... 10

2.2 Computer Process-Control Hardware and Software Concepts ........................... 15

2.2.1 Conventional Control versus Computer Control ..................................... 15

2.2.2 Computers for Process Control ................................................................ 19

2.2.3 Practical Controller Implementation ........................................................ 24

2.3 Background Summary ........................................................................................ 29

Chapter 3: PROJECT OBJECTIVES AND SPECIFICATIONS ................................. 31

3.1 Problem Statement ............................................................................................ 31

3.2 Device Specifications ....................................................................................... 31

3.3 Final Design ..................................................................................................... 34

3.3.1 Process Description ............................................................................... 34

iv
3.3.2 Description of Components ................................................................... 41
3.3.3 Testing the System: Two Key Components .......................................... 52

3.3.4 Computer Program Development for Process-Control ............................ 68

3.3.5 Development of a Supervisory Control and Data Acquisition Program ... 73

3.3.6 Setting-Up and Running the Control System Demonstrator .................... 92

Chapter 4: Results ......................................................................................................... 96

4.1 Open-Loop Process Response : A First Look ................................................... 96

4.2 Closed-Loop Process Response ....................................................................... 102

4.3 An Interesting Observation .............................................................................. 110

4.4 Using Commercial Software for CSD Process Analysis .................................. 112

Chapter 5: Conclusion ................................................................................................... 119

5.1 Future of the Control System Demonstrator ...................................................... 119

5.2 Concluding Remarks .......................................................................................... 120

Appendix A: Flowchart of LabVIEW Program ............................................................. 122

Appendix B: Control System Demonstrator Schematic ................................................ 126

Appendix C: Analog to Digital, Digital to Analog, and Dimmer Schematics ............... 127

Appendix D: RTD Sensor Circuit .................................................................................. 130

Appendix E: PBASIC Program To Acquire A Temperature Measurement .................. 131

Appendix F: LabVIEW G Program and Sub-VIs ......................................................... 131

Appendix G: PBASIC Proportional Control Program .................................................. 175

Appendix H: PBASIC Final Control Program ............................................................. 178

Appendix I: Operating Instructions, tips, cost breakdown............................................. 181

v
References ..................................................................................................................... 187

vi
FIGURES

Chapter 2
Figure 2.1 A Typical Block Diagram ............................................................................. 4

Figure 2.2 A Transfer Function in Block Diagram Form ............................................... 4

Figure 2.3 Step Response of a First Order Process ........................................................ 6

Figure 2.4 Step Response of a Second-Order Process ................................................... 7

Figure 2.5 Response of a Dead-Time Element .............................................................. 9

Figure 2.6 Block Diagram of a Composite Process Model ........................................... 11

Figure 2.7 Closed-Loop Step Response to a Load Change ........................................... 12

Figure 2.8 Stable Region in the S-Plane ........................................................................ 14

Figure 2.9 Continuous and Discrete Signals .................................................................. 15

Figure 2.10 A Typical Computer Control System ......................................................... 17

Figure 2.11 Typical Computer-Control Program Flowchart ......................................... 18

Figure 2.12 Op-Amp Based Analog Controller ............................................................. 24

Figure 2.13 A SCADA System Controlling Multiple Processes ................................... 26

Figure 2.14 Essential Features of an 8-bit Micro-Controller ......................................... 27

Chapter 3
Figure 3.1 Block Diagram Showing a Composite Process Model ................................. 34

Figure 3.2 Model of the Control System Demonstrator Process .................................... 35

Figure 3.3 Power Dissipated by a Resistor .................................................................... 37

Figure 3.4 System Steady-State Equilibrium Energy ..................................................... 38

Figure 3.5 Control System Demonstrator Actuator, Sensor, and Process ...................... 40

Figure 3.6 Component-Level Detail of the Control System Demonstrator .................... 41

vii
Chapter 3
Figure 3.7 The BASIC Stamp II Micro-controller .......................................................... 43

Figure 3.8 Oscilloscopic View of Duty Cycle at 20% .................................................... 45

Figure 3.9 Controller Block Diagram ............................................................................. 47

Figure 3.10 Expanded View of the Controller Block Diagram ...................................... 48

Figure 3.11 System Block Diagram ............................................................................... 50

Figure 3.12 Actual Hardware Implementation of the System Block Diagram .............. 51

Figure 3.13 Duty Vs. Drive ............................................................................................ 54

Figure 3.14 Voltage Vs. Duty ........................................................................................ 54

Figure 3.15 Voltage Vs. Drive ....................................................................................... 55

Figure 3.16 Dimmer Response ...................................................................................... 56

Figure 3.17 Linear Portion of Dimmer Output .............................................................. 57

Figure 3.18 Ideal Temperature Sensor Response .......................................................... 58

Figure 3.19 Temperature Vs. A-to-D Converter Output ............................................... 63

Figure 3.20 Measurement Error Increases With Temperature ...................................... 65

Figure 3.21 Temperature Function Changes as Span Changes ...................................... 66

Figure 3.22 The Affect which Proportional Band has on Controller Output ................ 69

Figure 3.23 Example G Program ............................................................................... 76

Figure 3.24 VI Control Panel ........................................................................................ 77

Figure 3.25 Subtraction Results .................................................................................... 77

Figure 3.26 First and Second Number Added ............................................................... 78

Figure 3.27 The CSD Uses Two Computer Programs .................................................. 81

Figure 3.28 The CSD Control Panel ............................................................................. 83

Figure 3.29 The LabVIEW Main Program ................................................................... 84

viii
Chapter 3
Figure 3.30 The PID Sub-Routine ............................................................................... 85

Figure 3.31 The Trapezoidal Rule For Approximating An Integral ............................ 86

Figure 3.32 Serial Cable Construction ......................................................................... 91

Figure 3.33 Overall Program Loop Structure .............................................................. 93

Figure 3.34 Variation of Sampling Time Over a Two Minute Period ......................... 95

Chapter 4
Figure 4.1 Open-Loop Response to a 50% Increase Step Input .................................. 97

Figure 4.2 Open-Loop Response to a 20% Increase Step Input .................................. 97

Figure 4.3 Exponential Versus Measured First Order Response 50% Step ................. 99

Figure 4.4 Exponential Versus Measured First Order Response 20% Step ................100

Figure 4.5 Open-Loop Response to a Load Change .................................................... 102

Figure 4.6 Proportional Control Response Comparisons ............................................ 104

Figure 4.7 Plot of Closed-Loop Response (Proportional + Integral Control) .............. 104

Figure 4.8 Stabilizing Affect of Derivative Action ...................................................... 105

Figure 4.9 CSD Display of PI Versus PID Control ..................................................... 107

Figure 4.10 PI Controller Output .................................................................................. 107

Figure 4.11 PID Controller Output ............................................................................... 108

Figure 4.12 Comparison of Responses to a Load Change ............................................ 109

Figure 4.13 Effect Due to Sensor Orientation .............................................................. 110

Figure 4.14 Minimum PLC Hardware Required To Control the CSD ......................... 115

Figure 4.15 Simple Ladder Logic Program Used To Implement PID Control ............. 115

Figure 4.16 PID Block Configuration Table ................................................................. 116

Figure 4.17 Example of a Typical RSTUNE Window .............................................. 116

ix
Figure 4.18 Frequency Response of CSD (Light Incident To RTD Face) ................... 117

Figure 4.19 Measured CSD Process Transfer Function (Light Incident To Sensor) .... 117

Figure 4.20 Measured CSD Process Transfer Function (Light Transverse To RTD) .. 117

x
TABLES

Chapter 3
Table 3.1 Summary of Demonstrator Specifications ................................................. 33

Table 3.2 Data Table for Dimmer Transfer Function Plot ........................................ 56

Table 3.3 Available Gain Combinations for the CSD PI Compensator .................... 89

Table 3.4 Relative Frequency of the Variation in the Sampling Time, t ................. 94

xi
ABSTRACT

This report describes the design and construction process for an instructional device
capable of demonstrating concepts of closed-loop feedback control to engineering
students at Western Michigan University. The device (designed and built by the author
of this report), is referred to throughout this document as a Control System
Demonstrator, and illustrates to students an example of how a closed-loop feedback
control system is implemented in practice. The CSD is a pedagogical supplement to be
presented by the course instructor to students, and is intended to bridge the gap between
the ideas of classical control-system design strategies and the practical implementation of
those strategies.

The objective of this report is to provide useful information to students who wish to
learn more about the implementation side of control-system design. The features of the
electronic hardware and software applications used in the construction of the control
system demonstrator are discussed, and the justification for the selection of particular
components is given. The details of how to program a Parallax, Inc. BASIC Stamp II
embedded micro-controller to perform the duties of the closed-loop feedback controller
are presented. Several controllers which could have been chosen for this purpose, but
were not, are also discussed in order to present the reader with additional options that
were considered during the design phase of the project. In addition, a closed-loop block
diagram for the device is presented. The relationship of each hardware or software
component is discussed as it relates to the block diagram. This was included to help the
students to see how the block diagram translates into a physical system.

The control system demonstrator has been designed primarily for the purpose of
illustrating a type of control strategy which is widely used throughout industry, and is
known as PID (Proportional + Integral + Derivative) control. The demonstrator utilizes a
PID algorithm to control a simple temperature process. The goal in the design of
demonstrator was for it to be able to illustrate three important ideas about PID control:
An increase in Proportional gain can decrease the steady-state error in the system
response to a set-point change or disturbance input. However, too much P gain can
cause the system to become unstable.
The addition of Integral action can eliminate the steady-state error after a set-point
change or disturbance input is introduced, but at the cost of a slower response time.
Too much Integral action can cause instability.
Derivative action has the ability to offset the negative effects due to integral action.
Derivative action cannot be used when a significant amount of noise is present in the
feedback signal, however. When this is the case, the controller output is erratic.

After chronicling the design and construction phase of the project, several test-runs of the
demonstrator are presented. These test runs illustrate how the device can be expected to
perform, and what results can be expected from the device under different sets of
conditions. The end results indicate that the device does in fact work as intended with
respect to the ideas regarding PID control.

xii
CHAPTER 1

INTRODUCTION

Currently, control systems courses offered by the mechanical engineering department


at Western Michigan University are without a laboratory. Consequently, students enrolled
in the introductory or advanced control systems courses are exposed to theory but are not
provided with the opportunity to see theoretical principles empirically demonstrated and
verified by an actual working control system.

A device designed specifically for the purpose of demonstrating important concepts


taught in control systems courses could be an effective educational tool for enhancing the
students learning experience. The device would likely have the effect of satisfying the
students need to see for themselves whether or not the theoretical principles taught in the
classroom affect the real-world system in the same way that theory predicts.

Because often, seeing is believing, it is expected that a control system demonstrating


device would prove to be effective in stimulating a students interest and appreciation for
course principles, and for increasing the desire of the student to learn more about control
systems engineering. Also, a device capable of demonstrating control system behavior
would be beneficial for the course instructor who wishes to use it as an example of how a
control system is implemented in practice.

Although the acquisition of a control system demonstrator has been proposed in the
past, commercially available products were judged to be too expensive. It is true that a
home-built demonstrator could be created for an acceptable cost, however the design and
construction of such a device would require an individual willing to devote the time,
energy, thought, and labor necessary to complete the project. The nature of this problem
is well suited to be the subject of a graduate-level project for a student who wishes to use
the work as a means of satisfying degree requirements. In addition to benefiting both the
students and instructor, the project would provide the graduate student with valuable
hands on experience in control system design and development. During the planning
and construction process, the student would likely learn about; hardware component
specification and selection, software design, meeting a budget, and designing a product to
satisfy the needs of a customer.

This report has been created in order to chronicle the design and construction process of a
practical device which may be used to demonstrate some important ideas taught in
control systems courses at Western Michigan University. The report begins with a
background section which is provided in order familiarize the reader with the concepts
that the device has been designed to demonstrate. The device specifications are then
presented, along with the actual components which have been selected in order to meet
these specifications. Next, the hardware and software construction process is discussed.
And finally, the results of the working device are presented and discussed.

1
CHAPTER 2

BACKGROUND

2.1 Review of Conventional Process Control

2.1.1 Process Control Overview

In the context of engineering, the term process may be defined as a collection of


interconnected hardware (e.g., tanks, pipes, gauges, shafts, motors, couplings, etc.), each
doing its part toward the overall objective of producing some type of product. It is the job
of the process engineer to design this hardware. On the other hand, the control engineers
focus is on physical variables (e.g., temperature, pressures, levels, flows, voltages,
speeds, positions, etc.) rather than hardware. How these variables affect one another, and
how they change with time is what interests the control engineer. The fundamental
objective in process control is to maintain certain key process variables as near their
desired values, called set points, as much of the time as possible (Ash and Deshpande 1) .

For the purpose of discussing process control systems , it is useful to categorize


physical variables as follows:

Outputsthese are the key process variables to be maintained at desired values, that is,
controlled.

Inputsthese are the variables that, when changed, cause one or more outputs to change.
These inputs may be further sub-classified as control inputs and disturbance inputs.

a) Control Inputsthese are also called manipulated variables. These variables are
changed by the controller to bring and maintain the outputs at set points.
b) Disturbance Inputsall other process variables that affect the outputs in any way
are called disturbance inputs or process loads. These disturbance inputs cause
unwanted changes in process outputs.

2
2.1.2 Dynamics and Mathematical Models

The objective of control strategy development is to determine how to change a control


input in order to correct a deviation between the desired value and the actual value of the
process output. The development of this strategy is complicated by the inertia or lag
which exists in processes. What is meant by lag is that if a sudden change is made in an
input, the output will not immediately follow. There will be a lag in time before the
output settles on its final value.

In order to effectively control a process, the first thing that is needed is knowledge of
how control inputs affect outputs, quantitatively. If a control input is changed by a known
amount, then it is often desired to know:

How much the output will change and in what direction it will change.
How long this change will take.
What the pattern of output variation with time is.

A mathematical model of the dynamics of the process provides the information


needed to answer these questions. This model gives a functional relationship between an
input and an output of a process and may be defined as any mathematical expression or
formula that when values of the independent variables (i.e., inputs) are given, enables
prediction of the value of the dependent variable (i.e., output). Mathematical models are
expressions from which physical behavior can be predicted, and are derived from the
laws of nature. Some examples of these laws are:

Conservation of mass and energy


Newtons laws of motion
Kirchoffs laws of electrical circuits
Equations of state for gases

These models usually take the form of differential equations involving time rates of
change of variables as well as the variables themselves. To predict the output behavior
resulting from a known change in the input, these differential equations must be solved.

Some processes can be described by linear differential equations, whereas other


processes are described by non-linear equations. In many cases, the behavior of the latter
can be approximated by linear differential equations about some normal operating point.
For many processes that are under control the interest is in their behavior around some
steady-state operating level, and often this approximation is applicable. However, for a
different operating level, new parameters may have to be established for the process
model.

3
A schematic representation of the cause-and-effect relationship between input and
output is referred to as a block diagram, shown in Figure 2.1. A single block may
represent each component belonging to the process. Each block usually has one control
input, one output, and may also have several identifiable and/or measurable disturbance
inputs. There may also exist several unidentifiable or unknown disturbance inputs that
affect the output. The block diagram also represents the quantitative cause-effect
relationship (i.e., mathematical model) between an input and an output.

Disturbance
inputs

Control Input Output


Process
or
plant

Figure 2.1
Typical Block Diagram

Linear differential equations can be converted, by Laplace transforms, into algebraic


equations from which transfer functions can be derived. Since Laplace transforms
convert a differential equation into an algebraic equation, the solution is greatly
simplified.

A transfer function G(s) is a mathematical expression that represents the ratio of the
Laplace transforms of a process output Y(s) to that of an input M(s).

G(s) = Y(s)
M(s)

Input Output
M(s) Y(s)
G(s)

Figure 2.2
Transfer Function Shown as a Block Diagram

4
2.1.3 Types of Dynamic Processes

Processes may be categorized as being one of the following types (Ash and
Deshpande 5) :

Instantaneous or steady state


First-order lag
Second-order lag
Dead-time or transport lag

Other processes may be of a higher order, but often their behavior can be
approximated as a first or second-order lag plus dead time.

Instantaneous Process
The dynamics of this class of processes is negligible. That is, the output follows
changes in input so quickly that the process always remains at steady-state, for all
practical purposes.

First-order Lag
The output of a first-order process follows the step change in input with classical
exponential rise. The model, parameters, and transfer function for this class of
processes are

Process model: dy/dt + y = Kpx

where
x = process input
y = process output
Kp = process steady-state gain
= time constant

5
First-order Lag (continued)

Transfer function: Gp(s) = Y(s)/X(s) = Kp/(s + 1)

Block diagram:

Kp

X(s) Y(s)
s+1

Dynamic parameters:

Steady-state gain Kp = final steady-state change in output/change in input


Time constant, : time to reach 63.2% of final value in response to a fixed (i.e.,
step) change in input
Examples of first-order lags include many sensor/transmitters, final control
elements, and numerous processes. The step response of a first-order lag is shown in
Figure 2.3.

Y Output

final 98%
value
86%

63.2%
of final
value
Time

Figure 2.3
Step Response of a First-order Process

6
Second-order processes
Some processes are inherently second order, including a spring/mass system, an
inductor/capacitor system, a U tube manometer, and so on. Such processes have the
following characteristics.

Process model: 2d2y/dt2 + 2dy/dt + y = KpX

where = time constant of the second-order process


n = 1/ = natural frequency of the process
= damping ratio
Kp = steady-state gain

Transfer function: Gp(s) = Y(s)/X(s) = Kp/(s2 + 2ns + n2)

Block diagram:

Kp

ns + n2
X(S) Y(S)
s2 + 2

A typical step response of a second order processes is shown in Figure 2.4.


Response

< 1 (Underdamped)

Input

= 1 (Critically)
damped

> 1 (Overdamped)

Time

Figure 2.4
Step Response of Second-order Processes

7
Two first-order lags in series, in which the output of the first process is the input to the
second, may be described by as a second-order process model which may be represented
as

Block diagram:
K K2

1


X(s) Y(s)
s+1 s+1
1 2

Process model: 12d2y/dt2 + (1 + 2)dy/dt + y = K1K2x

A comparison of this equation with that of the inherent second-order model gives

= time constant = (12)1/2


= (1 + 2)/(12)1/2 1.0 for two first-order processes in series
Kp = process gain = K1 K2

Dead Time or Transport Delay

For a pure dead-time process whatever happens at the input is repeated at the output
d time units later, where d is the dead-time. For example, consider the flow of a liquid
through an insulated pipe having a cross-sectional area A and length L at a volumetric
flow rate q. At steady state the temperature of the liquid at the entrance x will be the same
as the liquid at the exit of the pipe. If the temperature at the entrance changes, the change
will not be detected at the exit until d seconds later. This dead time is simply the time
required for the liquid to flow from the entrance to the exit and is given by

d = volume of pipe/volumetric flow rate = LA/q

The process model for pure dead time is given by

y(t) = x(t - d)

where y is the exit temperature.

The transfer function of the pure dead-time element is

Gp(s) = Y(s)/X(s) = e-ds

8
The response Y for an arbitrary input X is shown in Figure 2.5.

Input

Time

Output

dead time

Time

Figure 2.5
Response of a Dead-time Element

Higher-order Processes and Approximate Models

Most processes have many dynamic elements, each having a different time constant.
For example, each mass or energy storage element in a process can provide a first-order
dynamic element in the model. For some processes there can be many elements and
therefore the order of the model can become very large. Fortunately, it is possible to
approximate the behavior of such high-order processes by a system having one or two
time constants and a dead time. More specifically, when one or two time constants
dominate (i.e., are much larger than the rest), as is common in many processes, all the
smaller time constants work together to produce a lag which resembles pure dead-time.

9
2.1.4 Basic Feedback Control

If there are no disturbances, no control is needed once steady-state operating


conditions are achieved. Disturbance inputs cause outputs to deviate from desired values;
therefore, one or more control inputs must be changed in order to maintain the outputs at
the set point. A control strategy is required to achieve this objective. In this context,
control strategy may be defined as a set of rules by which control action is determined
when the output deviates from set-point. The control strategy is an algorithm or equation
that determines controller output (to the actuator) as a function of the present and past
errors, and is executed by the closed-loop system controller. This controller works in
conjunction with several other essential components which define the closed loop system,
as shown in the figure below.

Disturbance input
Controlled
Set point + Error M(s) variable
R(s) G(s) G(s) G(S)
_ c a

Controller Actuator Process

Manipulated variable

C(s)
m
G(s)
m

Sensor

A feedback control loop consists of the process for which it is desired to control, along
with actuators, sensors, and a controller. The actuator normally takes a low-energy
signal, and transforms and amplifies it in order to produce a corresponding action. It is
this action which is the manipulated or controlled input to the process. A sensor typically
takes a high energy signal from the measureable output of the process, and transforms it
into an equivalent low-energy signal. This signal is sent back to a comparator via the
feedback path, where it is often subtracted from the set-point. The output of the
comparator is the error, and the controller acts on the error to produce an output which is
dictated by the control strategy. This output is delivered to the actuator, and the cycle
continuously repeats itself in an attempt to achieve and maintain the set-point.

In some applications the actuator and sensor dynamics are negligible compared with
the dynamics of the process, in which case the block diagram can be simplified. Also,
sometimes the process transfer function includes the actuator and sensor dynamics, as
shown in the block diagram of Figure 2.6.

10
Disturbance
input

R(s) + Cm
+
_ G c (s) G p(s)
Set +
point Controller Process model
including actuator
and sensor dynamics

Figure 2.6
Block Diagram Showing a Composite Process Model

Basic Control Strategy

The basic control strategy in conventional feedback control is to compare the


measured variable with the desired value of that variable and if a difference exists, to
adjust the controller output to drive the error toward zero. The hardware that performs
this function is the automatic controller. The operation of the ideal three-mode controller
is described by the following equation (Ash and Deshpande 18) :


t
m(t) = K e(t) + 1 e(t)dt + d de(t) + ms (2.1)
c I dt
0

where

Kc = proportional gain
e(t) = error
I = integral time, seconds or minutes
d = derivative time, seconds or minutes
ms = steady-state controller output that drives error to zero
(this is sometimes called bias) The transfer function of the ideal controller
equation is

M(s) = G(s) = K 1 + 1 + s
E(s) c c I s d (2.2)

11
The ideal controller equation has a pure differentiator in it and therefore is not physically
realizable. The transfer function of most commercial controllers is

G(s) = K 1 + 1s
dS + 1
d S + 1
c c (2.3)
I

where is a constant << 1, typically in the range of 0.01 to 0.1.

To illustrate the effect of the proportional (P), proportional integral (PI), and
proportional + integral + derivative (PID) modes on control, the response of a first-order
system with dead time operating under the three types of controllers to a step change of
magnitude L in load is sketched in Figure 2.7.

KLL

1. Period of
C 3. oscillation, p

2.

Css
0
4.

Step upset of
magnitude L
occurs
Figure 2.7
Step Response of a First-order + Dead Time System to Load Change

12
Figure 2.7 shows the following characteristics of the three controller modes:

Curve (1): no control.

Curve (2): proportional only control: gives rise to a steady-state offset (or steady-state
error).

Curve (3): proportional + integral control: eliminates steady-state offset; however, has
slightly higher peak offset and slightly longer period of oscillation as compared to
proportional only control.

Curve (4): proportional + integral + derivative control: reduces the peak offset as well
as the period of oscillation over PI control.

It is important to note that although the response shown in Figure 2.7 is typical of
many systems, other systems may be affected differently by PID control. The nature of
the closed-loop response is determined largely by the dynamics of the particular process.
It is not meant to imply that all processes under closed-loop control will respond as
shown in Figure 2.7. However, it can be said that often times when proportional only
control is used, the closed-loop systems response can be well behaved and reasonably
fast compared to that of the open-loop process; that is to say, it can have improved
steady-state error and rise times. Typically, low values of proportional gain will give rise
to a heavily damped response and a large steady-state error (for example, if a unit step is
applied, the output may settle a long way from unity). Increasing the gain can affect the
response by reducing the offset, but increasing the gain too high can make the system
very oscillatory. If the gain is set sufficiently high, continuous oscillations can occur
(marginal stability), or even instability (an unbounded output). Instability occurs when
the roots of the denominator of the closed-loop transfer function lie to the right of the
imaginary axis on the s-plane, as shown in Figure 2.8.

When too large of a steady-state error becomes a problem, this can be eliminated with the
addition of integral action. However, introducing I-action tends to slow the closed loop
response; that is, it increases settling and rise times. Because of this affect that integral
action has on response times it is seldom used on its own as a control strategy.

The final control mode, derivative action, has no affect on steady-state error (because the
rate of change of the error signal at steady-state is zero) but during a transient it will tend
to speed up the response times. Derivative action is never used on its own. It is most
often used to compliment proportional and integral action to give the full PID control and
occasionally with the proportional mode for PD control. From Figure 2.7, the PID
controller is seen to give the best response of the three controller types. However, the

13
derivative mode is sensitive to process or measurement noise, is less forgiving of process
parameter changes, and is generally more difficult to tune. For these reasons PI
controllers are used in a vast majority of industrial applications (Ash and Deshpande 20) .

Imaginary
axis

S plane

Stable
region Real axis

Figure 2.8
Stable Region in the S Plane

14
2.2 Computer Process-Control Hardware and Software Concepts

2.2.1 Conventional Control versus Computer Control

In a conventional control loop all the signals are continuous functions of time, as
shown in Figure 2.9(a). For example, pneumatic control loops employ air pressure for
signal transmission, and electronic control loops use continuous voltage or current
signals. In general, these types of signals are referred to as analog signals and are
characterized by the fact that they contain information on the continuous variation of the
signal with respect to time.

Continuous signal Discrete signal


Signal

Signal

Time Time
(a) (b)

Figure 2.9
Continuous and Discrete Signals

15
The block diagram shown in Figure 2.6 represents an analog system. As explained
earlier, the measuring element senses the value of the controlled variable and transmits
this value to the controller. In the conventional (or analog) control system this value is
compared with the set-point in order to produce an error signal. The controller acts on
this continuous error signal, thereby producing a continuous control signal. This control
signal is fed to the actuator in order to reduce the error.

In contrast to conventional control systems, the sampled-data (or digital) control


system deals in part with discrete signals (Figure 2.9(b)). The term conventional
control is used to describe pure analog control systems because most newly
implemented controllers are digital in nature; that is; they will be implemented within a
digital computer which controls the process. In a digital compensator, the error signal is
formed inside a computer program. It therefore consists of a stream of sequential (or
discrete-time) data, usually in binary form. This enters the compensator, which uses a
numeric algorithm (within the computer program) to process the data. The limitations on
the algorithms complexity are dictated only by the memory size of the processor and its
speed of computation. In practice, many digital controllers are simply computer
implementations of analog controller designs. The main advantage of discrete computer-
based systems is their ability to provide additional information which can be used for
process monitoring, fault detection and alarms, and also their flexibility in terms of ease
of program modification. This becomes particularly important with MIMO (Multi-Input
Multi-Output) processes, or systems having a large number of control loops.

Because computer controllers deal with the discrete representation of a continuous


signal, the continuous form of a signal must be first converted into a digitized form
before it can be used by the computer. In order to measure the shape of a time domain
signal with a digital computer, a precisely timed sequence of individual amplitude
measurements, or samples, must be taken. These measurements must be taken close
enough together in time to adequately reproduce the characteristics of the continuous
signal.
After the signal is sampled there is a loss of information, but fortunately not all of the
information in a signal is required for closed-loop control. However, a certain amount of
information is required to sufficiently reconstruct the signal. A fundamental rule of
sampled data systems is that the input signal must be sampled at a rate greater than twice
the highest frequency component in the signal. This is known as the Shannon Sampling
Theorem, and the critical sampling rate is called the Nyquist Rate (Johnson 84) .
Violating the Nyquist criterion is called undersampling and results in aliasing. This
effect can be seen in a sampled signal as an apparent frequency of oscillation which
appears lower than that of the original signal. In the context of a control system design,
that would mean sampling at a minimum of double the highest cutoff frequency of the
system (open- or closed-loop). In practice, it is common to sample at about 10 times the
highest cut-off frequency present (Johnson 84). By oversampling, or sampling at a rate
several times higher than the minimum specified by the Nyquist rate, the signal resolution

16
and noise rejection can be enhanced. Too long of a sampling interval will lead to
degradation of the accuracy of the chosen control algorithm and possibly even closed-
loop instability, because the sampling process effectively introduces a dead-time into the
response.

Digital control systems have the same fundamental closed-loop elements as analog
control systems, however the controller block can be expanded to include additional
blocks representing the analog-to-digital and digital-to-analog conversions processes.
(Figure 2.10).

Computer
Set
point

Controller
Actuator Process
equation

Analog-to Digital-to
digital analog
converter converter

Measured
variable Controlled variable
Sensor

Figure 2.10
Typical Computer Control System

In the context of real-world control engineering, the process is always likely to be of a


continuous-time nature. The terms digital and analog therefore distinguish between
control systems that have some discrete-time (or digital) signals and those in which every
signal is of a continuous-time (or analog) type. In the case of the digital control system,
the analog signal representing the measured variable is converted into a digital form by a
device called an analog-to-digital converter (A/D converter). Likewise, the discrete
output signal from the controller equation (a.k.a., the compensator) is converted to analog
form by a device called a digital-to-analog converter (D/A converter). In between the
course of being converted from an analog form to a digital form and then back again to
an analog form, the measurement signal is processed by a computer program. A
flowchart for a generic program which might to do this by using a single-loop
proportional control algorithm is shown in Figure 2.11. From this flowchart a control
program could be developed by using a suitable programming language.

17
Start

Read control algorithm constants, steady-state algorithm output to


actuator, sampling period, and set point

Give D/A command to set actuator for steady-state operation

Give A/D command to read measured variable

Convert measured variable from a binary value to a decimal value

error = set point - measured variable

Controller output = (Controller gain) x error + bias

Give D/A command to forward controller output to actuator

YES NO
Is sampling period
up?

Figure 2.11
Flowchart of a Typical Computer Control Program

18
The program routine which calculates the controller output is essentially mimicking the
function of an analog compensator, but uses a discrete rather than a continuous error
signal to generate an output. In addition to acting purely as a compensator, instructions
may also be included in the program which; check that the read values are within known
limits of magnitude and rate-of-change, average several values to perform rudimentary
noise filtering, and/or check the output value against process limits (and modify it if
necessary).
It is noteworthy that the controller output is maintained at its last value until the next
one is calculated, so that a graph of the controller output against time resembles a series
of d.c. levels (a staircase type of waveform).

The real power of a computer in control applications lies in its ability to facilitate the
implementation of improved or advanced control strategies that would be impractical
with analog hardware. The development of model-based strategies requires the ability to
mathematically represent and analyze computer-control loops. As discussed earlier, this
can be done through mathematical modeling of the system dynamics. However, the
control-strategy parameters are determined from analysis of the system dynamics in the
discrete-time domain rather than the continuous time domain.

2.2.2 Computers for Process Control

The remainder of this section will focus on the use of computers as controllers in
process control loops, rather than analog controllers. This is because the design and
development of the Control-System Demonstrator Project will utilize a specific type of
computer controller, called a micro-controller. Before discussing the specifics of the
micro-controller, some general concepts about computers will be introduced, and some
different categories of commercial controllers will be looked at.

Although the focus of this report is on computers used in systems to monitor and
control processes, an introduction to a few important ideas which apply to all digital
computers may be useful for the designer who is interested in choosing a controller for a
computer-controlled control-system application. This information is included here
because it introduces background information which is related to the design of a
computer control program which will be discussed later on in this report. Those who
already have a basic understanding of the conceptual organization of a general computer
system may wish to skip to section 2.2.3 Practical Controller Implementation.

19
Conceptual Organization of a Computer System

There are three basic parts, or subsystems, in any computer system, no matter how
large or small. They are the central processing unit (or CPU), memory and the
input/output (I/O) interface (Ash and Deshpande 39) .

Central Processing Unit

The CPU is the heart of a digital computer, the subsystem which performs the actual
execution of instructions. The CPU also controls sequencing of operations and controls
communication with the memory and I/O interface subsystems.
Within the CPU are a number of hardware devices called registers which are used for
temporary storage and manipulation of numbers and instructions. Registers are made up
of electronic circuits called flip-flops which are two-state devices that can be changed
from one state to the other at any time on command from control circuits within the CPU.

Within digital computers, numbers are represented and manipulated in binary form, in
which each digit (called a bit) is either zero or one. The number of flip-flops in a single
register correspond to the number of bits the CPU transfers to or from memory in a single
operation. This number is called the word length of the computer. Thus a word is a
group of binary digits used to represent a number or instruction.

Arithmetic and logical operations are performed within the CPU on numbers
contained in registers according to instructions contained in other registers. Programs are
groups of instructions, usually stored in adjacent locations in memory, that are intended
to be executed sequentially or in another order specified by the instructions themselves.

Numbers are represented internally in one of two forms: fixed point or floating point.
In fixed-point (also called integer) representation, one word is used to represent a single
whole number or integer. In floating-point (also called real-number) representation,
numbers are stored and manipulated in the equivalent of a scientific notation format, in
which a number is represented by a characteristic, or exponent and a mantissa, or
fraction. Arithmetic operations on floating-point numbers are accomplished either with
special, extra cost floating point hardware or software. Many low cost CPUs are only
capable of performing fixed-point arithmetic, and floating-point arithmetic is usually
used only for applications requiring substantial numerical calculations.

20
Memory

The memory subsystem may consist of a number of different physical devices, but
conceptually there are only two types of memory: high-speed, random access memory
(often called main memory) and bulk memory (often called extended memory). (Ash and
Deshpande 40)
A typical computer has many thousands of words of main memory and can access
each and every word on a completely unconstrained (i.e., random) basis. The CPU can
read or change the contents of any selected word in main memory in a single operation.
A high-speed random-access memory that permits both read and write operations by the
CPU is called RAM (for random access memory). Another kind of memory, which the
CPU can read but not change, is called ROM (for read only memory). Variations that can
be reprogrammed by off-line devices are called PROM (for programmable ROM) or
EEPROM (for electrically erasable programmable ROM). A computer controller used
for this project will be discussed in subsequent sections (called a BASIC StampII) and
uses EEPROM memory.

Bulk (or extended) memory has a much greater storage capacity, and generally resides
on peripheral devices. These type of devices are much slower to access than main
memory and cannot be accessed for read and write operations in the same random
manner which main memory can. The most common devices for bulk storage are the disk
or magnetic tape. Not all computer systems have bulk memory, but they all have main
memory.

Input/Output (I/O) Interface

The I/O interface is the subsystem through which the CPU communicates with the
outside world. There are two basic kinds of I/O: operator I/O and process I/O (Ash and
Deshpande 41).

Operator I/O communicates with people. Process operators use such devices as
pushbuttons, thumb-switches, and keyboards to input data or commands to the computer,
and they receive information from the computer via such devices as CRT (cathode-ray
tube) screens and LED (light-emitting diode) numerical displays. Computer operators
and program developers use computer terminals ( a combination of CRT screen and
keyboard, mouse, etc.) to communicate with the computer.

Process I/O communication takes place directly between the CPU and all of the
process devices. Typical devices may include sensors, limit switches, tachometers, and
shaft encoders for input; control valves, motor starters, stepping motors, and motor-speed
controllers for output. Process devices (and some operator devices) are connected to the
computer through two parts of the I/O interface called the analog and digital I/O
subsystems.

21
To convert process input signals (usually voltages or currents from transmitters) to the
digital (numerical) form needed by the CPU, the analog I/O subsystem uses the
previously mentioned analog-to-digital (A/D) converter. The analog I/O subsystem also
contains hardware used to condition the analog signals, for example, circuits to reject
noise and smooth the input.

For output, the analog I/O subsystem converts numerical (digital) outputs from the
CPU into analog voltages or currents by means of the digital-to-analog (D/A) converter.
As previously discussed, a D/A converter sustains its output value until it is changed.

Hardware and Software

A complete computer system, regardless of whether it is being used for process


control, data processing, or any other function, consists of two basic kinds of
components: Hardware and Software.

Hardware refers to all physical components of the system such as the CPU, main
memory, bulk memory devices, the I/O interface and peripheral I/O devices such as
terminals. In essence, anything which can be touched is classified as hardware.

Software refers to all programs which are necessary for the operation of the system.
Software can be classified into three categories:

1. Application software consists of programs for tasks directly related to the primary
functions of the system. In a real-time process control-system, the application
software might include:

A program to read analog inputs into memory.


A program to convert these raw analog inputs to engineering units.
A program to compute control outputs based on input values.
A program to set analog outputs.
A program to print an operating log.

Also included in this category are utility programs for functions such as calculating the
square root of a number. Application programs are written by the user.

2. System-support software consists of programs that aid the user in the development
of application programs. Programs in this category are almost always vendor-
supplied. Included are:

Language processors and linkers which convert programs written in high level
languages such as FORTRAN into machine-language programs.
Editors, which facilitate the creation or modification of user-written programs.
Programs which aid in debugging

22
3. Executive software, often called the operating system of the computer, consists of
programs that oversee or supervise the actual operation of the system while it is
running, performing such functions as:

Scheduling and starting the execution of system-application programs.


Allocating main memory and loading programs into main memory from bulk
memory.
Overseeing I/O operations

The control engineer is primarily concerned with designing the application software.
However, the limitations and capabilities of the system-support and executive software
will often influence design of the application programs. For example, in many cases it is
necessary for the application program instructions to be consistently executed at the same
speed. This is required in order to maintain a constant sampling time. An executive
program called a real-time operating system is capable of controlling program execution
in such a way that instructions are carried-out in a time consistent manner. If an
application program is being run under a non real-time operating system, it may be
necessary to add external hardware (such as a timer) and instructions in order to maintain
a constant sample time.

The Stamp II micro-controller package used in this project alleviates the need for the
designer to choose the separate I/O interfaces, CPU, memory, and software. The
package is turn-key, where these components are all mounted on a small printed
circuit board. The executive software has been pre-programmed by the manufacturer,
and the system support and application software are included with the purchase of the
Stamp. The instruction set of the Stamp programming language PBASIC includes
operations which make I/O operations easy to perform.

Summary

In general, the design of a computer control system will involve the selection of both
hardware and software components. It is important to note that the selection of these two
categories of components are not independent. The type of hardware used can place
constraints on the type of software used and vice-versa, and therefore it is an important
consideration in the design of a computer controlled system.

In subsequent sections, a specific type of hardware component known as a micro-


controller will be discussed in detail, along with the application software used to instruct
its operation. A micro-controller will be used for this project as the computer-controller
for a selected process. This type of controller was chosen for this project due to its
simplicity and low cost. However, there are other types of controllers which are often
used in practice to control processes. The next section will briefly present some
commonly-used controllers, as well as introduce the important features of a micro-
controller.

23
3.2.3 Practical Controller Implementation

As discussed earlier, controller design is centered on obtaining a transfer function to


represent the compensator of the controller, be it analog or digital. This section will give
a brief introduction to different methods for implementing the compensator (as
represented by a transfer function in the system block diagram). A specific type of
controller, the 8bit micro-controller, will be introduced in more detail.

Practical Analog Controllers

Although it is possible to make non-electronic analog controllers (pneumatic, or even


purely mechanical in some situations), they are now rare in new equipment. One
example of a widely-used type of analog controller is the op-amp based PID controller
(Dutton, Thompson, Barraclough 375) .
Figure 2.12 shows this type of controller having (from equation 2.3) Kc = -(R2/R1 +
C1/C2), Td = -C1R2/Kc, and Ti = -KcR1C2.

C2

R2

R1 -

C
1

Figure 2.12
An Op-Amp Based Analog Controller

24
The type of circuit shown in Figure 2.12 has been used throughout industry for a number
of years to implement PID control. Its main disadvantage is that it is susceptible to high
frequency noise. In addition, it is not possible to set the values of all three controller
terms independently of each other. Most transfer functions can be generated by circuits
such as these, but they suffer from the normal op-amp limitations such as drift (the slow
variation of output voltage with temperature). They also lose out in comparison with
digital controllers in respect of being less flexible (in software it is possible to change
parameters easily, or even change the complete control strategy). However, they still
have a place in low-cost equipment and in controllers which must operate on a very fast
process, for which the sampling times of digital controllers are too long.

Practical Digital Controllers

Many newly designed control systems will be digital in nature, and there is now a
considerable choice of technologies for the implementation of digital controllers.
Practically all digital controllers have one thing in common...they are based on some
form of computer processor. The following are some of the possibilities (Dutton,
Thompson, Barraclough 375) :

A small general-purpose computer such as a PC can be used as a computer


controller. In order to interact with field devices, the PC will need to have
appropriate input-output cards installed which contain necessary filters, A-D and D-A
converters, and circuits which generate the necessary current or voltage outputs to
drive the field devices. Such a computer is able to act as an operator interface and
display and it can be programmed in a high-level language. Its balancing
disadvantages are that it expensive for use simply as a controller because of its
keyboard, screen and large memory provision. For use in an industrial setting, PCs in
rugged, hose-proof cases are available, but at an extra cost.

The PLC controller is mostly used for industrial applications. The architecture
of the PLC is similar to that of a general-purpose computer, however the PLC differs
in that it is designed to be placed in areas that can have substantial amounts of
electrical noise, electro-magnetic interference, mechanical vibrations, and extreme
temperatures. A typical PLC consists of a CPU, input and output modules, and
requires a CRT programming unit. The input and output modules form the interface
by which field devices are connected to the controller. The purpose of the interface is
to condition the various signals received from or sent to external (field) devices. The
PLC is often chosen to control sophisticated manufacturing processes where a large
number of inputs and outputs are needed to be managed.
Traditionally, PLCs have been used for the control of processes which required
equipment to be switched on and off in the correct sequence, at the right time, or
when a particular combination of events occurs. This form of control is known as
sequential on-off control. In contrast, a continuous controller generates an output

25
that can take on any value between zero and its maximum value. PLCs are
programmed in ladder logic which is a diagrammatic form of expression for on-off
control situations in which requirements are drawn as if they are to be implemented in
the form of relays, switches and other symbols. This method was originally
introduced to make PLC programming easier for electrical staff whose previous
experience was with hardware devices rather than software.
Note: In the discussion of the project follow, it will be shown that the project design
requires the use of both sequential on-off control and continuous control.

A dedicated microprocessor-based system (known as a micro-controller) is


usually less expensive than a general-purpose computer. This type of system can be
designed to include only the features required for control purposes. Like the PLC, it
is capable of performing both sequential and on/off control. In contrast to the PLC
however, a micro-controller is an inexpensive single-chip computer. This means that
the entire computer system lies within the confines of the integrated circuit chip. The
micro-controller also has features similar to those of a standard personal computer. It
is capable of storing and running a program (its most important feature) and contains
a CPU, RAM, ROM, I/O lines, serial and parallel ports, timers, and sometimes other
built-in peripherals such as A/D(analog-to-digital) and D/A(digital-to-analog)
converters. However, unlike a PC which has been designed to interface with a human
being, a micro-controller has been designed to interact with electronic devices.
The program for implementing the control algorithm in a micro-controller is usually
stored in EEPROM, with parameters normally being user-settable. The setting was
traditionally performed via a keypad or thumb-wheel switches on the unit itself, but it
is now common for many controllers to be distributed throughout a plant, and to be
networked to a central computer which sets both the parameters and set-points, as
well as monitoring process outputs. This type of an arrangement is known as a
SCADA system (supervisory control and data acquisition). Figure 2.13 is a schematic
of a general SCADA system.

Operators
Console

data transmission

Micro- Micro- Micro-


Controller Controller Controller
1 2 N

Process Unit 1 Process Unit 2 Process Unit N

Figure 2.13
A SCADA System Controlling Multiple Processes

26
At the bottom of the SCADA architecture are the data acquisition features
measurements for the purpose of feedback and operator information. Next up the line are
the control features, including manual commands and continuous and sequential
automatic algorithms. At the top level are the supervisory aspectsthe user interface,
trending, report generation, and so on.

The control project to be discussed later on will be seen to be a special case of the
SCADA type, utilizing just a single micro-controller.

Types of Micro-Controllers

There is a large variety of micro-controllers on the market today. The different types of
devices can be divided into three general categories (Predko 2):

Embedded (self-contained) eight-bit micro-controllers


16- to 32-bit micro-controllers
Digital Signal Processors (DSP)

The most important feature of the embedded or (eight-bit) micro-controller is that all
of the necessary resources(memory, I/O, etc.) are available on the chip. The bit number
of a micro-controller refers to the controller CPUs word length. In an application circuit,
the only other components which need to be provided are the power and clocking.
The primary role of this type of micro-controller is to provide inexpensive,
Power

Embedded Micro-controller
Device I/O

Processor
Variable
Memory

Clocking

Application UserI/O
Software &
Application Software
Input
Program
Memory

Figure 2.14
Essential Features of an 8-bit Micro-Controller
27
programmable logic control and interfacing to external devices. Thus, they typically are
not required to provide highly complex functions.(Fig 2.14)

Although a single embedded micro-controller is often unsuitable for use as a controller of


a large-scale process involving many control loops, it can be used for control in
applications where only a small number of process variables need to be measured, and
where the dynamics of the process are relatively slow. Typically, 8-bit micro-controllers
are unable to sample fast enough to capture signals that are faster than 1kHz (Predko 2) .
Still, this is sufficiently fast to be used in many applications (slow process, such as
temperature control). Again, the Basic Stamp II embedded micro-controller will be
introduced later in this report, and will be used as the controller for this project. Several
years ago, Parallax Inc. developed the BASIC Stamp and it has subsequently become
popular amongst both hobbyist and commercial product designers. The eight-bit Stamp
micro-controller has features which make it simple to connect to the real world and
very easy to program.

The 16 to 32-bit micro-controller is different from the embedded(eight-bit) type in


these devices rely completely on external memory, instead of built-in program and
variable memory.

Digital Signal Processors take sample data from an analog system and calculate an
appropriate response. The unique feature of this type of micro-controller is that the
hardware that performs the DSPs calculations run at a very high speed in order to sample
at an extremely fast rate. DSPs generally have on-board A/D converters which is a
feature not normally present on embedded micro-controllers.

In recent years, the embedded(8-bit) micro-controller has become increasingly popular


for use in many familiar commercial products such as electrical appliances and cellular
phones. Presently, more than five hundred million micro-controllers of this type are built
into the products that we buy each year (Predko 3) .

28
2.3 Background Summary

The background information introduced in the previous sections was introduced in


order to familiarize the reader with the essential elements of a complete control system.

For the engineering student enrolled in a typical introductory-level control systems


course, the work will generally be focused on methods of improving a systems
performance by making use of information contained in the process transfer function.
The transfer function contains the necessary information which will allow the student to
change the undesirable open-loop systems dynamics by incorporating it into a closed-
loop system. Using the process transfer function, the student learns how to create a
transfer function model for what has been previously been referred to as a compensator.
Thus, many students perspective of a control system is that of a schematic diagram
consisting of a series of blocks; each block representing a transfer function. This type of
schematic contains all the information needed for the student to design an appropriate
compensator, but does not provide component-level detail of the elements of an actual
system.

For example, the closed-loop block diagram of Figure 2.6 shows an input called R(s)
which is the set-point; however, the schematic provides no information as to the means
by which the system will receive the input, or how the system is to interface with a
human operator or other devices. The reason for this is that the block diagram schematic
is not meant to provide a detailed look at system hardware, but rather to provide a
pictorial representation of a system and its associated control structure and compensators.
The application of block diagram reduction techniques, or block diagram algebra,
condenses the Laplace transform system equations, together with any controller
equations, into a form suitable for design studies. The inverse transformation is used to
investigate a response in the time domain. Therefore, it is a mathematical tool and not a
blueprint for the construction of an actual device.

An ongoing theme throughout the remainder of this report will be to expand the block
diagram of Figure 2.6 with greater detail as hardware components for an actual system
are introduced. An effort will be made to explain the relationship that each hardware and
software component has to this fundamental block diagram. Eventually, the
fundamental diagram will evolve into a detailed schematic for an actual system; in this
case, a control system demonstrator which can be used to illustrate some of the ways that
PID compensation can affect a systems response.

This report was designed to be used as a resource for the interested student who is
currently studying control systems theory and wishes to learn about issues associated
with the design and construction of a practical closed-loop feedback control system. As
such, the details of the design of the control-system will be presented so that the student
has the information necessary to modify the system in order to improve it. For example,

29
a student may wish to tune PID parameters in order to try to achieve specified
performance goals. The student could then use this report to find the details of the
computer program which will allow him/her to make the necessary changes of the PID
parameters. The report will also be useful for the instructor who uses the project for
classroom demonstrations. Operating procedures, a bill of materials, and troubleshooting
suggestions will be presented which should aid the instructor in using the device,
maintaining it, and replacing parts if necessary.

30
CHAPTER 3

PROJECT OBJECTIVES AND SPECIFICATIONS

3.1 Problem Statement

As discussed in the introduction of this report, there is arguably a need for a practical
device capable of demonstrating important principles taught in control systems courses
offered by the College of Engineering at Western Michigan University. The details of the
design and development process for a project aimed at satisfying this need will be
presented throughout the remainder of this report. The following statement explicitly
states the purpose of this project which is:

To conceive, design, and develop a working system which will allow students to see
with their own eyes the demonstration of theoretical principles taught in control systems
courses. Also, the device should be a platform which will allow future students to have
the opportunity to design and test their own (more advanced) control strategies for
improving the systems performance.

The purpose of this device is to demonstrate engineering control systems course


principles, and therefore will hereafter be referred to as the Control System
Demonstrator; or more succinctly, by the acronym CSD.

3.2 Device Specifications

In order for the control system demonstrator to satisfy the needs of both the student
and instructor, it must possess certain qualities. The following paragraphs describe what
specifications an effective control system demonstrator should have. These specifications
will be used as a guideline for the selection of process and electronic hardware
components.

31
Specifications

The process should be chosen such that it is simple to understand and will not
confuse students or obscure the principles which the CSD must demonstrate. A
simple process should also help to reduce the cost. The components needed for the
project should be selected with the goal of keeping the overall cost between 300 and
400 dollars.

The system should yield a response which is fast enough to complete an entire
demonstration in a typical class period; if the process has too much lag, the students
may lose interest and the instructor will not have time to demonstrate all the desired
principles. The CSD should also be easy to use. The method of changing the system
parameters should be simple and fast; the device should automate itself through the
demonstration.

The overall appearance of the CSD should suggest quality and have aesthetic
appeal; the demonstrator should be relatively light-weight and small so that it is easy
to transport by a single person.

Appropriate data collection software should be selected to interface with the


demonstrator to produce a clear, readable, real-time, high resolution display of the
trend of the controlled process variable; in addition, the output data must be able to be
saved so that the response from one demonstration may be compared to the response
from another demonstration.

The user should be able to input and change system parameters via a graphical
human-machine interface (HMI); the interface should be a PC screen with virtual
instrumentation which will allow students to easily view current parameters and
inputs from the instructor/operator.

The CSD should be able to demonstrate both open- and closed-loop control. An
open-loop control mode should demonstrate how a disturbance input can cause the
steady-state system response to deviate from the set-point. A closed-loop mode
should be able to show the benefits and problems associated with each PID
parameter; namely, the relationship between proportional control and steady-state
error (an increase in proportional gain should result in a decrease in steady-state error
but also have a more oscillatory response). The CSD should be able to demonstrate
how PI control eliminates steady-state error, but also introduces additional lag into
the response. The system should be designed to demonstrate full PID control,
including the value and/or problems associated with derivative control.

32
The system should allow for the use of the sensor at different locations with
respect to the actuator. This will allow the CSD to be able to demonstrate the concept
of dead-time; the response measured by the sensor nearest to the actuator should have
less lag than the response measured by the sensor when it is farther away from the
actuator.

The system should include a mechanism for introducing a disturbance input to


the process. The disturbance should be controlled and repeatable so that each
response to a disturbance can be compared based only on the variation of known
parameters such as PID gains, without being confounded by variation in the
magnitude or duration of the disturbance. In order for a valid comparison of responses
to be made, the system will also need to be reset to the same initial state for all
demonstrations.

The housing of the demonstrators electronic components should allow the


components to be easily seen. The ability to view the electronic sub-assemblies will
allow students to see how a block diagram of a theoretical system is implemented
with hardware.

Table 3.1
Summary of Specifications

Specification Description

1 easy to understand process


2 inexpensive
3 fast response
4 easy to use
5 high quality
6 attractive appearance
7 lightweight
8 highly visible and readable output
9 capable of demonstrating open-loop control
10 capable of demonstrating PID closed-loop control
11 multiple sensor locations
12 capable of producing a disturbance input
13 good visibility of system components

33
3.3 Final Design

This section will introduce the device which has been designed to meet the stated
specifications.

Each hardware component of the system will be explained in terms of the


corresponding relationship to the aforementioned block diagram for a computer-
controlled closed-loop system:

Disturbance
input

R(s) + Cm
+ Gp (s)
_ Gc (s)
Set +
point Controller Process model
including actuator
and sensor dynamics

Figure 3.1
Block Diagram Showing a Composite Process Model

3.3.1 Process Description

The process to be controlled will be discussed first. A schematic of the process model
is shown below. The schematic represents the process of air being heated by an
electric resistance element as it flows through a pipe. The dotted line marks the boundary
of the system, which includes the inner surface of the pipe.

34
T

Q in

Qout

m
. .
m
heat generator
T1 T2

Figure 3.2
Model of the Control System Demonstrator Process

A physical law which governs the behavior of this process is the First Law of
Thermodynamics; which is also known as the Conservation of Energy Principle. It
states that energy can neither be created or destroyed; it can only change forms. In fact,
this principle is true for any system undergoing any process. In terms of an energy
balance this means,

Total energy Total energy Change in the


entering the leaving the = total energy of
system system the system

Although energy can be transferred to or from a system by several means such as


work, heat, and mass flow, the type of energy transfer which is of interest for this system
is the form of energy which can be transferred as a result of a temperature difference; i.e.

35
heat or thermal energy. In this case, the energy balance expression above can be written
specifically as a heat balance, and the conversion of electrical energy into thermal energy
is treated as heat generation (Cengel 15) . Heat generation refers to the conversion of
electrical energy into heat energy, rather than the creation of heat from nothing (which is
not possible according to the first law of thermodynamics). Letting the amount of heat
transferred during a process be denoted by Q,

Qin Q
out + Egen = E thermal,system (3.1)
}

}
Net heat
transfer
}
Heat
generation
Change in thermal
energy of the system

The process of Figure 3.2 is representative of a number engineering devices such as


water heaters and car radiators, and involves mass flow in and out of the system. This
type of process is known as an open process or control volume. The amount of mass
flowing through a cross-section of a flow device per unit time is called the mass flow rate
(Cengel 15) .

For a steady-flow system with one inlet and one exit, the rate of mass flow into the
control volume must be equal to the rate of mass flow out of it. When kinetic and
potential energies are negligible, which is usually the case, the steady-flow energy
balance for such a system reduces to (Cengel 16) ,
. . (3.2)
Q = m Cp( T - T )
2 1

where,

.
Q is the rate of net heat transfer into or out of the control volume
.
m is the mass flow rate

Cp is the specific heat at constant pressure


T is the temperature of the air entering the system
1
T is the temperature of the air at a location further down the pipe
2

36
Whereas the amount of heat transferred during a process is denoted by Q, the amount
of heat transferred per unit time is called heat transfer rate, and is denoted by Q with an
over-dot (which stands for the time derivative). The heat transfer rate has the unit
Joules/s, which is equivalent to a Watt; a unit of power.

For the process shown in Figure 3.2, the heat generation contribution from the energy
balance equation is provided by an electrical resistance element. In the context of the
control system, this element is the actuator. The actuator converts electrical energy into
thermal energy, and is capable of delivering this energy to the system at a rate defined by
the equation,

2
Power = (Voltage) (J/s) (3.3)
Resistance

voltage resistance element


supply

Figure 3.3
Power Dissipated by Resistor is a Non-Linear Function of Voltage Across Resistor

The resistance element is non-linear since it does not obey the principle of
superposition. Although a development of a mathematical model for the process is
beyond the scope of this report, a simple linear model of the systems actuator (a light-
bulb) could be expressed for a small deviation about a set-point as,

P = m V
where,

m = dP = 2 vo
dV R
vo

P is a small change in resistor's power output


V is a small change in voltage across the resistor
37
The term Vo is the controller output offset, or bias. It shifts the control systems
operating point, and is normally selected to be somewhere in the actuators mid-range of
operation so that it can respond to both positive and negative error signals.

For this process, the variable to be controlled is the air temperature at the location of
the sensor. Ambient air is pulled into the pipe (by some means such as a fan) and heated
by the resistance element. If it is desired to maintain a specific temperature at some
location within the pipe, the actuator must deliver sufficient energy (Egen) to the control
volume to overcome heat losses (Qout) from the system and maintain the total energy
content (Ethermal,system) of the control volume at a level consistent with the desired
temperature. In the context of control systems, this means that the controller will deliver
a voltage to the resistor which has a value dependent on the magnitude of the error and
the nature of the control strategy. As the magnitude of the error changes, the voltage
across the resistor changes, and therefore the power output of the resistor is modulated as
the controller searches for the appropriate rate of heat delivery in order to maintain the
set-point temperature at steady-state. At steady-state, this rate of energy delivery is
equivalent to the rate of net heat transfer as defined in equation 3.2 (Figure 3.4).

. .
m
m
T1 T2

. .
Q = m Cp( T - T )
2 1

Figure 3.4
Equilibrium Energy to System at Steady-State

38
Assuming it is desired to maintain the temperature T2 at a set-point, and the
temperature at the inlet (which is the ambient air temperature) remains constant, the net
heat transfer rate to the control volume which will be required to be delivered to the
system in order to maintain the set-point can be defined solely as a function of the mass
flow rate of the air through the tube. Equation 3.2 shows that as the mass flow rate
increases, the net heat transfer delivered to the system must also increase in order to
maintain the set temperature of T2. Therefore, if the mass flow rate suddenly increases,
the actuators power output must also increase so that it can provide the necessary rate of
heat transfer to the system in order to maintain the set temperature for the increased mass
flow rate. If the actuator does not respond by providing this additional energy, the
temperature T2 will begin to drop. In this case, the change in mass flow rate may be
viewed as acting as a disturbance input to the system which is at equilibrium. Likewise,
the power output of the light bulbs (in the form of heat) is the controlled input to the
process.

There are three different modes of heat transfer present in this process: conduction,
convection, and radiation:

Conduction is the transfer of energy from the more energetic particles of a


substance to the adjacent less energetic ones as result of interactions between the
particles (Cengel 20).
Convection is the mode of energy transfer between a solid surface and the
adjacent liquid or gas that is in motion, and it involves the combined effects of
conduction and fluid motion. The faster the fluid motion, the greater the convection
heat transfer (Cengel 29).
Radiation is the energy emitted by matter in the form of electromagnetic waves.
Thermal radiation is the form of radiation emitted by bodies because of their
temperature. Unlike conduction and convection, the transfer of energy by radiation
does not require the presence of an intervening medium. Energy transfer by radiation
is fastest of the three modes; radiation energy propagates at the speed of light (Cengel
30) .

The modes of heat transfer can each be a factor in the character of the systems
response. For example, when the dominant mode is through radiation heat transfer, its
reasonable to hypothesize that the effect of dead time should be reduced. This is the case
since dead time occurs in systems that have a movement of a material that requires a
finite time to pass from an input to a measured point. Since radiation heat transfer
requires no medium , the effect of dead-time should be reduced depending on how
dominant the radiation heat transfer mode is.

In Figure 3.2, the thermal energy generated by the resistor is delivered to each mass
within the system. Each mass acts as an energy storage element, and the number of these
elements defines the order of the system. Consider again the process of Figure 3.2, this
time with a light bulb acting as the resistor heating element (see Figure 3.5).

39
Tube

light bulb filament coil


temperature
glass sensor

air flow

Figure 3.5
Control System Demonstrator's Actuator, Sensor, and Process

If the actuator, sensor and process are to be considered together, the process has at least
five obvious energy storage elements: the filament, the glass bulb, the air mass flowing
through the system, the sensor and the tube. Each of these elements contributes to the
overall lag in the response of the controlled variable temperature.

40
3.3.2 Description of Components

Figure 3.5 represents the process, actuator and sensor elements of the CSD.
A simplified block diagram of the final design of the system (including controller and
support circuitry) is shown below (Figure 3.6).

12 VDC fan
60 Watt light bulbs RTD
temp. transducer air
flow

high
servo Light voltage input
actuated Dimmer
potentiometer

A/D converter signal


& conditioning
D/A converter circuit
circuit

PWM output
+- 15 VDC digital input
power
supply
BASIC STAMP II

information sent
back and forth Set-point and
through RS-232 link control parameters sent
to Stamp via LabVIEW
virtual control panel
graphical interface

Figure 3.6
Component-Level Detail of the Control-System Demonstrator

A more complete and detailed block diagram of the system and control circuitry is given
in schematic form in Appendix B.

41
As shown in Figure 3.6, the CSD is a computer controlled system. It is a SCADA
configuration, where only a single micro-controller is utilized. The controller selected for
this device is the Basic Stamp II micro-controller.

How a BASIC Stamp operates

The BASIC Stamp II is an 8-bit micro-controller that runs Parallax BASIC (PBASIC)
programs. They have fully programmable I/O pins which act as the computers I/O
interface and are used to connect directly to devices such as buttons, LEDs, speakers, and
potentiometers.
The Stamp I/O pins receive and send TTL (Transistor-Transistor Logic) level
voltages. TTL uses a 5-volt D.C. power supply and represents the two binary states as
follows :
Anything from 0 to 0.8 V D.C. is considered OFF or a binary 0
Anything from 2.0 to 5 V is ON or a binary 1

Using this protocol, the Stamp I/O pins are used to detect the on/off state of input
devices, and/or to drive low current/voltage devices. With just a few extra components,
these I/O pins can be connected to non-TTL devices, such as solenoids, relays, RS-232
networks, and other high current/voltage devices which may be used to control a process.

Architecture of a BASIC Stamp

BASIC Stamps are available in various physical packages, but all versions have the
same logical design, consisting of a 5-volt regulator, resonator, serial EEPROM, and
PBASIC interpreter. A PBASIC program is stored in EEPROM memory, which is read
from and written to by the interpreter chip. This interpreter chip takes the instructions one
at a time and performs the appropriate operation on the I/O pins or internal structures
within the interpreter. Because the PBASIC program is stored in an EEPROM, it may be
programmed and reprogrammed almost endlessly, without the need to first erase the
memory, as with many micro-controllers. To program a BASIC Stamp, you just connect
it to an IBM PC or compatible computers serial port and run the vendor-supplied editor
(system support) software to edit and download a program.

An actual picture of the Parallax Basic Stamp II micro-controller is shown in Figure 3.7.
It contains all the features shown in the schematic of Figure 2.14. For this application,
the Stamp is plugged into a carrier board, which includes a input voltage regulator, and a
small prototype area for temporary circuit construction. The carrier board allows the I/O
pins of the Stamp to be connected and disconnected to field devices quickly and easily.

42
Figure 3.7
The BASIC STAMP II Micro-Controller

The BASIC Stamp II has 16 I/O pins plus two synchronous serial pins for communication
with serial devices, holds 500 to 600 instructions and executes an average of 4000
instructions/sec (Basic Stamp Programming Manual) . These pins acts as both the
Operator and Process I/O interface, as discussed in section 2.2.2.

The analog-to-digital converter

The Basic Stamp micro-controller does not have the on-board capability to convert an
analog signal to a digital signal. A dedicated analog-to-digital converter is required to
perform this function. The A/D converter used for this project is the LTC1298. The
LTC1298 is a 12-bit, two-channel ADC packaged in a small 8-pin chip. Its high
resolution, low supply current, low cost, and small size make it a good companion for the
Stamp in sensor and data logging applications. A schematic of the LTC1298 is shown on
the following page.

43
+5 Volts

0-5V input
CS V input
CLK
. capacitor
CH0
0-5V input LTC1298
CH1 Dout
GND

pin 2 pin 1
pin 0

Connections to BASIC Stamp I/O pins

The analog (0-5V) signal is input to the LTC1298 via either the CH0 or CH1 pin. The
signal is then converted into a digital value and sent back to the Stamp via the Dout pin.

The Stamp can acquire the digital signal sent from the LTC1298 through any of its 16
general purpose I/O pins. The device requires a 5 volt power supply which is connected
to the V input pin. Since the LTC1298 is a 12-bit device, it is capable of representing an
analog signal as 212 = 4096 discrete values. Likewise, an 8-bit device is capable of
representing an analog signal as 28 = 256 discrete parts, and so on. Therefore, as the
number of bits of the a-to-d converter increases, the resolution of the digitized signal
increases. For this application, a 12-bit a-to-d converter was chosen because it provides
the best balance between high resolution and low cost. Temperature trends measured
with the 8-bit a-to-d converter tend to have a staircase-like appearance due to the lower
resolution, and the control action of the actuator tends to be jittery which is undesirable
for this application. Because the error signal is formed by subtracting the measured

44
temperature from the fixed set-point, a high resolution temperature measurement results
in a high resolution error signal. As the resolution of the error increases, smaller
deviations from the set-point are able to be detected, and therefore a tighter control
about the set-point is possible.

The digital-to-analog converter

Although the Stamp does not have the on-board capability to convert an analog signal
to a digital one, it does have the capability to perform the reverse procedure; that is, it is
capable of performing a digital to analog conversion. A procedure known as pulse-width
modulation (PWM) allows the Stamp (a purely digital device) to generate any value of
voltage between 0 and 5 volts on any of its I/O pins. It does this by rapidly switching the
voltage at the output pin from a low value of 0 volts to a high value of 5 volts. Over a
time interval of 1ms, the average voltage can take on any value between 0 and 5 volts,
depending on the ratio of on time to off time. This ratio is called the duty cycle.

An example of what PWM might look like on an oscilloscope for a 20% duty cycle is
shown in Figure 3.8. Here the voltage is high 20% of the time so the average voltage
would be 20% of 5 volts, or 1 Volt, over a 1ms time period.

total on = 20%

total off = 80%

Figure 3.8
20% Duty Cycle

45
The Stamp programming language PBASIC has a built in instruction which makes
generating an analog voltage very easy. The instruction is,

PWM pin, duty, cycles

PIN is a constant, expression or variable in the range 0..15


DUTY is a constant, expression or variable in the range 0..255
CYCLES is a constant or a variable in the range 0..255 representing the number
of 1 ms cycles to output

For example, if the instruction where to be specified as PWM 14, 100, 1


the result would be 1.96 Volts output from Stamp pin 14 for 1 cycle.

The voltage is calculated as,

Voltage = duty
* 5V
255

which, for this example is,

Voltage = 100
* 5V = 1.96V
255

For this project, DUTY will be defined as a variable. Since the value of DUTY is directly
responsible for the magnitude of the controller output, it must have a relationship to the
control algorithm used for closed-loop PID control. This relationship will be discussed
and developed in subsequent sections.

The Sensor

The temperature transducer selected for the CSD is the Omegafilm resistance
thermal detector (RTD). The working principle behind the RTD is that the electrical
resistivity of a metal changes with temperature. Some metals have a very predictable
change in resistance for a given change in temperature; these are the metals that are most
commonly used for fabricating an RTD. Platinum is by far the most popular due to its
near linearity with temperature, wide temperature operating range, and excellent long
term stability (Anderson 139) . Most importantly, for this application it was desired to
have a transducer with a fast response relative to the dynamics of the process
(approximating an instantaneous lag as discussed in section 2.1.3). When this is the case,
the transducer dynamics become effectively negligible with respect to the dynamics of
the process. The time constant for the chosen RTD is 0.1 second, which was expected to
be much faster than that of process. In order for the RTD to be used as the temperature

46
sensor for this application, additional support circuitry was required as shown in
Appendix D. In this circuit, the RTD acts as a variable resistor in a voltage divider
configuration. As the resistance of the RTD changes with temperature, the voltage across
the RTD changes. The circuit is calibrated over a temperature range of interest such that
the low end of the temperature range provides a voltage of zero and the high end of the
range provides a value of 5 volts.
Any temperature in the measurement range will be converted by the circuit into a value
between 0 and 5 volts. This temperature range of interest is called the span. It will be
shown in subsequent sections that as the span decreases, the resolution of the temperature
measurement increases. The temperature sensor circuit was designed to provide a 0 to 5
volt output in order to be compatible with the a-to-d converters input. The RTD
transducers requires an external power supply. Therefore, the circuit acts as a signal-
conditioner and transmitter circuit. This circuit and transducer work together in order to
perform the function of temperature sensor. Appendix D shows the physical hardware
which represents the sensor block of Figure 2.6

The procedure for calibrating the sensor will be discussed in the next section.

The DC Controlled Dimmer


This circuit uses a DC input voltage between 0 and 10 Volts to control an AC output
voltage varying between 0 and 115 Volts. The AC signal is then delivered to the light
bulbs, and the power output of the bulbs is controlled by modulating the DC input signal.
The dimmers DC input signal is the Stamp micro-controllers output generated by the
PWM command. Since the maximum output voltage of the Stamp is 5 Volts, an op-amp
circuit is needed to amplify the signal by a value of 2. The amplifier is located on the
A/D and D/A circuit. A schematic diagram of this circuit is shown in Appendix C. The
light dimmer used for this project is the Velleman K8003, which comes in kit form and
must be assembled (See Appendix C). In terms of the closed-loop block diagram, the
dimmer and light bulbs are the physical hardware which is represented by the actuator
block.

Having introduced the previous components, the controller block shown in Figure 3.9
can be further decomposed, revealing the function of these hardware components in
terms of the controller block diagram. The decomposition of Figure 3.9 is shown in
Figure 3.10.

set
point
Analog Error Analog
temperature G(s)
c
0-115 Volt AC
measurement Control Signal

Figure 3.9
Controller
47 Block Diagram
LABVIEW

set
Analog point CONTROLLER
0-5 Volt Analog
temperature 0-10 Volt
analog PWM DC 0-115 Volt AC
measurement
LabVIEW Program control signal Control Signal
Stamp
Stamp
+
A/D D/A Amp
control equation Dimmer
conv. conv. x2
-

Figure 3.10
Expanded View of the Controller Block Diagram

Other Components

The Airflow Tube

The CSD airflow channel is a 4 inch outside diameter, 1/8 inch thick, and 33 inch long
Plexiglas tube. The length and thickness of the tube were chosen somewhat arbitrarily,
and the diameter was chosen to accommodate the size of the light bulbs. The material of
the tube was selected to be Plexiglas to allow observers to see the location of the sensor
with respect to the actuator, and to make visible the amount of light produced by the
bulbs. Although the primary purpose of the light bulbs is to produce heat, the light
produced by the bulbs is a good visual indicator of the amount of action produced by the
actuator. In terms of the process, the material and dimensions of the tube are significant
in that the tube is an energy storage element and therefore affects the systems response.
For example, if a different material had been chosen for the tube, it would probably have
a different heat capacity and thermal conductivity than Plexiglas, which along with the
size of the pipe are variables affecting characteristics of the response of the open-loop
process.

48
The Fan

The means for providing airflow through the tube is a Panasonic FBL series 12V
DC fan. Since the fan is responsible for producing the disturbance input by increasing
the airflow rate through the tube, a fan capable of operating at different speeds and
producing an adequate volume of airflow was desired. The fan selected for the CSD
produces a maximum of approximately 32 CFM airflow, and can be operated in a voltage
range of 7-13.8 Volts. By adjusting the voltage input using a potentiometer, the speed of
the fan can be changed. The CSD process has been designed such that under normal
operating conditions, the fan operates at 50% power. When the fan produces the
controlled disturbance, the airflow is increased to a value of 75% of its maximum output.

The potentiometer controlling the fan speed is rotated by a computer-controlled servo-


motor. This allows the Stamp micro-controller to repeat the magnitude of the disturbance
input with greater precision than any human operator could possibly attain. It also allows
the computer to reset the process state to the same initial conditions for each
demonstration which is necessary in order to make comparisons of different responses.

Since the goal of the CSD is to demonstrate the affect which different PID values can
have on the closed-loop system response, the computer control of the disturbance input
has the ability to remove variation in the disturbance. This means that if compared
responses differ, the difference will be due primarily to the changing of PID values
and/or environmental conditions, rather than being confounded by variation in the
disturbance. The automatic control of the fan also relieves the instructor from having to
manually adjust the fan, thus making the CSD easier to use.

Power Supply

The power supply for the CSD is capable of providing 15VDC and up to 1.5 amps of
current. It transforms standard 115V AC mains supply from a wall outlet into DC
current, but also has terminals to provide unconverted 115V AC to components that
require AC such as the light bulbs. The DC current needs of the CSD are very small,
only needing about 0.2 Amps. A power supply capable of providing much more than this
was selected to supply the necessary current to drive any additional components that may
be added by students in the future.

Light Bulbs

Two 60 Watt light bulbs were selected to act as the thermal energy supply to the
system. Earlier, it was stated that a resistor in series with a voltage supply could be used
to provide thermal energy to the system. Unlike a resistor, a light bulb produces visible
light, and the efficiency of the light bulb depends on how much of the bulbs power
output is in the form of visible light. For the CSD, a low efficiency light bulb is actually
desirable, since the primary function of the bulb is to produce heat, rather than light.

49
Two 60W bulbs were selected rather than a single 120W bulb because 60W bulbs are
smaller, allowing for the use of a smaller diameter tube.

System Construction

The circuit components shown in Appendix D and C were soldered together on a


printed circuit board (PCB), and the system was wired together as shown in Appendix B..
The overall closed-loop block diagram for the system is shown in Figure 3.11. The wires
which carry the signals labeled are pointed-out by magenta arrows. The actual form of
the assembled system hardware is illustrated in Figure 3.12.

Figure 3.11
System Block Diagram

50
Figure 3.12
Actual Hardware Implementation of the System Block Diagram

51
3.3.3 Testing the System: Two Key Components

The proper functioning of two key interfaces is necessary for the CSD to work
properly. The first of these is the interface between the LTC1298 analog-to-digital
converter and the Stamp micro-controller. The other crucial interface is the power output
delivery from the Stamp to the dimmer circuit. This section briefly describes the
procedure for testing these interfaces, and includes two short PBASIC test programs for
reference. These test programs will be useful for helping those who may be interested in
the inner-workings of the CSD to understand the final control program which will be
presented later on.

Test 1: The Stamp Power Output Interface

This test involves the following components: The Stamp microcontroller, the A/D
D/A circuit, the dimmer, and the light-bulbs.

The goal of this test is to write a program that will output several voltages in the
range of 0-5V from Stamp I/O pin 14, and measure the corresponding output voltage
from the dimmer. These measurements will then be used to establish a relationship
between the program variable DUTY and the 0-115V AC output voltage of the dimmer
(which is the input to the light-bulbs). This relationship will then be used to write the
PBASIC code necessary to generate the proper controller output for a given error and
control strategy. The development of this code, as well as a simple control program will
be discussed in the next section.

Earlier, the PBASIC instruction PWM was introduced. This instruction commands
the Stamp micro-controller to generate a 0-5V analog output voltage on any of its 16 I/O
pins. The magnitude of the voltage is controlled by the DUTY variable, where again, the
command is:
PWM pin, duty, cycles

PIN is a constant, expression or variable in the range 0..15


DUTY is a constant, expression or variable in the range 0..255
CYCLES is a constant or a variable in the range 0..255 representing the number
of 1 ms cycles to output

By specifying the variable duty as,


Duty(drive) = drive * 255/100

52
the variable drive now determines the magnitude of the voltage output. This form of
DUTY is intuitive because drive can take on any value between 0 and 100, and can be
thought of as representing the percent of full scale output of the controller. A plot of
DUTY vs. DRIVE is shown in Figure 3.13. The Stamp owners manual states that the
voltage at the output pin varies linearly as a function of DUTY, as shown in Figure 3.14.
Then, the relationship between DRIVE and output voltage is shown in Figure 3.15.

53
Duty vs. Drive
300

250

200
duty(drive)

255 .
drive
100 150

100

50

0
0 20 40 60 80 100
drive

Figure 3.13

Voltage vs. Duty


5

3
duty .
voltage

5
255

0
0 50 100 150 200 250
duty

Figure 3.14

54
Voltage vs. Drive
5

3
drive .
255
voltage

100 .5
255

0
0 20 40 60 80 100
drive

Figure 3.15

If the actuator was to be driven by a 0-5V DC signal, then the equation describing the
linear relationship between voltage and DRIVE in Figure 3.15 would be used in the
computer program to specify the controller output. However, in this case the light-bulbs
require a 0-115 volt AC supply. The purpose of the low voltage DC signal is to control
the high voltage AC signal which controls the light-bulb power output. Therefore it is
necessary to establish a relationship between the variable DUTY and the AC output
voltage of the dimmer. Unlike the relationship between the output pin voltage and
DUTY, it was not known whether the sought-after relationship was linear or not. This
relationship would have to be established experimentally by measuring several values of
output voltage which correspond to the DUTY values specified to generate the given
voltage. This was done, and the results are shown below in Figure 3.16.

55
Table 3.2

Program 0-10VDC Dimmer Program


Variable Dimmer AC
(duty) Input Output
Voltage Voltage
(RMS)
0 0 0 again:
15 0.58 0.04 PWM,duty,40
30 1.16 0.04 pause 50
45 1.75 0.04 goto again
60 2.34 0.04
75 2.95 0.04
90 3.53 0.92
105 4.12 1.55
120 4.69 7.9 first indication of visible light
135 5.3 15.5
150 5.87 26.71
165 6.47 39.75
180 7.1 55.1
195 7.65 73.1
210 8.24 88.1
225 8.82 102.2
240 9.39 111
255 10 116.8

Dimmer Input-Output

140 12

120
10
Dimmer AC Output Voltage

Dimmer DC Input Voltage

100
8 Dimmer AC Output
Voltage (RMS)
80
6
60
0-10VDC Dimmer
Input Voltage
4
40

2
20

0 0
0 50 100 150 200 250 300

Input Variable (Duty)

Figure 3.16
Dimmer Input Voltage Vs. Duty

56
Figure 3.16 is a plot of two measured signals which are both functions of the variable
DUTY. The green curve represents the 0-10V DC dimmer input signal which is simply
the 0-5V DC Stamp output signal amplified by a factor of two. The results validate the
assumption that this signal is linear. The magenta colored curve is the AC voltage output
of the dimmer, which is clearly non-linear. The two signals are superimposed thereby
showing the transformation of the input signal(green) into the output signal(magenta) as
it is passed through the dimmer. The data which is plotted in Figure 3.16 is also shown in
tabular form below the graph. The table indicates that visible light from the light-bulb
was not present until the (RMS) voltage of the dimmers AC output signal reached a
value of approximately 8 volts.

As stated earlier, a test goal was to establish a relationship between the PBASIC
program variable DUTY and the 0-115V AC output voltage of the dimmer. Ideally, this
relationship would be linear. This is the case for the function describing the relationship
between DUTY and the 0-5V and 0-10V DC signals, but the function describing the AC
voltage as a function of DUTY is not so simple. A polynomial greater than 5th order
would be necessary to accurately represent the experimental data as a function. However,
if the domain of the function is restricted to values of DUTY greater than 120, then the
function can be represented approximately as linear. Since visible light is not generated
by the light-bulbs for values of DUTY less than 115, this portion of the input domain can
be ignored. The data which will then be used to determine AC output voltage as a
function of duty is the yellow highlighted portion of the table of Figure 3.16. A plot of
dimmer output voltage is shown in Figure 3.17, as well an equation determined by linear
regression for the line representing the experimental data.

Linearized Dimmer Output

140

120
AC Dimmer Output Voltage

100
y = 0.9062x - 106.19
80 Measured AC
Voltage
60
Linear
40 (Measured AC
Voltage)
20

0
0 50 100 150 200 250 300
-20
program variable (duty)

Figure 3.17
Duty Domain for a Linear Dimmer Output

57
As shown in Figure 3.17, the equation representing the AC dimmer output voltage as a
function of duty can be expressed as,

y = 0.9062x 106.19

and will be used in conjunction with the PID compensator algorithm to generate the
proper controller output for closed-loop feedback control. The development of the PID
algorithm will be shown later, but for now it is known that the algorithm will generate an
output dependent on the error and that the output will be stored in a variable called drive.
The value of drive may take on any value between 0 and 100, and represents a percentage
of the controllers full scale output. Once the value of drive has been generated by the
compensator algorithm, it can then be used in the above equation to determine the value
of DUTY necessary to generate the proper voltage at the selected output pin of the Basic
Stamp. For example, if the compensator algorithm were to calculate that the value of
drive for a measured error should be 75%, then DUTY would be found by solving for x in
the following equation:

drive * (Ymax ) + 106.19


= X
0.9062

where,
Ymax = the dimmer full-scale voltage output = 116.8
drive = 0.75
X = duty

By solving for x, it is seen that a duty value of approximately 213.8 is needed to produce
75% of full scale output of the controller. In this way, duty will be calculated for any
value of drive between 0-and-100%, and the general PWM instruction can be specified
as,

pwm 14, drive * ( 116.8 ) + 106.19 , 50


0.9062

In actuality, this statement will have to be modified slightly due to a limitation in the
Stamps arithmetic computational capabilities. In the background section of this report, it
was noted that some computers support floating point math, while others do not. The
BASIC Stamp does not, therefore only integer values can be used in computations. The
Stamp truncates the fractional part of a number during intermediate calculations, and any
value less than one and greater than zero will be truncated to zero. Therefore, if drive

58
were to be specified as some number between 0 and 1, the above statement would be
calculated as,
pwm 14, 0 * ( 116 ) + 106 , 50
0

which is obviously unacceptable. In order to keep the fractional part of any number, it is
necessary to multiply the number by base ten and raise it to an appropriate power. This
will shift the decimal place to the right so that the fractional part for which it is desired to
keep will be shifted into the integer portion of the number. This procedure has
limitations though. The Stamp has an 8 bit CPU, and is capable of using two 8 bit
registers to store a single number. This means that the largest number that the Stamp can
use in computations is 216 = 65,536. This puts limitations on how much decimal
accuracy can be obtained by multiplying by ten. For example, if it is desired to use the
number 75.783 in a calculation, it would be necessary to multiply by 103. This would
result in a value of 75783, and would overflow the register. Care must also be taken that
intermediate calculations do not overflow the register. This puts severe limitations on the
Stamp to make calculations with a great degree of accuracy. The shifting method to
preserve accuracy is used on our equation, while keeping these ideas in mind. Then our
new statement becomes,

drive*117+10619/91 (3.4)

Writing the statement this way is not an error. The Stamp always performs calculations
from left to right, without any regard to the normal order of operations. Addition and
subtraction are given the same priority as multiplication and division. In this final form,
it is necessary to specify the variable drive as having a value between 0 and 100. For
example, if again it is desired to produce 75% of the actuators full scale output, then:

drive = 75

pwm 14, drive*117+10619/91, 50

becomes,

pwm 14, 213, 50

This instruction commands the Stamp to generate an output voltage of (213/255)*5 or


approximately 4.18 DC Volts on output pin number 14. This results in (0.75)*116.8 or
87.6 AC Volts (RMS) being delivered to the light-bulb. Although drive is a constant in
this example, it will be a variable in the final closed-loop control program. Its value
depends on the nature of the error, and the output of the PID algorithm.

59
As shown, the procedure for defining a relationship between the dimmer output and
the variable duty required that voltage measurements be taken, and a calibration curve
established. This method works well, but variation of the power source can create a
source of calibration error. The value of duty for a given drive was established by
equation 3.4. It is based on parameters obtained from the linear-regression line for the
experimental data, and Ymax the measurement of the wall voltage. For a standard 115V
outlet, the voltage will be near 115V, but its exact value can vary depending on time and
location. The measured value of voltage vs. duty could possibly be slightly different for
different outlets, and therefore the calibration curve would be slightly different. However,
a robust closed-loop control system has the ability to minimize the affect that the
variation of parameters has on the system response, and the variation in the source
voltage is expected to be small. Therefore, it is expected that the effect due to any
calibration error should also be small.

60
Test2: Acquiring a Digital Temperature Value

This test involved the following hardware components: the RTD, the RTD sensor
circuit, the LTC1298 a-to-d converter, and the Stamp micro-controller.
The goal of this test was to write a PBASIC program in which the Stamp commands
the LTC1298 a-to-d converter to digitize the analog signal generated by the RTD circuit,
and to send the digitized temperature data to the Stamp. The PBASIC code which was
written to achieve this goal is presented in Appendix E as Test Program 1.

The first part of the test involved determining whether or not the newly constructed
RTD circuit was functioning properly. This was done by energizing the circuit, and using
a digital voltmeter to determine whether or not the circuit was generating the required 0-
5V signal in response to temperature changes. Using a hair dryer to blow hot air over the
RTD, a voltage measurement at the circuits output indicated that a changing signal in
this range was being generated. At this point, a measured temperature could not yet be
determined since the measurement was being expressed in terms of volts, and the circuit
had not yet been calibrated.

Having first determined that the analog RTD circuit was generating a signal, Test
Program 1 was downloaded to the Stamp. Whenever a program is downloaded from the
PC to the Stamp, the Stamp will immediately execute the program with no further action
required from the user. The program specifies that the digital temperature data be sent
back to the PC via the serial connector cable, and displayed. At this point, the output is a
meaningless number in the range of 0-4095, since this is the range of decimal numbers
the 12-bit a-to-d converter will assign to any 0-5V analog signal that it receives. In order
for this number to be meaningful, the sensor must be calibrated and scaled for
temperature.

The sensor was calibrated by first placing the RTD in a vacuum-insulated thermos
filled with ice water. The temperature of the water was then measured by using a Dr.
DAQ data logger and temperature sensor. The Dr.DAQ is a low cost data acquisition
system and is manufactured by Pico Technology. The temperature sensor comes pre-
calibrated and consists of a precision thermistor in a rubberized housing with a 6 foot
lead. The sensor has a resolution of 0.1C and an accuracy of 0.3C, and is suitable for
taking temperature measurements of liquids. By running the Dr. DAQ data acquisition
software, and Test Program 1 simultaneously, the ice-water temperature as measured by
the calibrated temperature sensor and the output from the analog-to-digital converter (as
measured by the RTD) were displayed side by side on the PC screen. The Dr. DAQ
temperature sensor and RTD were tied together to ensure that the RTD would be
calibrated based on the same temperature being measured by the Dr. DAQ sensor. Once
the temperature of the ice-water had stabilized at 34F, the left calibration trim-pot on the
RTD-conditioning circuit(as seen in Fig 3.12) was then rotated until the temperature
display read, channel 0: 0 . This resulted in the low end of the a-to-d converters
span (zero) being equivalent to 34F; a temperature which was chosen since it is lower
than any temperature expected throughout the process at any given location or time.

61
Next, a similar routine was performed in which hot water was used to set the high end
of the a-to-d converters span. Before heating the water to the temperature that would
define the high end of the span, the maximum process temperature needed to be
measured. This was done to ensure that the high-end of the span would be greater than
the highest temperature possibly generated by the light-bulbs, thereby enabling the
measurement of any temperature which may exist at any point and time within the
process. At an ambient room temperature of approximately 74F , this maximum
temperature was determined to be approximately 90F as measured by the Pico
temperature sensor nearest the fully actuated light bulb. The Pico temperature sensor and
RTD were then submerged in a water-bath which had been arbitrarily heated to a
temperature of 139F, a temperature sufficiently higher than the maximum expected
process temperature. The a-to-d converter was adjusted such that the output shown on
the display indicated a maximum value of 4095. The value 4095 corresponds to the
maximum output of the 12-bit a-to-d converter, and represents the maximum temperature
which may be measured by the RTD; that is, 139F.

The RTD temperature sensor circuit (Appendix D) was designed to have a linear
response. Therefore, the temperature vs. the numeric output of the a-to-d converter
should ideally have a response as shown in Figure 3.18, where y = span/4095 + 34.
The span is (139-34) = 105.

Ideal Temperature Sensor Output

160
Te 140 139
m y = 0.0256x + 34
pe 120
rat 100
ur
80
e
De 60
g.
40
F 34
20
0
0 1000 2000 3000 4000 5000
a-to-d numeric output

Figure 3.18
Span is 105F

62
In order to test the linearity of the circuit, a series of temperature measurements were
taken over the interval of 34-to-139F, and plotted as shown in Figure 3.19. The results
validate that the measured temperature versus the numeric output of the a-to-d converter
is indeed approximately linear over this temperature span.

Experimentally Determined Temperature vs. A-


to-D Converter Output

160
140
120 2
R = 0.9993 measured
Degrees F

100 temperature
80
60 Linear
40 (measured
temperature)
20
0
0 1000 2000 3000 4000 5000
Numeric Output of A-to-D Converter

Figure 3.19
Experimental Temperature Sensor Response

The experimental results validate the assumption that the following equation,

y = (105/4095)*X + 34 0.0256*X + 34 (3.5)

may be used to represent the relationship between the measured process variable
(temperature) and the numeric output of the a-to-d converter. All that remains is to
convert this equation into a suitable form such that it can be used in a computer program.

The Stamps inability to deal with floating point numbers means that the value 0.0256
must be multiplied by 10^4, such that it is converted into the integer value 256. By doing
this, the accuracy of the constant 0.0256 is preserved. However, now another problem
presents itself. The variable X (as shown in equation 3.5) is an integer which can take on
any value between 0 and 4095. The intermediate calculations which take place from left
to right are each stored in a memory register capable of storing numbers no greater than
2^16 = 65,536. When 0.0256 is expressed as 256 such that,

y = 256*X + 340000

63
the memory register for the variable y will overflow for any value of x between 0 and
4095. The overflow problem can be eliminated by shifting the decimal place of 0.0256 to
the right by two places, rather than 4. This results in the equation,

y = 2*X + 3400 (3.6)

since everything to the right of 2 will be truncated. Since the largest possible value for X
is 4095, the largest value which y may be is 11590. This number is less than the
maximum allowable number of 65,536, therefore the problem of overflow has been
corrected. However, now a new problem surfaces. The number of 11590 can be
interpreted as the real temperature value of 115.90 degrees Fahrenheit (later on, it will be
shown that another computer program implemented on a PC and capable of floating point
math will be used to acquire the integer number from the Stamp and convert in into a
floating point number; such as 115.90). The problem is, according to the exact
temperature equation, when X is 4095,

y = (105/4095)*4095 + 34 = 139

This indicates that the actually temperature is approximately 23 degrees higher than the
temperature which the computer control program would use as a basis for any control
action. Likewise, the temperature acquired and used by the Stamp would be inaccurate
over the entire measurement span by varying degrees.

The purpose of the CSD is to demonstrate the characteristics of the system transient
and steady state response to disturbance inputs and set-point changes. It compares these
responses in order to demonstrate the effect which changing PID parameters can have.
From this perspective, it is not important whether or not the temperature indicated truly
represents the actual temperature. However, if it were necessary to design a control
system to accurately measure and maintain a temperature, then this truncation error could
be a problem . For example, Figure 3.20 shows the error for the situation just described.
Over the span of 0 to 139 degrees, the a-to-d input variable X changes from 0 to 4095.
Likewise the error due to truncation varies over the span, and Figure 3.20 shows the error
as a function of X. The function representing truncation error indicates that the error
increases with increasing temperature. The truncation error is zero at 0 degrees and
approximately 23 degrees at 139F. In terms of control, if it were desired to accurately
(in this context accuracy refers to the ability not only to maintain a small steady state
error, but also to accurately measure the controlled variable) maintain a set-point, then it
may be impossible to eliminate steady-state error by simply adjusting compensator
values. For example, if it were desired to accurately maintain a set-point temperature of
74 degrees, then from equation 3.5 this would correspond to an analog-to-digital decimal
number input of,

74 = (105/4095)X +34

solving for X,
X= 1560

64
This calculation shows that the a-to-d output would be equal to 1560 if the actual
temperature was to be 74 degrees. However, if equation 3.6 is used to calculate
temperature for a given X, then the computer will believe that it has reached the set-point
of 74 degrees when X = 2000.

7400 = 2X +3400
solving for X,
X=2000

In reality, this value of X corresponds to a true temperature of,

True Temperature = (105/4095)*2000 + 34


True temperature 85F

Assuming the controller is maintaining its perceived temperature at the set-point at steady
state, in reality there will be a true steady state error of 85-74 = 11F. This problem
shows how steady-state error cannot be eliminated by implementing, for example,
integral control because the computer cannot see the error. This goes to show that,
compensation is ineffective unless the system is capable of accurately measuring the
controlled variable.

Relative Error
30
Actual Temp - Digital Temp

20
105 . ( ( 2 .X 3400 ) )
X 34
4095 100

10

0
0 2000 4000
X
A/D output

Figure 3.20
Measurement Error Increases With Temperature

65
Having made note of this potential for inaccuracy, there is an easy way to correct this
problem. Figure 3.21 below shows the temperature conversion equations for two different
spans. The equation for the blue line is based on a span of 105F. The low and high
temperature values which were chosen to define this span where selected somewhat
arbitrarily, with the only criteria being that these values be respectively less than and
greater than any temperature expected to exist at any time or place within the process.
The temperature equation resulting from this arbitrarily selected span, and the
corresponding difficulties implementing this equation in the Stamps fixed point
arithmetic were just discussed. In contrast to this equation, the function describing the
pink line is easily implemented in fixed point arithmetic, and results in a high degree of
accuracy. Here, the values selected to define the high and low values of the span were
not selected arbitrarily. These boundary values were selected such that the span divided
by the resolution of the a/d converter (4095) would be an integer when multiplied by 100,
where:

Temperature = [(157-34.15)/4095]*X + 34.15


= 0.03*X + 34.15

and when multiplied by 100,


Temperature = 3*X +3415 (3.7)

Comparing Temperature Equations for Two Different


Spans

180
160 157
Temperature Deg. F

y = 0.03x + 34.15
140 139
120
y = 0.0256x + 34
100
80
60 34.15
40
20 34
0
0 1000 2000 3000 4000 5000
a-to-d numeric output

Figure 3.21

66
An examination of equation 3.7 reveals two important facts. First, the largest output
value this function may produce occurs when X = 4095 and is,

Temperature = 3*4095 + 3415 = 15700


which can be interpreted as 157.00 F

Since this value is less than the maximum value capable of being stored in a memory
register (which is, 2^16 = 65,536), there wont be any overflow problems at any stage in
the calculation. Second, the equation is accurate to two decimal places in terms of the
temperature its measuring. In other words, the indicated temperature and the actual
temperature are the same for all temperatures over the span. This fact is the result of
carefully selecting the (span/resolution) in such a way that the result is an integer when
multiplied by 100, and eliminating the truncation error.

Obviously, the benefits of selecting the span properly are substantial in terms of
maintaining measurement accuracy. In the previous example, it was shown how this can
be done by changing the span from 105 degrees to 122.85 degrees. By doing this, the
accuracy of the temperature measurement was greatly increased; however, the resolution
of the measurement was slightly decreased. The digital representation of an analog signal
is, by definition, a discrete reproduction of something that is continuous. As the
resolution of the analog to digital converter is increased, and the span of measurement is
decreased, and the digital reproduction of the analog signal will increasingly resemble
that of the analog signal. Using the example just discussed, the resolutions can be
compared as,

resolution 1 = (span/a-to-d resolution) = (139-34)/4095 0.0256


resolution 2 = (157 34.15)/4095 = 0.03

This shows that for a given a-to-d converter resolution, that an increase in the span will
result in a decrease in the resolution of the measured variable. What this means in terms
of control is that the computer measurement having resolution 1 (compared to resolution
2) would be able to measure smaller changes in deviation from set-point. With all things
being equal, a higher resolution results in a better measurement and therefore better
control. In terms of this subject and its relevance to this project, the goal was to define
the smallest span which would allow for the measurement of all possible temperature
changes throughout the process, and to choose the span in such a way such that the
resolution (span/a-to-d resolution) is an integer in order to increase accuracy. By
choosing a span of 122.85 F, over the range of 34.15 to 157 degrees, the goal of high
accuracy and resolution was obtained. The CSD is capable of measuring changes in
temperature as small as 0.03 F, and from a control standpoint acting on deviations from
set-point as small as 0.03 F.

With the ability of the CSD to measure temperature and to change temperature
established, the next step in the CSD design process involved writing a short control

67
program to see if and how well the system is able to maintain a set temperature under
closed-loop control. The next section briefly describes the development of this program.

3.3.4 Computer Program Development for Process-Control

The information which was learned from the previous section can now be used for
the development of a computer-control program. This section will describe a simple
PBASIC program which was written to command the Basic Stamp micro-controller
to direct the CSD hardware in such a way that the air temperature at the location of
the sensor is maintained at a set value. The program will demonstrate how
proportional compensation is implemented in software.

Earlier, a function was derived which related the controller output to the PBASIC
program variable duty. It was shown that the variable duty could be expressed in
terms of the variable drive which has value that depends on the nature of the error and
the output of the PID algorithm. This algorithm is the software implementation of the
compensator transfer function. This algorithm will now be explained and
constructed--first for proportional-only (P control), and then later the integral and
derivative terms will be added.

Proportional Action

Proportional action is the basis for the three-mode controller. If the other two,
integral and derivative are present, they are added to the proportional contribution.
Proportional means that the percent change in the output of the controller is some
multiple of the percent change in the error measurement.
This multiple is called the gain of the controller. For some controllers,
proportional action is adjusted by using gain, Kp, while for others a proportional
band, PB, adjustment is used. Both have the same purpose and effect. The
relationship is defined as,

PB = (1/Kp) * 100 per cent

PB is the percentage of the controllers input range which will cause a change of 100
per cent in its output range.

Figure 3.22 illustrates this idea. The response of a proportional controller from an
input/output pointer can take on different values depending on which position the
pointer pivots about. With the pivot in the center between the input and output graph,

68
100 percent change in the error measurement is required to obtain 100 percent change
in output. A controller adjusted to respond in this way is said to have a 100 percent
proportional band. When the pivot is moved to the right-hand position, the
measurement input would need to change by 200 percent in order to obtain full output
change from 0 to 100 percent. This is called a 200 percent proportional band. Thus
the smaller the proportional band, the smaller amount the measurement must change
to cause full actuator output. In other words, the smaller the proportional band, the
greater the output change for the same size measurement change (Anderson 21) .

+50 100

+25 75

% Error 0 50 % Output

-25 25

- 50 0

Figure 3.22
Proportional Band and Controller Output

Proportional band is the concept for which the Drive algorithm for P-control is based
on. In terms of the system at hand, the controllers input range is the 0-5 V signal
which it receives from the temperature sensor. Since the span has been calibrated to
be 122.85F and within the boundaries of (34.15 to 157)F, this means that only
temperatures within this range may be measured. It also means that the set-point
must lie within this range. This implies that the maximum error which is possible is
equal to the span, which is again 122.85F, and occurs when one end of the boundary
is the set-point, and the other end is equivalent to the measured temperature. Any
error which has a value less than that of the span can be expressed as a percent of the
maximum error (or span). For a given PB, the controller output for P-control will
depend on this percent error (as shown in Figure 3.22). For example, if it is desired
for the controller to generate the maximum controller action when the temperature
deviates from set-point by 0.6F, then the required proportional band may be
calculated as,

69
PB = (0.6F/(maximum possible error)*100% = (0.6F/122.85F)*100% 0.5%

and since,

PB = (1/Kp)*100%

this corresponds to a gain,

Kp = (1/0.5)*100 = 200

With the CSD hardware set-up as shown in Figure 3.12, implementing


proportional control is a simple matter of combining the essential features from Test
Program 1, the PWM instruction, and few more lines of code which define what the
controller output should be for a calculated error. The computer program presented in
Appendix G was written for the purpose of controlling the air temperature at any
location within the CSD airflow channel, downstream from the light-bulbs. The code
as presented in Appendix G includes comments, so the interested reader may
understand more of the details associated with the program; the programs essential
operations are briefly discussed here.

The program first acquires a temperature measurement in binary form, converts


the measurement to decimal form, and subtracts the temperature measurement from
the user-defined set-point. The result of this calculation is then stored in a variable
called Error. Error is multiplied by a user-defined variable called P_Gain which
determines the value of proportional gain. The proportional gain multiplied by the
error is added to a constant. This constant is called BIAS and can be used to shift the
controllerss output when there is zero error to any given point in the actuators range
of 0 to 100%. In this case the bias was defined to be 50, or 50% power output of the
light bulbs when the set-point is equal to the measured temperature. The result of this
calculation is then stored in a variable called Drive, which can assume any value
between 0 and 100 (%). The value of Drive is then used in conjunction with the
PWM instruction to generate the required actuator output as discussed in Section
3.3.3.

This program requires the user to define a proportional gain, rather than a
proportional-band. The gain was set to a value of 200, corresponding to the value
determined in the prior example in which full actuator response is produced at a
0.6F deviation from set-point.

Before downloading the program to the Stamp, the ambient air temperature was
measured and determined to be approximately 80F. The set-point was defined

70
within the program to be 8200, or 82.00 degrees. The program was then downloaded
to and executed by the Stamp. Fortunately, it was discovered from the first trial run
of this program that the CSD was working properly and capable of maintaining a set
temperature.

After a short time, the output display screen indicated that the temperature, which
at the beginning of the test was near 80 degrees, had settled to a value near the set-
point of 82 degrees. Ultimately the temperature neared 82 degrees, but never settled
to a steady value. As the temperature neared the set-point, the light bulb flashed in a
strobe-like manner; quickly turning on and off. This behavior suggested that the gain
(set to 200) had been set high enough to cause continuous oscillations in the closed-
loop response.

The display of the temperature measurement is on the same editor screen used to
create DOS PBASIC programs. In the study of control systems, a great deal of
emphasis is given to the analysis of the trend of the controlled variable as it changes
with time. Although the Stamp editor program is capable of displaying the value of a
measured variable at any given instant in time, it is not capable of displaying data
graphically. A graphical display of the measured variable allows the data trend to be
seen at a glance, as well as important indices of control performance such as settling
time, overshoot, and other criteria as discussed in Section 2.1.4. In addition, there are
other limitations of the BASIC Stamp data analysis and display capabilities which
make it unsuitable to be used as the sole computer controller for the CSD. The
Stamps fixed-point arithmetic causes problems in the calculation of the controller
output value stored in the variable Drive. For example, assume that it is desired to
implement Proportional control using the program shown in Appendix G. Rather
than using a gain of K = 200, assume that it is desired to used a gain of K = 150.
Also assume that the set-point is set to a value of 80.90F, and that at a given instant
the measured temperature is 75.05F. Since the variable Drive is defined as;

Drive = Set-point Measured_Temperature*P_Gain

where,
set-point = 8090
Measured_Temperature = 7505

then,
Drive = 8090-7505*P_Gain (3.8)

which, using the standard order of operations


would be expressed in floating point representation as,

Drive = 100*(80.90 - 75.05)*P_Gain


= (80.90 75.05)*[100*P_Gain] (3.9)

(Expression (3.8) is the form which the Stamp uses to calculated expression (3.9))

71
Therefore, the true Proportional gain is the value of 100 multiplied by the value
stored in the variable P_Gain. Since the Stamp uses fixed-point arithmetic only, only
integers are allowed. That being the case, a Proportional gain of K= 150 would not
be possible since it would require P_Gain to have a value of 1.5, which would be
recognized as a 1 by the Stamp. Likewise, any Proportional gain less than 100 is not
possible since the Proportional gain must be an integer multiple of 100.

A proportional gain of K = 150 could be used, but only at the expense of a loss in
temperature resolution. For example, setting P_Gain = 150

Drive = 8090-7505/100*150
= 585/100*150
= 5*150 (3.10)

Expression (3.10) indicates that the 5.85F deviation from set-point is truncated to a
value of 5 degrees. Compared to the first example, the resolution of the error drops
from 1/100th degree to just 1 degree. At the same time, the resolution of gain
increases from 100 to 1. Neither case was deemed acceptable for the CSD.

Perhaps the best compromise would be;

Drive = Setpoint Measured_Temperature/10*P_Gain (3.11)

It can be shown that expression (3.11) would result in an error resolution of 1/10th
degree, and a gain resolution of 10. This would probably be acceptable, but the use
of an external computer program capable of executing floating-point arithmetic would
allow the calculation of Drive based on the maximum resolution of both gain and
temperature. Also, an external program capable of graphically displaying data was
needed along with an interface allowing the user to graphically input and change
control parameters to the Stamp without having to constantly re-download the entire
program with the new parameters. With this in mind, the data acquisition program
LabVIEW was chosen as the platform for creating an application capable of
satisfying these needs. The next section of this report briefly introduces LabVIEW,
along with some of this software applications built in functions which were used to
develop a SCADA program designed to manage the operation of the CSD.

72

You might also like