Вы находитесь на странице: 1из 12

! 2005 Microchip Technology Inc.

DS00988A-page 1
AN988
INTRODUCTION
The MCP9800 is a digital CMOS silicon temperature
sensor that provides an accurate digital temperature
measurement. Data is converted from an internal
diode temperature-sensing element to a digital format
that can be directly interfaced to a PICmicro

microcontroller unit (MCU). The MCP9800 sensor


offers many system-level advantages, including the
integration of the sensor and signal-conditioning
circuitry in a small Integrated Circuit (IC) package. The
MCP9800 also has a One-shot Conversion mode that
performs a single temperature measurement and then
goes into power-saving Shutdown mode. The One-
shot Conversion mode makes this sensor a good
choice for power-critical, portable applications.
The MCP9800 digital temperature sensor is especially
suited for embedded systems due to its I
2
C interface,
which serves to provide an industry standard method of
interface to a microcontroller. This application note will
discuss system integration, firmware implementation
and Printed Circuit Board (PCB) layout techniques for
using the MCP9800 in an embedded system.
The techniques for integrating the MCP9800 into an
embedded systems environment will be demonstrated
by using the PICkit1 Flash Starter Kit and a
MCP9800 PICtail daughter board. The MCP9800
PICtail daughter board plugs into the PICkit 1 Flash
Starter Kit expansion header J3, as shown in Figure 1.
The MCP9800 demonstration is designed to measure
and display temperature using the on-board 7-segment
LED display.
Gerber files for the PCB, source code and a hex file to
program a PIC16F684 are included in the companion
zip file, 00059R1.zip.
FIGURE 1: Block Diagram of the MCP9800 Digital Temperature Sensor Demonstration.
Author: Ezana Haile and Jim Lepkowski
Microchip Technology Inc.
V
DD
PICmicro

Flash
I
2
C Interface
SPI
GND
MCU
PICkit 1 Flash Starter Kit
PC
USB
J3
2
+5V
J2
2
SPI Interface
I
2
C
Alert Indicator
MCP9800 PICtail Demo Board
MCP9800
Thermal
Sensor
PIC16F737
Display Controller
7-Segment display
PIC16F684
Interface
Interface
Interfacing the MCP9800 I
2
C

Digital Temperature Sensor
to a PICmicro

Microcontroller
AN988
DS00988A-page 2 ! 2005 Microchip Technology Inc.
MCP9800 FUNCTIONAL
DESCRIPTION
The MCP9800 consists of an internal diode
temperature sensor, a user selectable 9-12-bit sigma
delta Analog-to-Digital Converter (ADC), digital
registers and a I
2
C communication port. Figure 2
provides a simplified block diagram of the MCP9800. A
schematic of the MCP9800 to PICmicro MCU interface
is shown in Figure 3.
FIGURE 2: Functional Block Diagram.
FIGURE 3: MCP9800 to PICmicro


MCU Interface.
Temperature Data Format
Temperature data is represented by a 9-12-bit twos
complement word with a resolution of 0.15C per bit to
0.0025C per bit. The temperature data is stored in the
temperature registers in a twos complement format, as
shown in Table 1.
TABLE 1: TEMPERATURE REGISTER
Refer to the MCP9800 data sheet, 2-Wire Accuracy
Temperature Sensor (DS21909), for more information
regarding the serial interface.
Resolution
9-Bit
10-Bit
11-Bit
12-Bit
Temperature
T
HYST

T
SET

Register
Register
Register
Register
Pointer
I
2
C/SMBus
Interface
Configuration
Register
ADC
Band-Gap
Temperature
Sensor
One-Shot
Shutdown
Fault Queue
Alert Polarity
Alert Comp/Int
SDA
SCK
I/O
SDA
SCK
ALERT
MCP9800
0.1 F
V
DD
GND
V
DD
PICmicro

MCU
Example using a 10-bit data:
Temperature = 41.5C
MSb Temperature Register = 00101001b
= 2
5
+ 2
3
+ 2
0
= 32 + 8 + 1 = 41
LSb Temperature Register = 10000000b = 2
-1
= 0.5
D7 D6 D5 D4 D3 D2 D1 D0
Address/
Register
Sign 2
6
2
5
2
4
2
3
2
3
2
1
2
0
02H
Temp. MSb
2
-1
2
-2
0 0 0 0 0 0 01H
Temp. LSb
! 2005 Microchip Technology Inc. DS00988A-page 3
AN988
REGISTERS
The MCP9800 family has four registers that are user-
accessible. These registers are specified as the ambi-
ent temperature register, the Temperature Limit-set
(T
SET
) register, the Temperature Hysteresis (T
HYST
)
register and device Configuration registers.
The Ambient Temperature register is a read-only
register and is used to access the ambient temperature
data. The data from the ADC is loaded in parallel in the
register. The T
SET
and T
HYST
registers are read/write
registers that provide user-programmable temperature
limits. If the ambient temperature drifts beyond the
programmed limits, the MCP9800 outputs an alert
signal using the ALERT pin (refer to ALERT Output
Configuration). The device Configuration register
provides access for the user to configure the
MCP9800s various features. These registers are
described in further detail in the following sections.
FIGURE 4: Register Block Diagram.
The registers are accessed by sending a register
pointer to the MCP9800 using the SPI interface. This
is an 8-bit pointer. However, the two Least Significant
bits (LSb) are used as pointers and all other bits need
to be cleared <0>. This device has additional registers
that are reserved for test and calibration. If these
registers are accessed, the device may not perform
according to specification. Refer to the MCP9800 data
sheet for detailed information.
ALERT Output
Control Logic
ALERT
Output
Resolution
Temperature
T
HYST

T
SET

Register
Register
Register
Configuration
Register
One-shot
Shutdown
Fault Queue
Alert Polarity
Alert Comp/Int
AN988
DS00988A-page 4 ! 2005 Microchip Technology Inc.
APPLICATIONS INFORMATION
The MCP9800 does not require any additional
components in order to measure temperature, though
it is recommended that a decoupling capacitor (a high-
frequency ceramic capacitor should be used) of 0.1 F
to 1 F be provided between the V
DD
and GND pins.
The capacitor should be located as close as possible to
the IC power pins in order to provide effective noise
protection to the sensor.
The MCP9800 measures temperature by monitoring
the voltage of a diode located on the IC die. The IC pins
of the MCP9800 provide a low-impedance thermal path
between the die and the PCB, allowing the MCP9800
to effectively monitor the temperature of the PCB. The
thermal path between the ambient air is not as efficient
because the plastic IC housing package functions as a
thermal insulator. Thus, the ambient air temperature
(assuming that a large temperature gradient exists
between the air and PCB) has only a small effect on the
temperature measured by the MCP9800.
A potential for self-heating errors can exist if the
MCP9800 I
2
C interface communication lines are
heavily loaded. Typically, the self-heating error is
negligible because of the relatively small current
consumption of the MCP9800. A temperature accuracy
error will result from self-heating if the I
2
C communica-
tion pins sink/source the maximum current specified for
the MCP9800. Therefore, to maximize the temperature
accuracy, the output loading of the I
2
C inteface signals
should be minimized.
MCP9800 PICtail DAUGHTER
BOARD
The MCP9800 PICtail daughter board is plugged into
the PICkit 1 Flash Starter Kit via expansion header J3.
Figure 5 shows the MCP9800 PICtail daughter board
plugged into the PICkit 1 Flash Starter Kit. For more
information on the PICkit 1 Flash Starter Kit, refer to the
PICkit1 Flash Starter Kit Users Guide (DS40051).
The MCP9800 PICtail daughter board consists of a
MCP9800 temperature sensor and a bypass capacitor.
The bypass capacitor (C
1
) is used to provide noise
immunity on the +5 VDC power supply. In addition, this
demo board has a 7-segment LED temperature display
circuit. Figure 6 shows a schematic of the board.
Refer to the MCP9800 Thermal Sensor PICtail
Demo Board Users Guide (DS51528) for further
details.
FIGURE 5: MCP9800 PICtail Daughter Board and PICkit1 Flash Starter Kit.
PICkit 1 Flash Starter Kit
USB Cable
Expansion
Header (J3)
Insert PIC16F684
Potentiometer RP1
Push-Button Switch SW1
MCP9800 PICtail Demo Board
! 2005 Microchip Technology Inc. DS00988A-page 5
AN988
FIGURE 6: MCP9800 PICtail Daughter Board Schematic.
1
4
5
2
RC1
RC0
RC5
GND
13
10
11
4
14
PICkit 1
Flash Starter Kit
+5V
SDA
U1
J3 J2
13
10
11
4
14
SCL
RC3
6 6
15
14
21
SCL
U2
SDA
V
DD
V
DD
V
DD
6
MCP9800 PICtail Daughter Board
MCP9800
PIC16F737
AN988
DS00988A-page 6 ! 2005 Microchip Technology Inc.
MCP9800 INTERFACE FIRMWARE
A block diagram of the firmware flow is shown in the Figure 7.
FIGURE 7: Block Diagram of the Firmware.
Initially, the position of the RP1 potentiometer is
determined using an ADC. This data is used to set the
ALERT output limit and hysteresis. Temperature data
is then obtained from the MCP9800. If the PC
requests temperature data, the raw temperature data
is transmitted using the USB cable. Refer to the
MCP9800 Thermal Sensor PICtail Demo Board
Users Guide (DS51528), for further detail. The SW1
switch position is determined to select the measure-
ment unit as degree Celsius or Fahrenheit. Once the
unit conversion is completed, data is transmitted for
display using the 7-segment display.
Initialization
Obtaining
Temperature
Value
Transmitting
Temperature for
Display
Converting
Temperature to
Desired Units
T
SET
and T
HYST

