DS18B20 sensor in the input7 always gives me the value 127. I have used the wizard and put the sensor facing down.
Thanks
Thanks
Attachments
-
295 bytes Views: 44
Last edited:
Sounds like a memory issue.
An error with the DS18B20 usually gives 0,255 or 85
What do you get in b0 if you run this code?
main:
readtemp 7,b0
Pause 500
debug
goto main
ernio.
Please try this first.
Remove the DS18B20 from the Datalogger.
Read Manual 2, page 135.
Build the circuit, and try the program.
What happens?
e
A few things,
PICAXE does not support the DS18S20, only the DS18B20 will work with readtemp.
The DS18B20 requires a good clean 5v supply.
Min 4.5v, max 5.5v, so a supply of 3.8v is unlikely to return anything meaningful.
The current manual 2 (Basic commands) has 188 pages.
The latest versions of all the manuals can be found from the "PICAXE Manual" link at the top of this forum.
Yes DEBUG or SERTXD with the variable you have loaded READTEMP into being the read value from the DS chip... of course you must still have the serial connection to the computer connected for the reading to appear on screen
Your text implies you are using input 0 without a pull-up resistor.I did it. Project board 18X. Input 0 without resistence, external power suply(5V), 4k7 resistence and the follow code:
main:
readtemp 7,b0
Pause 500
debug
goto main
I got b0=127. Does it mind that the sensor doesn't work? All the mesures seem consistent.
Thanks
Your text implies you are using input 0 without a pull-up resistor.
That code must have the DS18B20 on input 7 with a 4k7 pull-up.
#picaxe 18X
#com 1
#Terminal 4800
Symbol TReading = W0
Symbol Whole = B2
Symbol Fract = B3
Symbol SignBit = B4
Symbol Dig_ = B5
Symbol TempC_100 = W4
Top:
ReadTemp12 7,TReading
SignBit = TReading / 256 / 128
If SignBit = 0 Then Positive
' its negative
TReading = TReading ^ $ffff + 1
Positive:
TempC_100 = TReading * 6 ' TC = value * 0.0625
TReading = TReading * 25 / 100
TempC_100 = TempC_100 + TReading
GoSub DisplayTemp
Wait 1
GoTo Top
DisplayTemp:
Whole = TempC_100 / 100
Fract = TempC_100 % 100
If SignBit = 0 Then DisplayTemp_1
SerTxD ("-")
DisplayTemp_1:
SerTxD (#Whole, ".")
' be sure the fractional is two digits
Dig_ = Fract / 10
SerTxD (#Dig_)
Dig_ = Fract % 10
SerTxD (#Dig_, 13, 10)
Return
Try this on CT5 input7
Source: http://www.phanderson.com/picaxe/ds18b20_2.htmlCode:#picaxe 18X #com 1 #Terminal 4800 Symbol TReading = W0 Symbol Whole = B2 Symbol Fract = B3 Symbol SignBit = B4 Symbol Dig_ = B5 Symbol TempC_100 = W4 Top: ReadTemp12 7,TReading SignBit = TReading / 256 / 128 If SignBit = 0 Then Positive ' its negative TReading = TReading ^ $ffff + 1 Positive: TempC_100 = TReading * 6 ' TC = value * 0.0625 TReading = TReading * 25 / 100 TempC_100 = TempC_100 + TReading GoSub DisplayTemp Wait 1 GoTo Top DisplayTemp: Whole = TempC_100 / 100 Fract = TempC_100 % 100 If SignBit = 0 Then DisplayTemp_1 SerTxD ("-") DisplayTemp_1: SerTxD (#Whole, ".") ' be sure the fractional is two digits Dig_ = Fract / 10 SerTxD (#Dig_) Dig_ = Fract % 10 SerTxD (#Dig_, 13, 10) Return
There's little point in trying out slightly more complex software. Need to get the hardware working first.
Not sure if a DS18B20 can be used on IP0.
Try it on input 7 WITH a 4k7 pull-up using the code I posted.
If that does not work, then the sensor is probably faulty.
If it does, then progress to the more complex stuff.