Go to Post My hammer is my therapist, my weapon against bent metal, unwilling bolts, and tall nails. - Morgan Gillespie [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 05-02-2014, 19:51
Dinnesy Dinnesy is offline
Registered User
FRC #4968 (Robo Hawks)
Team Role: Teacher
 
Join Date: Dec 2013
Rookie Year: 2014
Location: Lively
Posts: 19
Dinnesy is an unknown quantity at this point
Unhappy Compressor won't shut off at certain PSI

We just got our compressor working today that's attached with a pressure switch and a relay. Our compressor turns on when we start the robot on teleoperated mode but it doesn't turn off when we reach a PSI of above 125 (factory default).
Our spike is connected up to slot 7 in the relay on the digital sidecar, and our pressure switch is connected to slot 3 on our digital I/O. Everything works fine except that the signal to the pressure switch isn't being received so it's not opening and closing the circuit. We aren't quite sure what the problem is, but here's my code dealing with the compressor, and the relay.

tldr;We are able to manually start and stop the compressor with a button on our joystick, but not have it work automatically via the pressure switch.

Code:
public class RobotTemplate extends SimpleRobot {    
        
    //Check robot for right numbers    
    Joystick controller = new Joystick(2);           

    Compressor mainCompressor = new Compressor(7,3); // Relay, Digital IO    
   
    Relay spike = new Relay(7);
        
    public void roboinit(){   
        mainCompressor.start();
        System.out.println("Robot Initiated:");
    }  

    public void operatorControl()
    {   
        System.out.println("Telop Activated:");
        mainCompressor.start();       
        while (true){                           
        
        //==================== Spike ====================//
        spike.set(Relay.Value.kOn);
        spike.set(Relay.Value.kForward);
       /* if(controller.getRawButton(5)){  
            
            //spike.set(Relay.Value.kForward);
            
        }
        else if(controller.getRawButton(6)){
            spike.set(Relay.Value.kReverse);
        }
        else{
            spike.set(Relay.Value.kOff);
        }
        */
        }
    }
Reply With Quote
  #2   Spotlight this post!  
Unread 06-02-2014, 07:01
pblankenbaker pblankenbaker is offline
Registered User
FRC #0868
 
Join Date: Feb 2012
Location: Carmel, IN, USA
Posts: 103
pblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of light
Re: Compressor won't shut off at certain PSI

Check the javadocs (they can be found under your home directory at sunspotfrcsdk/doc/javadoc/index.html) for the Compressor class. I'm pretty sure the constructor expects the two parameters to be the "pressure switch digital input channel" followed by the "spike relay channel". I think you have them reversed in your code. Try:

Code:
Compressor mainCompressor = new Compressor(3, 7); // DIO, Relay
Also, once you start the Compressor object, you should not manipulate the spike by hand. The while loop you show in your teleop code continually attempts to turn the compressor on. I would recommend that your remove the spike entirely from your class (comment it out for now). I suspect allocating it will cause a stack trace once you change the order of the parameters to the compressor (the WPI library won't typically let a Relay be constructed more than once with the same channel ID).

You might also want to put the state of the pressure switch out to the dashboard periodically so you can confirm that it is working:

Code:
public void operatorControl() {   
        System.out.println("Telop Activated:");
        mainCompressor.start();       
        while (isOperatorControl()) {
           // Add your code

           // Periodically update dashboard values
           updateDashboard();

           // Optional short sleep so main loop is not going full out
           Timer.delay(.01)                           
        }
}

// Time of last dashboard update
private double _LastUpdate = 0;

public void updateDashboard() {
    double now = Timer.getFPGATimestamp();
    // Don't need to update the dashboard values more than 5 times a second
    if ((now - _LastUpdate) >= 0.2) {
       SmartDashboard.putBoolean("Full Pressure", compressorMain.getPressureSwitchValue());
       // Add other smart dashboard things to monitor here
    }
}
Hope that helps,
Paul
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 22:39.

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