Go to Post It is the team that they build that is the important accompliishment.. - Wayne C. [more]
Home
Go Back   Chief Delphi > Technical > Pneumatics
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 07-02-2015, 13:59
Zalmay's Avatar
Zalmay Zalmay is offline
Registered User
FRC #4528
 
Join Date: Feb 2015
Location: United States
Posts: 11
Zalmay is an unknown quantity at this point
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();
		}
	}
}
 


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 05:37.

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