Hi,
I've been "playing" wih a DS18B20 and noted that it seems to work fine using only the PICaxe's internal Weak Pullup resistor (~30k) instead of the normal external pullup. It's a "Waterproof Probe" type (so I can't actually check if it's "genuine Dallas") with about 1m of cable, but for the following observation I am using a normal external pullup resistor:
As a follow-up to the above experiment I thought it could be useful to measure the normal voltage level on the data line (I believe the minimum should be 2.2 volts) using READADC. However, after the first READADC, READTEMP appears to always return 0 (zero). Of course READADC turns the Data pin into an input, but it should be this anyway and making it an output doesn't appear to help.
So I tried replacing the READADC{10} by my "equivalent" POKE/PEEK SFR commands and they DO NOT break the READTEMP. Here is my test code (using PE5), any ideas?
Cheers, Alan.
I've been "playing" wih a DS18B20 and noted that it seems to work fine using only the PICaxe's internal Weak Pullup resistor (~30k) instead of the normal external pullup. It's a "Waterproof Probe" type (so I can't actually check if it's "genuine Dallas") with about 1m of cable, but for the following observation I am using a normal external pullup resistor:
As a follow-up to the above experiment I thought it could be useful to measure the normal voltage level on the data line (I believe the minimum should be 2.2 volts) using READADC. However, after the first READADC, READTEMP appears to always return 0 (zero). Of course READADC turns the Data pin into an input, but it should be this anyway and making it an output doesn't appear to help.
So I tried replacing the READADC{10} by my "equivalent" POKE/PEEK SFR commands and they DO NOT break the READTEMP. Here is my test code (using PE5), any ideas?
Code:
#picaxe 20m2
#no_data
#define showbug
symbol Vcc = b.1 ; 18B20 supply
symbol Dat = b.0 ; 18B20 data
pullup 1 ; May permit omission of the external pullup resistor
do
high Vcc ; Supply rail to 18B20
readtemp dat,w1 ; Works fine on first pass
#ifdef showbug
readadc10 dat,w3 ; ** BREAKS Readtemp **
#else
call readadc1 ; Read ADC value of b.1 into w3 using SFRs
#endif
sertxd(#w1," C ",#w3,cr,lf)
pause 3000
loop
symbol ADRESL = $3B ; ADC Low byte
symbol ADRESH = $3C ; ADC High byte
symbol ADCON0 = $3D ; ADC control register 0
symbol ADCON1 = $3E ; ADC control register 1
readadc1:
pokesfr ADCON1,%10000000 ; Right Justify result
pokesfr ADCON0,%00000111 ; Select b.0 (AN1) input and ADC on
pokesfr ADCON0,%00000111 ; Start conversion
peeksfr ADRESL,b6,b7 ; Read w3
return
#rem Terminal Typical Result:
16 C 1020
0 C 1021
0 C 1021