Encoder not working on Pico 2W #17082
Replies: 4 comments 4 replies
-
There is a problem with RP2350 pins when used as inputs - see this issue. I'm not sure if this is relevant to the basic encoder script, but it will almost certainly affect the RP2 version which uses the PIO. In my view the |
Beta Was this translation helpful? Give feedback.
-
Re PIO solutions you might like to try the workround here. As written it fixes GPIO numbers 0 and 1, but check the RP2350 manual for the means of adapting to other pins. In my testing PIO input was utterly broken without that code. There is another possible issue in that the signals from mechanical encoders aren't particularly clean logic signals. I use 1KΩ pullups to try to get reasonably fast transitions. It is possible that the revised hardware/firmware is particularly intolerant of these signals. To put this into context, the portable driver has been used on a wide range of platforms (STM32, ESP32, ESP8266, RP2040, and probably others) without problems. As a general point, given that you're using |
Beta Was this translation helpful? Give feedback.
-
Assume a mechanical encoder linked to 0v, with 1KΩ pullups to 3V3: if the voltage swing isn't 0-3.3V, something is electrically very wrong. |
Beta Was this translation helpful? Give feedback.
-
I have now tested from machine import Pin
from encoder_portable import Encoder
from time import sleep
px = Pin(0, Pin.IN)
py = Pin(1, Pin.IN)
e = Encoder(px, py)
while True:
print(e.position())
sleep(1) I haven't yet tested the PIO version, but I would expect it to be problematic without the fix I identified above. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I have a rotary encoder that was working just fine on a Pico 1 W, using Peter Hinch's asyncio encoder. I was forced to migrate to Pico 2 as I needed more memory, but the same code does not trigger any interupts on the Pico 2. I am using Micropython v1.25.0-preview.380.g226434055.
Encoder driver form https://github.com/peterhinch/micropython-samples/blob/master/encoders/ENCODERS.md
I am using encoder.py... not encoder_rp2.py, which to be honest, I didn't find until today. encoder_rp2.py generates interupts, but the values generated are"interesting"... encoder.py does not do anything on Pico 2.
Hardware is fine.. works with my simple IRQ that just compares encoder Pin values, but Peter's code is rather more elegant ;-)
However, the reason for reporting the issue here is that there seems to be something broken in v1.25 ... at least, running on a Pico 2.
Beta Was this translation helpful? Give feedback.
All reactions