DS18B20 parasite power

neiltechspec

Senior Member
Comments please.

Been playing with DS18B20's.

This alternate way of parasite power using just two wires seems to work quite well.

Reading every 6 seconds, the supplied Vdd to the two wire 18B20 never drops below 4.3v.

Using the correct method & my method, stuck the two together & varied the temp from 5c (outside) & 50c of both & they read the same.

Code:
;Indoor DS18B20 (if fitted) on pin c.1
;Outdoor DS18B20 (if fitted) on pin c.2
;Lantronix Port 2 on pin c.4
;display temp to 1 decimal place resolution


#picaxe 08M2
#no_data
#terminal 4800

main:
	high c.2
	do
	for b0=1 to 5
	if b0=5 then gosub clscreen
	gosub indoor
	gosub outdoor
	pause 5000
	next
	loop

indoor:					;read temperature, sertxd & serout it 
	readtemp12 C.1,w9			;read raw data into variable w9
	
	if w9=0 then			;check for DS18B20 fitted
	 sertxd("Indoor DS18B20 not present",13,10)
	 serout C.4,T2400,("Indoor Sensor not present",13,10)
	 pause 750
	 return
	endif
	
	b22 = 43				;sign is "+"

	if w9 > 2048 then			;check for below 0 deg
	 b22 = 45				;if temp is below 0 sign is "-"
	 let w9 = - w9			;two's compliment
	endif
	
  	w10 = w9 * 10 / 16
  	
  	bintoascii w10,b23,b24,b25,b26,b27
  	
  	sertxd ("Indoor Temp: ",b22,b25,b26,".",b27,"c",13,10)
  	serout C.4,T2400,("Indoor Temp: ",b22,b25,b26,".",b27,"c",13,10)
	
	return
	
outdoor:					;read temperature, sertxd & serout it
	readtemp12 C.2,w9			;read raw data into variable w9
	
	high c.2
	
	if w9=0 then			;check for DS18B20 fitted
	 sertxd("Outdoor DS18B20 not present",13,10,13,10)
	 serout C.4,T2400,("Outdoor Sensor not present",13,10,13,10)
	 pause 750
	 return
	endif
	
	b22 = 43				;sign is "+"

	if w9 > 2048 then			;check for below 0 deg
	 b22 = 45				;if temp is below 0 sign is "-"
	 let w9 = - w9			;two's compliment
	endif
	
  	w10 = w9 * 10 / 16
  	
  	bintoascii w10,b23,b24,b25,b26,b27
  	
  	sertxd ("Outdoor Temp: ",b22,b25,b26,".",b27,"c",13,10,13,10)
	serout C.4,T2400,("Outdoor Temp: ",b22,b25,b26,".",b27,"c",13,10,13,10)
	
	return
	
clscreen:
	serout C.4,T2400,(27,91,50,74)	;clear terminal screen
	pause 80
	serout C.4,T2400,(27,91,72)		;home cursor
	pause 80
	b0=1
	return
Picture cockup - C.3 & C.4 are transposed.

Neil.
 

Attachments

Last edited:

westaust55

Moderator
Yes parasitic powered mode will work but can be prone to more difficulties.
(See my 1-Wire network thread)
One Ds18B20 is okay but with multiple devices on one pin with an X1 or X2 part and longer cables you may need to reduce the pull up resistor or need to revert to separately powered methods.
 

neiltechspec

Senior Member
Obviously what I have done is unlikely to work for more than 1 sensor.

I tried this because I only have 1 spare pair left in the two cat5's going out to the garage, only need 1 sensor.

Might try a small supercap (.047F) on it, it will take longer to charge up but should give a more stable Vcc for the 18B20.

Neil
 

westaust55

Moderator
Adding a cap to the combined 'power and data' line in parasitic mode is not going to work.
It will affect the rise and fall time of the data. A lower value of pull up resistor is likely to improve the situation allowing more current through during the temperature conversion process.
I have used values down to 2.2 kOhms where an extensive 1-Wire network is involved.
 

Buzby

Senior Member
Oh yes it does !!!.

I think you need to look again at the schematic.
I think Westie is talking about the 'real' parasitic power scheme, as opposed to the one you have built. The 'real' parasitic power facility needs no extra components with the 18B20, and has Vdd ( pin 3 ) connected to ground.

Your 'pseudo' parasitic power uses a diode and capacitor to provide volts to Vdd, and this method will benefit from (a) a decent capacitor, and (b) a low Vf diode.

'Real' parasitic power is a real pain in the ****, much better to do what you did, or use a 3 core cable !.
 

neiltechspec

Senior Member
Right, I wondered what he was on about.

My simple method seems to be working quite well. Been running now for 24 hours over about 25m of cat5 on the last available pair.

Purchased some supercaps of the bay this afternoon, 0.047F, will stick one of those on it & watch the
supply voltage for bit & see what happens, no doubt it will take a bit to charge up initially.

Neil.
 

premelec

Senior Member
Did you stay with the 1000uF cap or have to go larger? I would think that even less than 1KuF would do considering what "true" parasitic power runs on with IC internal cap [not large]. I like your diode isolation...
 

westaust55

