|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Pneumatics Code
Hey, thanks to some great help from Jon236, Alan Anderson and Mark McLeod, I think I got some code that *might* work with the pneumatics system...
If someone could take a look over it and maybe give me some pointers, that'd be great! (School is closed until Tuesday...Furlough days. )Code:
#include "WPILib.h"
#include "1771Constants.h"
#include <iostream>
using namespace std;
namespace Team1771
{
class Team1771Robot : public SimpleRobot
{
RobotDrive driveTrain;
Joystick leftStick;
Joystick rightStick;
Joystick manipulator;
Compressor compressorControl;
Solenoid turret;
public:
Team1771Robot(void):
driveTrain(LEFT_DRIVE_MOTOR_PORT,
RIGHT_DRIVE_MOTOR_PORT),
leftStick(LEFT_JOYSTICK_PORT),
rightStick(RIGHT_JOYSTICK_PORT),
manipulator(MANIPULATOR_JOYSTICK_PORT),
compressorControl(3,3,COMPRESSOR_PORT,7),
turret(5) //THIS *HAS* TO BE CHANGED
//I just made up random number
//TODO: Figure out how to hook it up!!!
{
compressorControl.Start();
};
void Autonomous(void)
{
GetWatchdog().SetEnabled(false);
while(IsAutonomous() && !IsDisabled())
{}
}
void OperatorControl(void)
{
GetWatchdog().SetEnabled(false);
while (IsOperatorControl() && !IsDisabled())
{
//FIRE AWAY CAP'N!
if(manipulator.GetRawButton(1))
{
//Seeing if I have enough. Just a rough estimate.
if(compressorControl.GetPressureSwitchValue() < 100)
{
cout << "Not enough power to fire. " << endl;
cout << compressorControl.GetPressureSwitchValue() << endl;
Wait(1);
}
else //Fire into the crowd! Rawr!
{
//Uncomment to see pressure values before firing
/*
cout << compressorControl.GetPressureSwitchValue() << endl;
*/
turret.Set(1); //I think this will tell the solenoid(I think its the solenoid?)
//to switch and let the air fire from the chamber.
turret.Set(0);//Then that should turn it off?
//TODO: Figure out if 1 is letting air in, or if 0 is.
//Uncomment this below for seeing how much pressure we lose from firing.
/*
cout << compressorControl.GetPressureSwitchValue() << endl;
*/
Wait(1);
}
}
}
}
};
START_ROBOT_CLASS(Team1771Robot);
}
One of my questions that I already have however, is with the Compressor.Start() I noticed in the Compressor.h file, there is a function called void SetRelayValue(Relay::Value relayValue). Does the Compressor class automatically call this is needed? From what I understand, calling compressorControl.Start() will turn on the compressor, and automatically keep the pressure to a certain level. |
|
#2
|
||||
|
||||
|
Re: Pneumatics Code
Hey. Admittedly I don't have too much experience programming for the new control system (I was delegated to electronics this past year), but a couple things look kind of fishy. First of all, I don't think you're supposed to be disabling the Watchdog like that. From what I remember of the documentation and example code, you should be Feed()ing it. Also, I don't think doing
Code:
turret.Set(1) Code:
turret.Set(0) Code:
turret.Set(manipulator.GetRawButton(1)) Code:
int shootercounter
void Pneumatics()
{
if( shootercounter > 0 )
shootercounter-- //decrement the counter
else
turret.Set(0); //close the valve
if( manipulator.GetRawButton(1) )
{
//open the valve for 200 cycles
shootercounter = 200;
turret.Set(1);
}
}
Last edited by Lord_Jeremy : 10-10-2009 at 10:28. |
|
#3
|
|||||
|
|||||
|
Re: Pneumatics Code
Another issue is the pressure switch doesn't behave the way you want.
The pressure switch value will only be 1 or 0. It will trip to 1 if the pressure is or falls below 95 psi. Once tripped it will remain at 1 until pressure rises to 115 psi. At 115 psi it resets to 0 and stays that way until pressure falls below 95 psi again. So part of the automatic compressor operation is built in to the pressure switch they send us in the KOP. You'd have to buy (fairly expensive) a pressure transducer to get a constant readout of current pressure the way you want. Last edited by Mark McLeod : 10-10-2009 at 12:30. |
|
#4
|
|||
|
|||
|
Re: Pneumatics Code
As for the watchdog, it doesn't matter for us now. We have been programming it that way, and whenever we did try feeding it, it would gives us Watchdog errors.
For the turret.Set(1) and turret.Set(0), I added a Wait in between them for 2 seconds. That should make the solenoid open up for 2 seconds, right? For the pressure switch readings, I guess that means you can't get it to be over 115 PSI? When we hooked it up manually (using 2 batteries and manually sparking them to fire) we fired it at 120 PSI, but we used a manual gauge thing. If I use compressorControl.Start(), does that mean it will never put the pressure above 115? |
|
#5
|
|||||
|
|||||
|
Re: Pneumatics Code
Quote:
Start() will always cut off at 115psi using the current KOP pneumatic system and won't run again until the pressure falls to 95psi. There were some older KOP pressure switches that were set at 120psi and you might be able to buy a switch pre-set for 120psi. If you can't launch anywhere in the range of 95-115psi, then you probably want to use your own code rather than Start(). If your goal is to launch only at a particular pressure each time, then you'll either have to watch the gauge and operate the compressor manually, or dump enough pressure each use to trip the pressure switch (by dropping to 95psi) and let it build up to 115psi, or buy a pressure transducer. If it must be at 120psi every time, then you could force the compressor to run a minute more after the pressure switch cuts off to build up to 120psi. Last edited by Mark McLeod : 10-10-2009 at 23:52. |
|
#6
|
|||
|
|||
|
Re: Pneumatics Code
Okay, thanks a lot!
The only reason I had it test the pressure in my code, was because I wouldn't want it to fire if it only had like 60 PSI. ![]() As far as my solenoid firing, would that work? My thought was that it would switch the valves on the FESTO Solenoid for a second, allowing air to shoot out. |
|
#7
|
|||||
|
|||||
|
Re: Pneumatics Code
With the Wait() added, as Jeremy suggested, the solenoid should operate the way you expect.
The solenoids we get in the Kit won't supply the fast, sudden pressure you need to launch a t-shirt though. There are different solutions for how to do the valve that other teams have used. T-shirt launchers have been talked about a lot on Chief Delphi, so check out some of those threads for how other teams have done it: |
|
#8
|
|||
|
|||
|
Re: Pneumatics Code
Okay, thanks for answering all my questions. (I ask a lot.
)Maybe I could use the Axis camera to look at the pressure gauge... ![]() Edit: For the solenoid, although it is attatched to the spike motor, do I need to declare it as Solenoid firingCannon or Relay firingCannon? Last edited by nighterfighter : 11-10-2009 at 16:56. Reason: Solenoid / Relay |
|
#9
|
|||||
|
|||||
|
Re: Pneumatics Code
Declare it as a solenoid if you've attached it to the Pneumatic Bumper.
Declare it as a Relay if you've attached it to a Spike, controlled in turn by a Digital Sidecar Relay output. You can still do your check for sufficient pressure. Just never fire if it's "1" and wait for it to turn to "0" again. Last edited by Mark McLeod : 11-10-2009 at 19:02. |
|
#10
|
|||
|
|||
|
Re: Pneumatics Code
Okay, thanks.
If it becomes declared as a Relay, what is the equivalent of the Solenoid's boolean of 0/1? I assume kForward? |
|
#11
|
|||||
|
|||||
|
Re: Pneumatics Code
A single solenoid like a Festo would be kForward and kOff.
A double solenoid would be kForward and kReverse. |
|
#12
|
||||
|
||||
|
Re: Pneumatics Code
Er, I think that would depend on the type of double solenoid you used and how it was wired to the spike. For instance the ones Team 1546 used last year (the same ones supplied in the KoP previously) actually had two sets of solenoid power terminals. To use one spike for both solenoids, you'd need to rig up a couple diodes. I think there's a diagram of what to do in regards to that somewhere around here. I don't recall if a different type of double solenoid valve was included in the KoP last year, so my advice may be out of date.
|
|
#13
|
|||
|
|||
|
Re: Pneumatics Code
Awesome guys, thanks.
I think I have some code that *should* work, I'll have to wait until Tuesday to find out... Thanks for answering my questions, I ask too many. I get bored if im not in school, and if I can't actually test my code. x_x |
|
#14
|
|||||
|
|||||
|
Re: Pneumatics Code
Quote:
We only see one solenoid type in FRC. They are all simple coils that get energized or not, essentially, two single solenoids in one package. Typically, the major variations you'll see in wiring a double solenoid on FRC robots are:
Last edited by Mark McLeod : 12-10-2009 at 11:14. Reason: Added diagrams |
|
#15
|
|||
|
|||
|
Re: Pneumatics Code
Hey, I got an idea!
Since I can't really know the pressure (without buying an expensive item...we are flat broke for this project. ) I decided to make my own gauge...thing. I made a new integer, called compressorValue, and I will use that to store the value of the pressure left. I can do some tests, and see how much pressure is used by firing one shot, and how much is added in X amount of seconds of the compressor running... But, this is where my question is. :/ Will the times change based on the pressure? Eg: Will it increase quicker at first, then increase slower as the pressure builds? Or is the compressor (the ones that came in the KoP) powerful enough that this resistance is negligible? |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problems integrating CMUCAM code and IFI Default Code | Windward | Programming | 2 | 06-02-2007 16:48 |
| problems using gyro/adc code with camera default code | tanstaafl | Programming | 7 | 22-01-2006 23:09 |
| Pneumatics-Code [and piston output length] | reilly | Programming | 5 | 13-02-2005 11:42 |
| Pneumatics-Code [and piston output length] | reilly | Technical Discussion | 0 | 10-02-2005 12:21 |
| Team THRUST - Kevin's Code and Camera Code Combine | Chris_Elston | Programming | 3 | 31-01-2005 22:28 |