Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Compressor won't start (http://www.chiefdelphi.com/forums/showthread.php?t=82790)

kennypu 15-02-2010 23:28

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:
Code:

#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\n");
                       
                }
        }
};

START_ROBOT_CLASS(RobotDemo);

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

buddyb 16-02-2010 00:21

Re: Compressor won't start
 
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. :)

kennypu 16-02-2010 19:10

Re: Compressor won't start
 
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

oddjob 16-02-2010 19:25

Re: Compressor won't start
 
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.

kennypu 16-02-2010 21:39

Re: Compressor won't start
 
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.

oddjob 16-02-2010 21:52

Re: Compressor won't start
 
Quote:

Originally Posted by kennypu (Post 921657)
I'm quite sure everything is wired correctly....the spike has power and the pwm is in relay 1.

Your code:
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.

kennypu 16-02-2010 21:55

Re: Compressor won't start
 
Quote:

Originally Posted by oddjob (Post 921666)
Your code:
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.

oddjob 16-02-2010 22:07

Re: Compressor won't start
 
Quote:

Originally Posted by kennypu (Post 921668)
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?


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:

Code:

  Relay *m_relay_1;

...

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


kennypu 16-02-2010 22:11

Re: Compressor won't start
 
Quote:

Originally Posted by oddjob (Post 921679)
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:

Code:

  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].

kennypu 17-02-2010 15:16

Re: Compressor won't start
 
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?

kennypu 18-02-2010 15:05

Re: Compressor won't start
 
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.

Racer26 18-02-2010 16:31

Re: Compressor won't start
 
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:

Code:

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.

kennypu 18-02-2010 18:37

Re: Compressor won't start
 
Quote:

Originally Posted by 1075guy (Post 923177)
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:

Code:

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...

oddjob 19-02-2010 08:23

Re: Compressor won't start
 
Quote:

Originally Posted by 1075guy (Post 923177)
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.


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?

Racer26 19-02-2010 09:11

Re: Compressor won't start
 
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.


All times are GMT -5. The time now is 13:39.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi