3 temperature sensor – Texas Instruments MSC1210 User Manual

Page 141

Advertising
background image

Temperature Sensor

12-5

Analog-to-Digital Converter

12.3 Temperature Sensor

As shown in the chart above describing the ADMUX SFR, when all bits are set
to 1 (i.e. ADMUX = FFh), all the MUX inputs (AIN0-7, AINCOM) are discon-
nected from the ADC, and the ADC inputs are connected to measure two diode
junctions with different currents. This differential voltage will change linearly
with temperature, thus providing an integrated linear temperature sensor.

When using the temperature sensor, the voltage returned by the ADC is used
to determine the temperature in the following formula:

Float temp =

α * volts – 282.14;

This converts the voltage into a temperature in degrees centigrade. The above
temperature can, of course, be converted to Fahrenheit or Kelvin using stan-
dard conversion formulas. One value of

α

that gives good results is 2664.7.

The value of

α

can vary from part to part and is determined from experimental

data.

The following program is a simple example that returns the current tempera-
ture as detected by the MSC1210:

#include <REG1210.H>

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

#define LSB 298.0232e−9 /* LSB=5.0/2^24 */

#define ALPHA 2664.7

/* derived for some devices */

extern void autobaud(void);

extern long bipolar(void);

void main(void)

{

float volts, temp, resistance, ratio, lr, ave;

int i, k, decimation = 1728, samples;

CKCON = 0; // 0 MOVX cycle stretch

autobaud();

printf(”2MSC1210 ADC Temperature Test\n”);

//Timer Setup

USEC= 10; // 11MHz Clock

ACLK = 9; // ACLK = 11,0592,000/10 = 1,105,920 Hz

// modclock = 1,105,920/64 = 17,280 Hz

// Setup ADC

PDCON &= 0x0f7;

//turn on adc

ADMUX = 0x0FF;

//Select Temperature Diodes

ADCON0 = 0x30;

//Vref On, Vref Hi, Buff off, BOD off, PGA=1

ADCON2 = decimation & 0xFF; // LSB of decimation

Advertising