Comments (7)
If you want to use KY-040 you need to understand mechanical switch bouncing. I bet what you are getting is a bounce that takes longer then the runt filtering built in. You need to add a small capacitor to the switch and only move it SLOWLY. Mechanical encoders are only stable at VERY low speeds, like a knob that someone moves with their fingers.
Check out this document: http://web.engr.oregonstate.edu/~traylor/ece473/lectures/debounce.pdf for more information.
Closing issue because it it an electrical problem.
from esp32encoder.
I understand what bounces are and why I would possibly get tick errors. that's fine
I'm still unclear on the error message I get
E (33) pcnt: pcnt_counter_clear(158): PCNT UNIT ERROR
there are similar messages when I compile your example as well.
from esp32encoder.
try removing your encoder from the circuit entirely. Verify with an o-scope (at least 10 Mega-samples/sec) that the lines are clean. If you still get the error after verifying the signals are perfectly clean, let me know.
I can not reproduce the error on my hardware, so i suspect electrical issues.
from esp32encoder.
Also, what is the reason for trying to clear the encoder before attaching? Try removing that as well.
from esp32encoder.
Also, what is the reason for trying to clear the encoder before attaching? Try removing that as well.
Good catch - that's because in your example you did it like that :)
I switched the order of the commands
encoder.attachHalfQuad(encoderDTPin,encoderCLKPin); // Attach pins for use as encoder pins
encoder.clearCount();
and now the error message is gone.
--> suggest you fix this in your example as well
thx for the good work and sharing !
working code for an example:
#include <ESP32Encoder.h>
ESP32Encoder encoder;
const uint8_t encoderCLKPin = 13; // encoder CLK
const uint8_t encoderDTPin = 14; // encoder DT
int32_t encoderCntr = 0L;
void setup() {
Serial.begin(115200);
ESP32Encoder::useInternalWeakPullResistors = true; // Enable the weak pull down resistors
encoder.attachHalfQuad(encoderDTPin,encoderCLKPin); // Attach pins for use as encoder pins
encoder.clearCount();
Serial.println(F("Play with your encoder"));
}
void loop()
{
int32_t currentEncoderCntr = encoder.getCount();
if (currentEncoderCntr != encoderCntr) {
if (currentEncoderCntr > encoderCntr) {
Serial.print(F("tick + = "));
} else {
Serial.print(F("tick - = "));
}
encoderCntr = currentEncoderCntr;
Serial.println(currentEncoderCntr);
}
}
from esp32encoder.
example updated in 0.3.2
from esp32encoder.
thx!
from esp32encoder.
Related Issues (20)
- [Question] What do Full , Half, and Single mean? HOT 3
- Unused variable TAG prevents compilation when compiler warnings "more" or "all" selected
- ESP32Encoder::useInternalWeakPullResistors = DOWN does not work
- Compilation fails in Arduino IDE 2.0 for esp32c3 HOT 2
- esp32s3 crashes with Encoder.ino HOT 1
- A simple example of using the library HOT 2
- PCNT issue using FastAccelStepper 0.28.1 with ESP32Encoder 0.10.1 + workaround
- Not compiling for ESP32-S2 HOT 3
- Compile error 0.10.0 and 0.10.1 HOT 6
- Encoder Library with PCNT as Frequency Counter
- Function working and direction HOT 6
- Encoder not working in IO2, IO4. HOT 3
- Compile fails with soc.h not found HOT 5
- Not working with tasks HOT 1
- Compiling error HOT 12
- Attach Single edge problem HOT 1
- ESP32-C3 compile fail
- setCount after setup() HOT 2
- Encoder get difference from last read HOT 1
- Definition of NONE confliccts with other libraries
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp32encoder.