|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#46
|
|||
|
|||
|
Re: Limit Swtich Help
Quote:
Code:
if(-axis > 0.5 && limitPressed2 == true) { //I am using true because the limit switch is off when open and on when closed
victor1.set(1);
victor2.set(1);
} else if(axis > 0.5 && limitPressed == false) {
victor1.set(-1);
victor2.set(-1);
}else {
victor1.set(0);
victor2.set(0);
} if(xbox.getRawButton(4) && limitPressed3 == true) {
spike1.set(Relay.Value.kForward);
spike2.set(Relay.Value.kForward);
} else if(xbox.getRawButton(1) && limitPressed 4 == true) {
spike1.set(Relay.Value.kReverse);
spike2.set(Relay.Value.kReverse);
} else {
spike1.set(Relay.Value.kOff);
spike1.set(Relay.Value.kOff);
}
Last edited by curtis0gj : 02-07-2015 at 12:37 PM. |
|
#47
|
|||
|
|||
|
Re: Limit Swtich Help
Jon Stratis, does this look okay I feel as if I don't need to set my limit switches to true/false in the if statements also should I add any timer delays?
Code:
public void operatorControl() {
while (isOperatorControl() && isEnabled()) {
double leftaxis = xbox.getRawAxis(1);
double rightaxis = xbox.getRawAxis(4);
double rightyaxis = xbox.getRawAxis(5);
robot.arcadeDrive(stick.getY() * 0.5, stick.getX() * 0.5); //Change the 0.5 for sensitivity, I removed get throttle I may need it again.
limitPressed = limit.get();
limitPressed2 = limit2.get();
limitPressed3 = limit3.get();
limitPressed4 = limit4.get();
/* REMINDER limitPressed is an opposite type of limit switch!
* victor1 and victor2 will power the lead screw.
* victor3 will open and close arms.
* limitPressed will be the bottom of the lead screw.
* limitPressed2 will be the top of the lead screw.
* limitPressed3 will the for the left minimum arm distance.
* limitPressed4 will be for the max arm distance.
* The print lines are helpful for testing boolean states.
//System.out.println("limitPressed=" + limitPressed); //Read the RoboRIO log for some values.
//System.out.println("limitPressed2=" + limitPressed2);
//System.out.println("limitPressed3=" + limitPressed3);
//System.out.println("limitPressd4=" + limitPressed4);
*/
if(-leftaxis > 0.5 && limitPressed2 == true) {
victor1.set(1);
victor2.set(1);
} else if(leftaxis > 0.5 && limitPressed == false) {
victor1.set(-1);
victor2.set(-1);
} else {
victor1.set(0);
victor2.set(0);
}
if(-rightyaxis > 0.5 && limitPressed4 == true) {
victor3.set(1);
} else if(rightyaxis > 0.5 && limitPressed3 == true) {
victor3.set(-1);
} else {
victor3.set(0);
}
if(-rightaxis > 0.5) {
spike1.set(Relay.Value.kForward);
spike2.set(Relay.Value.kForward);
} else if(rightaxis > 0.5) {
spike1.set(Relay.Value.kReverse);
spike2.set(Relay.Value.kReverse);
} else {
spike1.set(Relay.Value.kOff);
spike2.set(Relay.Value.kOff);
}
}
}
|
|
#48
|
||||
|
||||
|
Re: Limit Swtich Help
That looks great to me. I think it'll work great for you!
|
|
#49
|
|||
|
|||
|
Re: Limit Swtich Help
Alright awesome thanks for all the help I will try it out tomorrow.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|