View Single Post
  #23   Spotlight this post!  
Unread 06-03-2013, 22:58
efoote868 efoote868 is offline
foote stepped in
AKA: E. Foote
FRC #0868
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2005
Location: Noblesville, IN
Posts: 1,426
efoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond repute
Re: Sensor "de-noising"

Quote:
Originally Posted by Ether View Post
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);
If I understand what you're doing, .03 is a nice way to represent 2 ^ -5, and if you wanted more or less consecutive bits (allowing longer debouncing) you'd adjust the exponent accordingly.
__________________

Be Healthy. Never Stop Learning. Say It Like It Is. Own It. Like our values? Flexware Innovation is hiring!. We're looking for Senior Automation, Software, and System Engineers. Check us out!