robert-hh / Onewire_DS18X20

Classes for driving the DS18x20 sensor with the onewire protocol for Pycom MicroPython
11 stars 6 forks source link

Adjust timing for pure-Python variant within "write_bit" method? #9

Closed amotl closed 4 years ago

amotl commented 4 years ago

Hi again,

when looking at the code within the write_bit method

https://github.com/robert-hh/Onewire_DS18X20/blob/a51a423e635f32c6885da511d615f7e636ccfda9/onewire.py#L81-L83

we are thinking about whether it makes sense to handle it like within read_bit

https://github.com/robert-hh/Onewire_DS18X20/blob/a51a423e635f32c6885da511d615f7e636ccfda9/onewire.py#L55-L57

This PR also removes the sleep_us(1) within that method. https://github.com/pycom/pycom-libraries/pull/51/files

Cheers, Andreas.

robert-hh commented 4 years ago

The write timing is less critical.

robert-hh commented 4 years ago

Actually, the sleep_us(60) takes about 74us, And what should be the 1 us pulse lasts 8 us. But the ds18b20 does not care so much. The write low time is 1-15µs, the write high time is 60-120µs. So it is all within the bounds.