|
Temperature Sensor - Collecting
Temperature Data and Sending it to a PC
This tutorial shows how to use a microcontroller
to interface to a Dallas 1620 temperature sensor IC. This value can be
used by the microcontroller directly or, as in this tutorial, sent to the
PC. It uses the AT89C2051
microcontroller to collect data and send it to the PC. A MAX232CPE
chip is used to convert the signals from and to RS232 levels for sending
and receiving through the serial port. For more details on some aspects
of the hardware, refer to the Data
Collection tutorial.
The Temperature Sensor
To get a temperature reading we use the Dallas
DS1620 integrated circuit. It is an 8 pin chip that has a built in system
that measures the temperature and converts the reading into a 9 bit binary
value. It has an accuracy of 0.5 degrees C and a range of -55 to 125 C.
The temperature reading is updated about once per second. A digital interface
is included in the chip that allows us to connect a microcontroller to
the chip and send it commands and receive the temperature data back from
the chip.

The temperature is received in the microcontroller
as 2 bytes. The second byte only contains a sign bit to signify whether
the temperature is above or below 0 degrees Celsius. For this project we
are ignoring the sign bit and just using the first byte. We will assume
the temperature is above 0 degrees C (32 F). The value in the first byte
is the number of 0.5 degree increments. For example, if we get a 1 then
the temperature is 0.5 degrees C. If we get a 10 then the temperature is
5 degrees C. The range of possible values is 0 to 250 which is 0 to 125
degrees C. (The DS1620 can also measure down to -55 degrees C).
For this project we are only using the serial interface pins, 1, 2,
and 3. The pins 5, 6, and 7 have other functions that are used in thermostats.
They change from 0 to 1 when a certain temperature is reached (for example,
to turn a heater on and off). For more details about
this and the details of the DS1620, click
here to get the data sheet.
Refer to the diagram below to build the circuit.
The Data Collection Tutorial
has more detailed instructions on using the MAX232 chip.

The Software
The basic process of compiling an assembly language
program and loading it into the microcontroller was covered in the first
microcontroller project. The 2051 assembly language program
for this project is temp.asm. It is included on the software CD that
comes with the kit. You will need a device programmer such as the PG302
to download the program into the 2051.
The temp.asm program demonstrates a serial interface with another chip.
This is a fairly common situation. The serial interface can be created
with only 2 or 3 pins. There is usually a clock line and a data line. In
this case there is also a control line called Reset that acts as a control
signal, signaling the begin and end of each communication sequence. The
clock is generated by the microcontroller, giving the microcontroller complete
control over the bit by bit transmission. In this case the microcontroller
is responsible for initiating each exchange of data over the serial link.
Another possible configuration (for example, 2 microcontrollers linked
together) could allow the device on either end to initiate an exchange.
Make sure the power is off to the circuit you
have built. Connect the circuit to the
PC's serial port, Comm1. Connect the power to the breadboard. The
circuit should send a continuous stream of values to the PC. To see
the values on the PC, try this sample
program. After downloading, double click it to extract
the files and then run setup.exe to install it. The sample program receives
the original value and displays it on the screen. It also converts the
value to Celsius and Fahrenheit and displays those. The source code
for the sample program (written in VB 5.0) is on the CD included with the
kit.
The parts for this project are included in the
Sensor Kit. The Sensor Kit also includes the parts needed to do the temperature
sensor project and the data
collection project. The kit includes:
1
- AT89C2051-24PC Microcontroller
(unprogrammed)
1 - 11.0592 MHz Crystal
2 - 33pF Capacitors
1 - 150pF Capacitor
1 - 10 uF Capacitor
1 - 220 uF Capacitor
1 - 8.2k Resistor
5 - 240 Ohm Resistors
5 - 510 Ohm Resistors
5 - 1k Resistors
5 - 2.2k Resistors
5 - 5.1k Resistors
5 - 10k Resistors
5 - 15k Resistors
1 - MAX232
1 - ADC0804 (Analog to Digital Converter IC)
5 - 1 uF capacitors
1 - DB9 connector
1 - CDS Photocell Light Sensor
1 - DS1620 Temperature Sensor
Jumper Wires
1 - CD with source code (click
here to see full contents of CD)
To see the tutorial for the
Light Sensor, click here.
To see the tutorial
for the LCD Module, click here.
If you do not have any electronic parts, get the Microcontroller Beginner
Kit in addition to this kit and you will have everything you need to build
this (and many other) projects. It includes a power supply, a breadboard,
the PG302 device programmer, and much more. Click
here for more information.
Catalog
-- Support -- Privacy
Policy -- About Us
This page last updated on December
2, 2004.
|