PDA

View Full Version : Temp. monitor with the LTC1298 and LM335

Tex4u
01-21-2007, 08:38 AM
I have a question about the conversion of the·data from the LTC1298.· I am monitoring a LM335 for temperature and have it tied to Pin 2 (channel 0) of the LTC1298.· (pin 3, channel 1, of the LTC1298·is monitoring light level with a photo resistor.)· So I am running in dual channel mode.· When I run a modified version of the code in this document: http://www.parallax.com/dl/docs/prod/appkit/ltc1298.pdf (http://www.parallax.com/dl/docs/prod/appkit/ltc1298.pdf)·
·
I get the number 2425 for·18C and 65F approximately.·
I have been working the math and I can convert the number 2425 to 20.9c easy enough with a calculator.· The question comes when I ask the BS2 to do the math.· I came up with a conversion numbers for converting the AD output to temperature.· For C·= ad/116 and F = ad/35.· I also want to display the temperatures as 20.9C and 69.2F

O.k. My question.· Someone·tell me there is an easier way to do this kind of math.· This was a simple problem and I had to jump through some hoops to keep the numbers above zero, to the left of the decimal point and below 65535.

Here is the code I came up with.

...
Again:
· For· oddSign = 0 to 1
· Gosub Convert
· Debug CRSRXY, 0, 0, "Temp "
· Debug CRSRXY, 0, 1, "Light"
· Debug CRSRXY, 6, 0 + oddSign, "- ", DEC AD, CR
· IF oddSign = 1 then goto ch1
· Tempc = (ad / 4) * 10 / 29
· Debug CRSRXY, 18, 0, "C : ", DEC Tempc / 10, ".", DEC1 Tempc
· Tempf = (ad * 10) / 5 * 10 / 8 * 10 / 88
· Debug CRSRXY, 31, 0, "F : ", DEC Tempf / 10, ".", DEC1 Tempf
· Several more "IF ad" statements related to temperature values.
··...
· Pause 100
Ch1:
Next
Pause 800
Goto Again

Thanks,

Tex

Tracy Allen
01-22-2007, 12:51 AM
Tempc = ad * 10 / 116
or
Tempc = ad ** 5650 ' impiies * 5650/65536

Fahrenheit temperature requires an offset of 32 degrees.

Tempf = Tempc * 9 / 5 + 320 ' in tenths of degrees

or

Tempf = Tempc */ 461 + 320 ' */ 461 implies * 461/256

Look up the ** and */ operators in the Stamp manual and at www.emesystems.com/BS2math1.htm (http://www.emesystems.com/BS2math1.htm)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

Tex4u
01-22-2007, 10:04 AM
Hey Tracy,

Thank you for your help. I guess I was making it a lot harder than I needed to.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

There are 10 types of people in the world.
··
Those that understand binary and those that don't.