Description
CircuitPython version and board name
Adafruit CircuitPython 9.2.4-7-g1c0b37e504 on 2025-02-04; Pimoroni Pico Plus 2 W with rp2350b
Code/REPL
import board
import rotaryio
import time
encoder = rotaryio.IncrementalEncoder(board.GP15, board.GP14)
while True:
time.sleep(0.1)
print(encoder.position)
# Code to test output of encoder using digitalio
#
# import board
# import digitalio
# import time
# encoderpin1 = digitalio.DigitalInOut(board.GP14)
# encoderpin2 = digitalio.DigitalInOut(board.GP15)
# encoderpin1.direction = digitalio.Direction.INPUT
# encoderpin2.direction = digitalio.Direction.INPUT
# while True:
# time.sleep(0.1)
# print(encoderpin1.value, " - ", encoderpin2.value)
Behavior
Rotaryio position of a rotary encoder attached to an external filter circuit then to GPIO pins 14 and 15 on a Pimoroni Pico Plus 2W (RP2350b) does not change when turned.
Description
I have an EC12E type rotary encoder connected to a Pimoroni Pico Plus 2 W (GPIO14 and 15). The encoder uses the recommended external filter circuit from the datasheet (see image) rather than connect directly to the board.
If I try to use rotaryio the position never updates, it's constantly stuck on a position value of 0. However, if I read the encoder pins as digitalio inputs I can see both pins read True by default and when I spin the encoder I can see it flipping between True and False as you would expect.
This seems to be the same behaviour as #9695 but this was reported fixed in PR #9682, a further RP bug was reported #10024 which references these but this was also reported fixed by PR #10025.
Additional information
I attempted to use the same board with a spare encoder and no filtering circuit and that did seem to work with rotaryio and so I thought that the circuit might be at fault.
I have a handheld multimetre which has some basic oscilloscope functionality. So I hooked it up to the GPIO and when using rotaryio I can see the state as high but the low signal does not seem to be returning to GND it hovers at what looks like around halfway between the high signal and GND (if my multimetre has a way to see the actual voltage number on the oscilloscope graph I don't know how). I thought there might be a slight short so I checked the pins and cleaned the board, no change.
I then thought to check those same pins connected to the same filtered encoder circuit but using digitalio instead of rotaryio, using the oscilloscope to measure that, the circuit is going to GND properly as the encoder is turned. This implies to me that the circuit does not have a short or anything like that and that is has to be something about how rotaryio is implemented that is different to just reading the pins using digitalio.
I can only deduce that either the way this circuit is designed is incompatible with rotaryio or something about how roraryio works has a bug for RP2350b when using an external filtering circuit like this.