How to convert output of LTC1298 to Temperature F
MikeS
Posts: 131
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
Post Edited (MikeS) : 3/28/2009 2:30:06 PM GMT
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 [b]CON[/b] [b]_clkmode[/b] = [b]xtal1[/b] + [b]pll16x[/b] [b]_xinfreq[/b] = 5_000_000 [b]OBJ[/b] text : "tv_text" Ain:"CD_LTC1298" [b]VAR[/b] 'long temp [b]word[/b] temp [b]pub[/b] start text.start(12) Ain.start(0) text.[b]str[/b]([b]String[/b]("The Temperature = ")) text.out(12) 'change color text.out(9) ' white text red background [b]waitcnt[/b](clkfreq + [b]cnt[/b]) ' Pause 1 Second [b]repeat[/b] temp :=Ain.GetADC(0) ' get channel 0 analog input 'temp := temp ** 8002 ''does not work text.dec(temp) ' output to tv [b]waitcnt[/b](clkfreq + [b]cnt[/b]) ' 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
Comments
I am thinking it needs to be the lower 32 bits, not the upper 32 bits?
* 8002 doesn't work, returns a big 7 digit number
MikeS
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...
I had thought about the Floating Point math object but am not sure how to apply it.
MikeS
temp /= 849
Don't know if this is the proper way... but I think it will get there...
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 -> [url=Http://www.rawcircuits.com]www.rawcircuits.com[/url]
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
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
Once again you have saved my bacon. Your help and guidance on these forums is much appreciated.
Give your self a raise!
Thanks,
MikeS