کسی از دوستان با DS18B20 کار کرده لطف کنه دستورات لازم برای راه اندازیش در PICBASIC رو یادم بده.از دستورات زیر و شبیه اینها استفاده کردم اما جوابی نشد دیگه واقعا موندم چه کنم.
readtemp: 'Read DS18B20 sensor data, works with only one sensor, no id used.
OWOUT DQ, 1,[$CC, $44] 'Initialise Temp conversion
PAUSE 1000 'Wait for conversion - 1 second!
OWOUT DQ, 1, [$CC, $BE] 'Get sensor to send data from scratchpad
OWIN DQ,2,[y] 'Read first 2 bytes of data (temperature) and store in temp variable
IF temp.Bit11 = 1 THEN
sign="-"
temp2 = 625 * ~temp+1 'Multiply to load internal registers with 32-bit value
tempC = DIV32 1000 'Use Div32 value to calculate precise deg C
ELSE
sign="+"
temp2 = 625 * temp 'Multiply to load internal registers with 32-bit value
tempC = DIV32 1000
tempc=tempc/10 'Use Div32 value to calculate precise deg C, eg 201 for 20.1C
ENDIF
RETURN
readtemp: 'Read DS18B20 sensor data, works with only one sensor, no id used.
OWOUT DQ, 1,[$CC, $44] 'Initialise Temp conversion
PAUSE 1000 'Wait for conversion - 1 second!
OWOUT DQ, 1, [$CC, $BE] 'Get sensor to send data from scratchpad
OWIN DQ,2,[y] 'Read first 2 bytes of data (temperature) and store in temp variable
IF temp.Bit11 = 1 THEN
sign="-"
temp2 = 625 * ~temp+1 'Multiply to load internal registers with 32-bit value
tempC = DIV32 1000 'Use Div32 value to calculate precise deg C
ELSE
sign="+"
temp2 = 625 * temp 'Multiply to load internal registers with 32-bit value
tempC = DIV32 1000
tempc=tempc/10 'Use Div32 value to calculate precise deg C, eg 201 for 20.1C
ENDIF
RETURN
دیدگاه