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)
- Trouble with RPM calculation HOT 2
- cannot even compile example for regular esp32 dev board HOT 7
- Encoder limit? ESP32S3 Bootloop Issue "Too Many Encoders!" HOT 4
- wrong counting with fast encoder HOT 2
- Liberary doesn't work when generating a PWM signal (when pins 15 and 16 split the PWM and encoder) HOT 6
- Support for MCP23017 GPIO expander
- compatibility with ESP32 core V3 HOT 2
- 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.