orgua / OneWireHub

OneWire slave device emulator
GNU General Public License v3.0
343 stars 86 forks source link

ESP8266 calibration, still needs verifcation & cleanup #27

Closed chasm-git closed 7 years ago

chasm-git commented 7 years ago

Some comments. Feeding the watchdog in the while loop is not a great idea but works. The feed command is specific to the Arduino ESP8266 implementation. I put it in a precompiler conditional so that other architectures still compile.

The ESP8266 has two possible CPU speeds, 80 and 160MHz, which resulted in two calibration values. Both still need confirmation with a logic analyser or oscilloscope. Automatically detecting CPU speed at compile time would also be nice.

Running the code for ~100 measurements had clear winners. Here is the serial debug output for both cases:

esp8266 80mhz 22 instructions per loop DEBUG TIMINGS for the HUB (measured in loops): (be sure to update VALUE_IPL in src/OneWireHub_config.h first!) value : 275 nanoseconds per loop reset min : 1563 reset max : 3490 reset tout : 18181 presence min : 72 presence low : 581 pres low max : 1745 msg hi timeout : 54545 slot max : 490 read1low : 218 read std : 72 write zero : 109

esp8266 160mhz 26 instructions per loop DEBUG TIMINGS for the HUB (measured in loops): (be sure to update VALUE_IPL in src/OneWireHub_config.h first!) value : 162 nanoseconds per loop reset min : 2646 reset max : 5907 reset tout : 30769 presence min : 123 presence low : 984 pres low max : 2953 msg hi timeout : 92307 slot max : 830 read1low : 369 read std : 123 write zero : 184

orgua commented 7 years ago

thanks for the investigation. will merge now. Did you succeed in emulating any sensors with the ESP? is there any additional wdt.reset needed? the difference in IPLs is very odd! Teensy is capable of changing CPU speed and i have never seen this behaviour. And there shouldn't. That's why i choose the IPL-Format. There must be some background process running at constant intervals or something similar.