Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Problem with the compressor class (http://www.chiefdelphi.com/forums/showthread.php?t=112453)

gitlitz 31-01-2013 13:00

Problem with the compressor class
 
Hey, I am from team 4590.

We are having trouble with the compressor- it does nothing.
The pressure switch is connected to DigitalInput 1 and the Spike to Relay 2.
This is our full simple code:

note: when we use the Relay.Set() function (and don't use the Compressor class at all) the compressor works.

Code:

#include "WPILib.h"
 
class RobotDemo : public SimpleRobot
{
        Joystick stick;
        Compressor comp;

public:
        RobotDemo(void):
                stick(1),
                comp(1,2)
        {
                comp.Start();
        }

        void Autonomous(void)
        {
                Wait(2.0);                               
        }

        void OperatorControl(void)
        {
                while (IsOperatorControl())
                {
                        Wait(0.005);
                }
        }
       
        void Test() {

        }
};

START_ROBOT_CLASS(RobotDemo);


Joe Ross 31-01-2013 13:12

Re: Problem with the compressor class
 
How is the pressure switch wired?

bob.wolff68 02-02-2013 11:06

Re: Problem with the compressor class
 
I believe the problem is that you won't have any effect on things if you do your comp.Start() from the constructor - RobotDemo(). It is much more normal to see the starting of the compressor at the beginning of OperatorControl() outside of the while loop. And if you need the compressor in Autonomous, you would also call comp.Start() in the beginning of Autonomous().

bob

mikets 03-02-2013 04:06

Re: Problem with the compressor class
 
Quote:

Originally Posted by bob.wolff68 (Post 1226354)
I believe the problem is that you won't have any effect on things if you do your comp.Start() from the constructor - RobotDemo(). It is much more normal to see the starting of the compressor at the beginning of OperatorControl() outside of the while loop. And if you need the compressor in Autonomous, you would also call comp.Start() in the beginning of Autonomous().

bob

Our code calls compressor start in the robot class constructor. It works fine. Compressor takes time to charge up the air tanks so you would want to start the compressor as soon as possible. If not the robot constructor, it should be at least the beginning of RobotInit.

gitlitz 03-02-2013 15:28

Re: Problem with the compressor class
 
Thank you for answering.

I have started the compressor in the OperatorControl() and it worked, but then I tried again to start it in the ctor and it also worked.

I have tried to look for the problem and I saw that it only works when I instantiate a RobotDrive. Can it be or is it just a coincidence?

Joe Ross 03-02-2013 19:46

Re: Problem with the compressor class
 
If you digitital side car is not properly wired, I could see trying to run multiple PWMs cause a problem with reading the pressure switch.

gitlitz 04-02-2013 15:00

Re: Problem with the compressor class
 
It turn out one of the wires of the pressure switch was not connected properly.
Once we fixed it the Compressor started and stopped as expected.

Thank you for your help.


All times are GMT -5. The time now is 12:56.

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