Home   |  Schematics |  Products |  Tutorials  |  Datasheets  |  Robotics   |   Download    |   Link Exchange


Direct Current
Alternating Current
Digital Electronics
PC Architecture
Electronics Dictionary
Resources

Experiment
Calculator/Converters
Radio
Newsletter
Associations and Societies
Component Manufacturers

 

Electronics Symentics


Microcontroller Advanced Kit - Temperature Sensor Project

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, 

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.

    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





Home  Products  Tutorials   Schematics   Robotics   Resources   Radio Stuff    Career    Download   Link Exchange

HTML Sitemap   XML Sitemap


Terms & Conditions  Privacy Policy and Disclaimer