Go to Post Life? What's a life? I mean, outside of [I]FIRST[/I], that is. - Blue_Mist [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-2013, 15:02
Mr.Roboto3335's Avatar
Mr.Roboto3335 Mr.Roboto3335 is offline
Wait, What?
AKA: Jimmy
FRC #3335 (Cy-Borgs)
Team Role: Programmer
 
Join Date: Nov 2011
Rookie Year: 2011
Location: Texas
Posts: 47
Mr.Roboto3335 is an unknown quantity at this point
Programming Pneumatics

I have to program 2 pistons and i'm having a hard time understanding how to do that.
__________________
Wait, what?
Reply With Quote
  #2   Spotlight this post!  
Unread 07-02-2013, 15:10
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Re: Programming Pneumatics

First you need to learn how to program four solenoids. One for extending and one for retracting each.
Reply With Quote
  #3   Spotlight this post!  
Unread 07-02-2013, 15:56
Mr.Roboto3335's Avatar
Mr.Roboto3335 Mr.Roboto3335 is offline
Wait, What?
AKA: Jimmy
FRC #3335 (Cy-Borgs)
Team Role: Programmer
 
Join Date: Nov 2011
Rookie Year: 2011
Location: Texas
Posts: 47
Mr.Roboto3335 is an unknown quantity at this point
Re: Programming Pneumatics

Would this be correct? (Please don't steal)

/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/

package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Timer;

/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the SimpleRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the manifest file in the resource
* directory.
*/
public class TheReaper extends SimpleRobot {
RobotDrive drive = new RobotDrive(1, 2);
Joystick leftStick = new Joystick(1);
Joystick rightStick = new Joystick(2);
Joystick miscStick = new Joystick(3);
Compressor mainCompressor = new Compressor(1,2);
Solenoid piston1extract = new Solenoid(1);
Solenoid piston1retract = new Solenoid(2);
Solenoid piston2extract = new Solenoid(3);
Solenoid piston2retract = new Solenoid(4);

public void robotinit() {
mainCompressor.start();
}

/**
* This function is called once each time the robot enters autonomous mode.
*/
public void autonomous() {

}

/**
* This function is called once each time the robot enters operator control.
*/
public void operatorControl() {
while (isOperatorControl() && isEnabled()){

drive.tankDrive(-leftStick.getY(), -rightStick.getY());
Timer.delay(0.01);
if(miscStick.getRawButton(3)){
piston1extract.set(true);
piston1retract.set(false);
}else if(miscStick.getRawButton(4)){
piston1extract.set(false);
piston1retract.set(true);
}if(miscStick.getRawButton(7)){
piston2extract.set(true);
piston2retract.set(false);
}else if(miscStick.getRawButton(8)){
piston2extract.set(false);
piston2retract.set(true);
}else{
piston1extract.set(false);
piston1retract.set(false);
piston2extract.set(false);
piston2retract.set(false);
}
}

}

/**
* This function is called once each time the robot enters test mode.
*/
public void test() {

}
}
__________________
Wait, what?
Reply With Quote
  #4   Spotlight this post!  
Unread 07-02-2013, 18:43
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 543
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Programming Pneumatics

Quote:
Originally Posted by Mr.Roboto3335 View Post
Would this be correct? (Please don't steal)

}if(miscStick.getRawButton(7)){
piston2extract.set(true);
piston2retract.set(false);
}else if(miscStick.getRawButton(8)){
piston2extract.set(false);
move the if off of the brackets.

so its

}
if(){
}

you have it set up

}if(){
}

which gives the false illusion of an else statement. anyway, that wont work for piston 1 because it imminently gets de-fired if piston 2 isnt being fired / retracted.

also, you have no compressor regulator
Reply With Quote
  #5   Spotlight this post!  
Unread 07-02-2013, 21:11
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Re: Programming Pneumatics

Logically, sort of. First, try to put your code into code blocks. It makes your code look nice :P They look like [code ] put your code here [/code ] without the spaces after them. Follow the above suggestions as well.
Code:
            else
            {
                piston1extract.set (false);
                piston1retract.set (false);
                piston2extract.set (false);
                piston2retract.set (false);
            }
The above code has a logic error. When not in operation, the pneumatic cylinder should be retracted, so the solenoid that is connected to the forward most valve on the cylinder (the one closest to the functioning end) is enabled while the other is disabled. The code should look sort of like this (which is C++)
Code:
else
{
        Reverse2->Set(1);
	Reverse->Set(1);
        Forward2->Set(0);
	Forward->Set(0);
}
Here's some pseudo code / C++ that demonstrates some basic logic:
Code:
if (Button1)
{
	Forward->Set(1);
	Reverse->Set(0);
	Wait(0.1);
}
else if (!Button1)
{
        Forward->Set(0);
	Reverse->Set(1);
	Wait(0.1);

}
It's pretty much the same for both languages

Last edited by ekapalka : 07-02-2013 at 21:16.
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 12:49.

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