kapraran / FreqCountESP

A frequency counter library for esp32
https://kapraran.github.io/FreqCountESP/
MIT License
31 stars 7 forks source link

bouncing input signal hack #2

Open Ludwolf opened 2 years ago

Ludwolf commented 2 years ago

Hi Nikos, thank you for the code, works well with proper edges, e.g. from function generator.

I use your module for RPM measurement on my CNC DC-spindle. I added a line-follower-module for RPM measurement, which provides a pretty good, but not perfect rectangle edge.

Bouncing I suppressed with 0.1 nF capacitor at input, and the following code hack in your module.

Any better / alternative idea ?

Greetings from Wolf Ludwig, ludwolf@t-online.de :-)

void IRAM_ATTR onRise() { portENTER_CRITICAL_ISR(&_FreqCountESP::sMux); if(digitalRead(FreqCountESP.mPin)){ _FreqCountESP::sCount++; } portEXIT_CRITICAL_ISR(&_FreqCountESP::sMux); }

danalvarez commented 1 year ago

Although I was not able to see any bouncing on my input signal, I found similar issues that were solved by configuring the glitch filter. More info here: https://github.com/espressif/arduino-esp32/discussions/8368

Maybe it helps someone!