Temperature Control Using a Microcontroller:
An Interdisciplinary Undergraduate Engineering Design Project
                                                 James S. McDonald
                                           Department of Engineering Science
                                                  Trinity University
                                                San Antonio, TX 78212
                                                                                        Electronics enclosure
Abstract. This paper describes an interdisciplinary design                                 Temperature controller
project which was done under the author’s supervision by a                      88 88
group of four senior students in the Department of Engineer-
ing Science at Trinity University. The objective of the project                                                     10.25" Top View
                                                                      4.5"                       Slide Chamber
was to develop a temperature control system for an air-filled
chamber. The system was to allow entry of a desired cham-
ber temperature in a prescribed range and to exhibit over-
shoot and steady-state temperature error of less than 1 de-           1.75"
                                                                                                  16"
gree Kelvin in the actual chamber temperature step response.
The details of the design developed by this group of students,
based on a Motorola MC68HC05 family microcontroller, are              4.5"                       Slide Chamber      6.25" Front View
described. The pedagogical value of the problem is also dis-
cussed through a description of some of the key steps in the
design process. It is shown that the solution requires broad                    Fan     Heater
knowledge drawn from several engineering disciplines includ-
                                                                               Figure 1. Slide dryer mechanical layout
ing electrical, mechanical, and control systems engineering.
                                                                   describe the problem and the students’ solution in some de-
                                                                   tail, and to discuss some of the pedagogical opportunities of-
                     1 Introduction                                fered by an interdisciplinary design project of this type. The
                                                                   students’ own report was presented at the 1997 National Con-
The design project which is the subject of this paper origi-       ference on Undergraduate Research [1].
nated from a real-world application. A prototype of a micro-             Section 2 gives a more detailed statement of the problem,
scope slide dryer had been developed around an OmegaTM             including performance specifications, and Section 3 describes
model CN-390 temperature controller, and the objective was         the students’ design. Section 4 makes up the bulk of the paper,
to develop a custom temperature control system to replace          and discusses in some detail several aspects of the design pro-
the Omega system. The motivation was that a custom con-            cess which offer unique pedagogical opportunities. Finally,
troller targeted specifically for the application should be able   Section 5 offers some conclusions.
to achieve the same functionality at a much lower cost, as the
Omega system is unnecessarily versatile and equipped to han-                            2   Problem Statement
dle a wide variety of applications.
     The mechanical layout of the slide dryer prototype is         The basic idea of the project is to replace the relevant parts of
shown in Figure 1. The main element of the dryer is a large,       the functionality of an Omega CN-390 temperature controller
insulated, air-filled chamber in which microscope slides, each     using a custom-designed system. The application dictates that
with a tissue sample encased in paraffin, can be set on caddies.   temperature settings are usually kept constant for long peri-
In order that the paraffin maintain the proper consistency, the    ods of time, but it’s nonetheless important that step changes
temperature in the slide chamber must be maintained at a de-       be tracked in a “reasonable” manner. Thus the main require-
sired (constant) temperature. A second chamber (the electron-      ments boil down to
ics enclosure) houses a resistive heater and the temperature
controller, and a fan mounted on the end of the dryer blows
                                                                        allowing a chamber temperature set-point to be entered,
air across the heater, carrying heat into the slide chamber.            displaying both set-point and actual temperatures, and
     This design project was carried out during academic year
1996–97 by four students under the author’s supervision as a
                                                                        tracking step changes in set-point temperature with ac-
                                                                         ceptable rise time, steady-state error, and overshoot.
Senior Design project in the Department of Engineering Sci-
ence at Trinity University. The purpose of this paper is to        Table 1 gives a more precise statement of specifications.
       Table 1. Temperature controller specifications              LED displays controlled by a display driver. All these in-
                                                                   puts and outputs are accommodated by parallel ports on the
    Set-point temperature entry                                    6805. Chamber temperature is sensed using a pre-calibrated
    Range                                         60–99  C        thermistor and input via one of the 6805’s analog-to-digital
    Precision                                       1 C           inputs. Finally, a pulse-width modulation (PWM) output on
    Set-point temperature display                                  the 6805 is used to drive a relay which switches line power to
    Range                                         60–99  C        the resistive heater off and on.
    Precision                                       1 C                Figure 3 shows a more detailed schematic of the elec-
    Chamber temperature display                                    tronics and their interfacing to the 6805. The keypad, a Storm
    Range                                         60–99  C        3K041103, has four keys which are interfaced to pins PA0{
    Precision                                       1 C           PA3 of Port A, configured as inputs. One key functions as a
    Accuracy                                       1 C           mode switch. Two modes are supported: set mode and run
    Chamber temperature step response                              mode. In set mode two of the other keys are used to specify
    Range (steady state)                          60–99  C        the set-point temperature: one increments it and one decre-
    Accuracy (steady state)                        1 C           ments. The fourth key is unused at present. The LED displays
                                                                   are driven by a Harris Semiconductor ICM7212 display driver
    Maximum overshoot                               1 C
    Settling time (to 1  C)                       120 s          interfaced to pins PB0{PB6 of Port B, configured as outputs.
                                                                   The temperature-sensing thermistor drives, through a voltage
                                                                   divider, pin AN0 (one of eight analog inputs). Finally, pin
     Although not explicitly a part of the specifications in Ta-   PLMA (one of two PWM outputs) drives the heater relay.
ble 1, it was clear that the customer desired digital displays
of set-point and actual temperatures, and that set-point tem-                                                         Vdd
                                                                       MC68HC705B16
perature entry should be digital as well (as opposed to, say,
                                                                                  PA0
through a potentiometer setting).                                                 PA1
                                                                                  PA2
                                                                                  PA3
                   3 System Design                                                                        Keypad
The requirements for digital temperature displays and set-
point entry alone are enough to dictate that a microcontroller-
based design is likely the most appropriate. Figure 2 shows a
block diagram of the students’ design.                                            PB0       A
                                                                                  PB1       B
                                                                                  PB2       C
          Slide Chamber                                                                                 28
                                                                                  PB3       D
                                                                                  PB4       A1
                                                                                                                  2 x 2-digit
           Temperature                                                            PB5       A2                7-seg LED display
                                            Heater
             Sensor                                                               PB6       E1
                                                                                            ICM7212
                                                                                                                      Vdd
                                            Relay                                 AN0
                         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
Lumped-element thermal systems are described in almost any
introductory linear control systems text, and just this sort of                    Figure 5. Pole-zero diagram of Gaq (s)
model is applicable to the slide dryer problem.
     Figure 4 shows a second-order lumped-element thermal                   Obtaining a complete thermal model, then, is reduced to
model of the slide dryer. The state variables are the temper-        identifying the constant K and the three unknown time con-
atures Ta of the air in the box and Tb of the box itself. The        stants in (3). Four unknown parameters is quite a few, but
inputs to the system are the power output q(t ) of the heater        simple experiments show that 1=τ p1  1=τz ; 1=τ p2 so that
and the ambient temperature T∞ . ma and mb are the masses of         τz ; τ p2  0 are good approximations. Thus the open-loop sys-
the air and the box, respectively, and Ca and Cb their specific      tem is essentially first-order and can therefore be written
heats. µ1 and µ2 are heat transfer coefficients from the air to
                                                                                                                     K
the box and from the box to the external world, respectively.                                      Gaq (s) =                                   (4)
                                                                                                                   τs + 1
                                        Tb ; mb ; Cb                 (where the subscript p1 has been dropped).
                                                                          Simple open-loop step response experiments show that,
                              Ta ; ma ; Ca                           for a wide range of initial temperatures and heat inputs, K 
             q(t )                                                   0:14  =W and τ  295 s.1
                           µ1 (Ta , Tb )        µ2 (Tb , T∞)
                                                                                        4.2 Control System Design
                                                T∞
                                                                     Using the first-order model of (4) for the open-loop transfer
          Figure 4. Lumped-element thermal model                     function Gaq (s) and assuming for the moment that linear con-
                                                                     trol of the heater power output q(t ) is possible, the block dia-
    It’s not hard to show that the (linearized) state equations      gram of Figure 6 represents the closed-loop system. Td (s) is
corresponding to Figure 4 are                                           1 Of course the system is not actually linear, so the apparent parameter
            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
Thomas Nau, Assistant Director of Computing at Universität Ulm, Germany.
He can be contacted at URL mailto:Thomas.Nau@rz.uni-ulm.de, the
software is available at ftp://ftp.uni-ulm.de/pub/pcb, and an email
list can be subscribed to at mailto:pcb@majordomo.uni-ulm.de.