![]() |
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!
|
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)
|
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); } |
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.
|
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 |
| All times are GMT -5. The time now is 11:33. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi