Hello,

I'm using an example code for a DS1820 that does the math for the display to show either Fahrenheit or Celsius to 2 decimal places. I don't understand the math that's done here and was wondering if anyone could suggest a way to do the conversion without the decimal places.

This works fine and isn't a problem in my programs but I'd like to use Darrel Taylor's "Temp_Convert" include file so I can display negative temperatures and I think the math here is screwing up the conversion in the include file. In his example code "Test_Temp_Convert" the temperatures are declared before the conversion with whole numbers so I thought if I could get whole numbers returned with the code I'm using below then the include file might work. Has anyone used Darrels "Temp_Convert" include file with a DS1820? I'd be grateful for any help.

Thanks
jessey

Code:
Update_Pond_Temperature: 
 OWOut Sensor_Input, 1, [$CC, $44]    ' Start Water_Temp conversion
waitloop:
 OWIn Sensor_Input, 4, [count_remain] ' Check for still busy converting
 IF count_remain = 0 THEN waitloop

 OWOut Sensor_Input, 1, [$CC, $BE]    ' Read the Water_Temp
 OWIn Sensor_Input, 0, [Water_Temp.LOWBYTE, Water_Temp.HIGHBYTE, _
                        Skip 4, count_remain, count_per_c]

  IF Temp_Displayed = Celsius then
     ' Calculate Water_Temp in degrees C to 2 decimal places 
     Water_Temp = (((Water_Temp >> 1) * 100) - 25) _
                          + (((count_per_c - count_remain) * 100) / count_per_c)
   RETURN 
  ENDIF
 
  IF Temp_Displayed = Fahrenheit then
     ' Calculate Water_Temp in degrees C to 2 decimal places 
     Water_Temp = (((Water_Temp >> 1) * 100) - 25) _
                          + (((count_per_c - count_remain) * 100) / count_per_c)
     ' Convert Water_Temp from Celsius degrees to Fahrenheit to 2 decimal places 
     Water_Temp = (Water_Temp */ 461) + 3200
   RETURN 
  ENDIF
Then to display I use this:
Code:
  IF Temp_Displayed = Fahrenheit then 
    LCDOut $fe, $c0,"H2o=",DEC Water_Temp / 100,0,"F "  
  ENDIF
  IF Temp_Displayed = Celsius then   
    LCDOut $fe, $c0,"H2o=",DEC Water_Temp / 100,0,"C " 
  ENDIF