Go to Post The manual can be compared to a textbook in school. If you choose not to use your textbook, you are asking to fail classes. - dez250 [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 11-02-2014, 12:08
mechanical_robot's Avatar
mechanical_robot mechanical_robot is offline
Registered User
no team
Team Role: Driver
 
Join Date: Jul 2013
Rookie Year: 2013
Location: United States
Posts: 92
mechanical_robot will become famous soon enough
NEED Help With turning on the compressor

In C++ I just can't figure out how to turn on the compressor. So I have used this code(which is below). But whenever I turn on the robot and enable it, it just makes this very high pitched sound that only certain younger people can hear on the team. I am sure I have it wired correctly too also I have tried pretty much every wire combination for the compressor that I can think of. This isn't the only problem either, since this code is for a mecanum wheel drive whenever I enable the robot one of the talons turn one of the 4 wheels very slowly while the others remain stationary, though this code work very good without our the compressor code in it (one of the wheels don't drift).

Any help appreciated, though I have already gone through the wpilib screen steps. Any example code from previous years would also be appreciated.


Here is the code


#include "WPILib.h"


/**
* This illustrates how to use 4 Talons to drive the robot
* Created from SimpleTemplate
*/
class RobotDemo : public SimpleRobot
{
RobotDrive *myRobot; // robot drive system
Compressor *m_compressor;
Joystick stick; // only joystick
Talon talon_lf;
Talon talon_rf;
Talon talon_lr;
Talon talon_rr;

public:
RobotDemo():
//myRobot(1, 2), // these must be initialized in the same order
stick(1), // as they are declared above.
talon_lf(1),
talon_rf(2),
talon_lr(3),
talon_rr(4)



{
myRobot = new RobotDrive(talon_lf, talon_lr, talon_rf, talon_rr);
myRobot->SetExpiration(0.1);
m_compressor = new Compressor(4, 2);
m_compressor->Start();

// invert as needed
//myRobot->SetInvertedMotor(RobotDrive::kRearLeftMotor, true);
myRobot->SetInvertedMotor(RobotDrive::kFrontRightMotor, true);
//myRobot->SetInvertedMotor(RobotDrive::kFrontLeftMotor, true);
myRobot->SetInvertedMotor(RobotDrive::kRearRightMotor, true);

}

// destructor. Added by brian
~RobotDemo()
{
delete myRobot;
delete m_compressor;

}

/**
* Drive left & right motors for 2 seconds then stop
*/
void Autonomous()
{
myRobot->SetSafetyEnabled(false);
//myRobot->Drive(-0.5, 0.0); // drive forwards half speed
//Wait(1.0); // for 2 seconds
myRobot->Drive(0.0, 0.0); // stop robot
}

/**
* Runs the motors with arcade steering.
*/
void OperatorControl()
{
printf("4 Talon Test\n");

myRobot->SetSafetyEnabled(true);
while (IsOperatorControl())
{
// arcade drive with one stick
//myRobot->ArcadeDrive(stick); // drive with arcade style

// macadum drive
float gyroAngle = 0.0; // we don't have a gyro connected
myRobot->MecanumDrive_Cartesian(stick.GetX(), stick.GetY(), stick.GetZ(), gyroAngle);

Wait(0.005); // wait for a motor update time
}
}

/**
* Runs during test mode
*/
void Test() {

}
};

START_ROBOT_CLASS(RobotDemo);

This is the end of the code
  #2   Spotlight this post!  
Unread 11-02-2014, 12:50
E Dawg E Dawg is offline
... is not done with FRC yet.
AKA: Ethan
FRC #0159 (Alpine Robotics)
Team Role: Mentor
 
Join Date: Feb 2013
Rookie Year: 2012
Location: Fort Collins, CO
Posts: 267
E Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud of
Re: NEED Help With turning on the compressor

Is the code posted here default from WPI? If so, it's an electrical problem. I'd advise triple-checking all of the PWMs. Also, make sure that the relay connected to the compressor is lighting up green when it is supposed to.
  #3   Spotlight this post!  
Unread 11-02-2014, 13:27
mechanical_robot's Avatar
mechanical_robot mechanical_robot is offline
Registered User
no team
Team Role: Driver
 
Join Date: Jul 2013
Rookie Year: 2013
Location: United States
Posts: 92
mechanical_robot will become famous soon enough
Re: NEED Help With turning on the compressor

Quote:
Originally Posted by E Dawg View Post
Is the code posted here default from WPI? If so, it's an electrical problem. I'd advise triple-checking all of the PWMs. Also, make sure that the relay connected to the compressor is lighting up green when it is supposed to.
No thats my team's code not wpilib's
  #4   Spotlight this post!  
Unread 11-02-2014, 14:28
danielms853 danielms853 is offline
Lead Programmer 2013&2014 seasons
AKA: Dan S.
FRC #4122 (O-Bots)
Team Role: Programmer
 
Join Date: Feb 2014
Rookie Year: 2013
Location: NY
Posts: 3
danielms853 is an unknown quantity at this point
Re: NEED Help With turning on the compressor

You could try to see if the relay works

Initializing : Relay compRelay;
compRelay(COMPRESSOR_RELAY_CHANNEL),

and then set it to turn on if you hit a button

if (stick.GetRawButton(PICK_A_BUTTON))
compRelay.Set(Relay::kOn);
else
compRelay.Set(Relay::kOff);

If this works (side car relay light turns on) on the hardware side, but it doesn't turn on, check your hardware. Also, make sure you connected the relay to a relay port, not a pwm port

Once this works, and you know if the compressor works, and you can debug the auto cutoff switch.

P.S. if you're running a 2013 crio image with 2014 wpi, it won't work, we tried.
  #5   Spotlight this post!  
Unread 12-02-2014, 09:45
sukhjinder564's Avatar
sukhjinder564 sukhjinder564 is offline
Registered User
FRC #0564
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2011
Location: New York
Posts: 11
sukhjinder564 is an unknown quantity at this point
Re: NEED Help With turning on the compressor

As stated previously, check your wiring for the compressor and check to make sure your ports are correct. Try looking at the light on the spike relay. If it is green, the compressor should be working. If it is orange, your spike is not getting a signal. Also check if the Spike is plugged in as a relay on the digital sidecar. If it is, check to see if a green LED comes on next to the port that the spike is plugged in. If it comes on, you have a wiring issue. If not, you have a software issue
  #6   Spotlight this post!  
Unread 12-02-2014, 11:28
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: NEED Help With turning on the compressor

Code:
		//myRobot(1, 2),	// these must be initialized in the same order
		stick(1),		// as they are declared above.
I'm not quite clear on what the must means in the comments here. Can someone with more insight into the SimpleRobot constructors chime in? What happens when you don't initialize them in the same order?
  #7   Spotlight this post!  
Unread 12-02-2014, 14:16
MrRoboSteve MrRoboSteve is offline
Mentor
AKA: Steve Peterson
FRC #3081 (Kennedy RoboEagles)
Team Role: Mentor
 
Join Date: Mar 2012
Rookie Year: 2011
Location: Bloomington, MN
Posts: 577
MrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond repute
Re: NEED Help With turning on the compressor

It doesn't look like a c++ standard requirement.

I don't have the Wind River compiler here at work, but suspect it makes sense if you have dependencies between the fields. For example, if you have four speed controllers and a RobotDrive, it makes sense to construct the speed controllers first, and then the RobotDrive that depends on them.
__________________
2016-17 events: 10000 Lakes Regional, Northern Lights Regional, FTC Burnsville Qualifying Tournament

2011 - present · FRC 3081 Kennedy RoboEagles mentor
2013 - present · event volunteer at 10000 Lakes Regional, Northern Lights Regional, North Star Regional, Lake Superior Regional, Minnesota State Tournament, PNW District 4 Glacier Peak, MN FTC, CMP
http://twitter.com/MrRoboSteve · www.linkedin.com/in/speterson
  #8   Spotlight this post!  
Unread 12-02-2014, 14:45
ekovacs ekovacs is offline
Registered User
AKA: Evan Kovacs
FRC #2539
Team Role: College Student
 
Join Date: Dec 2012
Rookie Year: 2011
Location: Palmyra, PA
Posts: 21
ekovacs is on a distinguished road
Re: NEED Help With turning on the compressor

My team had this problem earlier this year. Try moving this line to OperatorControl instead of where it currently is.

Code:
 m_compressor->Start();
  #9   Spotlight this post!  
Unread 13-02-2014, 05:34
Bill_B Bill_B is offline
You cannot not make a difference
FRC #2170
 
Join Date: Jan 2010
Rookie Year: 2004
Location: Connecticut
Posts: 1,099
Bill_B has a reputation beyond reputeBill_B has a reputation beyond reputeBill_B has a reputation beyond reputeBill_B has a reputation beyond reputeBill_B has a reputation beyond reputeBill_B has a reputation beyond reputeBill_B has a reputation beyond reputeBill_B has a reputation beyond reputeBill_B has a reputation beyond reputeBill_B has a reputation beyond reputeBill_B has a reputation beyond repute
Re: NEED Help With turning on the compressor

Wheel drift could be the result of uncalibrated Talons. All of your drive motor talons need to be calibrated as shown in the talon manual. If you swap one out, recalibrate them all again, even if they had been calibrated once upon a time somewhere else. I don't think it applies to swapping motors, but what could it hurt?
__________________
Nature's Fury FLL team 830 - F L eLements
FRC team 2170 - Titanium Tomahawks
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:36.

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