Stumped Trying to convert Deg C to Deg F
Guido
Posts: 195
I am using Peter Andersons PIC One Wire Controller using a DS18B20 Temperature sensor. I am having a heck of a time converting his program to Read Degrees F. Any Help would be appreciaqted.
Guido
Main:
DO
AGN:
··· SEROUT 9, T9600, 10, [noparse][[/noparse]"P0", "W0cc", "S044"]···· 'perform temp meas
···································································· ' note strong pullup
··· PAUSE 1100················································ ' wait for conversion to complete
··· SEROUT 9, T9600, 10, [noparse][[/noparse]"P0", "W0cc", "W0be"]···· ' send temperature data
··· SEROUT 9, T9600, 10, [noparse][[/noparse]"R0"]···················· ' fetch data
··· SERIN 8, T9600, 1500, TimeOut, [noparse][[/noparse]DEC X.LOWBYTE]
··· PAUSE 100
··· SEROUT 9, T9600, 10, [noparse][[/noparse]"R0"]···················· ' fetch data
··· SERIN 8, T9600, 1500, TimeOut, [noparse][[/noparse]DEC X.HIGHBYTE]
··· PAUSE 100
··· ' now do the calculations
··· SignBit = X / 256 / 128
··· IF SignBit = 1 THEN ' its negative
······ X = X ^ $ffff + 1 ' take the two's comp
··· ENDIF
··· ' multiply by 6.25 - This is 100 * Tc
··· Y = X / 4·· ' 0.25
··· X = X * 6 + Y
··· Whole = X / 100
··· Fract = X // 100
··· IF SignBit = 1 THEN
······ DEBUG "-", DEC Whole, ".", DEC2 Fract, CR
··· ELSE
······ DEBUG DEC Whole, ".", DEC2 Fract, CR
··· ENDIF
··· PAUSE 3000 ' wait 3 secs
· LOOP
Guido
Main:
DO
AGN:
··· SEROUT 9, T9600, 10, [noparse][[/noparse]"P0", "W0cc", "S044"]···· 'perform temp meas
···································································· ' note strong pullup
··· PAUSE 1100················································ ' wait for conversion to complete
··· SEROUT 9, T9600, 10, [noparse][[/noparse]"P0", "W0cc", "W0be"]···· ' send temperature data
··· SEROUT 9, T9600, 10, [noparse][[/noparse]"R0"]···················· ' fetch data
··· SERIN 8, T9600, 1500, TimeOut, [noparse][[/noparse]DEC X.LOWBYTE]
··· PAUSE 100
··· SEROUT 9, T9600, 10, [noparse][[/noparse]"R0"]···················· ' fetch data
··· SERIN 8, T9600, 1500, TimeOut, [noparse][[/noparse]DEC X.HIGHBYTE]
··· PAUSE 100
··· ' now do the calculations
··· SignBit = X / 256 / 128
··· IF SignBit = 1 THEN ' its negative
······ X = X ^ $ffff + 1 ' take the two's comp
··· ENDIF
··· ' multiply by 6.25 - This is 100 * Tc
··· Y = X / 4·· ' 0.25
··· X = X * 6 + Y
··· Whole = X / 100
··· Fract = X // 100
··· IF SignBit = 1 THEN
······ DEBUG "-", DEC Whole, ".", DEC2 Fract, CR
··· ELSE
······ DEBUG DEC Whole, ".", DEC2 Fract, CR
··· ENDIF
··· PAUSE 3000 ' wait 3 secs
· LOOP
Comments
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
Thank You very much works great. Maybe you can also help me with this. I would like to serout the Temperature readings to another stamp. But I don not want to waste two word Variables to do it? Any Ideas
Thanks Again Bean