Dallas 1-wire (ONEWIRE lib) implementation: drive or float high?

I'd like that :wink: :beers:
I've also found an interpretation of WAG that could be applied to @Hotaman
Urban Dictionary: WAGS

Spioler WAG What A Genius. A term used to denote a person of great intellect.
1 Like

@ScruffR, Thank You for the awesome complement!

@pwallington, Nice! added to my useful acronym database, thanks!

@MORA, I accept responsibility for not fully documenting the lib. I included examples of using the lib as is the common practice, but I drank the koolade of free software and didn’t include any documentation other than comments (which I did update a bit in the current version). I’ll fix that!

On the other hand, as the developer it is your responsibility to fully understand the code you are using.

The lib puts you, the developer in charge of how the buss is handled because I have no idea of what devices your using or what new devices will be created or how you want to use the device. In most 1-wire cases, the master always polls for status so in reality, it is not an issue how you handle the bus. Leaving it floating is the default.

Bottom line, it’s up to YOU, the lib should work correctly as long as you use it correctly for your situation.

1 Like

Some of the responses so far indicate that you can pull it high. Mora has it right, in general, you should not pull it high. The devices on the bus are are open collector to ground and can only signal the bus by pulling it low. If you drive it high with your chip you will not see the devices attempting to respond. The pull-up resistor is typically 1K to 5K ohms, but for long cables, I have used as low as 100 ohms.

Now for the exception: The 1-wire bus driver ICs do pull the line high, but only briefly. Looking at your top diagram, during the period that the master is sending a zero (pulled low) the voltage on the bus is essentially zero. When the master releases the line (the pull-up resistor now try pulls the line high) the rise time can be very slow since you are charging capacitance in the cable and each 1-wire device (each device contains a capacitor with a blocking diode that it uses for power when the bus is low). With long cables or several 1-wire devices, the voltage on the bus may not fully recover before the slave device(s) respond by pulling the line low. If the bus voltage doesn’t recover to at least > 3 volts, it can result in errors. The 1-wire bus drivers IC compensate for this by actively pulling the line high for about 800 uS. Looking at you timing diagram, this is during the 1uS after the master write but before the start of a new slot time.

Hope this helps,
Tim

1 Like

@tbitson, Tim it did nothing for me, your preaching to the choir and it will probably confuse many who have not read much of the documentation on the subject. Most of the folks here are just using 1820s. I constantly ask, and never get a request for anything else.

Are you or someone else having a problem communicating to a 1-wire device using the OneWire lib?

If so, please give me the details and I’ll fix it.

I know of no problems at this time. I have no reason to ‘fix’ code that works flawlessly for me so I’m spending my time helping out some of the other libs in preparation for the Electrons release.

One final word… I got snowed in last week and got a little board so I updated the OneWire lib to v1.3.

The git repo is updated and it is now available in the web IDE as well.

Version 1.3 puts this debate to rest. It will only drive the line HIGH at the end of a BYTE write when the power flag is TRUE (the default is FALSE). The bit write function never drives the line HIGH.

3 Likes