Compressor won't start

For some reason, our compressor won’t start when the code deploys fine, and we have the compressor and pressure gauge switch hooked up correctly ( I think). The compressor should start soon as the robot is turned on correct? The compressor for us doesn’t even start even if we enable teleops in the DS. Any help will be appreciated. I may be missing a simple step, so if anybody has an idea, please give suggestions. Here is the code btw:


#include "WPILib.h"

#include "Vision/AxisCamera2010.h"
#include "Vision/HSLImage.h"
#include "PIDController.h"
#include "Gyro.h"
#include "Target.h"
#include "DashboardDataSender.h"

//#define MINIMUM_SCORE 0.01

/**
 * This is a demo program showing the use of the RobotBase class.
 * The SimpleRobot class is the base of a robot application that will automatically call your
 * Autonomous and OperatorControl methods at the right time as controlled by the switches on
 * the driver station or the field controls.
 */ 
bool moveState = false;
class RobotDemo : public SimpleRobot
{
	RobotDrive myRobot; // robot drive system
	Joystick stick; // only joystick
	Jaguar leftMotors;
	Jaguar rightMotors;
	Compressor compressor;
	Relay relay;
	//DashboardDataSender *dds;
	//Gyro *gyro;
	//PIDOutput *pidOutput;

public:
	RobotDemo(void):
		myRobot(3, 4),	// these must be initialized in the same order
		stick(1),		// as they are declared above.
		leftMotors(1),
		rightMotors(2),
		compressor(4,2)
	{
		
		//start the compressor
		compressor.Start();
		AxisCamera &camera = AxisCamera::getInstance();
		//dds = new DashboardDataSender();
		//gyro = new Gyro(1);
		//pidOutput = new SamplePIDOutput(myRobot);
		GetWatchdog().SetExpiration(0.1);
		
		
	}

	/**
	 * Drive left & right motors for 2 seconds then stop
	 */
	void Autonomous(void)
	{
		GetWatchdog().SetEnabled(false);
		myRobot.Drive(0.5, 0.0); 	// drive forwards half speed
		Wait(2.0); 				//    for 2 seconds
		myRobot.Drive(0.0, 0.0); 	// stop robot
	}

	/**
	 * Runs the motors with arcade steering. 
	 */
	void OperatorControl(void)
	{
		GetWatchdog().SetEnabled(true);
		while (IsOperatorControl())
		{
			GetWatchdog().Feed();
			//myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)
			if(stick.GetRawButton(1))
			{
				moveState = 0;
			}
			if(stick.GetRawButton(3))
			{
				moveState = 1;
			}
			if(moveState == false)
			{
				//do nothing
			}
			if(moveState == true)
			{
				leftMotors.Set(-stick.GetY());
				rightMotors.Set(stick.GetZ());
				Wait(0.005);
			}
			
			// Create and set up a camera instance. first wait for the camera to start
					// if the robot was just powered on. This gives the camera time to boot.
					//Wait(10.0);
					//printf("Getting camera instance
");
			
		}
	}
};

START_ROBOT_CLASS(RobotDemo);


as you can see, its quite simple, however I don’t know what is going on. Thanks again,
ken

As far as I know, the WPILib kills any and all attempts to supply power to anything when the Watchdog hasn’t been fed, or the robot is disabled. Try setting the compressor to start when Teleop is enabled.

Good luck. :slight_smile:

I tried the method above and no success. I have also connected to the netconsole, and there seems to be no errors. I need help guys xP

Are you sure it’s not a wiring problem? Is the Spike powered by +12V and connected to the correct Relay output? Is there a breaker in the distribution board? Is the sidecar powered? Does the compressor turn on if it’s connected direct to +12V? The code seems fine to me.

The pressure switch shouldn’t be a problem, because the compressor will turn on even if that’s disconnected.

I’m quite sure everything is wired correctly. The solenoids etc are currently not wired, but the compressor is attached to the spike relay. the spike has power and the pwm is in relay 1. The pressure guage is plugged into digital 1. If it helps I tried using the GetPressureSwitchValue() function, and I only get the readings of 0 or 1, unless that is normal. We tried running the compressor directly from the battery to see if the readings will change, but no change.

Your code:


    compressor(4,2)

The compressor spike should be on relay output #2, or change the code to use Relay #1. The pressure switch should be on digital port #4, but you can leave the port unconnected until you get the compressor to turn on.

