Go to Post I've been busier than a hog farmer at feedin' time. - Andy Baker [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 18-02-2011, 10:51
pigpc1993 pigpc1993 is offline
Registered User
AKA: Colin Feeney
FRC #3716 (WARP)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2009
Location: Manhasset, NY
Posts: 41
pigpc1993 is an unknown quantity at this point
Joysticks

We are having issues with our code on programming the joysticks. When we press the button our solenoids switch but sometimes they will switch right back. The Dashboard shows that they switch and then switch back sometimes. So I know they are opening. Any suggestions. Here is the code we are using

Code:
            if(js2.getRawButton(3) == true && j2b3 == false){
                s1.changeSolenoid(a1, a1End);
                s2.changeSolenoid(a2, a2End);
                j2b2 = true;
            }
            else{
                j2b2 = false;
            }
Reply With Quote
  #2   Spotlight this post!  
Unread 18-02-2011, 11:27
mobilegamer999 mobilegamer999 is offline
Registered User
FRC #3357 (Comets)
Team Role: Programmer
 
Join Date: Feb 2008
Rookie Year: 2008
Location: Michigan
Posts: 124
mobilegamer999 is a jewel in the roughmobilegamer999 is a jewel in the roughmobilegamer999 is a jewel in the rough
Re: Joysticks

should it be j2b2 in the primary if statement as opposed to j2b3? not sure if that was a typo in posting, if so, then I might need a little bit more detail to help you.
__________________
Reply With Quote
  #3   Spotlight this post!  
Unread 18-02-2011, 12:02
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: Joysticks

Quote:
Originally Posted by pigpc1993 View Post
We are having issues with our code on programming the joysticks. When we press the button our solenoids switch but sometimes they will switch right back. The Dashboard shows that they switch and then switch back sometimes. So I know they are opening. Any suggestions. Here is the code we are using

Code:
            if(js2.getRawButton(3) == true && j2b3 == false){
                s1.changeSolenoid(a1, a1End);
                s2.changeSolenoid(a2, a2End);
                j2b2 = true;
            }
            else{
                j2b2 = false;
            }
What you are experiencing is called "contact bounce". From Wikipedia:

Quote:
Contact bounce (also called chatter) is a common problem with mechanical switches and relays. Switch and relay contacts are usually made of springy metals that are forced into contact by an actuator. When the contacts strike together, their momentum and elasticity act together to cause bounce. The result is a rapidly pulsed electric current instead of a clean transition from zero to full current. The effect is usually unimportant in power circuits, but causes problems in some analogue and logic circuits that respond fast enough to misinterpret the on-off pulses as a data stream.
You have to implement a filter function commonly called a switch "debounce" to get rid of the problem.
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
Reply With Quote
  #4   Spotlight this post!  
Unread 18-02-2011, 12:06
pigpc1993 pigpc1993 is offline
Registered User
AKA: Colin Feeney
FRC #3716 (WARP)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2009
Location: Manhasset, NY
Posts: 41
pigpc1993 is an unknown quantity at this point
Re: Joysticks

Quote:
Originally Posted by Mike Betts View Post
What you are experiencing is called "contact bounce". From Wikipedia:



You have to implement a filter function commonly called a switch "debounce" to get rid of the problem.
How might a fix this?
Reply With Quote
  #5   Spotlight this post!  
Unread 18-02-2011, 12:26
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: Joysticks

Quote:
Originally Posted by pigpc1993 View Post
How might a fix this?
I would start by searching for the word debounce... You may find something.
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
Reply With Quote
  #6   Spotlight this post!  
Unread 18-02-2011, 18:12
Patrickwhite's Avatar
Patrickwhite Patrickwhite is offline
May the North be with you
FRC #0610 (The Coyotes)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Toronto
Posts: 88
Patrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of light
Re: Joysticks

One thing you can try is editing your else to an else if:
Code:
 ...
} else if (js2.getRawButton(3) == false) {
...
}
This makes sure it only reverts to true when the button is released.
__________________
while(!going.isTough());
tough.exit();

What will we do tonight, Warfa?
The same thing we do every night, Patrick. Sit and wait for Electrical.

Last edited by Patrickwhite : 18-02-2011 at 18:13. Reason: typo
Reply With Quote
  #7   Spotlight this post!  
Unread 19-02-2011, 21:58
SuperBK's Avatar
SuperBK SuperBK is offline
Registered User
AKA: BrianK
FRC #1225 (Amperage Robotics)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Henersonville, NC
Posts: 358
SuperBK is just really niceSuperBK is just really niceSuperBK is just really niceSuperBK is just really nice
Re: Joysticks

The easiest way to implement debounce is to have a counter where you have to read an input for a certain number of times for it to be considered valid.
__________________
Brian K
Team 1225 Robotics Mentor
Reply With Quote
Reply


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 22:19.

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