Moderator
typo fix
I think Westie is talking about the 'real' parasitic power scheme, as opposed to the one you have built. The 'real' parasitic power facility needs no extra components with the 18B20, and has Vdd ( pin 3 ) connected to ground.

'Real' parasitic power is a real pain in the ****, much better to do what you did, or use a 3 core cable !.
Correct. Maybe neiltechspec should use a term like "pseudo parasitic" or "power thief" to avoid confusion with real parasitic power as described in the Datasheet.
I did work purely from the text (using iPhone) and based on the terminolgy did not open the attachment.

There are some 1-wire devices that can only work in a "true" parasitic power mode.
 
Last edited:

Buzby

Senior Member
Correct. Maybe neiltechspec should use a term like "pseudo parasitic" or "power thief" to avoid confusion with real parasitic power as described in the Datasheet.
There are some 1-wire devices that can only work in a "true" parasitic power mode.
Actually, all 1-Wire devices use parasitic power. It's only the power hungry devices, thermo's etc., that have the Vdd option.

I've found in these cases that using the Vdd, to either real 5v or the 'diode & cap', is much more reliable, with real 5v being the 'cleanest' option.

Some of the 'official' 1-Wire adapters can provide the 'strong' pullup, but I don't think the PICAXE 'readtemp' instruction provides for this.

Personally I always stick with real 5v to Vdd.

Regarding the size of the cap in the 'diode&cap' circuit, I've never needed more than 10uF.
 

neiltechspec

Senior Member
Well, if the schematic had been looked at then it would have been obvious what I meant.

I tried a 10uf and the 'power thief' Vdd seemed to drop near or below 3v during readtemp12's.

Hence the bigger cap and setting the relevant picaxe pin high between readtemp12's, gives it plenty of time to charge up (around 4 seconds).

Obviously 3 wires with a real Vdd is better, but I only have 2 available.
 

Buzby

Senior Member
... I tried a 10uf and the 'power thief' Vdd seemed to drop near or below 3v during readtemp12's ....
That could be true, I've never gone to 12 bit. The datasheet says it could be using 1.5mA for up to 750mS, and will work down to 3v.

Using these figures you could calculate the minimum cap size needed.

If I had more time I'd Google for 'capacitor discharge calculator', or something like that.

Cheers,

Buzby
 

Technical

Technical Support
Staff member
Some of the 'official' 1-Wire adapters can provide the 'strong' pullup, but I don't think the PICAXE 'readtemp' instruction provides for this.
There are two quite different ways of reading temp from a DS18B20:

1) start the conversion, wait 750ms with a strong pullup applied, read the result
2) start the conversion, poll the device to see when it is ready, read the result

where

1) is slow (as you always wait 750ms) but can support true parasitic power with a strong pullup
2) can be much faster to process as the result is read as soon as the conversion is complete. However does not support parasitic power mode.

As most PICAXE users use a powered sensor the PICAXE M2/X2 parts use the second approach within the 'readtemp' command.
However with X2 parts you could use owin/owout instead and hence use strong pullups to make your own parasitic power compatible version of 'readtemp'.
 

Buzby

Senior Member
... As most PICAXE users use a powered sensor the PICAXE M2/X2 parts use the second approach within the 'readtemp' command.
However with X2 parts you could use owin/owout instead and hence use strong pullups to make your own parasitic power compatible version of 'readtemp'.
Err, no, I won't be doing that !.

I'm quite happy with the way PICAXE handles it. If I was really stuck for one more core in my cable I'd go for the 'diode&cap' option, like Neil has done.

Cheers,

Buzby
 

Kiwipatch

New Member
Further...

What is 'Strong Pullup' (4k7 or is itmuch lower ?)
Or how is this a STRONG Pull UP achieved please.... There seems to be lots of diagrams of _ve and -ve pins strapped together.
I see they even make a three legged DS18B20-PAR '2 wires' device that has this done inside the plastic package at the die level +ve leg is NC to outside world ) to save all the work of adding your own shot circuit !
Also... Picaxe only seems to ever return the mysterious '85'.... Perhaps the hidden meaning to ????

Tips:
WPU (pullup command ) works a treat and simplifies things even more so on those commercial 3m leaded made up probes :)
Adjacent pins on a picaxe can supply virtual +ve and -ve for a 'quicky' bread board demo or check on room temperature with 0 'Zero' wires

~ A
 

hippy

Technical Support
Staff member
Also... Picaxe only seems to ever return the mysterious '85'.... Perhaps the hidden meaning to ????
When a DS18B20 initialises; its temperature reading register is set to 85 as a default. When the device has its temperature requested it should take a temperature reading, perform its conversion, update its register, which is then read by the PICAXE.

Getting 85 back means that the DS18B20 is not doing that, is not taking its reading, is not completing the conversion, or not updating its register. Basically something isn't quite right and things are not working as they should.
 

neiltechspec

Senior Member
My orginal posting still works everytime over two wires (with 0.047F supercap).
10 second intervals reading the following sensors
Indoor DS18B20
Outdoor DS18B20
HTU21D humidity detector + temp under solar panels on roof
BMP180 barometric pressure + temp in the loft
Averaged over 5 sec anemometer windspeed

It's been running now for over 5 years without noticable failure.

Neil.
 
Top