Go to Post Mob JVN for autographs - Jay Trzaskos [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

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #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();
		}
	}
}
  #2   Spotlight this post!  
Unread 07-02-2015, 15:09
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: 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
__________________
http://team2168.org
  #3   Spotlight this post!  
Unread 07-02-2015, 20:55
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 521
ozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant future
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
Closed Thread


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