PDA

View Full Version : How to convert output of LTC1298 to Temperature F



MikeS
03-28-2009, 09:32 AM
I have successfully connected an LM34DZ to an LTC 1298 ADC and can display the raw data on the tv monitor. I am having trouble converting the raw value into Fahrenheit.
I have the same circuit with an SX and I convert this way (temp = temp ** 8002) and it works. But I must be doing something wrong in Spin. Any help is appreciated.
MikeS




''LM34_LTC1298_tv.spin
CON

_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000

OBJ

text : "tv_text"
Ain:"CD_LTC1298"



VAR

'long temp
word temp

pub start
text.start(12)
Ain.start(0)
text.str(String("The Temperature = "))
text.out(12) 'change color
text.out(9) ' white text red background
waitcnt(clkfreq + cnt) ' Pause 1 Second
repeat

temp :=Ain.GetADC(0) ' get channel 0 analog input
'temp := temp ** 8002 ''does not work
text.dec(temp) ' output to tv
waitcnt(clkfreq + cnt) ' wait a sec
text.out($0A) 'move cursor x axis
text.out(18) '19 spaces



Post Edited (MikeS) : 3/28/2009 2:30:06 PM GMT

Joms
03-28-2009, 09:36 AM
Try " temp *= 8002 "

I am thinking it needs to be the lower 32 bits, not the upper 32 bits?

MikeS
03-28-2009, 09:48 AM
Joms
* 8002 doesn't work, returns a big 7 digit number

MikeS

Joms
03-28-2009, 09:57 AM
Hmmm... Maybe it is really hot in there?

I will try a few things... It will give me a break from my serial string problem for a bit...


EDIT:

Without the calculation ( *8002 part ) what does it return for a number? If it is a decimal point number you will probably have to use the floating point math object...

MikeS
03-28-2009, 10:04 AM
It is 77 degrees in the room and the LM34 is reading .777 with the voltmeter. The output to the TV monitor is 660. the output does change accordingly with heat and cold applied to the LM34.
I had thought about the Floating Point math object but am not sure how to apply it.
MikeS

Joms
03-28-2009, 10:12 AM
Try this...

temp /= 849

Don't know if this is the proper way... but I think it will get there...

MikeS
03-28-2009, 10:19 AM
No dice, returns 0

grasshopper
03-28-2009, 12:26 PM
What I do is find the slope and calculate the temperature. Take 2 readings one at 0 (ice water) and one at another preferred constant, like boiling water.

Plot these 2 reading against the A2D numbers that are read at the temperatures - then calculate the slope.

for example in ice the temp is close to 32 degrees and you'll read some A2D number ( Y2 - Y1 ). Repeat the same for another temperature like boiling water 212 and some A2D number (X2 / X1)

Y2 - Y1 / X2 - X1 = m

Y = m X + B

Calculate the rest, its simple..

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit my site -> www.rawcircuits.com (Http://www.rawcircuits.com)

MikeS
03-28-2009, 05:39 PM
I think the problem may be with the ** operator, resolution different in Propeller and Stamp. (Returns 32 bits vs 16 bits)
Tracy Allen gave me the conversion several years ago( http://forums.parallax.com/forums/default.aspx?f=5&m=56355 ) and it works for the BS2 and SX/B great.
I even changed the variable length in the spin program to WORD but still no help. Maybe inaccuracy in the LTC1298 Object? just guessing.
MikeS

LTC1298 Spin Object is returning the same number as the STAMP LTC1298 program. problem is the Math.
MikeS

Post Edited (MikeS) : 3/28/2009 2:13:15 PM GMT

Tracy Allen
03-28-2009, 11:43 PM
Mike,

The LTC1298 produces an output count ratiometric to its power supply. If it is powered from 5.0 volts, then the conversion is,
5000/4096 = 1.220703125 mV per bit. Temperature from the LM34 is 10 mV per degF, so, for example, if the ADC value is 1000, then the temperature is 122 degF. degF = ADCounts * 0.122. If you want that in tenths of a degree it would be, degF10 = ADCounts * 1.22.

On the Stamp, you calculate 65536 * 0.1220703125 = 8000. The change to 8002 may have been a fudge factor to account for power supply, calibration etc. On the Prop, the ** operator work with 2^32 instead of 2^16, so 2^32 * 0.12207031125 = 524288000.
degF := ADCounts ** 524_288_000
The ** operator internally first multiplies times 524,288,000 and then divides by 2^32, and 524,288,000/4,294,967,296 is the best approximation (with denominator 2^32 instead of 10^10) to 0.1220703125.

If you want resolution to 0.1 degF, then the multiplier becomes 1.220703125. And 0.22073125*2^32 = 947,912,704.
degF10 := ADCounts ** 947_912_704 + ADCounts

If your power supply for the LTC1298 is not 5 volts, you'll have to recalculate the factor and calibrate for the individual sensor.

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

MikeS
03-29-2009, 01:26 AM
Tracy,
Once again you have saved my bacon. Your help and guidance on these forums is much appreciated.
Give your self a raise!
Thanks,
MikeS