Go Down

Topic: DS18B20 multiple sensors (Read 9306 times) previous topic - next topic

GoForSmoke




Time to look at the datasheet, it tells all.  The only difference is that you have to supply extra power when a temp conversion (or EEPROM write) is in progress.  The datasheet shows how to do it, it's simple; it takes an extra i/o pin though.  You just enable the pin after issuing the conversion command.  That in turn bypasses the pull-up resistor on the data line (Q) so that the device has plenty of power to do the temp conversion or write to its EEPROM.  Look at the datasheet, they have a nice write-up on how it all works.


Is that for parasite mode only?



Yes it is.


Then a common power line could save an I/O pin ... is that per device?

Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

afremont

I don't know if you can save an i/o pin, but you can sure save running an extra wire to all the devices.  In parasite mode, the device draws power thru the data pin.  The Vcc pin of the device is tied to ground so that the device "knows" that it is in parasite mode.  Enough power can be drawn thru the pullup resistor to do most things.  However, temp conversions and EEPROM writing need more power than can be sucked thru the resistor in a short time.  This is where the microcontroller toggles a pin connected to a transistor that "pulls up" the data line to Vcc bypassing the resistor.  Now the sensor on the other end of the wire has all the juice it needs to do the conversion.  The datasheet for the sensor goes into great detail about all this.
Experience, it's what you get when you were expecting something else.

GoForSmoke

I would rather the wire than a pin and a wire or many pins and many wires. Using the pin for extra power only when the device works will need a wire regardless and might need many of both.

Why would you need a pin to supply power if you're not running off a pullup?

Is the point of parasite power to reduce power consumption for battery operation?

Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

afremont

The dallas 1-wire bus is made up of either 2 or 3 wires with the sensors attached along the bus.  One bus wire is ground and one is the data line.  The third (optional) wire is to carry a full 5V to the devices.  Since the data bus uses a pullup resistor, power can be sourced from the bus by the device.  If you ground the normally 5V supply pin on the device, it will draw power from the data line.

Since the data line on the bus has a pullup on it, only a limited amount of current can be supplied to the device.  This is fine until the device needs to execute a CONVERT command to sample the temp and measure it.  This requires more current than can be drawn thru the data line.  So back at the head end of the bus (where the microcontroller is) after issuing a CONVERT command enables full power to the data line by bypassing the pullup resistor.  The device can then draw as much current as it needs.  After the CONVERT command is finished, the microcontroller disables the pullup bypass so that communications can take place on the data line.  This saves running the 5V power wire to each device.

I don't know what you mean about many wires, all devices can reside on one bus.  Please just download the document, it explains it all much better.
Experience, it's what you get when you were expecting something else.

GoForSmoke


The dallas 1-wire bus is made up of either 2 or 3 wires with the sensors attached along the bus.  One bus wire is ground and one is the data line.  The third (optional) wire is to carry a full 5V to the devices.  Since the data bus uses a pullup resistor, power can be sourced from the bus by the device.  If you ground the normally 5V supply pin on the device, it will draw power from the data line.

Since the data line on the bus has a pullup on it, only a limited amount of current can be supplied to the device.  This is fine until the device needs to execute a CONVERT command to sample the temp and measure it.  This requires more current than can be drawn thru the data line.  So back at the head end of the bus (where the microcontroller is) after issuing a CONVERT command enables full power to the data line by bypassing the pullup resistor.  The device can then draw as much current as it needs.  After the CONVERT command is finished, the microcontroller disables the pullup bypass so that communications can take place on the data line.  This saves running the 5V power wire to each device.

I don't know what you mean about many wires, all devices can reside on one bus.  Please just download the document, it explains it all much better.


I see that no extra pin is needed. The data pin goes OUTPUT HIGH during the conversion only.

If the device has a conductive chassis you would only need 1 wire.
Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

afremont

#35
Mar 04, 2013, 01:21 pm Last Edit: Mar 04, 2013, 01:44 pm by afremont Reason: 1


The dallas 1-wire bus is made up of either 2 or 3 wires with the sensors attached along the bus.  One bus wire is ground and one is the data line.  The third (optional) wire is to carry a full 5V to the devices.  Since the data bus uses a pullup resistor, power can be sourced from the bus by the device.  If you ground the normally 5V supply pin on the device, it will draw power from the data line.

Since the data line on the bus has a pullup on it, only a limited amount of current can be supplied to the device.  This is fine until the device needs to execute a CONVERT command to sample the temp and measure it.  This requires more current than can be drawn thru the data line.  So back at the head end of the bus (where the microcontroller is) after issuing a CONVERT command enables full power to the data line by bypassing the pullup resistor.  The device can then draw as much current as it needs.  After the CONVERT command is finished, the microcontroller disables the pullup bypass so that communications can take place on the data line.  This saves running the 5V power wire to each device.

I don't know what you mean about many wires, all devices can reside on one bus.  Please just download the document, it explains it all much better.


I see that no extra pin is needed. The data pin goes OUTPUT HIGH during the conversion only.

If the device has a conductive chassis you would only need 1 wire.



There appears to be a communications gap here, I guess I'm not explaining it effectively.  I'd like to think that I know how this stuff works considering I successfully implemented a SEARCH ROM function in PIC assembler about 10 years ago.  It's in the public domain, and I wrote it straight from the Dallas flow chart.  I have some 1-wire temp sensors on one of my boards right here in front of me and I have used both methods to power the devices in the past.

What you mean by the data line "OUTPUT HIGH" during a conversion only?  It does precisely what I said, it expects to be able to draw power from the data line in parasite power mode since the regular power pin is grounded.  The microcontroller must assure that sufficient power is available by enabling what Dallas calls a "strong pullup".  This is just powering the data line by bypassing the pullup resistor, either by a transistor or some other method that usually requires 1 pin to enable.  It all boils down to one thing, if you can afford a pin, you can save on wiring.  You'll also have to modify your software to work with it.  Speaking of the devil, if you look at the 1-Wire Arduino library you will see that the library author allowed for using parasite power mode.

I wish you much luck with your endeavors to use chassis ground as part of your circuitry.  You'll certainly learn allot about dealing with EMI.  
Experience, it's what you get when you were expecting something else.

GoForSmoke



The microcontroller must assure that sufficient power is available by enabling what Dallas calls a "strong pullup". 


I dunno about PIC but with AVR I can make a pin pullup by setting it INPUT HIGH. If I'm not using that same pin to read data for a while, I can switch it to OUTPUT and give the line 5V. If I want to, I can switch the same pin to INPUT again. With the ability to switch modes in less than a usec, why do I need an extra pin? I can throw an extra resistor, even 1k on the pin and it won't affect the current from low-tolerance pullup in the AVR (20k-50k, does PIC have built-in pullup resistors?) much but limit the OUTPUT HIGH current lots.
 
Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

afremont

The internal pullups of an AVR or PIC are not strong enough to operate the bus normally.  I suppose you could switch the data line pin to output mode and power the bus during a conversion or EEPROM write, but it may not be enough current if you have several sensors and you issue a mass temperature convert.  In the case of the OP with 20 sensors, it wouldn't be near enough.  You'd need another pin and a transistor.
Experience, it's what you get when you were expecting something else.

GoForSmoke

So there's conditions where one way makes more sense than another. Dat's noice.
Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

ottehoman

This becomes interesting when using breakout boards where the 4.7k resistors are mounted on the board itself... This probably means that one is limited to around 10 or so DS18B20's from DFROBOT (see tinyurl.com/b6h6evz) or similar stuff. If you need more than ~10, one should probably use the discrete sensors instead.

michinyon

Why would you need "another pin"  to supply 5V to the sensors ?

You'd need another wire,  to use the 3 wire mode,  but you could connect that third power supply wire to +5V in
all sorts of ways without using "another pin".

GoForSmoke

I guess he would rather spend a pin and extra code than some wire.
That pin would feed the existing data wire with more current through a transistor.
If you've got 2-conductor wire, that will work without another wire and all those connects.
Or if you have a ground chassis (most any car or bike) you could get away with 1 wire.

Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

afremont

#42
Mar 06, 2013, 09:13 am Last Edit: Mar 06, 2013, 09:18 am by afremont Reason: 1

Why would you need "another pin"  to supply 5V to the sensors ?

You'd need another wire,  to use the 3 wire mode,  but you could connect that third power supply wire to +5V in
all sorts of ways without using "another pin".


Clearly I've missed it again.  In parasite power mode, you don't supply power to the Vcc pin of the sensor, it is GROUNDED.  The sensor gets its power from the DQ data line, but the 1mA supplied is not enough to power the device during a temperature conversion.  The device requires 1.5mA and the 4.7k pullup is too big.  Also, you can tell all the devices on the bus to start a temp conversion at the same time so that they overlap the long delay during the conversion (750mS for 12 bits).  If you had 20 devices, then you'd need to supply 30mA to the DQ bus by bypassing the pullup in some fashion.  At any rate, the Vcc pin isn't being connected to anything but ground when using parasite power mode.

EDIT:  Please, I beg both of you to download this document and look at Figure 4 and Figure 5 if nothing else:
http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf
Please.
Experience, it's what you get when you were expecting something else.

afremont

#43
Mar 06, 2013, 09:30 am Last Edit: Mar 06, 2013, 09:37 am by afremont Reason: 1

I guess he would rather spend a pin and extra code than some wire.



Well yeah, it's kinda the whole point of having parasite power mode.  I didn't invent it, just trying to explain how it works.  By using only two wires (DATA and GND aka 1-wire parasite mode), you can often more easily find some way to wedge it into an existing system.  For example you can stick these on unused pairs of cat-5 cable.  It would be allot messier if you needed another wire.  Running cable is not cheap.

You have to keep in mind that none of these devices were created with the home hobbyist in mind.  They were designed to solve real world problems in an industrial environment.  Sure it's easy to run another 12" wire at home, it's another thing to demand a shielded set of three or four wires run thru a factory when you can just toss some code and an open i/o pin at it and use an empty twisted pair already going right where you need it.  Not to mention that if you have an old plant, you probably have some network coax already installed that's not doing anything since the cat-5 was installed.  You could use that for 1-wire if you wanted.
Experience, it's what you get when you were expecting something else.

GoForSmoke



Why would you need "another pin"  to supply 5V to the sensors ?

You'd need another wire,  to use the 3 wire mode,  but you could connect that third power supply wire to +5V in
all sorts of ways without using "another pin".


Clearly I've missed it again.  In parasite power mode, you don't supply power to the Vcc pin of the sensor, it is GROUNDED.  The sensor gets its power from the DQ data line, but the 1mA supplied is not enough to power the device during a temperature conversion.  The device requires 1.5mA and the 4.7k pullup is too big.  Also, you can tell all the devices on the bus to start a temp conversion at the same time so that they overlap the long delay during the conversion (750mS for 12 bits).  If you had 20 devices, then you'd need to supply 30mA to the DQ bus by bypassing the pullup in some fashion.  At any rate, the Vcc pin isn't being connected to anything but ground when using parasite power mode.

EDIT:  Please, I beg both of you to download this document and look at Figure 4 and Figure 5 if nothing else:
http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf
Please.


Arduino UNO pin can supply 40 mA at 5V without damage.

*-*-*-*-*-*-* the mystical, magical Parasite mode, the only way that makes sense! *-*-*-*-*-*-*

Why do I want to read that document? You explained the same thing already but seem to have trouble that anyone else should think that running a power wire makes any sense. Okay, fine, there's a special big-deal parasite mode.. got the message and the junk mail, thank you.

As Uncle Frank used to say: Is that a real poncho or is that a Sears' poncho?
Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

Go Up