EE 476: Laboratory 6
Digital Thermometer with fan
Introduction.
You will build a digital thermometer which displays temperature on a LCD display
and controls a fan with user-selectable turn-on temperature.
Procedure:
We will be changing MCUs for this lab. You will use the Mega163
because it has built-in analog-to-digital converters (ADC). Your TA has put
the Mega163 on an STK200 development board.
Things to watch for:
- Change the header file to
<Mega163.h>
- You will need to program the clock select bits: choose "External crystal/slow
power up"=1010
- The most accurate way to use the ADC requires that you use the internal
voltage reference. You MUST use it because we cut the trace which supplies
external Aref. For each different mcu that you use, you will need to measure
Aref (STK200 header 'analog' pin 9) and use the value in your code.
- TIMSK bit definitions are different from the 8515
- UART register names have changed
- The programmer dongle connects to the PC parallel port. Do
NOT use the Altera dongle.
The LM34 temperature sensor produces a voltage output
of 10 mV/degree F. You will need to perfrom an analog-to-digital conversion
using the mcu to read the voltage. There is some code
to show you how to set up the ADC. For optimum accuracy, you will need to amplifiy
the output of the LM34 by a factor of 2 (using an LMC7111
opamp) before feeding it into the A/D converter. Filtering the opamp output
may lower spike noise. Use the scope to decide if you need a filter.
You will need to drive a fan from the mcu. Fans usually have magnetic motors
which can cause nasty inductive spikes to wipe out the transistors in the mcu
port. The circuit
shown in one of last year's final projects is fairly safe. The diode placed
across the motor shorts out spikes when the motor is turned off.
Assignment
Write a program and construct a circuit which will
- Measure room temperature with an LM34 and convert the output voltage to
a number using an A-to-D converter program running on the mcu.
- Format the termperature and display appropriate messages on an LCD.
- When the user briefly presses one of two buttons (labeled increase and decrease),
display the fan set point temperature. Make the default fan set point temperature
(at RESET time) be greater than room temperature.
- If the user holds either button down for more than 1/2 second, the set point
is modified in the appropriate direction and displayed.
- If the actual sensor temperature is above the set point, turn on the fan.If
the fan is pointing at the LM34, it should cool the tempature sensor and turn
itself off.
You will demo all the features above to your TA.
Your written lab report should include:
- A schematic of the circuit you built.
- A summary of the accuracy of your measurements. You should look at noise
on the opamp output using the scope. You should also look at the stability
of the A/D converter at constant voltage input.
- A heavily commented listing of your code.
Copyright Cornell University Feb 2002