1-Wire Parasitic Power
If anyone has problems getting their Maxim/Dallas DS18B20 or DS18S20 temperature sensors working using parasitic power you might be interested in this. For shorthand I will use sensor = DS18B20/DS18S20.
There a two ways to run a 1-wire sensor: power the Vdd pin (with say 5 volts), or use parasitic power.
The 3 wire solution (ground, data line (DQ), and Vdd) is straight forward, and requires a 4.7K ohm resistor between DQ and Vdd (known as a 'weak' pull-up). Software-wise the Convert and Read Scratchpad commands are seperated either by a.) the temperature conversion time (Tconvert) which varies according to measurement resolution for the DS18B20, typically 750ms for 12 bit resolution, and for the DS18S20; b.) after the Convert command, the device should respond by transmitting 0 while the temperature conversion is in progress and 1 when the conversion is done. Method b.) can't be done in parasitic mode.
The 2 wire/parasitic power solution (aka 1-wire) uses ground and DQ. DQ still requries the 4.7K ohm weak pull-up resistor. However things change between issuing the convert command and the read scratchpad command. The sensor now requires a voltage of value Vdd (e.g. 5 volts) applied to the DQ pin for a period Tconvert (which is 750ms - see aboe), 10us after the convert command was issued. After 750ms the voltage is removed and the scratchpad command issued. During the 750ms a capacitor is charged on the chip and provides the power for the reading the temperature and storing it EEPROM. This may require a peak current of 1.5ms.
Now if you ignore this and just have the 4.7K ohm pull-up, it won't work. Measuring the voltages across the pull-up (Vr) and DQ ((Vdq) gives (actual measurements here):
Vdd = Vout from mbed board = 4.8V
Vr max = 2.96V gives Vdq = 1.84V Vr min = 0.26V gives Vdq = 4.54V
max current = 0.63mA min current = 0.055mA
As you can see in practice, current drawn is a lot less, but enough to drop Vdq down to 1.84V. This voltage is the pull-up supply voltage (Vpu), and for parasitic power this should be between 3 and 5.5 volts. Clearly this won't work.
To get 3 volts across the DQ line, 4.8 - 3 = 2.8 volts should be dropped across the pull-up resistor. With a typical current of 0.63mA, this give a value of 2.8/0.63 = 2.9K ohms. The nearest E12 series resistor is either 2.7K or 3.3K ohms.
Using a 3.3K ohm pull-up we get:
Vr max = 2.15V / Vdq = 2.65V Vr min = 0.18V / Vdq = 4.62V
with current approx. as above.
Now this should still be too low but I've found using a 3.3K ohm pull-up works, and is enough for parasitic power operation.This is not spec sheet compliant but does for the curious who want to get their breadboard model working.
1. Don't use parasitic power. Go ahead and go crazy and run a whole extra wire out to your temperature sensor. Its easier.
2. For breadboarding parasitic power try a 3.3K ohm or 2.7K ohm pull-up rather than the 4.7K ohm recommended. I've found both work. Don't forget to add a 750ms wait between the covert and read scratchpad commands (note: the wait period is same for non-parasitic if you are not reading the bus to see when it goes high).
3. If you are serious about using parasitic power for whatever reason, find a transistor circuit to apply Vdd to the DQ line for the required period. This will of course require another output pin on your processor to trigger it. The spec sheet mentions a MOSFET. As 5V x 1.5mA (max) = 7.5mW is disappated, the MOSFET is overkill.
You need to log in to post a comment