Pages: [1]   Go Down
Author Topic: Pull up resister with DS18B20: why?  (Read 2075 times)
0 Members and 1 Guest are viewing this topic.
UK
Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone

I'm using a DS18B20 with the one-wire library on an Arudino Uno to measure temperature.  Works great.

I used a pull-up resistor between data and +5v as advised, however, while I understand the need for a pull-up (or down) resistor when dealing with inputs that a chip is monitoring, I don't really know why, when the chip is providing a data 'output' in this case, I need the pull-up.

Can anyone advise?  It's working fine but I'd like to know more about the need for it.

By the way, I'm using the DS18B20 to measure water temperature and after MUCH searching and reading-up on how to waterproof an LM35 device for temperature sensing, I found a waterproof ready-potted DS18B20 in a stainless steel casing for about £3.50 on eBay.  I don't think I could buy the LM35 and assorted waterproofing parts for that amount, let alone pre-assembled - so for anyone considering waterproofing an LM35 - it's worth trying this route.

Thanks!
Logged

Offline Offline
God Member
*****
Karma: 0
Posts: 547
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Input pins are high impedance and essentially open circuit as far as loading goes. Without some load at the end of the line all of your interconnecting wire will act as an antenna and that "hum" will be added to the dc voltage you want to read giving you very inaccurate readings. ?In the industiral setting we don't read many analog sensors as voltages but as closed loop currents using the 4-20 format where the monitoring point converts it to a voltage and corrects for the 4mA representing a 0 reading.
Logged

UK
Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Wow, thank you for such a detailed answer!
Really helpful.
Logged

0
Offline Offline
Faraday Member
**
Karma: 7
Posts: 2526
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Some devices create an output signal simply pulling the output line down to ground, then "let go" and allow them to float.  The pullup brings the output back up to Vcc.

In addition, some of the Dallas One-Wire devices (some 1820 variants among them) can operate on parasitic power - you don't have to run power to the device, it simply steals enough power from the output to operate.

-j
Logged

UK
Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the extra info.

I'd read about parasitic power but haven't tested it yet.  Once complete, the sensor will be at the end of a good few metres of cable so whether I use that, or use 3 cores, depends on whether parasitic power is more or less useful over longer runs.
Logged

Cumming, GA
Offline Offline
Edison Member
*
Karma: 18
Posts: 1627
Ultimate DIY: Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have good luck with parasitic power, so try it first.  I have runs of about 10-20 meters with no issues at all.  Worst case, you might need to have a stronger pullup (2.2K ohms)  before having to resort to adding the extra power source.  When using parasitic power on the DS18x20 connect the Vcc pin to GND pin.  (meaning: Connect pin 1 to pin 3 on the DS18x20)
« Last Edit: January 09, 2012, 10:44:17 am by pwillard » Logged

UK
Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks!

Just to confirm then:

Vcc + GND connected together
Pullup between them and pin 2
Connect GND to GND on the Arduino
Connect my input pin on the Arduino to pin 2

... and connect +5v to pin 2 as well?

Sorry to ask the obvious!
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks!

Just to confirm then:

Vcc + GND connected together

If by that you mean pins 1 and 3 of the DS18B20 connected together, yes.

Pullup between them and pin 2

No, pullup between the Arduino i/o pin and Arduino +5v

Connect GND to GND on the Arduino

yes, pins 1 and 3 of the DS18B20 connected to Arduino GND.

Connect my input pin on the Arduino to pin 2

Yes.

... and connect +5v to pin 2 as well?

No! Pin 2 receives power through the pullup resistor.
« Last Edit: January 09, 2012, 12:09:29 pm by dc42 » Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

UK
Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you, everyone!

I appreciate the parasitic power diagrams are available on the datasheet but it's easier to learn through these discussions.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just wanted to add my thanks to Dc42 for the information. I was wondering about the same stuff, but Cog1 asked it much better than I could.
Logged

Offline Offline
Edison Member
*
Karma: 4
Posts: 1726
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The only problem with paristic power is that it takes a little longer to make the reading conversion and that no other transmission can happen at the same time on the one wire bus
So having multiple devices means it will take some time to collect all the reading, which normally is no big deal, just wanted to let you know about that
Logged

Pages: [1]   Go Up
Jump to: