Andreas
November 4, 2019, 12:57am
93
Andreas
November 4, 2019, 3:48am
94
… also answering @kjm here:
Andreas:
German
Zu diesem Thema lief uns gerade noch die esponewire.c für ESP32 aus dem ESP32-Port des aktuellen Genuine MicroPython über den Weg, die dort timing-kritische Dinge maschinennah implementiert – gerade das Lesen und Schreiben von Bits auf den Bus und die Einhaltung des Protokolls und der Contenance.
English
On this topic we just ran across the esponewire.c for ESP32 from the ESP32 port of the current Genuine MicroPython, which implements timing critical things machine-oriented - especially reading and writing bits on the bus and complying with the protocol and maintenance.
In fact, modonewire.c
would be the right file implementing this functionality. The esponewire.c
referenced above was the file for ESP8266 which seems to have slipped into the ESP32 port tree accidentally.
However, we failed on porting this to Pycom MicroPython appropriately. While we have come quite far making it compile, it panics at runtime right away when trying to reset the onewire bus.
Andreas
November 4, 2019, 8:11pm
95
I was too quick on that detail. After getting into the MicroPython code, I see that porting/enabling the modonewire.c
from Genuine MicroPython on Pycom MicroPython will require more efforts than I will be able to dedicate to this topic for now.
– andreas about 16 hours ago
We have been able to wrap up some things and share it with the community.
However, going further into the details of this topic is beyond what we can currently do about it.
Andreas
Split this topic
November 6, 2019, 12:52pm
96
Andreas
November 6, 2019, 12:54pm
97
Hallo nocheinmal,
I've tried a couple of different flavours of the OneWire library with a single DS18B20 temperature sender. Both routines, the one at the bottom of the page at https://docs.pycom.io/tutorials/all/owd/, and a more resent version at...
pycom:master
← robert-hh:master
opened 07:11PM - 16 Jun 18 UTC
The reason for a change was the observation, that with about 1 in
300 measureme… nts were wrong, some of them obviously. So I made a few
changes:
1. The timing of readbit was changed to shorten the initial low puls
to 2 µs by not calling sleep_us() at all and reading the state of the bit
about 8 µs later. That matches better the datasheet.
2. The CRC check was enabled in the method read_temp_async(). The function
returns None, when the CRC is wrong
3. The crc8() method is now table based, with two 16 byte tables, which is
about 5 times faster (1.9 ms -> 0.37 ms for 9 bytes)
4. Some inefficient optimizations in the onwire class were removed.
Especially caching system call names in local variables for calls
used only once in a functions was dropped and replaced by storing
the callee names in the class. That saves a few microseconds - maybe not worth
the effort.
With change 1, readings with wrong crc are more rare now, about 1 in 15000,
and enabling the crc check allows to detect them.
The crc8 implementation is a Python port of the code published here:
http://lentz.com.au/blog/tag/crc-table-generator
P.S.: Bitte nicht vergessen, den Garbage Collector während der Messung abzuschalten.
Viele Grüße,
Andreas.
Andreas
November 6, 2019, 12:57pm
98
Korrekt, das müssen wir noch nachreichen.
Andreas
November 16, 2019, 10:21pm
99
@robert-hh was so kind to upload his improved 1-Wire/DS18X20 driver to a repository on GitHub.
This will enable us to contribute some minor improvements. Thank you so much!
Andreas
November 16, 2019, 10:24pm
100
weef:
Wenn als erster Wert nach dem Bestromen der DS18B20 aus dem 2 byte-Temperaturregister 0550h
(“85°C”) kommt, denn das ist klar ein Indiz, daß diese Register ausgelesen wurden, ohne, daß vorher eine temperature conversion dort gestartet wurde.
Wir haben hierzu gerade noch entsprechende Eingaben gemacht.
Vielen Dank für Eure Rückmeldungen und Verbesserungsvorschläge dazu!
Andreas
November 17, 2019, 3:18am
101
Finally, we have been able to make this work on Pycom MicroPython.
pycom:Dev
← daq-tools:modonewire
opened 07:44PM - 04 Nov 19 UTC
Dear Pycom team,
first things first: Thank you so much for your hard work on … bringing this hardware and software ecosystem to the world and congratulations to four years of Pycom by the way.
Coming from [1] and [2], we are interested to get more stable readings from some DS18B20 sensors we have attached to one of our FiPy devices by bringing in the 1-Wire driver from the upstream vanilla MicroPython [3].
In order to get started with that, we added this PR which enables the respective extmod at compile time and would be happy to get further support on that.
With kind regards,
Andreas.
[1] https://community.hiveeyes.org/t/untersuchung-und-verbesserung-des-timings-bei-der-ansteuerung-der-ds18b20-sensoren-unter-micropython/2309
[2] https://forum.pycom.io/topic/5330/onewire-py-problem
[3] https://docs.micropython.org/en/latest/esp32/quickref.html#onewire-driver
We have published respective firmware images called 0.7.0-vanilla-dragonfly-onewire
. See also Inofficial firmware bakery for Pycom/ESP32 devices - #2 by Andreas .
Andreas
November 17, 2019, 3:56am
102
Die Testhardware läuft ab sofort mit FiPy-1.20.1.r1-0.7.0-vanilla-dragonfly-onewire
, die Meßwerte können unter amo-fipy-workbench betrachtet werden.
Andreas
November 17, 2019, 3:49pm
103
Die Implementierung der Maskierung der 85°C auf Treiberebene geht u.U. doch einen Schritt zu weit:
@robert-hh said within #8 :
In the new version I intentionally did not implement this test. 85°C is a valid result, which must not be suppressed by the driver. Checking must be done by the calling code, which knows the context.
I see your point here. Thanks!
weef
November 17, 2019, 4:30pm
104
So machen sie es bei Ethersex :
/* a value of 85.0°C will only be stored if we get it twice, to
* eliminate communication errors */
uint8_t tempis85 = temp.val == (temp.twodigits ? 8500 : 850);
if ((tempis85 && ow_sensors[i].conv_error) || !tempis85)
ow_sensors[i].temp = temp;
/* set a semaphore of if we had a conversion or communication error */
ow_sensors[i].conv_error = tempis85;
Verwendet wird das dann z.B. so hier:
1 Like
Andreas
November 17, 2019, 4:45pm
105
Slight out-of-band signalling using a semaphore. Good thing. Danke!
So kann man die Implementierung der Spezifikation im Treiber selbst unterbringen, aber der calling code kann dann selbst je nach Kontext unterscheiden, wie Robert es vorschlägt.
Danke für diesen Hinweis, ich habe ihn weitergegeben . Da wir dort im 1-Wire/DS18X20-Treiber derzeit leider nur einen diskreten Rückgabewert haben und keine Datenstruktur, wird es momentan vermutlich schwierig, das entsprechend unterzubringen.
Vielen Dank @weef !
Die ersten Tests mit 200 Messungen an 5 DS18B20 mit den überarbeiteten Onewire-Treibern sehen sehr gut aus.
1 Like
Andreas
November 17, 2019, 10:30pm
107
Exzellent, vielen Dank für die Rückmeldung. Mittlerweile sind wir schon eine Runde weiter: @wtf konnte bestätigen, dass die neuen C-level Treiber auch ordnungsgemäß laufen, siehe Dragonfly firmware for Pycom/ESP32 - #6 by Andreas sowie Annapurna firmware images for Pycom/ESP32 .
P.S.: Die aktuellste Variante des pure-Python Treibers von Robert beherrscht nun auch Parasite Power Mode, siehe GitHub - robert-hh/Onewire_DS18X20: Classes for driving the DS18x20 sensor with the onewire protocol for Pycom MicroPython .
Andreas
November 18, 2019, 8:50pm
108
Andreas:
Danke für diesen Hinweis, ich habe ihn weitergegeben. Da wir dort im 1-Wire/DS18X20-Treiber derzeit leider nur einen diskreten Rückgabewert haben und keine Datenstruktur, wird es momentan vermutlich schwierig, das entsprechend unterzubringen.
Das ist das aktuelle Ergebnis hierzu, @robert-hh hat es der Dokumentation des Treibers hinzugefügt. Danke nochmals an @weef !
Diskussion
robert-hh:master
← hiveeyes:assert-conversion-success
opened 05:17PM - 18 Nov 19 UTC
Hi Robert,
this is a non-invasive variant to #8. If this does not make any se… nse, feel free to close it right away.
With kind regards,
Andreas.
Dokumentation
read_temp(rom)
Get the temperature reading of the addressed device as degree Celsuis. In case of an CRC error, None is returned.
Warning : After power up and before a conversion cycle has been performed, the DS18x20 sensors will return the value 85°C. Since this is also a valid return value, the calling app must decide, whether it is a reasonable value in the given context.
– Class DS18X20 » Method “read_temp”
Der DS18B20-Treiber ist deutlich verbessert worden. Z.Z. wird bei ca. jeder 500. bis 600. Messung ein CRC-Fehler erkannt. Die kann man gut behandeln, durch Auslassen oder den letzten Wert.
Das Problem mit den 85°C ist kaum eins, vor jeder Messung gibt es “convert_temp”, “read_temp” ergibt dann einen Wert oder bei CRC-Fehler “None”.
Nicht erkannte Fehler habe ich bislang noch nicht gesehen.
Danke an @amotl und @robert-hh
1 Like
Andreas
November 19, 2019, 9:11pm
110
@robert-hh just shared this very interesting analysis with me. Thanks a bunch!
2 Likes
Andreas
November 21, 2019, 11:41am
111
Mittlerweile haben wir den modonewire
C-level Treiber für uns erschließen können und wir sind zuversichtlich, dass etwaige Timing-Probleme damit endlich der Vergangenheit angehören.
pycom:Dev
← daq-tools:modonewire
opened 07:44PM - 04 Nov 19 UTC
Dear Pycom team,
first things first: Thank you so much for your hard work on … bringing this hardware and software ecosystem to the world and congratulations to four years of Pycom by the way.
Coming from [1] and [2], we are interested to get more stable readings from some DS18B20 sensors we have attached to one of our FiPy devices by bringing in the 1-Wire driver from the upstream vanilla MicroPython [3].
In order to get started with that, we added this PR which enables the respective extmod at compile time and would be happy to get further support on that.
With kind regards,
Andreas.
[1] https://community.hiveeyes.org/t/untersuchung-und-verbesserung-des-timings-bei-der-ansteuerung-der-ds18b20-sensoren-unter-micropython/2309
[2] https://forum.pycom.io/topic/5330/onewire-py-problem
[3] https://docs.micropython.org/en/latest/esp32/quickref.html#onewire-driver
Aktiviert werden kann der “native”-Treiber über folgende Konfigurationseinstellung im Terkin-Datenlogger .
{
"id": "bus-onewire-0",
"family": "onewire",
"number": 0,
"enabled": True,
"pin_data": "P11",
#"driver": "native",
},
Dank @wtf ’s Testaufbau konnten wir bereits vorsichtige Erfolge dazu verzeichnen.
We just heard back from @wtf that
@wtf is using Annapurna for Pycom/ESP32 , which essentially builds upon Dragonfly.
Pictures <a class="lightbox" href="https://community.hiveeyes.org/uploads/default/original/2X/f/f52e54352d7455b51b9d13162e0df1daa658e82b.jpeg" data-download-href="https://community.hiveeyes.org/uploads/default/f52e54352d7455b51b9d13162e0df1daa658e82b" title="signal-attachment-2019-11-14-233341">[signal-attachment-2019-11-14-233341]&l…
Andreas
November 22, 2019, 10:37pm
112
I just wanted to share this piece just recently observed by @wtf , @roh and @weef even with the C-level modonewire
driver. It’s probably not timing related but… no idea - is it a borked counterfeit!?