Programming
Raw Data
Reporting
RP1
T
SET
/
T
HYST
Raw Temperature Scaled Temperature
Converted Temperature
BCD Temperature
T
A
SW1
! 2005 Microchip Technology Inc. DS00988A-page 7
AN988
Figure 8 shows the flow diagram that describes the
temperature unit conversion.
FIGURE 8: Temperature Unit Conversion Flow Diagram.
The temperature data from the MCP9800 is checked
for positive or negative reading. If the temperature is
below 0C, the reading is converted to the two's
compliment. Then, based on the position of the SW1
switch, the unit-conversion is followed as shown above.
The SPI interface is used to transmit the temperature
data to the 7-segment display driver PICmicro MCU
(PIC16F72). This PICmicro MCU receives temperature
data from the PICkit 1 Flash Starter Kit and displays it
on the 7-segment display. The display requires refresh-
ing, therefore, this MCU continuously displays the
received temperature data. The flow diagram is shown
in Figure 9.
FIGURE 9: Display Flow Diagram.
SIGN is positive
SIGN is negative
Two's complement
TEMP
Multiply TEMP by
9
Divide TEMP by 5
Add 32*256 to
TEMP
Sign-extend value
into third byte
Convert to
Fahrenheit?
Y
N
TEMP MSb
set?
N
Y
Initialization
Display Refresh Receive Display
DIgits
Display Digits
AN988
DS00988A-page 8 ! 2005 Microchip Technology Inc.
The SPI interface routine protocol for the 7-segment
display driver is designed to function as a generic tool
to display any data. The protocol is described in the
MCP9800 Thermal Sensor PICtail Demo Board
Users Guide (DS51528). The flow diagram in
Figure 10 shows the firmware structure for the serial
interface.
FIGURE 10: Firmware Structure for the Serial Interface.
Is SIGN
negative?
Send next digit as
dash
Send next digit as
100's digit
Is 100's digit 0?
Is 10's digit 0?
Send next digit as
10's digit
Send next digit as
1's digit with
decimal point
Are we trying to
send the first
digit?
Send next digit as
blank
Are more digits
available?
Are more digits
available?
Send next digit as
10th's digit
Send next digit as
100th's digit
N
N
N
N
N N
Y
Y
Y
Y
Y Y
! 2005 Microchip Technology Inc. DS00988A-page 9
AN988
CONCLUSION
The MCP9800 digital temperature sensor PICtail
daughter board demonstrates the ease of integrating a
digital output IC temperature sensor to a PICmicro

