help with unstable DS18B20

Hi
Can anyone offer me some advice
I am having difficulties using readtemp with a DS18B20.

(Using debug) The readings from the chip fluctuate between 25 (actual temp), 129 and 9 (or 12,13). this is very frustrating because i'm trying to turn a fan on at >=25 and off <=18, and the fluctuating readings cause the fan to pulse on and off.

The chip is connected approx 10m from the picaxe chip and the 4k7 pullup via telephone cable

I'm wondering if the increased resistance of the cable would change the value of the pullup resistor, (just a thought), or maybe the DS18b20 is faulty, or... or... I just don't know!



Thanks for any help
 

westaust55

Moderator
I doubt the the DS18B20 is faulty.
10 metres of telephone cable should be acceptable still. I have done tests using up to 40 metres of audio cable which is far from the best but will work.

Are you using the DS18B20 in:
1) separately powered mode, or
2) parasitically powered mode.

If parasitically powered, then try with a separate powered, by taking 5V from the PICAXE circuit via a third core in the telephone cable.

As I read from your post your pull-up resistor is at the PICAXE That is the correct location. Try dropping the pull up resistor to say 2k2 Okms.

Do not earth any spare cores in the cable as that can increase capacitance and distort to signal.

Can you upload a circuit diagram and your program listing.
 

MartinM57

Moderator
First simple test is to connect the DS18B20 by a 10cm cable - does that fix the instability? If not, it's not the cable :)

I always use "Separate Power Mode" - just follow Manual 2 wiring example under the readtemp command.

Finally, are you really sure it is a DS18B20 - we've been round the houses before with DS18B20 problems where it turned out it was some strange variant purchased incorrectly. Where did you get it from?
 

hippy

Ex-Staff (retired)
Testing closer to the chip would be my first step.

We really need to have a program plus full circuit diagram, know which PICAXE, what supply voltage, what speed it's running at, how the DS18B20 is read ( READTEMP/12 or OWIN/OWOUT ), which pin it's connected to, whether parasitically powered or not, whether any other one-wire devices are connected or not, to make educated guesses at what could be wrong if it's not a faulty DS18B20.
 
I doubt the the DS18B20 is faulty.
10 metres of telephone cable should be acceptable still. I have done tests using up to 40 metres of audio cable which is far from the best but will work.

Are you using the DS18B20 in:
1) separately powered mode, or
2) parasitically powered mode.

If parasitically powered, then try with a separate powered, by taking 5V from the PICAXE circuit via a third core in the telephone cable.

As I read from your post your pull-up resistor is at the PICAXE That is the correct location. Try dropping the pull up resistor to say 2k2 Okms.

Do not earth any spare cores in the cable as that can increase capacitance and distort to signal.

Can you upload a circuit diagram and your program listing.

Hi Thanks for your help

I will change pullup resistor to 2K2 Ohms as suggested and see if it fixes the problem

I didn't think that 10m was too far either and was planning another unit that has a longer run so it's nice to know that a longer distance has been tried successfully

No other cores within the cable are earthed

The DS18B20 is powered in the circuit directly as per manual2 readtemp

the code segment is as follows

Cheers


;Picaxe 28x1

Symbol TReading = b11
Symbol fanstatus = b12
Symbol fanontime = b21
Symbol fan = 3
setfreq m4
settimer t1s_4

main:
if timer >= 60 then gosub incrementtimer ;increment variable fantime every minute
ReadTemp 3,TReading ; read value from i/p 3 into b11
pause 750
if treading >= 25 and fanstatus <> 1 then : gosub turnfanon : elseif treading <=18 and fanstatus = 1 and fanontime >= 5 then: gosub turnfanoff : endif
; fanstatus is set to 1 when fan is on and 0 when it is off
;fanontime value has been added to avoid o/p 3 pulsing due to unstable readings from DS18B20
goto main

incrementtimer:
let timer = 0
let fanontime = fanontime + 1
return

turnfanon:
let fanstatus = 1
let fanontime = 0
high fan
return
turnfanoff:
let fanstatus = 0
low fan
return
end
 
