Go to Post The problem is though, as long as the teams are allowed to work on their robots on Thursday, they will, and they'll never learn to finish it before the event. - sanddrag [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 07-02-2015, 14:11
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();
		}
	}
}
We know that the problem is not with the hardware itself since we are able to use the pistons manually via the solenoid. It is most likely a problem with the code, specifically the moveArm() method.
Reply With Quote
  #2   Spotlight this post!  
Unread 07-02-2015, 16:48
Team3266Spencer's Avatar
Team3266Spencer Team3266Spencer is offline
Team Captain and Lead Programmer
AKA: Spencer Lanman
FRC #3266 (Robots-R-US)
Team Role: Programmer
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Richmond, Indiana
Posts: 280
Team3266Spencer is an unknown quantity at this point
Re: Need help programming double solenoids!

Please explain what you mean by "won't work."
__________________
2012: Buckeye Regional, Queen City Regional, Human Player
2013: Queen City Regional, Buckeye Regional, Crossroads Regional
Shooter Operator
2014: Crossroads Regional, Queen City Regional
Catapult Operator
2015: Georgia Southern Classic Regional (Winner), Queen City Regional
Chainsaw Operator
Want to talk? TeamSpeak: team3266.noip.me
Reply With Quote
  #3   Spotlight this post!  
Unread 07-02-2015, 18:30
CreativeName55 CreativeName55 is offline
Registered User
FRC #2729 (Storm Robotics)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2011
Location: Marlton
Posts: 17
CreativeName55 is an unknown quantity at this point
Re: Need help programming double solenoids!

The two possibilities I see are the setting it to off, as I have no idea what that does (we've always set it to a position and left it there until we set it the other way), or if the solenoid's not receiving the right voltage. Some solenoid's are meant to receive 12V, some 24V. If they're wired wrong, they don't work
Reply With Quote
  #4   Spotlight this post!  
Unread 07-02-2015, 20:41
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,654
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Need help programming double solenoids!

We're not using pneumatics this year, and I was not programming last year, so maybe this won't make sense with the 2015 setup. However, I remember that our lead programmer last year spoke of "strobing" the double solenoids when the buttons were pressed rather than "setting" them. I believe that this is because (physical) double solenoid valves only need to be supplied with current for a fraction of a second; when no voltage is applied to either side, they physically maintain their state through the position of the internal piston.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
Reply


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 13:35.

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