Go to Post Gracious Professionalism, it's hard to describe, but I sure know when I'm not living up to it. - rsisk [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 03-14-2013, 08:36 PM
tuXguy15's Avatar
tuXguy15 tuXguy15 is offline
Team Mentor
AKA: Devin Kolarac
FRC #2559 (Normality Zero)
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Harrisburg, PA
Posts: 127
tuXguy15 is an unknown quantity at this point
Question 3 Position Solenoid Help

Hello, my team has just got this new solenoid that take up two ports on the cRio. This solenoid allows us to put as much or little air in a cylinder as we want or it can handle. What we are trying to do is make it so when you press button 8 and hold it, it will go up until you let go then it will stop right where it is. If you hold button 9 down it will go down and stop where it is when you let go. I can make it go the whole way up or down for a regular solenoid, but I don't know how to make it go and stop when you want it to. Can anyone help me out? Thanks!
Reply With Quote
  #2   Spotlight this post!  
Unread 03-14-2013, 09:03 PM
sparkydp sparkydp is offline
Registered User
AKA: David Page
FRC #0435 (Robodogs)
Team Role: Mentor
 
Join Date: Apr 2005
Rookie Year: 2002
Location: Raleigh, NC
Posts: 32
sparkydp is on a distinguished road
Re: 3 Position Solenoid Help

A schematic or link to the part might help, but I think what you want to do is set your solenoid #1 output on if button 8 is pressed, #2 output on if 9 is pressed, and set both to off when neither is pressed. What is probably happening now, is you're not clearing the output in the neither pressed case, so it just remembers the last setting it had (and keeps extending or retracting)
Reply With Quote
  #3   Spotlight this post!  
Unread 03-15-2013, 07:10 AM
tuXguy15's Avatar
tuXguy15 tuXguy15 is offline
Team Mentor
AKA: Devin Kolarac
FRC #2559 (Normality Zero)
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Harrisburg, PA
Posts: 127
tuXguy15 is an unknown quantity at this point
Re: 3 Position Solenoid Help

So something like this?
-----
if(joystick1.getRawButton(8)) {
solenoid7.set(true);
}else{
solenoid7.set(false);
}

if(joystick1.getRawButton(9)) {
solenoid8.set(true);
}else{
solenoid8.set(false);
}
Reply With Quote
  #4   Spotlight this post!  
Unread 03-15-2013, 03:14 PM
tuXguy15's Avatar
tuXguy15 tuXguy15 is offline
Team Mentor
AKA: Devin Kolarac
FRC #2559 (Normality Zero)
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Harrisburg, PA
Posts: 127
tuXguy15 is an unknown quantity at this point
Re: 3 Position Solenoid Help

OK so this did work but i also need an alternative button that will make it go up the whole way with out holding it... Do i just put a timer in it to make it go up for a certain time till it is up or is there a simpler way.
Reply With Quote
  #5   Spotlight this post!  
Unread 03-15-2013, 06:10 PM
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 429
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: 3 Position Solenoid Help

You could set two buttons up to to change the state of the solenoid when they transition from not being pressed -- to being pressed.

The only problem I foresee with this is if you ever wanted to stop the thing from moving, you would need to set up a new command on another button which set both solenoid channels to their false state. (Added to the code example)

This can be thought of as a rising edge trigger. Something (whatever is in the if statement) will happen once when the button is pressed, and never again until the button is released and pressed again.

Code:
//These should be declared outside of the method which code
// is executing in.
Boolean currentButton1Value = false,
        prevButton1Value    = false,
        currentButton2Value = false,
        prevButton2Value    = false;




//The below code should be placed in whatever method is continually
//  executing code (e.g. teleop periodic)


//Check the current button values
currentButton1Value = joystick1.getRawButton(1);
currentButton2Value = joystick1.getRawButton(2);

//If the button was just transitioned from not pressed to pressed,
//  extend? completely.
if((currenButton1Value == true) && (prevButton1Value == false)) {
  //The only way to get in here is if button 1 is currently true,
  //  and used to be false.
  solenoid7.set(true);
  solenoid8.set(false);
}

//If the button was just transitioned from not pressed to pressed,
//  retract? completely.
//Using a simplified form for the boolean logic (does the same thing as above)
if(currenButton2Value && !prevButton2Value) {
  solenoid7.set(false);
  solenoid8.set(true);
}

//Keep a history of the button presses
prevButton1Value = currentButton1Value;
prevButton2Value = currentButton2Value;

if(joystick1.getRawButton(3)){
  solenoid7.set(false);
  solenoid8.set(false);
}
Note this code isn't tested, and I don't know what your application is, so I'm not sure if it fits the need well. Hope it helps.
__________________
http://team2168.org

Last edited by otherguy : 03-15-2013 at 06:13 PM. Reason: added code for stopping motion on button 3
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 08:55 AM.

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