QUERY · ISSUE
pulse counter quadrature encoder
enhancement
How can I use this firmware to get the output of the quadrature encoder
CANDIDATE · PULL REQUEST
ESP32: Add Quadrature Encoder and Pulse Counter classes.
port-esp32
Applied to industrial encoders. Has a 32-bit wide counter!!! Has a 32-bit wide matching value !!! (64 bit wide is possible).
Count pulses on Pin(17) with direction on Pin(16) an irq handler on zero value.
from machine import Counter, Pin
def irq_handler(self):
print('irq_handler()', self.id(), self.status(), self.value())
cnt = Counter(0, src=Pin(17, mode=Pin.IN), direction=Pin(16, mode=Pin.IN))
cnt.irq(irq_handler, Counter.IRQ_ZERO) # set irq handler
print(cnt.value()) # get current counter value
Please note that this pull request
ESP32: Add Quadrature Encoder and Pulse Counter classes. #8766
and
docs\machine: Add Counter and Encoder classes. #8072
and
mimxrt: Add Quadrature Encoder and Pulse Counter classes. #7911
are mutually agreed upon.
Note: MicroPython-lib PR Add Stepper Motor PWM-Counter driver. requires this PR.