Go to Post Sometimes our greatest failures lay the foundations for our greatest success. - =Martin=Taylor= [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 13-02-2014, 09:55
TechWarlock TechWarlock is offline
Programming Dude
AKA: Jacob
FRC #1396 (Pyrobots)
Team Role: Programmer
 
Join Date: Feb 2014
Rookie Year: 2011
Location: New York
Posts: 24
TechWarlock is an unknown quantity at this point
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
  #2   Spotlight this post!  
Unread 13-02-2014, 10:01
eddie12390's Avatar
eddie12390 eddie12390 is offline
Registered User
AKA: Eddie
FRC #3260 (SHARP)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Pittsburgh
Posts: 285
eddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of light
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?
  #3   Spotlight this post!  
Unread 13-02-2014, 10:04
TechWarlock TechWarlock is offline
Programming Dude
AKA: Jacob
FRC #1396 (Pyrobots)
Team Role: Programmer
 
Join Date: Feb 2014
Rookie Year: 2011
Location: New York
Posts: 24
TechWarlock is an unknown quantity at this point
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.
  #4   Spotlight this post!  
Unread 13-02-2014, 10:07
eddie12390's Avatar
eddie12390 eddie12390 is offline
Registered User
AKA: Eddie
FRC #3260 (SHARP)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Pittsburgh
Posts: 285
eddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of light
Re: Compressor Programming Help

Quote:
Originally Posted by TechWarlock View Post
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?
  #5   Spotlight this post!  
Unread 13-02-2014, 10:10
TechWarlock TechWarlock is offline
Programming Dude
AKA: Jacob
FRC #1396 (Pyrobots)
Team Role: Programmer
 
Join Date: Feb 2014
Rookie Year: 2011
Location: New York
Posts: 24
TechWarlock is an unknown quantity at this point
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
  #6   Spotlight this post!  
Unread 13-02-2014, 10:14
eddie12390's Avatar
eddie12390 eddie12390 is offline
Registered User
AKA: Eddie
FRC #3260 (SHARP)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Pittsburgh
Posts: 285
eddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of light
Re: Compressor Programming Help

Quote:
Originally Posted by TechWarlock View Post
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?
  #7   Spotlight this post!  
Unread 13-02-2014, 11:11
TechWarlock TechWarlock is offline
Programming Dude
AKA: Jacob
FRC #1396 (Pyrobots)
Team Role: Programmer
 
Join Date: Feb 2014
Rookie Year: 2011
Location: New York
Posts: 24
TechWarlock is an unknown quantity at this point
Re: Compressor Programming Help

thank you for everything, we figured it out, it was our electronics, the pressure switch was wired wrong
  #8   Spotlight this post!  
Unread 18-02-2014, 12:10
wadehas wadehas is offline
Registered User
FRC #1258
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2004
Location: Seattle
Posts: 8
wadehas is an unknown quantity at this point
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.
Closed Thread


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 02:45.

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