Toaster Oven Control System
Toaster Oven Control System
Toaster Oven Control System
Rev. 1, 03/2007
Application Note
1 Introduction Contents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Traditionally, electric toaster ovens have implemented 2 Design Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.1 System Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
temperature control using discrete components, 3 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
including solenoids, thermostats, and thermal fuses. 4 Hardware Implementation . . . . . . . . . . . . . . . . . . . . . . . . 3
Some of these components may be expensive and 4.1 User Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
5 Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
unreliable. These components can be replaced by an 6 Software Implementation. . . . . . . . . . . . . . . . . . . . . . . . . 4
embedded control system. By using the appropriate 6.1 On-off Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
7 Execution Flow and System States . . . . . . . . . . . . . . . . . 5
control method and components, system costs can be 7.1 Benefits of the Solution . . . . . . . . . . . . . . . . . . . . . . . . . 10
reduced and performance increased. Embedded systems 8 Testing and Validation . . . . . . . . . . . . . . . . . . . . . . . . . . 10
allow you to add new functions without replacing the 9 Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
10 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
whole system, which reduces weight and space
requirements and eases component replacements.
This document helps users convert a discrete control
system to an embedded system. Using a domestic toaster
oven as an example, it also demonstrates that an on-off
control system can be implemented on a low-end 8-bit
MCU. This embedded control system is based on the
low-cost, high-performance MC9S08QD2, a member of
the HCS08 family of 8-bit microcontroller units
(MCUs). Two potentiometers give you control of oven
temperature and toasting time. By pressing a push
button, you can start or stop the device. This design also
uses a low-cost temperature sensor that provides a more
accurate on-off feedback control system.
2 Design Requirements
2.1 System Overview
The user can specify the temperature, toasting time, and start or stop the heating process at any time. An
indicator light informs the user the device is heating, while a sound generated by the device indicates the
process is complete.
To provide feedback to the control system, the system has a temperature sensor. Due to the voltage
operation difference between the heating element and the MCU, there is a coupling stage (capable of
managing standard domestic line voltage levels) to switch the heating device on and off.
3 Modes of Operation
This system is intended to work in two modes. The first mode is toaster mode, in which the user specifies
the desired temperature and the desired heat time. After this time has elapsed, the toaster turns off
automatically and informs the user by making a beep sound. The user may also stop the device at any time
by pressing the pushbutton.
The second mode is oven mode, which is entered when the user turns off the time knob. In this mode, the
user doesn’t specify a cooking time, but only the desired temperature. Therefore, the oven heats to the
desired temperature until the user turns it off. Figure 1 shows the user inputs.
Heating level
Low High
Toast time
Toast mode
1 min
Start / Stop
4 Hardware Implementation
4.1 User Inputs
The time and heat potentiometers are read by the on-chip analog-to-digital converter on the MC9S08QD2.
The pushbutton is connected to a general input with the internal pull-up resistor enabled.
VDD
MC9S08QD2 Heating
Coupling Power device
VDD PTA3 Stage Stage (Resistive
Time ADC0 PTA4 load)
10 kΩ VDD
ADC1 ADC2
PTA5 VSS
Heat
10kΩ 5 VDC
VDD
150 Ω 150 Ω
Temperature VDD
Sensor
(LM35) Speaker
Start/Stop
10 kΩ
10 kΩ
BKGD/MS
Figure 2. Electrical Schematic
5 Development Tools
The programming language used for this application is C. This application was developed using
CodeWarrior 5.1 with the MC9S08QD2/4 patch properly installed.
6 Software Implementation
6.1 On-off Control
On-off control is the simplest kind of control and is used in almost all domestic electric toaster ovens.
When the temperature of the oven is lower than the desired temperature, the heater is turned on. After the
oven’s temperature has reached the desired temperature, the heater is turned off. The heater cannot vary
the heat intensity; it only turns the oven on or off (Figure 3).
This kind of control system presents a problem of temperature oscillating around the set-point. The turn-on
temperature differs slightly from the turn-off temperature. This difference is called hysteresis and prevents
the oven from switching rapidly and unnecessarily when the temperature is near the set-point.
On-off control can be used for non-critical applications, when a slight variation in the output is acceptable.
Control systems like this are cheap, effective and can represent a good design choice.
Temperature
Hysteresis
Desired
temperature
Heating Time
timeout
Button pressed
Startup IDLE Button ON or END
Initialize Wait for Heat at Time out Turn off
MCU button to desired heater and
be pressed temperature beep
The MCU must be configured at startup before entering the main loop. This includes initializing
configuration registers, system clock, ADC, and general-purpose inputs/outputs (GPIOs). After startup,
the application enters an infinite loop that executes the state machine.
The idle state waits for the button to be pressed to change to the on state so the toaster oven can start
heating. In the on state, the system reads the user inputs to select the proper operation mode (oven or
toaster) and starts heating until the desired temperature is reached. The on-off control algorithm is
performed during this state. The flow diagram for the on state is shown in Figure 5. The machine only
changes to end state when a timeout occurs or a button is pressed.
System states are separated into functions. During the application’s main loop, the state machine calls the
function depending on the actual state. The program also checks if an RTI overflow has occurred or if a
button is pressed at that moment. No interrupts are used in the program. Because this is a non-critical
system, a polling method is used instead.
The start/stop button is read in at least two states; therefore, you need a method to determine if the button
was pressed to avoid changing the state repeatedly. To avoid this problem,the software uses flags
(variables) instead of reading the actual push button status. After the button has been pressed, a flag is set
to alert you of this. When you release the button, the previous flag is cleared. To enhance this functionality,
the program uses a debounce timer to avoid triggering false mechanical rebounds from the push button.
The real time interrupt (RTI) of the MC9S08QD2 is used as a time base. It is configured to overflow every
1.024 seconds. In this way, the program knows that one second has elapsed and checks if the desired time
has elapsed.
Previous State
No Is heating Yes
time equal
to 0?
Turn on LED
Is actual
temperature
No Yes
greater than or
-
equal to turn-off
value?
Is actual
No temperature less Yes
- Turn off heater
than turn-on
value?
Turn on heater
No Button Yes
was
pressed?
End
No Has timer reach Yes
desired value?
Figure 6 shows the flow diagram of the END state in which the heater is turned off. A 2 kHz sound is then
generated by the speaker output pin. The timer/pulse-width modulator of the MC9S08QD2 generates the
audible tone, and the RTI counts the duration of the sound.
Previous State
Set SoundDuration
Start timer and start RTI
Timer
No overflow Yes
has
occurred?
Toggle Speaker pin
RTI
overflow Yes
has
occurred?
No
Decrease SoundDuration
No Sound Yes
Duration equals
0?
End
9 Conclusion
This application note shows designers interested but not familiarized with digital embedded systems how
to implement a simple on-off control system with a low-end 8-bit microcontroller. It serves as a basic guide
that can be easily modified and enhanced to suit designer and user needs. This solution, however, does not
represent a fully-validated end user product, but it should serve more as a primer for those interested in
embedded systems and their many advantages.
10 References
• Barr, Michael. Closed-Loop Control Embedded Systems Programming, August 2002 , pp. 55-56.
• D.H. Williams, Charles. Types of Feedback Control.
• LM35 Precision Centigrade Temperature Sensors data sheet.
• Ochoa Alfredo, Lara Alex & Gonzalez Gabriel. High Resolution Digital Dimmer. AND8011.
Web Support:
http://www.freescale.com/support Freescale Semiconductor reserves the right to make changes without further notice to
any products herein. Freescale Semiconductor makes no warranty, representation or
USA/Europe or Locations Not Listed: guarantee regarding the suitability of its products for any particular purpose, nor does
Freescale Semiconductor, Inc. Freescale Semiconductor assume any liability arising out of the application or use of any
Technical Information Center, EL516 product or circuit, and specifically disclaims any and all liability, including without
2100 East Elliot Road
Tempe, Arizona 85284 limitation consequential or incidental damages. “Typical” parameters that may be
+1-800-521-6274 or +1-480-768-2130 provided in Freescale Semiconductor data sheets and/or specifications can and do vary
www.freescale.com/support in different applications and actual performance may vary over time. All operating
parameters, including “Typicals”, must be validated for each customer application by
Europe, Middle East, and Africa: customer’s technical experts. Freescale Semiconductor does not convey any license
Freescale Halbleiter Deutschland GmbH under its patent rights nor the rights of others. Freescale Semiconductor products are
Technical Information Center not designed, intended, or authorized for use as components in systems intended for
Schatzbogen 7 surgical implant into the body, or other applications intended to support or sustain life,
81829 Muenchen, Germany
+44 1296 380 456 (English) or for any other application in which the failure of the Freescale Semiconductor product
+46 8 52200080 (English) could create a situation where personal injury or death may occur. Should Buyer
+49 89 92103 559 (German) purchase or use Freescale Semiconductor products for any such unintended or
+33 1 69 35 48 48 (French) unauthorized application, Buyer shall indemnify and hold Freescale Semiconductor and
www.freescale.com/support its officers, employees, subsidiaries, affiliates, and distributors harmless against all
claims, costs, damages, and expenses, and reasonable attorney fees arising out of,
Japan: directly or indirectly, any claim of personal injury or death associated with such
Freescale Semiconductor Japan Ltd. unintended or unauthorized use, even if such claim alleges that Freescale
Headquarters
ARCO Tower 15F Semiconductor was negligent regarding the design or manufacture of the part.
1-8-1, Shimo-Meguro, Meguro-ku,
Tokyo 153-0064 RoHS-compliant and/or Pb-free versions of Freescale products have the functionality
Japan and electrical characteristics as their non-RoHS-compliant and/or non-Pb-free
0120 191014 or +81 3 5437 9125
[email protected] counterparts. For further information, see http://www.freescale.com or contact your
Freescale sales representative.
Asia/Pacific:
Freescale Semiconductor Hong Kong Ltd. For information on Freescale’s Environmental Products program, go to
Technical Information Center
2 Dai King Street http://www.freescale.com/epp.
Tai Po Industrial Estate
Tai Po, N.T., Hong Kong Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
+800 2666 8080 All other product or service names are the property of their respective owners.
[email protected]
© Freescale Semiconductor, Inc. 2007. All rights reserved.
For Literature Requests Only:
Freescale Semiconductor Literature Distribution Center
P.O. Box 5405
Denver, Colorado 80217
1-800-441-2447 or 303-675-2140
Fax: 303-675-2150
[email protected]