[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_content.php on line 1014: Undefined array key 3
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_content.php on line 1014: Undefined array key 3
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4130: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3009)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4130: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3009)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4130: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3009)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4130: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3009)
Controlling your World the Easy Way • Interfacing an MCP9700 analog temp sensor...???
Page 1 of 1

Interfacing an MCP9700 analog temp sensor...???

Posted: Thu Jun 20, 2013 6:20 pm
by RBSe
Hi,

In trying to fill the box of my Digi-Key order I ran across the MCP9700 (pdf) analog temp sensor for $0.30 and i thought it might work well on the EZSBC1 analog inputs.
The I.C. is a TO-92 case and has a range of -40c to +125c, 10mv/degree C output with a 500mv + offset .
How would I get a Farenheit output with 1 decimal in control basic code...???
Thanks for your help.

Robert
.

Re: Interfacing an MCP9700 analog temp sensor...???

Posted: Thu Jun 20, 2013 9:08 pm
by Daniel
Hi Robert

There are many ways including just measuring the voltage, subtracting 500mV and then converting Celsius to Fahrenheit by multiplying by 9/5 and adding 32. There is a more direct way.
The sensor is specified from -40C to 125C and it is linear. With a bit of arithmetic it is easy to find that at -40 the readout measurement on the 10-bit ADC with a 3300mV reference will be 31 and 125 it will be (ideally) 542.5. Since the ADC does not measure fractions of a bit lets round that to 543. At -40C the temperature is also -40F and at 125C the temperature is 257 Fahrenheit.
Now we have the four points needed to use the MAP function described in the user manual on p37.

Code: Select all

'MCP9700 in Fahrenheit
'MCP0700 connected to pin 10 of the EzSBC1
PINMODE 10,ADC  'Use pin 10 as ADC input
tempX= INADC( 10 )
TempF = MAP( tempX, 31, 543, -40, 257)

'Multiply by ten, truncate the decimals and divide by 10 to get one decimal
TempF = ( INT (TempF*10) )/10.0  
PRINT TempF
END


Daniel

Re: Interfacing an MCP9700 analog temp sensor...???

Posted: Thu Jun 20, 2013 11:46 pm
by Andries Pretorius
Nice efficient coding Daniel!!

Thank you

Andries

Re: Interfacing an MCP9700 analog temp sensor...???

Posted: Fri Jun 21, 2013 9:41 pm
by RBSe
Fantastic Daniel!

I knew it would be a good example on how to use the MAP command.
But, i did not expect it to be so efficient and concise
Now i understand the power of the MAP command much better.
Thanks Daniel,

Robert
.