DS18B20 on long wire
AGCB
Posts: 327
in Propeller 1
I have a weather station program that runs continuously and would like to monitor the temperature in my outside shop also. I've read that 'one wire' devices don't do well with long wires.
Is there an easy way to remedy this? It sounds like the problem is mainly in the signal timing. Would it help to slow down the PROP clock speed while the DS18B20 is read? Or could the 'one wire' object be modified for timing?
I've also looked at this MAXIM discussion but can't see how to use 2 or 3 prop pins for the "one wire' read.
https://www.maximintegrated.com/en/app-notes/index.mvp/id/244
My weather station is here and several other threads in which I was helped by forum members. Thanks!
https://forums.parallax.com/discussion/168567/spurius-characters-occationally#latest
Thanks
Aaron
Is there an easy way to remedy this? It sounds like the problem is mainly in the signal timing. Would it help to slow down the PROP clock speed while the DS18B20 is read? Or could the 'one wire' object be modified for timing?
I've also looked at this MAXIM discussion but can't see how to use 2 or 3 prop pins for the "one wire' read.
https://www.maximintegrated.com/en/app-notes/index.mvp/id/244
My weather station is here and several other threads in which I was helped by forum members. Thanks!
https://forums.parallax.com/discussion/168567/spurius-characters-occationally#latest
Thanks
Aaron
Comments
BTW, you need only one Prop pin for the 1Wire read, not two or three.
-Phil
of resistance in the wiring?
How long is a piece of string?? er wire to your outside shop.
what about lightening protection.
I have had an outdoors 18B20 temp sensor running for some time on about 20 feet of wire- using parasitic power- and no problems.
A sightly longer run to the hot water tank and I get problems at higher temperatures (80 c plus) again using the parasitic power arrangement. I think it would be ok if I used an extra wire to feed it power.
The signal timing is etched in silicon- it cant be changed.
In parasitic mode (data and 0v only) the vcc pin and 0v pin of the 18B20 are s/c and data is sent and received in the same data line, so that's two wires.
By supplying power directly to the vcc pin of the 18B20 higher temperatures and longer lines can be achieved, so that's 3 wires.
The prop only needs one pin with a 4k7 pullup.
set the pin to input.
write a zero to the pin.
now when you make the pin output it will pull the pin low.
when you set the pin to input the pullup resistor pulls it high.
while in input mode you can read the pins value- it doesnt matter that you have written a zero to it already- that only effects the pin when it is made output.
You can achieve better performance in parasitic mode by sending a full binary 1 enhancing the current supply to the 18B20 during idle periods and when transmitting, but not when receiving! ALL transactions are initiated by the controlling microprocessor.
Study the data sheet.
Its a good beginners project as the protocol is simple- a short pulse low is a 1, a long pulse is a 0. (if I recall correctly)
for the values of short and long- study the data sheet.
Dave
people seem to have had issues with judging by various forums. Once its working you can
try changing to parasitic mode, but remember to take out the decoupling caps if you had any.
In particular before trying a long wire configuration, test on a breadboard in case your sensor
is broken or counterfeit (DS18B20 is expensive enough that there are definite reports of counterfeits).
These days CAT5 seems to be the goto cheap signal cable choice, using 3 wires rather than 2 isn't
so pressing...
(the type they bury directly) inside of conduit.
I've used these sensors several times before but less than 10' away.
How would the decoupling cap be? On + wire?
Decoupling cap goes between + & - on the sensor end/board.
-Phil
I'm using Cam Thompson's onewire.spin. He has the Prop pull the one-wire pin LOW for 4 microseconds in order to start a read operation. The DS18B20 expects to respond within 15 microseconds, that is, within 11 microseconds after the end of the low pulse, so the pullup resistor has to bring the line back high within 11 microseconds. There isn't much you can do with that timing, since the 15 microseconds is set in stone in the one-wire protocol.
For one project that was measuring temperature profiles in a reservoir, I constructed a 26 meter cable, which had 16 DS18B20's strung out along its length. The time constant works out something like this: 150 pF per meter for the cable, which multiplies out to 3.9 nF. And with a 1000Ω pullup resistor, it comes out to 3.9 µs time constant. The cable has a three-wire direct power arrangement. I'm sure it would not have worked with parasite power.
You should have no problem with 20 feet, especially given the 3-wire arrangement.
In Nuts and Volts #82, JonnyMac used a 1K pull-up, and in this tread from August 2009 he says that this allows 3.3 mA to flow from 3.3V.
https://forums.parallax.com/discussion/115369/1-wire-object-has-no-way-of-talking-to-the-configuration-registers-anybody-kn
If possible avoid parasitic power
and have a look here:
https://maximintegrated.com/en/app-notes/index.mvp/id/148
I'm out of town till weekend but will be trying this ASAP when I get home. Much good info and encouraging too!
I like monitoring things, some just for fun but others for important reasons. If I can get the shop temperature working good there may be other things to checkup on.
Thanks again
Aaron
Here's a 'scope shot from my 26m cable driven simply by a Prop pin with 1kΩ pullup, and also a 100Ω resistor in series with the Prop pin. The 100Ω in series is part of the pin protection, but it also helps to distinguish pulses from the Prop from responses from the DS18B20.
The bottom yellow trace shows the Prop issuing first the long reset pulse, followed by the presence pulse that is put on the bus by all of the DS sensors simultaneously. Then the Prop is sends a skip rom command followed immediately by a convert-T command. That makes all of the sensors on the bus at once start their temperature conversion, which takes time, up to 750ms for 12 bit resolution. Subsequent commands (not shown on the 'scope) test if the conversion is complete and then read back the readings one sensor at a time.
The middle orange trace is zoomed in on the skip rom command, $CC (=%11001100), sent least significant bit first, and then the convert-T, $44 (=%01000100). The top red trace is further zoomed in on a zero bit and a one bit. The falling edge is fast due to only 100Ω and the pin low impedance to ground. The rising edge is slower, due to the 1kΩ pull up to the +3.3V supply, and the time constant with the cable capacitance is close to 6µs. Cam's oneWire driver allows 8 microseconds for both the low time and for the recovery between bits.
3 different wire types with soldered splices. Next I'm going to try adding 1 or 2 more sensors and see what happens.
Thanks
Aaron
Discovery
Better to use a single piece of plastic well pipe rather than conduit. That way no water can get into the pipe as long as the ends are sealed or start and end indoors. Used it to connect two out buildings to the main house several years ago and had no problems with comms during my time there. As a bonus the pipe is much lower cost than PVC conduit.
Comes in 1" and maybe larger, 100' rolls and maybe longer