arduino / ArduinoCore-mbed

330 stars 195 forks source link

RP2040 unreliable encoder and external interrupts #583

Open ale-novo opened 1 year ago

ale-novo commented 1 year ago

Hello, working with ConfigurableFirmata and RP2040 ive noticed the encoder library works unreliably for this board. I get encoder readings however they are unreliable. meaning if i turn left sometimes the value increases, sometimes decreases, skips steps, and the same the other way. Also there is no correlation with the number of clicks of the encoder and the increase/decrease of the reading. I suspect this issue is related with RP2040 interrupts.

This works great for other boards like arduino nano for instance.

Sketch: https://github.com/PaulStoffregen/Encoder/blob/master/examples/Basic/Basic.ino

Encoder library: https://github.com/PaulStoffregen/Encoder

Support for RP2040 in this fork of the encoder library: https://github.com/oerkel47/Encoder/

Ive installed the RP2040 board in the Arduino IDE ARDUINO MBED OS RP2040 3.4.1

ive done some research and this issue has been reported here https://github.com/arduino/ArduinoCore-mbed/issues/253 and here: https://github.com/PaulStoffregen/Encoder/issues/69

in theory it was fixed here: https://github.com/arduino/ArduinoCore-mbed/pull/256

however its not working for me, can you please help me? having the encoder work is the last piece in the puzle to start using RP2040 for my projects. thanks a lot.

alessandromrc commented 1 year ago

Hi @ale-novo you could look into my own implementation to get encoders working without using any code from the actual core to avoid issues like these here: https://github.com/alessandromrc/rp2040-mini-core/blob/fcf086a96f4388b3d22462bce10a06858bd4d5d0/core.hpp#L482