0
\$\begingroup\$

I am using a Dallas DS18B20 thermometer that communicates with Maxim's one wire protocol. I'm having issues at the initialization sequence. I have pulled the line high for 500 uSeconds, pulled the line low for 510 uSeconds (the reset), pulled high for 45 uSeconds, waited for 120 uSeconds for the thermometer to pull the line low as a response (the presence pulse), and then sampled the signal to make sure it was low. If it is not low, something went wrong. When I look at the signal in my 'scope, I see it get pulled down for 510 uSeconds and the pulled up for 680 uSeconds. This means the thermometer did not respond at all (45 + 120 + 500 = 675 uSeconds). What am I doing wrong?

\$\endgroup\$
  • \$\begingroup\$ Maybe your code? Have you checked for small glitches? \$\endgroup\$ – Voltage Spike Jul 27 '16 at 19:21
  • \$\begingroup\$ A schematic would help. In lue of one, are you running parasitic? If so, What is your capacitor? What voltage are you running? What value is your pull-up? What is the cable length? Are you sure your driver is tri-stating? \$\endgroup\$ – Mark Jul 27 '16 at 19:31
  • \$\begingroup\$ @laptop2d the code is working fine. I'm just waiting for the thermometer to do its job. Mark, it is not in parasitic mode and even if it was the capacitor is in the thermo. I am using 3.3V from my STM32F4 board. I haven't been using a pull-up, just turning GPIOs on and off for certain times. My cable length is maybe 4 inches. I might be a little out of my depth here with tri-stating but there isn't any kind of switch in my setup. The GPIO port is high and the data wire is supposed to pull it low. I have been referencing this \$\endgroup\$ – Tyler Jul 27 '16 at 19:49
  • 1
    \$\begingroup\$ One-wire is very timing sensitive. Can you include a scope shot to verify the pulse timing. \$\endgroup\$ – MarkU Jul 27 '16 at 20:05
  • \$\begingroup\$ @MarkU here is the picture that shows the 500 uSeconds and this shows the 680 uSeconds. Mark is correct with the resistor (if you post it as an answer I will accept it). I apologize if my inner novice is showing. I'm a software guy who is wondering into the world of electronics. Thanks for the help! \$\endgroup\$ – Tyler Jul 28 '16 at 0:11
2
\$\begingroup\$

If the STM32F4 is pulling high, then you can't expect the DS18B20 to be able to pull low. You should bring your output high for a short time (a couple of microseconds would do), and then tri-state it. The pullup resistor will then hold it high until the DS18B20 pulls it low (the STM32F4 may have an internal pullup). As it is, you probably have contention on that net, which may eventually destroy one or the other.

Note that in that article that you linked to that he is using a 3.9kohm resistor as a pullup. Also note that he is tri-stating the line by making it an input (which would be necessary anyway in order to read it).

\$\endgroup\$
0
\$\begingroup\$

Make sure that you have configured the port in open-drain mode and pulled up. If it have been push pull mode, then you may have damaged the part, much better to experiment with a new one.

If I remember right, that waiting period to test the presence may be variable. You can miss it by just looking after a fixed time. I had implemented the code by testing at every 10 uS in a total 300 uS loop.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.