hiveeyes / terkin-datalogger

Datalogger for MicroPython and CPython.
https://terkin.org
GNU Affero General Public License v3.0
60 stars 28 forks source link

Investigate reading the HX711 #81

Closed amotl closed 4 years ago

amotl commented 4 years ago

While discussing #80, @poesel and I stumbled over the code at hx711.py#L121-L128. We took the original implementation from hx711.py#L41-L46 by @geda.

When comparing it to the canonical HX711 library for Arduino by @bogde at HX711.cpp#L110-L167, I come to the conclusion we should protect the whole read sequence from system interrupts, right?

cc @robert-hh

poesel commented 4 years ago

we should protect the whole read sequence from system interrupts, right?

That would be nice but disabling the IRQs for such a long time causes a crash. I know, I tried. :(

robert-hh commented 4 years ago

I just pulled up the test files from my HX711 test. Using >2 Million test, I did not see an indication of a false read either at the SPI or Bit-Bang solution. Comparing shorter test series of 100000 samples each with different setting (e.g. 10 samples/sec and 80 samples/sec) also revealed no substantial difference between SPI and bit-banging. The set-up was for all test a weight sensor attached to a table and a 10 kg piece of steel hanging on it. The difference seen may be caused by a temperature drift. At 10 samples/sec, it takes 3 hrs for a test sequence.

@amotl: The original @geda implementation did not disable interrupts. So it had sometimes long pulses, resulting in read errors. So I made a PR to change that.