Finally, are you really sure it is a DS18B20 - we've been round the houses before with DS18B20 problems where it turned out it was some strange variant purchased incorrectly. Where did you get it from?
Hi
I bought the DS18B20 from an authorised Aussie dealer, Hopefully it should be a legit chip.
Cheers
 
Testing closer to the chip would be my first step.

We really need to have a program plus full circuit diagram, know which PICAXE, what supply voltage, what speed it's running at, how the DS18B20 is read ( READTEMP/12 or OWIN/OWOUT ), which pin it's connected to, whether parasitically powered or not, whether any other one-wire devices are connected or not, to make educated guesses at what could be wrong if it's not a faulty DS18B20.
Hi

Picaxe is 28x1

Supply voltage is 5v from a LM7805, i originally was using a L78S05 but changed to the higher powered LM7805 hoping that this might be the reason for the chip being unstable but problem was still there %^&*

using readtemp to read from i/p3

DS18B20 is directly powered as per manual 2 diagram

No other one-wire devices are connected

I will definitely try a shorter run as a test.
If this doesn't work then I'll buy another DS18b20 and see if it's different

I'd love to solve, this because in future i want to use several of these chips together as one-wire devices using OWIN/OWOUT.

Thanks for your help
 

inglewoodpete

Senior Member
I think what Martin is asking is: "Does the chip have DS18B20 or 18B20 printed on it?" There are a lot of variants and some of the digital comms protocols are different to the DS18B20. If you have the wrong one, the PICAXE may give strange readings.

I have 2 DS18B20's working reliably on the same 10m run of telephone cable (1 signal wire for each chip) with a 20X2 (also works with an 08M).
 

MartinM57

Moderator
Might be the wrong chip though (unlikely ;))

You just need to do standard fault finding - simplify eveything and build it back up until it breaks.

First step is simple code

#PICAXE 28x1
#TERMINAL 4800
Symbol TReading = b11
setfreq m4

do
ReadTemp 3,TReading
sertxd ("Temp is ", #TReading, CR, LF)
loop

..is that reliable?
 

hippy

Ex-Staff (retired)
Before doing anything else test the DS18B20 closer to the PICAXE.

Do you have a scope ? If so have a look at what the signal is on Input Pin 3 before changing the pull-up. Also look at the output pin of the DS18B20 and its power supply.

Is the pull-up at the PICAXE or at the DS18B20 end of the cable ?

What is this fan and how is it controlled ? Have you tried operation and temperature reading with the fan not connected ? It may be that when the fan switches on it causes interference which causes DS18B20 mis-readings, the 10m cable acting as an aerial.

Get a magnifying glass and check the DS18B20 does have that marking, not DS18B20-P or similar.
 
Before doing anything else test the DS18B20 closer to the PICAXE.

Do you have a scope ? If so have a look at what the signal is on Input Pin 3 before changing the pull-up. Also look at the output pin of the DS18B20 and its power supply.

Is the pull-up at the PICAXE or at the DS18B20 end of the cable ?

What is this fan and how is it controlled ? Have you tried operation and temperature reading with the fan not connected ? It may be that when the fan switches on it causes interference which causes DS18B20 mis-readings, the 10m cable acting as an aerial.

Get a magnifying glass and check the DS18B20 does have that marking, not DS18B20-P or similar.
Hi
Nope NO scope :D
Pullup is at picaxe
12v Fan is controlled via a relay that is switched by picaxe
Will look and see if it errors occur with relay off, the aerial is an interesting suggestion.

Thanks
 
I think what Martin is asking is: "Does the chip have DS18B20 or 18B20 printed on it?" There are a lot of variants and some of the digital comms protocols are different to the DS18B20. If you have the wrong one, the PICAXE may give strange readings.

I have 2 DS18B20's working reliably on the same 10m run of telephone cable (1 signal wire for each chip) with a 20X2 (also works with an 08M).
Point taken
Will get out the magnifying glass and have a good look
cheers

PS I used to live on a old farm called "Inglewood"
 

cactusface

Senior Member
Ds18b20??

Hi,
This sounds a bit like my first attemps with the DS18B20 or is it marked DS18B20P? that was my problem! I'd got hold of the "P" version, this can run without a power supply, but it needs a FET to get power from the data line, also this can only be done at certain times, so I was getting nothing or data that did'ent make any sense!!

Just an idea
Regards
Mel.
 

InvaderZim

Senior Member
If it works with a short cable but not a long, note which conductors you used. If some of the wires are twisted pairs it can affect your situation.
 

ed1066

Member
I will change pullup resistor to 2K2 Ohms as suggested and see if it fixes the problem
I found this thread as I was having some instability problems with a DS18B20 on a 6m 4 core cable connected on to a 2m 3 core cable. The 4 core was power (5V), ground, a signal to an OLED display and the DS18B20 signal wire. The 3 core cable was just the 3 wires on to the DS18B20. The DS18B20 signal was pulled high with a 4k7 at the PIAXE 20X2 end.

In the program I was careful to use the readtemp command over 1 sec after any serout signals to the OLED. But despite this, about 1 reading in 30 came back as garbage.

Following this thread I reduced the pullup resistor right down to less than 2k ohms and the problem appears to be solved.

I want the flexibility to connect the DS18B20 on its 2m lead to the board with the PIAXE 20X2 or at the end of the 6m OLED cable (still 4 core with the DS18B20 signal wire still connected to the relevant pin, C.2), so I tried it with the lower pullup resistance, and that worked too. Great news.

My question is, .. is there long term damage or other problems with having a lower pullup resistance? If things work so much better with this low resistance value, why is 4k7 recommended? In each of my cases there is a longish lead (8m total) so my guess is that the capacitance in the lead causes more current to need draining in the time required, hence the smaller resistance is needed. But that's just a guess.

Comments welcome.

Ed
 

westaust55

Moderator
The DS18B20 is in fact a 1-Wire device that can be used on a network. The READTEMP command is a specific command for the DS18B20 and only allows one device to be connected to each PICAXE IO pin.
USING the more general 1-Wire commands available in the X1 and X2 PICAXE parts, it is possible to establish a 1-Wire network comprising many devices.

Reducing the value of the pull-up resistor for some 1-Wire devices and longer cable cable lengths is a valid solution.

Have a read of the tutorial I posted here: http://www.picaxeforum.co.uk/showthread.php?15306-One-Wire-Devices-Networks/page5
In particular the first few pages which cover topics such as the pull up resistor requirements.
 

shoei600

New Member
I made a unit with 4 sensors attached for a friends villa recently, one of the sensors he wired to about 15 metres of 4 core phone cable, constant garbage was returned.

We stuck with the 4k7 pull up at the picaxe end but he replaced the cable for standard cat5e and used 2 pairs.

Problem solved and its been solid ever since.
 

westaust55

Moderator
I made a unit with 4 sensors attached for a friends villa recently, one of the sensors he wired to about 15 metres of 4 core phone cable, constant garbage was returned.

We stuck with the 4k7 pull up at the picaxe end but he replaced the cable for standard cat5e and used 2 pairs.

Problem solved and its been solid ever since.
The difference is that:
1. ordinary phone cable has parallel conductors over entire length
2. Cat5/5e/6 cable has twisted pairs (increasingly tighter/more twists per metre 5-->5e-->6) which helps prevent/cancel electrical noise pickup.

I have successfully used untwisted screened audio cable to about 40 metres and CAT5e cable to 100 metres - each with 5 DB18B20's at the end.
 

john2051

New Member
Hi, just a small query.
You say the 78S05 isnt as powerful as the regular 7805. The way I understand it is that the 'usual' 7805 is good for up to one amp. The 78S05 is supposed to be up to two amps, with the T rated for three amps.
Some of the cheap dc fans will draw quite a large current at switch on, maybe this is causing a voltage sag, upsetting either the sensor or the picaxe.

regards john
 

westaust55

Moderator
@John,
I take it you are referring to post 7 which was posted in September 2010

However your data is otherwise correct with respect to 2 Amp and 3 Amp regulators.

Also the 78H05 is/was a 5 Amp TO3 version - which I have used a few of in the past.
 
Top