microcontroller. The MCP9800 is a CMOS silicon digital


temperature sensor that provides many system-level
advantages, including the integration of the sensor and
the signal-conditioning circuitry in a small IC package.
This provides for easy system integration and
minimizes the required PCB space, component count
and design time.
BIBLIOGRAPHY
1. AN871 Solving Thermal Measurement
Problems Using the MCP9800 and TC77 Digital
Silicon Temperature Sensors, DS00871,
Lepkowski, J., Microchip Technology Inc., 2003
2. PICkit 1 Flash Starter Kit Users Guide,
DS40051, Microchip Technology Inc, 2003
3. MCP9800 Data Sheet, 2-Wire Accuracy
Temperature Sensor, DS21909,
Microchip Technology Inc., 2004
4. MCP9800 Thermal Sensor PICtail Demo
Board Users Guide, DS51528,
Microchip Technology Inc., 2005.
AN988
DS00988A-page 10 ! 2005 Microchip Technology Inc.
NOTES:
! 2005 Microchip Technology Inc. DS00988A-page 11
Information contained in this publication regarding device
applications and the like is provided only for your convenience
and may be superseded by updates. It is your responsibility to
ensure that your application meets with your specifications.
MICROCHIP MAKES NO REPRESENTATIONS OR WAR-
RANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED,
WRITTEN OR ORAL, STATUTORY OR OTHERWISE,
RELATED TO THE INFORMATION, INCLUDING BUT NOT
LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE,
MERCHANTABILITY OR FITNESS FOR PURPOSE.
Microchip disclaims all liability arising from this information and
its use. Use of Microchips products as critical components in
life support systems is not authorized except with express
written approval by Microchip. No licenses are conveyed,
implicitly or otherwise, under any Microchip intellectual property
rights.
Trademarks
The Microchip name and logo, the Microchip logo, Accuron,
dsPIC, KEELOQ, microID, MPLAB, PIC, PICmicro,
PICSTART, PRO MATE, PowerSmart, rfPIC, and
SmartShunt are registered trademarks of Microchip
Technology Incorporated in the U.S.A. and other countries.
AmpLab, FilterLab, Migratable Memory, MXDEV, MXLAB,
PICMASTER, SEEVAL, SmartSensor and The Embedded
Control Solutions Company are registered trademarks of
Microchip Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, dsPICDEM,
dsPICDEM.net, dsPICworks, ECAN, ECONOMONITOR,
FanSense, FlexROM, fuzzyLAB, In-Circuit Serial
Programming, ICSP, ICEPIC, Linear Active Thermistor,
MPASM, MPLIB, MPLINK, MPSIM, PICkit, PICDEM,
PICDEM.net, PICLAB, PICtail, PowerCal, PowerInfo,
PowerMate, PowerTool, rfLAB, rfPICDEM, Select Mode,
Smart Serial, SmartTel, Total Endurance and WiperLock are
trademarks of Microchip Technology Incorporated in the
U.S.A. and other countries.
SQTP is a service mark of Microchip Technology Incorporated
in the U.S.A.
All other trademarks mentioned herein are property of their
respective companies.
2005, Microchip Technology Incorporated, Printed in the
U.S.A., All Rights Reserved.
Printed on recycled paper.
Note the following details of the code protection feature on Microchip devices:
Microchip products meet the specification contained in their particular Microchip Data Sheet.
Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchips Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
Microchip is willing to work with the customer who is concerned about the integrity of their code.
Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as unbreakable.
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchips code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Microchip received ISO/TS-16949:2002 quality system certification for
its worldwide headquarters, design and wafer fabrication facilities in
Chandler and Tempe, Arizona and Mountain View, California in
October 2003. The Companys quality system processes and
procedures are for its PICmicro

8-bit MCUs, KEELOQ

