Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Compressor Programming Help (http://www.chiefdelphi.com/forums/showthread.php?t=126383)

TechWarlock 13-02-2014 09:55

Compressor Programming Help
 
i have code that starts and stops the compressor but it doesnt seem to work. Can anyone see whats wrong with the code


Code:

#include "WPIlib.h"
#include "compressor.h"

class RobotDemo : public SimpleRobot
{
                RobotDrive Frankbot; // robot drive system
                Joystick leftjoy;
                Joystick rightjoy;
                Joystick joystick3;     
                Relay Comp;
                Jaguar Winch;
                Jaguar Claw;
                Jaguar Granata;
                Solenoid Sol1;
                Solenoid Sol2;
                Solenoid Sol3;
                Solenoid Sol4;
public:
        RobotDemo(void):
                Frankbot(1, 2), //these are the PWM ports
                leftjoy(1),       
                rightjoy(2),
                joystick3(3), 
                Comp(1, 1),
                Winch(7), 
                Claw(9),
                Granata(5),
                Sol1(1, 1),
                Sol2(1, 2),
                Sol3(1, 3),
                Sol4(1, 4)
                {
        //        usermessages = DriverStationLCD::GetInstance();
        //        Camera->WriteResolution(AxisCamera::kResolution_160x120);
        //        Camera->WriteCompression(20);
        //        Camera->WriteWhite
    //  Balance(AxisCameraParams::kWhiteBalance_FixedIndoor);
        //        Camera->WriteMaxFPS(30);
        //        Camera = &AxisCamera::GetInstance();
        //        myRobot.SetExpiration(0.1); // test
                }

        void Autonomous(void)
                {
                Compressor *c = new Compressor(1, 1);
                                                            c->Start();
                }
void OperatorControl(void)
        {
                int Off = 7;
                int On = 8;
                int ClawTurn = 10;
                int ClawTurn1 = 11;
            int Claw1 = 4;
                int Claw2 = 5;
                int WinchUp = 4;
                int WinchDown = 5;
                int Solup = 2;
            int Soldown = 3;
                int Sol2Up = 2;
                int Sol2Down = 3;
            static float speedModifier = 0.7;
                static float speedModifier2 = -0.8;
                Frankbot.SetSafetyEnabled(true);
                Compressor *c = new Compressor(1, 1);
                                                            c->Start();
                while (IsOperatorControl())
                {
                        Frankbot.TankDrive(-leftjoy.GetY() * speedModifier, rightjoy.GetY() * speedModifier2);
                                       
                       
                        if(joystick3.GetRawButton(On)){
                                                c->Start();
                        }

                        else if(joystick3.GetRawButton(Off)) {
                                                c->Stop();
                        }
                        else {
                                c->Stop();
                        }
                        if(leftjoy.GetRawButton(WinchUp)) {
                        Winch.Set(0.5);
        }
               
        else if(leftjoy.GetRawButton(WinchDown)) {
                        Winch.Set(-0.5);
        }
        else {
                        Winch.Set(0.0);
                }
        if(rightjoy.GetRawButton(Claw1)) {
                                        Claw.Set(0.5);
                                }
                               
        else if(rightjoy.GetRawButton(Claw2)) {
                                        Claw.Set(-0.5);
                                }
        else {
                                        Claw.Set(0.0);
                                }
        if(rightjoy.GetRawButton(ClawTurn)) {
                                                Granata.Set(0.2);
                                        }
                                       
        else if(rightjoy.GetRawButton(ClawTurn1)) {
                                                Granata.Set(-0.2);
                                        }
        else {
                                                Granata.Set(0.0);
                                        }
       
        if(leftjoy.GetRawButton(Solup)){
                        Sol1.Set(true);
                        Sol2.Set(false);
                }
                else if(leftjoy.GetRawButton(Soldown)){
                        Sol1.Set(false);
                        Sol2.Set(true);
                }
                else {
                        Sol1.Set(false);
                        Sol2.Set(false);
                }
                if(rightjoy.GetRawButton(Sol2Up)){
                                        Sol3.Set(true);
                                        Sol4.Set(false);
                                }
                else if(rightjoy.GetRawButton(Sol2Down)){
                                        Sol3.Set(false);
                                        Sol4.Set(true);
                                }
                else {
                                        Sol3.Set(false);
                                        Sol4.Set(false);
                                }
                        }
        }

        };
START_ROBOT_CLASS(RobotDemo);

Any and all help is appreciated, thank you

eddie12390 13-02-2014 10:01

Re: Compressor Programming Help
 
Code:

                        if(joystick3.GetRawButton(On)){
                                                c->Start();
                        }

                        else if(joystick3.GetRawButton(Off)) {
                                                c->Stop();
                        }
                        else {
                                c->Stop();
                        }

This says that if you're holding button 8 on the joystick the compressor will run. Keep in mind that the only time that the compressor will run is when that button is held. Is that the intended behavior?

TechWarlock 13-02-2014 10:04

Re: Compressor Programming Help
 
that was intended, but is there anyway to do it so that when the button is pressed it turns on and then turns off according to the pressure switch, besides that is anything else wrong with the compressor code because it doesn't run at all.

eddie12390 13-02-2014 10:07

Re: Compressor Programming Help
 
Quote:

Originally Posted by TechWarlock (Post 1342357)
that was intended, but is there anyway to do it so that when the button is pressed it turns on and then turns off according to the pressure switch, besides that is anything else wrong with the compressor code because it doesn't run at all.

The call to C->Start() will start the thread that automatically checks the Pressure Switch and shuts off the compressor as needed. Is there a properly connected pressure switched plugged into DIO 1? Also, have you tried using a Relay object and manually starting the compressor? If so, does it function?

TechWarlock 13-02-2014 10:10

Re: Compressor Programming Help
 
yeah i used a relay object and it worked the compressor turned on, but it doesnt work with the code currently on it

eddie12390 13-02-2014 10:14

Re: Compressor Programming Help
 
Quote:

Originally Posted by TechWarlock (Post 1342365)
yeah i used a relay object and it worked the compressor turned on, but it doesnt work with the code currently on it

Can you use a multimeter on your pressure switch to determine whether or not there is an output voltage?

TechWarlock 13-02-2014 11:11

Re: Compressor Programming Help
 
thank you for everything, we figured it out, it was our electronics, the pressure switch was wired wrong

wadehas 18-02-2014 12:10

Re: Compressor Programming Help
 
Why don't you initialize and start the compressor in the constructor for the Robot?

That is what we we do, and never have to deal with anywhere else.


All times are GMT -5. The time now is 02:34.

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