PaulStoffregen / Encoder

Quadrature Encoder Library for Arduino
http://www.pjrc.com/teensy/td_libs_Encoder.html
540 stars 239 forks source link

ESP32 compiles but it is not accurate #64

Open Mesihas opened 3 years ago

Mesihas commented 3 years ago

There is no point on posting this on EXPRESSIF.COM

For me compiles perfect. The problem is that for each encoder rotation (1 point) I get multiples values and most of the times is not clean in terms of sequential move like:

33 34 33 34 33 34 35 36

This represents 1 move... How can accurately get a proper and unified value for every rotation point ?

danthegoodman1 commented 3 years ago

I have a similar issue, except no matter which direction I go I only get either 0 or 1:

0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
brunnwart commented 3 years ago

My experience is that this lib cannot be used für esp32. It just "looses" many counts (using interrupts by taking into account the ISR_ATTR topic) and thus it is absolutely far from precise and therefore useless. Unfortunately I haven't found a working alternative so far.

jpswensen commented 3 years ago

I was just looking at this today and I think I have a potential solution on the ESP32, but don't know how it would integrate well with this library. Using FreeRTOS (which is available in ArduinoIDE with the ESP32 core), you can designate a thread to run on a particular core.

As a quick first test, I plan on kicking off a single thread on the second core whos only responsibility is to poll the various GPIO set up for encoders. It seems like a waste of a whole core, but should be faster than interrupts.

StefanL38 commented 2 years ago

With ESP32 or ESP8266 use NewEncoder from gfvalvo instead https://github.com/gfvalvo/NewEncoder

best regards Stefan