code hopping
devices, Serial EEPROMs, microperipherals, nonvolatile memory and
analog products. In addition, Microchips quality system for the design
and manufacture of development systems is ISO 9001:2000 certified.
DS00988A-page 12 ! 2005 Microchip Technology Inc.
AMERICAS
Corporate Office
2355 West Chandler Blvd.
Chandler, AZ 85224-6199
Tel: 480-792-7200
Fax: 480-792-7277
Technical Support:
http://support.microchip.com
Web Address:
www.microchip.com
Atlanta
Alpharetta, GA
Tel: 770-640-0034
Fax: 770-640-0307
Boston
Westborough, MA
Tel: 774-760-0087
Fax: 774-760-0088
Chicago
Itasca, IL
Tel: 630-285-0071
Fax: 630-285-0075
Dallas
Addison, TX
Tel: 972-818-7423
Fax: 972-818-2924
Detroit
Farmington Hills, MI
Tel: 248-538-2250
Fax: 248-538-2260
Kokomo
Kokomo, IN
Tel: 765-864-8360
Fax: 765-864-8387
Los Angeles
Mission Viejo, CA
Tel: 949-462-9523
Fax: 949-462-9608
San Jose
Mountain View, CA
Tel: 650-215-1444
Fax: 650-961-0286
Toronto
Mississauga, Ontario,
Canada
Tel: 905-673-0699
Fax: 905-673-6509
ASIA/PACIFIC
Australia - Sydney
Tel: 61-2-9868-6733
Fax: 61-2-9868-6755
China - Beijing
Tel: 86-10-8528-2100
Fax: 86-10-8528-2104
China - Chengdu
Tel: 86-28-8676-6200
Fax: 86-28-8676-6599
China - Fuzhou
Tel: 86-591-8750-3506
Fax: 86-591-8750-3521
China - Hong Kong SAR
Tel: 852-2401-1200
Fax: 852-2401-3431
China - Shanghai
Tel: 86-21-5407-5533
Fax: 86-21-5407-5066
China - Shenyang
Tel: 86-24-2334-2829
Fax: 86-24-2334-2393
China - Shenzhen
Tel: 86-755-8203-2660
Fax: 86-755-8203-1760
China - Shunde
Tel: 86-757-2839-5507
Fax: 86-757-2839-5571
China - Qingdao
Tel: 86-532-502-7355
Fax: 86-532-502-7205
ASIA/PACIFIC
India - Bangalore
Tel: 91-80-2229-0061
Fax: 91-80-2229-0062
India - New Delhi
Tel: 91-11-5160-8631
Fax: 91-11-5160-8632
Japan - Kanagawa
Tel: 81-45-471- 6166
Fax: 81-45-471-6122
Korea - Seoul
Tel: 82-2-554-7200
Fax: 82-2-558-5932 or
82-2-558-5934
Malaysia - Penang
Tel:011-604-646-8870
Fax:011-604-646-5086
Philippines - Manila
Tel: 011-632-634-9065
Fax: 011-632-634-9069
Singapore
Tel: 65-6334-8870
Fax: 65-6334-8850
Taiwan - Kaohsiung
Tel: 886-7-536-4818
Fax: 886-7-536-4803
Taiwan - Taipei
Tel: 886-2-2500-6610
Fax: 886-2-2508-0102
Taiwan - Hsinchu
Tel: 886-3-572-9526
Fax: 886-3-572-6459
EUROPE
Austria - Weis
Tel: 43-7242-2244-399
Fax: 43-7242-2244-393
Denmark - Ballerup
Tel: 45-4450-2828
Fax: 45-4485-2829
France - Massy
Tel: 33-1-69-53-63-20
Fax: 33-1-69-30-90-79
Germany - Ismaning
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44
Italy - Milan
Tel: 39-0331-742611
Fax: 39-0331-466781
Netherlands - Drunen
Tel: 31-416-690399
Fax: 31-416-690340
England - Berkshire
Tel: 44-118-921-5869
Fax: 44-118-921-5820
WORLDWIDE SALES AND SERVICE
04/20/05

Вам также может понравиться