|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Need help programming double solenoids!
I am a member of team 4528, the Automatons. I need help figuring out why my pneumatics code for double solenoids won't work.
Code:
package org.usfirst.frc.team4528.robot;
import edu.wpi.first.wpilibj.Compressor; //Pneumatics
import edu.wpi.first.wpilibj.Joystick; //DriveTrain
import edu.wpi.first.wpilibj.RobotDrive; //DriveTrain
import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.DoubleSolenoid; //Pneumatics
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Victor; //Motors
public class Robot15 extends SampleRobot
{
Victor frontLeft;
Victor rearLeft;
Victor frontRight;
Victor rearRight;
Victor pully;
RobotDrive myRobot;
XBoxJoystick gamestick;
DoubleSolenoid pistonArm;
Compressor compressor;
public void Robot()
{
frontLeft = new Victor(1); //Set to appropriate PWM port
rearLeft = new Victor(2); //Set to appropriate PWM port
frontRight = new Victor(3); //Set to appropriate PWM port
rearRight = new Victor(4); //Set to appropriate PWM port
pully = new Victor(5); //Set to appropriate PWM port
pistonArm = new DoubleSolenoid(7, 6);
compressor = new Compressor(); //Set to null
gamestick = new XBoxJoystick(0); //Set to appropriate victors
myRobot = new RobotDrive(frontLeft, rearLeft, frontRight, rearRight);
}
public void useElavator()
{
if(gamestick.getRightZ() > 0)
{
pully.set(gamestick.getRightZ()); //Sets value of trigger to speed of motor
}
else if(gamestick.getLeftZ() > 0)
{
pully.set(-gamestick.getLeftZ()); //Sets value of trigger to speed of motor
}
else
{
pully.set(0.0); //Doesn't run if trigger not pressed
}
}
public void moveArm()
{
compressor.start();
compressor.setClosedLoopControl(true); //Lets PCM handle the automatic turning on and off of compressor once pressure hits 120 psi
if(gamestick.getAButton() == true)
{
pistonArm.set(DoubleSolenoid.Value.kForward); //Pushes piston whenever 'A' button is pressed
System.out.println("'A' button is pressed: Piston moves forward");
}
else if(gamestick.getBButton() == true)
{
pistonArm.set(DoubleSolenoid.Value.kReverse); //Reverses piston whenever 'B' button is pressed
System.out.println("'B' button is pressed: Piston moves backward");
}
else
{
pistonArm.set(DoubleSolenoid.Value.kOff); //Disables piston
}
}
public void operatorControl()
{
myRobot.setSafetyEnabled(false);
while(isOperatorControl() && isEnabled())
{
//squaredInputs help to lower speed value of analog sticks at lower values
myRobot.tankDrive(gamestick.getLeftY(), gamestick.getRightY(), true);
Timer.delay(0.005);
useElavator();
Timer.delay(0.005);
moveArm();
}
}
}
|
|
#2
|
||||
|
||||
|
Re: Need help programming double solenoids!
What CAN ID is the pneumatics control module on?
It needs to be oset to zero for the constructor you're calling yo work. http://team2168.org/javadoc/edu/wpi/...enoid-int-int- If you have it on a different ID, you should use http://team2168.org/javadoc/edu/wpi/...d-int-int-int- Do you see the LEDs on the PCM change when you press the joystick buttons? For more info on the PCM, look here: http://controls.team2168.org |
|
#3
|
||||
|
||||
|
Re: Need help programming double solenoids!
otherguy is right on all counts.
Though we should mention where the official documentation is http://wpilib.screenstepslive.com/s/...ribution-panel ...and... http://wpilib.screenstepslive.com/s/...control-module |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|