0% found this document useful (0 votes)
54 views

Temperature Sensors: Vendor Number Weblink For The Part Description Unit Price

This document discusses temperature sensors and provides code examples for interfacing a LM34CZ temperature sensor with a Freescale 9S12C32 microcontroller. It describes the LM34CZ temperature sensor, including its analog voltage output, and provides a circuit diagram for amplifying the sensor output. It also provides C code snippets for initializing the microcontroller's analog-to-digital converter and reading temperature values from the sensor.

Uploaded by

karthik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Temperature Sensors: Vendor Number Weblink For The Part Description Unit Price

This document discusses temperature sensors and provides code examples for interfacing a LM34CZ temperature sensor with a Freescale 9S12C32 microcontroller. It describes the LM34CZ temperature sensor, including its analog voltage output, and provides a circuit diagram for amplifying the sensor output. It also provides C code snippets for initializing the microcontroller's analog-to-digital converter and reading temperature values from the sensor.

Uploaded by

karthik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Temperature Sensors

There are several common types of temperature sensors, namely, semiconductor (silicon) type,
thermistors, resistive temperature devices, and thermal couples. The output signals of the sensors
can be in various formats such as analog voltage output, serial (SPI or IIC) output, or logic
output. A semiconductor type temperature sensor with analog voltage output will be discussed
in this subsection. The particular temperature sensor is LM34CZ. This is a temperature sensor for
general purpose applications.

This section shows how to connect the temperature sensor to the CSM-12C32 module and
provide the C-codes for initializing the on-chip analog-to-digital converter for capturing the
analog output voltage from the temperature sensor. Pictures, ordering information and web link
of the datasheet are shown below.

Source: LM34CZ datasheet

Part
Vendor Number Weblink for the part Description Unit Price

Precision temperature
Hobby
LM34CZ LM34CZ TEMP sensor: analog voltage $6.50
Engineering
output

Hardware interfacing to the Freescale 9S12C32 MCU


As shown in the diagram above, there are three pins in the package. The power supply is
connected to pins Vs and GND. Consult the datasheet for the acceptable range of Vs. The pin
Vout is the analog output voltage pin and is to be connected to the analog-to-digital converter.
The resolution of the temperature sensor is 10 mV/°F. For instance, at 72 °F, the analog output
voltage is 0.72 V. For a narrow range of temperature sensing, an optional amplifier for increasing
the output voltage level is recommended. The non-inverting amplifier structure can be used. The
circuit diagram is shown below. The gain of the amplifier is 1+R2/R1. The resistance R1 and R2
are to be selected so as to achieve your desired gain. It is recommended that the resistors be of
1% accuracy or better so that the gain factor can be more accurate. The operational amplifier can
be a general purpose type such as 741 or precision type.
Software development

A code snippet in C below can be used for initializing the ADC of the MCU to interface with the
LC34CZ. It is assumed that the analog voltage is fed to the channel 0 of the ADC module. Other
assumptions are included in the comment statements. The code snippet can be easily modified
for other conversion settings.

void initADC(void) {

ATDCTL2 = 0x80; // turn on ADC ATDCTL2_ADPU=1


ATDCTL3 = 0x08; // 1 conversion/sequence
ATDCTL4 = 0x01; // 10-bit conv., 2Mhz ADC clock (assume bus clock=8MHz),
// fastest conv.
ATDCTL5 = 0x80; // right justify, unsigned, non-scanning,
// non-multichannel
return;
}

Note that 10 bit resolution is recommended. Such resolution is 5 mV per bit. If a gain factor of 2
is used for amplifying the analog output voltage of the LM34CZ, the resolution for temperature
is 0.25 °F per bit. The resolution can be higher if the gain factor is larger.

A C function for reading the analog voltage is shown below. The delay for 1 ms in the function is
to give sufficient time for the ADC to finish the conversion. Every execution of this function will
result in a new temperature reading stored in the variable temperature.

void readTemp(void) {
short temperature;

ATDCTL5 = 0x80; // initiate ADC conversion


waitms(1); // delay 1 ms, this function was covered in class
temperature = ATDDR0; // read temperature
// note that for right justified data, there needs not the
// instruction temperature >> 6 for left justified case
return temperature;
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy