- Published: Saturday, 02 October 2010
- Written by Graham Mitchell
- Hits: 7066
The MCP9700, MCP9700A, MCP9701 and MCP9701A Temperature Sensors from Microchip offer exceptional performance for the price of the ICs. Each have different temperature ratings and accuracy parameters. Here's a list of features:
- Tiny Analog Temperature Sensor
- Available Packages: SC70-5, SOT-23-5, TO-92-3
- Wide Temperature Measurement Range:
- -40°C to +125°C (Extended Temperature)
- -40°C to +150°C (High Temperature) (MCP9700/9700A)
- ±2°C (max.), 0°C to +70°C (MCP9700A/9701A)
- ±4°C (max.), 0°C to +70°C (MCP9700/9701)
- Optimized for Analog-to-Digital Converters (ADCs):
- 10.0 mV/°C (typical) MCP9700/9700A
- 19.5 mV/°C (typical) MCP9701/9701A
The datasheet can be found here: MCP9700/9700A/9701/9701A Datasheet.
Device Packages + Interfacing
As shown on the right, the MCP97xxx sensors are available in different packaging and are very simple to interface with.
Vdd, GND and Vout are all that are required.
You should check the datasheet to get a better idea of the paramaters for the device you decide to use, though keep in mind that the user module listed below will automatically calculate the temperature depending on the device in use.
A recent discussion with Burt on the forums lead to some code snippets that would make interfacing with the MCP97xxx devices very easy. The user module is listed at the end of this article, and here's an example of using the module:
(this example will sample the temperature sensor and display the result in Word and Integer format every 500mS)
Points of Note
- The pin connected from the PIC to Vout should be configured as analogue before calling the user module. I have done this in the above example with the statement "ADCON1 = $E".
- Once "MCP97.ReadTemperature(pChannel)" has been called, the temperature results are stored in a public structure with multiple variable types. This makes it easy to quickly use the type of variable for different scenarios (for example, "Utils.Digit" can only parse byte, word and longword type variables - not integers.
- Temperature.WordVal - stores the temperature result as a word type variable with a scale of 10 (-12.1 = 121, +25 = 250)
- Temperature.Positive - if the WordVal is postive, then this flag is set true. Otherwise it is set false. (-12.1 = false, +25 = true)
- Temperature.IntVal - stores the temperature result as an integer type variable with a scale of 10 (-12.1 = -121, +25 = 250)
- You can use different devices by including the option definition like so: #option MCP97_Device = MCP9701A
Valid options are MCP9700, MCP9700A, MCP9701, MCP9701A.
Save the following code to the Swordfish "UserLibrary" folder, and call it "MCP97.bas"