Temperature Projects:Using a Digital Temperature Sensor

PROJECT 17 – Using a Digital Temperature Sensor

Function

This project shows how we can interface a DSI620 type digital temperature sensor to our microcontroller. The ambient temperature is measured con- tinuously and then displayed in degrees centigrade on three TIL3II type alphanumeric displays. Positive temperature is displayed from 0oC toI25oC. Negative temperature is displayed with a leading letter ‘E’ in the range down to -55oC.

Circuit Diagram

The block diagram of this project is shown in Fig. 5.I. DSI620 is a digital IC temperature sensor which measures the ambient temperature and provides the output as 9 bits of digital serial data. The microcontroller extracts the temperature data from the DSI620 and then displays the temperature on three TIL3II type alphanumeric displays.

Before describing the circuit diagram in detail, it is useful to look at the operation of the DSI620 temperature sensor IC.

Temperature Projects-0024

DS1620 Digital Thermometer IC

DSI620 is a digital thermometer and thermostat IC that provides 9 bits of serial data to indicate the temperature of the device. The pin configuration of the DSI620 is shown in Fig. 5.2. VDD is the power supply which is normally connected to a +5 V supply. DQ is the data input/output pin. CLK is the clock input. RST is the reset input. The device can alsoact as a thermostat. THIGH is driven high if the DSI620’s temperature is greater than or equal to a user defined temperature TH. Similarly, TLOW is driven high if the DSI620’s temperature is less than or equal to a user defined temperature TL. TCOM is driven high when the temperature exceeds TH and stays high until the temperature falls below TL. User defined temperatures TL and TH are stored in non-volatile memory of the device so that they are not lost even after removal of the power.

Data is output from the device as 9 bits, with the LSB sent out first. The temperature is provided in 2’s complement format from -55oC to +I25oC, in steps of 0.5oC. Table 5.I shows the relationship between the temperature and data output by the device.

Temperature Projects-0025

Temperature Projects-0026

Data input and output is through the DQ pin. When RST input is high, serial data can be written or read by pulsing the clock input. Data is written or read from the device in two parts. First, a protocol is sent and then the required data is read or written. The protocol is 8-bit data and the protocol definitions are given in Table 5.2. For example, to write the thermostat value TH, the hexadecimal protocol data 0I is first sent to the device. After issuing this

Temperature Projects-0027

command, the next nine clock cycles clock in the 9-bit temperature limit which will set the threshold for operation of the THIGH output.

For example, the following data (in hexadecimal) should be sent to the device to set it for a TH limit of +50oC and TL limit of +20oC and then subsequently to start the conversion:

Temperature Projects-0028

A configuration/status register is used to program various operating modes of the device. This register is written with protocol 0C (hex) and the status is read with protocol AC (hex). Some of the important configuration/status register bits are as follows:

Temperature Projects-0029

The complete circuit diagram of this project is shown in Fig. 5.3. Bit 2 of port 3 is connected to the RST input of DSI620, bit I is connected to the clock input and bit 0 of port 3 is connected to the DQ pin of the DSI620. Three TL3II type alphanumeric displays are connected to port I of the microcontroller. Digit I is controlled from bit 7 of port I, digit 2 from bit 6 of port I, and digit 3 from bit 5 of port I.

Program Description

The program reads the temperature from the DSI620 thermometer IC and displays the temperature on three TIL3II type displays continuously with I second delay between each displayed output. The following PDL describes the operation of the program:

Temperature Projects-0030

Temperature Projects-0031

Program Listing

The full program listing is given in Fig. 5.4. The display digit latches and the DSI620 control lines are assigned to bit variables at the beginning of the program. Also the used protocols are defined and assigned to global variables. For example, read_temp is assigned tohexadecimal number AA, start_conv is assigned tohexadecimal number EE and so on.

When the program starts, the digit latches digit1_latch, digit2_latch, and digit3_latch are all set to I to avoid any erroneous writes to the displays. A function conigure_ds1620 is then called to set the configuration register/status

Temperature Projects-0032

Temperature Projects-0033

Temperature Projects-0034

Temperature Projects-0035

for continuous operation. Temperature conversion is then started by calling the function start_temp_conversion. This function sends protocol EE (hex) to the DSI620. An endless loop is then formed using the for statement with no parameters. Inside this loop, function read_temperature reads the 9-bit temperature value and returns in variable TEMP. Function display_temperature displays the temperature on the three TIL3II displays. This loop is repeated with about a I second delay between each output.

Function read_temperature returns the temperature tothe calling program as an unsigned integer. This function calls function read_from_ds1620 with the argument AA (in hex) toget the temperature. Function read_from_ds1620 is a general routine which reads data from the DSI620. This function sends a protocol data to the DSI620 and then reads data bytes from the DSI620 corresponding to the sent protocol. The RST input of the device is first set to I. A for loop is then formed to iterate eight times to send serial protocol data to the DSI620. LSB is sent out first. Local variable this_bit stores the bit to be sent out at each iteration. Another for loop reads data from the DSI620 and stores this data in variable ds1620_data. At the end of the read cycle the RST input is set back to0 and the data in ds1620_data is returned tothe caller.

Function write_to_ds1620 is a general function and it sends a protocol, followed by data bits, to the DSI620. The RST input of the DSI620 is first set toI. A for loop is then formed to iterate eight times and the protocol bits are sent out serially to the DQ input of the DSI620. Variable this_bit stores the bit to be sent out at each iteration. After this, another for loop sends out the required number of data bits to the DSI620. At the end of the write cycle, the RST input is returned to0.

Function display_temperature receives the temperature data as its argument and displays the temperature on the three TIL3II type alphanumeric displays. If the temperature is negative, the first display digit is set todisplay letter ‘E’. The temperature value tobe displayed is divided by 2 since the temperature is returned by the DSI620 in 0.5oC intervals. For example, a reading of decimal I00 corresponds to 50oC. Each digit is displayed after converting the data to decimal format.

Components Required

In addition to the basic components required by the microcontroller, the following components will be required for this project:

Temperature Projects-0036

Leave a comment

Your email address will not be published. Required fields are marked *