Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Counter debounce #516

Closed
off14 opened this issue Jun 10, 2017 · 13 comments · Fixed by #8021
Closed

Counter debounce #516

off14 opened this issue Jun 10, 2017 · 13 comments · Fixed by #8021
Labels
stale Action - Issue left behind - Used by the BOT to call for attention

Comments

@off14
Copy link

off14 commented Jun 10, 2017

Hi, if i configure debounce for counter let say 50 or 100,
it works ok, when my gas meter is fast enough. but when the consumption is super low, magnet can close the contact for half second and even for one second (slow rolling), or even stop at "closed" state. in this case every such event is treated AS TWO events - first when the proximity sensor closes, and the second when it opens.
making debounce too high is not an option - it can miss two events in this case.

can you build a counter option to treat only CLOSING as event (not both, closing and opening).

thanks

@arendst
Copy link
Owner

arendst commented Jun 10, 2017

You'll have to find some kind of debounce on your magnet as I'm already using only the falling edge of the signal as interrupt. I have no means to select another option.

@off14
Copy link
Author

off14 commented Jun 17, 2017

Thanks for the explanation,
anyway - the counter right now increases on both changes - from DOWN to UP and from UP to DOWN.
why not to make this option selectable? e.g. UP only, to calculate only changes from down to UP,

@Stalkk
Copy link

Stalkk commented Jun 18, 2017

I can confirm the issue.
I try to use TCRT5000 - module like this https://www.aliexpress.com/item/TCRT5000-Tracking-Module-Tracker-Infrared-Reflective-Sensor-For-Arduino-Robot-Smart-Car/32408909714.html and my counter counts always twice.

P.S. not always, only if my electricity meter rotates slower then X. if i turn on eg. water boiler it rotate faster and counter increments by 1.

@off14
Copy link
Author

off14 commented Jun 20, 2017

@arendst any chance you can look at this option?

@arendst
Copy link
Owner

arendst commented Jun 20, 2017

@off14 try to fiddle around with the counter interrupt routine in file xsns_counter.ino at line 81:

attachInterrupt(pin[GPIO_CNTR1 +i], counter_callbacks[i], FALLING);

Change FALLING to another nice Arduino supported value and experiment.

Make sure your counter input is ESP8266 compatible (3V3 NOT 5V).

@off14
Copy link
Author

off14 commented Jun 21, 2017

my counter is a reed switch between GPIO14 and GND (magnetic)

hall sensor is another option - but will experiment later, not works perfectly with 3.3V

@Stalkk
Copy link

Stalkk commented Jun 21, 2017

I think i have fixed my issue with a hardware capacitor debouncing.

@off14
Copy link
Author

off14 commented Jun 23, 2017

do i need any resistor (pullup or pull down) if i use standard GPIO14 ? and connect it to ground via REED switch
PS i've seen pullup necessary for re-using tx/rx pins for toggle switch

@sandervandegeijn
Copy link

I have a similar problem with a sensor. On my water meter I measure the reflection. If the water meter stops at the wrong position the sensor goes mad: it keeps pulsing like mad. Now I would like to ignore the pulses if they are not X msec apart. With a classic debounce option set to 1000ms I will get a incorrectly measured pulse every second.

@bubblefish12
Copy link

@neographikal
I had this problem too with 5V

now with 3.3V no Problem

@stale
Copy link

stale bot commented Jun 5, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Action - Issue left behind - Used by the BOT to call for attention label Jun 5, 2018
@stale
Copy link

stale bot commented Jun 21, 2018

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem.

@stale stale bot closed this as completed Jun 21, 2018
@gabbermorph
Copy link

I have still the same issue on Slow rotations on my Gasmeter with the reed contact.
On Slow Rotations it counts twice, even with debounce on 3200.

And what means Counter1n?

Its actually running on a USB adapter 550mA through a FTDI on 3.3v.

ascillato2 pushed a commit that referenced this issue May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Action - Issue left behind - Used by the BOT to call for attention
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants