Temperature Control Using A Microcontroller: An Interdisciplinary Undergraduate Engineering Design Project
Temperature Control Using A Microcontroller: An Interdisciplinary Undergraduate Engineering Design Project
Temperature Control Using A Microcontroller: An Interdisciplinary Undergraduate Engineering Design Project
Microcontroller Thermistor
line
Relay
PLMA
Displays Heater
Keypad & Drivers
Electronics Enclosure
Figure 3. Schematic of microcontroller board
Figure 2. Temperature controller hardware block diagram
Software on the 6805 implements the temperature con-
The microcontroller, a Motorola MC68HC705B16 (6805 trol algorithm, maintains the temperature displays, and alters
for short), is the heart of the system. It accepts inputs from the set-point in response to keypad inputs. Because it is not
a simple four-key keypad which allow specification of the complete at this writing, software will not be discussed in de-
set-point temperature, and it displays both set-point and mea- tail in this paper. The control algorithm in particular has not
sured chamber temperatures using two-digit seven-segment been determined, but it is likely to be a simple proportional
controller and certainly not more complex than a PID. Some Taking Laplace transforms of (1) and (2) and solving for
control design issues will be discussed in Section 4, however. Ta (s), which is the output of interest, gives the following
open-loop model of the thermal system:
4 The Design Process K (τz s + 1) 1
Ta (s) = Q(s) + T∞ ;
∆(s) ∆(s)
Although essentially the project is just to build a thermostat,
it presents many nice pedagogical opportunities. The knowl- where K is a constant and ∆(s) is a second-order polynomial.
edge and experience base of a senior engineering undergrad- K, τz , and the coefficients of ∆(s) are functions of the various
uate are just enough to bring him or her to the brink of a solu- parameters appearing in (1) and (2).
tion to various aspects of the problem. Yet, in each case, real- Of course the various parameters in (1) and (2) are com-
world considerations complicate the situation significantly. pletely unknown, but it’s not hard to show that, regardless
Fortunately these complications are not insurmountable, and of their values, ∆(s) has two real zeros. Therefore the main
the result is a very beneficial design experience. transfer function of interest (which is the one from Q(s), since
The remainder of this section looks at a few aspects of we’ll assume constant ambient temperature) can be written
the problem which present the type of learning opportunity
Ta (s) K (τz s + 1)
just described. Section 4.1 discusses some of the features of Gaq (s) = = (3)
Q(s) (τ p1 s + 1)(τ p2 s + 1)
a simplified mathematical model of the thermal properties of
the system and how it can be easily validated experimentally. Moreover, it’s not too hard to show that 1=τ p1 < 1=τz < 1=τ p2,
Section 4.2 describes how realistic control algorithm designs i.e., that the zero lies between the two poles. Both of these are
can be arrived at using introductory concepts in control de- excellent exercises for the student, and the result is the open-
sign. Section 4.3 points out some important deficiencies of loop pole-zero diagram of Figure 5.
such a simplified modeling/control design process and how
Im
they can be overcome through simulation. Finally, Section 4.4
gives an overview of some of the microcontroller-related de-
sign issues which arise and learning opportunities offered.
,1 =τ p2 ,1 = τz ,1 τ p1
=
Re
4.1 Mathematical Model
maCa Ṫa = µ1 (Ta , Tb ) (1) values vary with initial conditions and input magnitude. The effect on closed-
loop performance is not too serious, but it gives the student a good idea of
mbCb Ṫb = µ1 (Ta , Tb ) , (Tb , T∞ ) (2) what nonlinearity means and how feedback tends to mitigate its effects.
the desired, or set-point, temperature, C(s) is the compensator This simulation model has proven particularly useful in
transfer function, and Q(s) is the heater output in watts. gauging the effects of varying the basic PWM parameters and
hence selecting them appropriately. (I.e., the longer the pe-
Q(s) K riod, the larger the temperature error PWM introduces. On
Td (s) C(s) Ta (s) the other hand, a long period is desirable to avoid excessive
τs + 1
relay “chatter,” among other things.) PWM is often difficult
for students to grasp, and the simulation model allows an ex-
ploration of its operation and effects which is quite revealing.
Figure 6. Simplified block diagram of the closed-loop system
4.4 The Microcontroller
Given this simple situation, introductory linear control
Simple closed-loop control, keypad reading, and display con-
design tools such as the root locus method can be used to
trol are some of the classic applications of microcontrollers,
arrive at a C(s) which meets the step response requirements
and this project incorporates all three. It is therefore an excel-
on rise time, steady-state error, and overshoot specified in Ta-
lent all-around exercise in microcontroller applications.
ble 1. The upshot, of course, is that a proportional controller
In addition, because the project is to produce an actual
with sufficient gain can meet all specifications. Overshoot is
packaged prototype, it won’t do to use a simple evaluation
impossible, and increasing gains decreases both steady-state
board with the I/O pins jumpered to the target system. Instead,
error and rise time.
it’s necessary to develop a complete embedded application.
Unfortunately, sufficient gain to meet the specifications
This entails the choice of an appropriate part from the broad
may require larger heat outputs than the heater is capable of
range offered in a typical microcontroller family and learning
producing. This was indeed the case for this system, and
to use a fairly sophisticated development environment. Fi-
the result is that the rise time specification cannot be met.
nally, a custom printed-circuit board for the microcontroller
It is quite revealing to the student how useful such an over-
and peripherals must be designed and fabricated.
simplified model, carefully arrived at, can be in determining
overall performance limitations. Microcontroller Selection. In view of existing local exper-
tise, the Motorola line of microcontrollers was chosen for this
4.3 Simulation Model project. Still, this does not narrow the choice down much.
A fairly disciplined study of system requirements is neces-
Gross performance and its limitations can be determined us- sary to specify which microcontroller, out of scores of vari-
ing the simplified model of Figure 6, but there are a number ants, is required for the job. This is difficult for students, as
of other aspects of the closed-loop system whose effects on they generally lack the experience and intuition needed as well
performance are not so simply modeled. Chief among these as the perseverance to wade through manufacturers’ selection
are guides.
Part of the problem is in choosing methods for interfac-
quantization error in analog-to-digital conversion of the ing the various peripherals (e.g., what kind of display driver
measured temperature and should be used?). A study of relevant Motorola application
the use of PWM to control the heater. notes [2, 3, 4] proved very helpful in understanding what basic
approaches are available, and what microcontroller/peripheral
Both of these are nonlinear and time-varying effects, and the combinations should be considered.
only practical way to study them is through simulation (or The MC68HC705B16 was finally chosen on the basis of
experiment, of course). its available A/D inputs and PWM outputs as well as 24 digital
Figure 7 shows a SimulinkTM block diagram of the I/O lines. In retrospect this is probably overkill, as only one
closed-loop system which incorporates these effects. A/D A/D channel, one PWM channel, and 11 I/O pins are actually
converter quantization and saturation are modeled using stan- required (see Figure 3). The decision was made to err on the
dard Simulink quantizer and saturation blocks. Modeling safe side because a complete development system specific to
PWM is more complicated and requires a custom S-function the chosen part was necessary, and the project budget did not
to represent it. permit a second such system to be purchased should the first
prove inadequate.
80 + 0.137
− PID pwm.m 0.05 0.392
Set−point
Temperature
Sum
Compensator
Saturation/
Heater
PWM
S−Function
295.2s+1
G_aq(s) Thermistor A/D Converter
Scale Factor Microcontroller Application Development. Breadboard-
ing of the peripheral hardware, development of microcon-
troller software, and final debugging and testing of a custom
printed-circuit board for the microcontroller and peripherals
Figure 7. Simulink block diagram of closed-loop system all require a development environment of some kind.
The choice of a development environment, like that of the based temperature control system with digital set-point en-
microcontroller itself, can be bewildering and requires some try and set-point/actual temperature display. A particular de-
faculty expertise. Motorola makes three grades of develop- sign of such a system has been described, and a number
ment environment ranging from simple evaluation boards (at of design issues which arise—from a variety of engineering
around $100) to full-blown real-time in-circuit emulators (at disciplines—have been discussed. Resolution of these issues
more like $7500). The middle option was chosen for this generally requires knowledge beyond that acquired in intro-
project: the MMEVS, which consists of ductory courses, but realistically accessible to advance under-
a platform board (which supports all 6805-family parts),
graduate students, especially with the advice and supervision
of faculty.
an emulator module (specific to B-series parts), and Desirable features of the problem, from a pedagogical
a cable and target head adapter (package-specific).
viewpoint, include the use of a microcontroller with simple
peripherals, the opportunity to usefully apply introductory-
Overall, the system costs about $900 and provides, with some level modeling of physical systems and design of closed-loop
limitations, in-circuit emulation capability. It also comes with controls, and the need for relatively simple experimentation
the simple but sufficient software development environment (for model validation) and simulation (for detailed perfor-
RAPID [5]. mance prediction). Also desirable are some of the technology-
Students find learning to use this type of system chal- related aspects of the problem including practical use of re-
lenging, but the experience they gain in real-world micro- sistive heaters and temperature sensors (requiring knowledge
controller application development greatly exceeds the typical of PWM and calibration techniques, respectively), microcon-
first-course experience using simple evaluation boards. troller selection and use of development systems, and printed-
circuit design.
Printed-Circuit Board. The layout of a simple (though
definitely not trivial) printed-circuit board is another practi- Acknowledgements
cal learning opportunity presented by this project. The fi-
nal board layout, with package outlines, is shown (at 50% of The author would like to acknowledge the hard work, dedica-
actual size) in Figure 8. The relative simplicity of the cir- tion, and ability shown by the students involved in this project:
cuit makes manual placement and routing practical—in fact, Mark Langsdorf, Matt Rall, Pam Rinehart, and David Schuch-
it likely gives better results than automatic in an application mann. It is their project, and credit for its success belongs to
like this—and the student is therefore exposed to fundamen- them.
tal issues of printed-circuit layout and basic design rules. The
layout software used was the very nice package pcb,2 and the References
board was fabricated in-house with the aid of our staff elec-
tronics technician. [1] M. Langsdorf, M. Rall, D. Schuchmann, and P. Rinehart,
“Temperature control of a microscope slide dryer,” in
1997 National Conference on Undergraduate Research,
(Austin, TX), April 1997. Poster presentation.
[2] Motorola, Inc., Phoenix, AZ, Temperature Measurement
and Display Using the MC68HC05B4 and the MC14489,
1990. Motorola Semiconductor Application Note AN431.
[3] Motorola, Inc., Phoenix, AZ, HC05 MCU LED Drive
Techniques Using the MC68HC705J1A, 1995. Motorola
Figure 8. Printed-circuit layout for microcontroller board Semiconductor Application Note AN1238.
[4] Motorola, Inc., Phoenix, AZ, HC05 MCU Keypad Decod-
ing Techniques Using the MC68HC705J1A, 1995. Mo-
5 Conclusion torola Semiconductor Application Note AN1239.
The aim of this paper has been to describe an interdisciplinary, [5] Motorola, Inc., Phoenix, AZ, RAPID Integrated Devel-
undergraduate engineering design project: a microcontroller- opment Environment User’s Manual, 1993. (RAPID was
developed by P & E Microcomputer Systems, Inc.).
2 pcb is freely distributable software for UNIX/X11. It is written by