oh woops sorry about that, I tried both (1,1 and 4,2 because it came from an example), but neither worked. So the pressure switch isn’t required to get the compressor running? like I can just set it, but leave the pwm out and it’ll work as long as the compressor is hooked up? Or did you mean go ahead and try to get the relay working eg using the Relay class.
I know you can run the compressor using the relay class, but I also know that using the compressor class simplifies things a lot, so I want to avoid that.

The software turns the compressor on even if the pressure switch is not wired. It’s one less thing to go wrong when you are first testing, but you must use the pressure switch after things are working. Leave the selected digital port unconnected for now, just to be sure it’s not preventing the compressor from turning on. As you suggested, I would try using the Relay class next. Something like this, untested:


  Relay *m_relay_1;

...

  m_relay_1 = new Relay(1);
  m_relay_1->SetDirection(Relay::kForwardOnly);
  m_relay_1->Set(Relay::kOn);


yeah, thats a good point, I should try to get the compressor working first -.-. I’ll get back after I try it out tomorrow, thanks oddjob x].

ok, I just tried it and the compressor did not run. Is it suppose to run when I turn on the robot or when I enable teleops? It did not work either way anyways. I’m assuming there is a problem with the wiring then?

bump. I still can’t get the compressor running :3. Should the relay port on the sidecar’s LED (the 2 things on the side), should one of them be on when the compressor is in operation? I remember it being on berfore, but is not on right now.

The compressor WILL NOT RUN without the pressure switch connected, this is because the switch is a normally closed contact, that goes open when its reached pressure.

The code you showed shows Digital In 4 as where its expecting the switch, and Relay 2 as where its outputting the signals. The LEDs on the sidecar near the relay ports will switch when its working.

Also, I highly recommend using pointers instead of directly instantiating your objects:


class myRobot : public SimpleRobot 
{
RobotDrive* driveBase;
Jaguar* someMotor;
Solenoid* someSolenoid;
Compressor* theCompressor;

myRobot(){
driveBase = new RobotDrive(1,2,3,4);
someMotor = new Jaguar(5);
someSolenoid = new Solenoid(1);
theCompressor = new Compressor(1,1);
theCompressor->Start();
}

void Teleop(){
someMotor->Set(1);
}

};

This way, you can pass them by reference, instead of by value, which breaks things. Its good practice.

Thanks 1075guy!!! for some odd reason, using the pointers made it work o.o. Now off to work the solenoids…

I didn’t check our pressure switch, but it’s odd that everything works. The compressor turns on and off as expected, confirmed by the pressure gauge, and the compressor runs when the switch is not wired. That’s why I thought the switch must be normally open, but reading the spec, it is normally closed. We’re declaring the standard Compressor object and using m_compressor->Start(). Maybe the floating cRIO digital input is picking up noise and sensing it as a logic low, turning on the compressor?

Is possible, maybe… Floating digital inputs generally read high, but I’ve seen them be low occasionally… I would check for an aluminum shaving or something lodged in your sidecar.

I know I should start a new post for this, but since It’s the same topic, I’d rather get help from the experienced few on this topic.

We have sort of the opposite issue, my compressor starts by the use of compressor->Start(); but does not automatically turn on. I’ve used a multimeter to test if the switch’s state changes after reaching 115psi, and it does… but the compressor never starts.

Originally, I declared the compressor on digital one and relay one:

Compressor *compressor;

then:

compressor = new Compressor(1,1);

and when that failed, I tried changing the digital switch to DIO 5 (5,1) in the code and sidecar, and still nothing!. The relay I know for sure works properly, I’ve tested it, but I don’t know what else it could be! Also, I’m pretty sure the switch is wired correctly… black and white pwm wires on the switch. Any Idea what could the problem be?

  • Meezy

When you run the code, does the spike relay flash green or red instead of staying at orange color?

no, the relay stays solid green and powers the compressor even after the pressure goes above 120psi…

I’m looking into implementing code that solely reads the value of the switch and controls the compressor without using compressor.Start(); is the switch supposed to read 1 or 0 after reaching 115 psi?

We’ve tried two different pressure switches, and I just tried using the relay and digital input seperately…

The compressor turns on, with the relay green but never off still!

I don’t know what to do, and it’s odd why it’s not workign right now… any thoughts? We’ve even changed the relay’s out…