OneWire 2.2 preview

Yes, that's a good point.

I've mainly used the DS18*20 datasheets for timing info. This page is somewhat different. The main difference is they give a minimum of 5us for parameter A. In the datasheet has a minimum of 1us. That concerns me. Here's the info I've been using for OneWire:

OneWire's read timing is intentionally a couple us short to allow for a couple extra microseconds of delay for the slowness of 8 MHz AVR executing the other instructions. The DS18B20 datasheet also shows the sampling must occur before 15 us, and seems to indicate that sampling at exactly 15 us risks reading at the first instant the voltage might start rising. That's why I have a total of 13 us before sampling the bit.

Given 1us minimum pulse width, and 13 total (at least in delayMicroseconds, probably pushing to 14 on 8 MHz AVR), I wanted to allow as much time for the pullup resistor as possible, but not risk making the pulse too narrow. 3X the minimum (at least the minimum in the datasheet) seemed like a good idea, stealing only 2 of the 12 possible microseconds for the pullup to charge the line's capacitance.

The other interesting thing about this app note is parameter A is used for both read and write. The worksheet says A's range is 5 to 15 us, which makes perfect sense for a write. But if A is also used for the read, as shown in the diagram (and they have no separate parameter for the beginning of a read), the upper end of that range obviously can not be correct. It really makes me doubt this page is the best possible advice about 1-wire timings.

Also, OneWire cheats somewhat for writing. It drives the line high, rather than using the pullup resistor. The timing can be somewhat longer because the uncertainty of the pullup is not a factor. That's utterly incompatible with a multi-master bus, but OneWire is a master-only library. But it does give really predictable timing for writes, which are most of the bus time, and have no CRC checking. Most devices send a CRC at the end of their data while reading.

For writing, the worksheet's range for A is 5 to 15 us, and OneWire drives 10 us. I really believe that is a good approach, to use a longer time for A while writing, and a shorter time while reading.

However, I'm not saying the timings in OneWire are absolutely the best possible numbers. I'm going to think on this more over the next couple days, and try experimenting a bit. Maybe adjusting slightly makes sense....

Thanks for bringing this up. :slight_smile: