View Single Post
  #1   Spotlight this post!  
Unread 06-11-2015, 17:09
mschwab013's Avatar
mschwab013 mschwab013 is offline
Registered User
AKA: Matt Schwabenbauer
FRC #0291
Team Role: College Student
 
Join Date: Jan 2012
Rookie Year: 2008
Location: Erie, PA
Posts: 87
mschwab013 is a name known to allmschwab013 is a name known to allmschwab013 is a name known to allmschwab013 is a name known to allmschwab013 is a name known to allmschwab013 is a name known to all
Alternating Compressors

This past week Team 291 was finishing up the off-season t-shirt cannon we had been working on. We quickly realized that we would need to add a second compressor to avoid overheating. We wanted to be able to alternate between the compressors in order to give each a break.

This is the code that I wrote to allow us to alternate between the 2 compressors. It's in C++ and being used with an old cRio. We thought this was a really neat idea so I figured I would share it here. As you might have guessed 'comp1' and 'comp2' are the compressors. 'di1' is the pressure switch. A button on the controller was added to allow for a manual override so we could run both at once if needed. We haven't had any issues yet but suggestions for improvements are always appreciated.

Code:
int toggle_comp=1;
bool comp_previous=0;
bool button1=0;

button1 = stick->GetRawButton(1);

if(di1->Get()==1 && comp_previous==0)
{
	comp1->Set(comp1->kOff);
	comp2->Set(comp2->kOff);
	toggle_comp++;
	comp_previous=1;
}
else if(di1->Get()==1 && comp_previous==1)
{
	comp1->Set(comp1->kOff);
	comp2->Set(comp2->kOff);
}
else if(di1->Get()==0 && comp_previous==1)
{
	comp_previous=0;
}

if(di1->Get()==0 && toggle_comp%2==0 && button1==0)
{
	comp1->Set(comp1->kOff);
	comp2->Set(comp2->kOn);
}
else if (di1->Get()==0 && toggle_comp%2!=0 && button1==0)
{
	comp1->Set(comp1->kOn);
	comp2->Set(comp2->kOff);
}
else if (di1->Get()==0 && button1==1)
{
	comp1->Set(comp1->kOn);
	comp2->Set(comp2->kOn);
}
Note: This is just the code pertaining to the compressor in teleop and not the entire program
__________________


2013 Pittsburgh- Gracious Professionalism award, 7th seed, 6th alliance captian, quarter-finalist(291,3492,4601)
2013 Queen CIty- Chairman's Award, 39th seed
2012 Pittsburgh- 23rd seed
2012 Buckeye- 34th seed, 2nd alliance, quarter-finalist(291,1241,4085)
2011 Pittsburgh- 13th seed, 5th alliance, quarter-finalist(291,337,3504)
2011 Buckeye- 18th seed, 8th alliance, quarter-finalist(279,291,3496)
2010 Finger Lakes- 15th seed, 5th alliance, quarter-finalist(291,1507,1559)
2010 Buckeye- Chairman's Award, Imagery Award, Quality Award, 4th seed, 1st pick, 1st alliance, semi-finalist(291,1014,1629)