View Single Post
  #7   Spotlight this post!  
Unread 16-06-2014, 18:35
Domenic Rodriguez's Avatar
Domenic Rodriguez Domenic Rodriguez is offline
Registered User
FRC #0316 (LuNaTeCs)
Team Role: College Student
 
Join Date: Sep 2010
Rookie Year: 2011
Location: Grove City, PA
Posts: 213
Domenic Rodriguez has a spectacular aura aboutDomenic Rodriguez has a spectacular aura aboutDomenic Rodriguez has a spectacular aura about
Re: Pneumatics system code

Quote:
Originally Posted by Team 4939 View Post
Sorry for not replying earlier, but I just haven't been able to test the code that you all helped out with yet, due to exams and such. I should be able to test the system out tomorrow and I will post a reply letting you know how it worked out. I was able to get a picture: http://postimg.org/image/wvu8lykol/ . If that makes a difference to the code.

Also I was wondering something about where to plug the spike in, I pluged one end to the solenoid, and the other end into port 5 on my Digital side car.

I noticed in the code that Domenic Rodriguez posted :

Code:
 // Pneumatics
    Compressor compressor = new Compressor(1, 1);
    Solenoid solenoid = new Solenoid(1);
    DoubleSolenoid doubleSolenoid = new DoubleSolenoid(2, 3);

Ports 1, 2, and 3 are labeled.

Where should I plug my Spike into?

Thank You to all that helped me get this far, just a little more help is needed.
To clarify, are you planning on controlling your solenoid with a Spike Relay, or with the solenoid module on the cRIO?

The Solenoid and DoubleSolenoid classes only work for controlling solenoids through the solenoid module. If you are controlling your solenoid through a relay, you will need to use the Relay class instead.

Judging by your picture, it looks like you are using a double solenoid. I've never controlled a solenoid through Spikes before, but I believe you will need two Spikes, one for each side. Edit: Nope, see Mark McLeod's post below.

Updated code:
Code:
package edu.wpi.first.wpilibj.templates;
 
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.Relay;
 
public class RobotTemplate extends SimpleRobot {
    
    RobotDrive chassis = new RobotDrive(1,2);
    Joystick mainStick = new Joystick(1);
    Jaguar jaguar = new Jaguar(3);
    Jaguar jag = new Jaguar(4);

    // Pneumatics
    Compressor compressor = new Compressor(1, 1);
    Relay spike = new Relay(2);
    
    public void robotInit() {
        compressor.start();
    }

    public void autonomous(){ 
        chassis.setSafetyEnabled(false);
        chassis.drive (-0.5, 0.08);
        Timer.delay(2.0);
        chassis.drive (0, 0.0);
    }
    
    public void operatorControl() {
        chassis.setSafetyEnabled(true);
        while (isOperatorControl() && isEnabled()) {
            double speed = mainStick.getY();
            double rot = -mainStick.getX();
            chassis.arcadeDrive (speed, rot);
            if (mainStick.getRawButton(3)){
                jag.set(1);
                jaguar.set(-1);
            }
            else if (mainStick.getRawButton(4)){
                jaguar.set(-1);
                jag.set(1);
            }
            else{
                jaguar.set(0);
                jag.set(0);
            }

            // Solenoid
            if (mainStick.getRawButton(1))
                spike.set(Relay.Value.kForward);
            else if (mainStick.getRawButton(2))
                spike.set(Relay.Value.kReverse);
        }
    }
}
__________________

LuNaTeCs - Learning Under Nurturing Adults Teaching Engineering Concepts and Skills - Small and Mighty!

FRC 316 LuNaTeCs - Student (2011-2014), Lead Programmer (2011-2014), Team Captain (2013-2014), Operator (2013), Drive Coach (2014), Mentor (2015-????)
'11 Philly Regional Finalists, '13 Chestnut Hill Finalists, '13 Lenape Champions, '13 Archimedes Division, '14 Chestnut Hill Champions, '14 Lenape Champions
FTC 7071 EngiNerds - Founding Advisor (2013-2014) | FRC 5420 Velocity - Founding Advisor (2015)
Grove City College Class of '18, Electrical/Computer Engineering (B.S.E.E)


Last edited by Domenic Rodriguez : 17-06-2014 at 14:34. Reason: Tried to answer a question I didn't know the answer to.