endail / hx711-pico-c

Implementation of single and multiple HX711 use via RP2040's state machine
https://endail.github.io/hx711-pico-c/
MIT License
32 stars 7 forks source link

Increase frequency to 10MHz #20

Closed endail closed 2 years ago

endail commented 2 years ago

image

Experiment with delaying and reading at the absolute minimum rates possible. Currently resolution is at 1us.

endail commented 2 years ago

After increasing the PIO state machine frequency from 1MHz to 10MHz, the HX711 is still performing well and readings are very stable.

https://github.com/endail/hx711-pico-c/blob/7cb93f12af2a690adc6c9521753c6989165df7c2/src/hx711_noblock.pio#L82-L86

Removing the T3 delays does not seem to have any effect. However, I am reluctant to remove them because they are the bare minimum according to the datasheet and low-quality HX711 ICs/boards may not have the same performance.

endail commented 2 years ago

T2 is still unneeded due to the delays in reading the data pin and jump instructions.

endail commented 2 years ago

T4 also unneeded for the same reason as T2.

endail commented 2 years ago

T1 is a little more complicated.

https://github.com/endail/hx711-pico-c/blob/7cb93f12af2a690adc6c9521753c6989165df7c2/src/hx711_noblock.pio#L80-L83

RP2040 datasheet states: image

With no delay following wait (ie. wait 0 pin 0 [1]), and assuming the next instruction executes immediately after the wait condition is met, the clock pin will go high following that second instruction (ie. set pins, 1 [T3 - 1]). The set pins, 1 portion of the instruction will take one cycle, which at 10MHz is 100ns (0.1us), which is the absolute minimum for T1 anyway.

Conclusion? T1 is also unneeded.

endail commented 2 years ago

PIO program documentation also needs an update to reflect these changes.