lerameur
- 17th December 2006, 03:36
HI,
I have been trying to make a DS18S20 work, I have used the code on Rentron to guide me.
http://www.rentron.com/PicBasic/one-wire3.htm
BUt what I get around 3000 degrees as my output.
I basically took his code and removed the Fahrenheit calculation and put it on a LCDout command. with no minus temperature.
shouldn't the command Div32 give me the temperature in Celcius directly ?
ken
Start_Convert:
OWOUT Comm_Pin, 1, [$CC, $44]' Skip ROM search & do temp conversion
Wait_Up:
OWIN Comm_Pin, 4, [Busy] ' Read busy-bit
IF Busy = 0 THEN Wait_Up ' Still busy..?, Wait_Up..!
OWOUT Comm_Pin, 1, [$CC, $BE]' Skip ROM search & read scratchpad memory
OWIN Comm_Pin, 2, [R_Temp.Lowbyte, R_Temp.Highbyte]' Read two bytes / end comms
GOSUB Convert_Temp
GOTO Start_Convert
Convert_Temp:
Sign = "+" Dummy = 625 * R_Temp ' Multiply to load internal registers with 32-bit value
TempC = DIV32 10 ' Use Div32 value to calculate precise deg C
Lcdout $fe, 1 'Clear screen
Lcdout "Value: ", DEC TempC, Deg,"C " 'Display the decimal value
RETURN
END
I have been trying to make a DS18S20 work, I have used the code on Rentron to guide me.
http://www.rentron.com/PicBasic/one-wire3.htm
BUt what I get around 3000 degrees as my output.
I basically took his code and removed the Fahrenheit calculation and put it on a LCDout command. with no minus temperature.
shouldn't the command Div32 give me the temperature in Celcius directly ?
ken
Start_Convert:
OWOUT Comm_Pin, 1, [$CC, $44]' Skip ROM search & do temp conversion
Wait_Up:
OWIN Comm_Pin, 4, [Busy] ' Read busy-bit
IF Busy = 0 THEN Wait_Up ' Still busy..?, Wait_Up..!
OWOUT Comm_Pin, 1, [$CC, $BE]' Skip ROM search & read scratchpad memory
OWIN Comm_Pin, 2, [R_Temp.Lowbyte, R_Temp.Highbyte]' Read two bytes / end comms
GOSUB Convert_Temp
GOTO Start_Convert
Convert_Temp:
Sign = "+" Dummy = 625 * R_Temp ' Multiply to load internal registers with 32-bit value
TempC = DIV32 10 ' Use Div32 value to calculate precise deg C
Lcdout $fe, 1 'Clear screen
Lcdout "Value: ", DEC TempC, Deg,"C " 'Display the decimal value
RETURN
END