Go to Post I actually love and am very thankful for what all these amazing engineering role models put into this program year in and year out. - Bill Gold [more]
Home
Go Back   Chief Delphi > Technical > Electrical
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #16   Spotlight this post!  
Unread 04-02-2011, 11:38
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Toggle switches to Analog board?

Switch bounce would affect switches connected to a digital input at least as much as it would analog inputs. Most of the time, the programming is going to be such that it simply doesn't care whether the switch gets detected several times in quick succession.

For reading a switch on an analog input, the WPILib "analog trigger" function is what you want. That rejects glitch-type noise as part of its implementation.
  #17   Spotlight this post!  
Unread 04-02-2011, 11:38
JamesBrown JamesBrown is offline
Back after 4 years off
FRC #5279
Team Role: Engineer
 
Join Date: Nov 2004
Rookie Year: 2005
Location: Lynchburg VA
Posts: 1,284
JamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond repute
Re: Toggle switches to Analog board?

Edit: Looks like I need to type faster if I am going to post in the same threads as Al and Alan. But what I posted may still be usefull so I will leave it up.


Quote:
Originally Posted by Al Skierkiewicz View Post
Yes, You guys are right. I have to stop answering these questions while I am working on interfaces here. Alan, can you add something about programming so that switch bounce doesn't confuse the readings?
I am not Alan but I should be able to help here any way. To debounce a switch in software what you want to do is ensure that the press that was detected was a true press, not just noise or bounce. The easiest way to do this is once a press is detected start a counter, if the counter reaaches a certain value (10ms is probably acceptable for FRC Applications) then acknowledge that the switch is pressed. If the switch is released before counter times out the reset the counter and ignore the bounce.

Psuedo Code
Create Counter- Initialize to Zero

Assuming Switch sampling occusr every ~1ms

If (Software_representation of switch = not-pressed)

If switch is not pressed
Reset Counter
Set Software representation of switch to not-pressed
else (switch is pressed)
increment counter
end if

if counter > 10
Set software representation of swtch to pressed
end if

Then you can reverse the switched/not-switched cases for then the butto is pressed if you need to detect the release as well.
__________________
I'm Back


5279 (2015-Present)
3594 (2011)
3280 (2010)
1665 (2009)
1350 (2008-2009)
1493 (2007-2008)
1568 (2005-2007)
  #18   Spotlight this post!  
Unread 04-02-2011, 17:58
sircedric4's Avatar
sircedric4 sircedric4 is offline
Registered User
AKA: Darren
no team (The SS Prometheus)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Lousiana
Posts: 245
sircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond repute
Re: Toggle switches to Analog board?

Cool discussion, I am happy I can use my SPST switches. I already had a bunch purchased and laying around. I also appreciate the pseudocode. Thanks again.
  #19   Spotlight this post!  
Unread 04-02-2011, 18:23
Unsung FIRST Hero
Al Skierkiewicz Al Skierkiewicz is offline
Broadcast Eng/Chief Robot Inspector
AKA: Big Al WFFA 2005
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1996
Location: Wheeling, IL
Posts: 10,798
Al Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond repute
Re: Toggle switches to Analog board?

Darren,
Sorry I led you down the rosy path earlier.
__________________
Good Luck All. Learn something new, everyday!
Al
WB9UVJ
www.wildstang.org
________________________
Storming the Tower since 1996.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 20:49.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi