View Single Post
  #22   Spotlight this post!  
Unread 06-03-2013, 09:25
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,128
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Sensor "de-noising"

Quote:
Originally Posted by Kevin Sevcik View Post
It's been a while since I've done IIR filters and such, so my math on them is rusty. Is that actually exactly equivalent to checking than the signal has been 1 for the last X ms? It would seem that it would tolerate some blips low. And it definitely switches 1->0 quicker than 0->1.

Mind you, it's probably a perfectly cromulent and simple solution to the OP's actual problem, it just seems different than actual debouncing.
As shown, it debounces only in one direction: it requires 5 ones in a row to switch the output to 1, but only one zero to switch back to zero (and stay zero until 5 more consecutive ones are seen).

If you want to debounce in both directions, change the second line to

Code:

if(output==0) output=truncate(ave+0.03); else output=truncate(ave+1-0.03);

Last edited by Ether : 06-03-2013 at 09:42.