My team is using a pnaumatics system on our robot. The problem is, it loses pressure very quickly (even with two air tanks as part of the system). We are manually adding air to the tanks by connecting the compressor to the battery directly. Is there a way to operate the compressor programmatically with Java (turn it on and off)? Perhaps using the Compressor
class? We figure this might be the best approach to prevent the robot from losing air pressure half-way through a match. Any help is appreciated!
If you wire it with the PCM you don’t need any code…
Not entirely true.
If you wire your compressor into a Pneumatic Control Module (PCM), and have also wired the pressure switch into the PCM, then all you need to do is instantiate a Solenoid
or DoubleSolenoid
class in your code. If any amount of either of these exist in your code, the compressor will automatically run in closed loop control mode.
Meaning if the pressure drops (below 90PSI? I’m not sure what the switch is set at), the compressor will be turned on, and when the pressure reaches 120PSI, the compressor will be turned off. You don’t need to do anything else to make this happen.
This means you don’t need to use the Compressor
class, unless for example, you wanted to force the compressor off during a climb for example. Note, you can’t force the compressor on if the pressure switch is open.
Edit: Added diagram
Do you mean that it loses pressure when you actuate the cylinders, or just sitting there? If the second, you would do quite well to find and fix those leaks. First, listen for hissing and feel around the fittings. If you don’t find the leak(s), spray some bubble juice (soapy water) on the joints and look for places where it bubbles. Make sure all plastic hose ends are cut square and clean, and all tapered pipe threads have about two to three wraps (not one, not four) of teflon tape and are fairly tight but not TOO tight. I usually use a wrench, but wrap my thumb and first finger around the plumbing so I know I’m not applying too much torque.
Interesting – you mention " the compressor will automatically run in closed loop control mode. Meaning if the pressure drops (below 90PSI? I’m not sure what the switch is set at), the compressor will be turned on, and when the pressure reaches 120PSI, the compressor will be turned off." We are not seeing this functionality happen. We are using a DoubleSolenoid
, but the compressor (which is connected correctly as specified in your diagram) is not being activate at all. We are manually connecting the compressor to the battery to add pressure to the tanks. Below is the code:
public class PneumaticsSubsystem extends SubsystemBase {
/*
The Pneumatics Control Module (PCM) we will be using has
been given the default CAN id of 0. This means we do not
have to specify an id in the DoubleSolenoid constructor.
In the DoubleSolenoid constructor, we only need to specify
the port numbers on which the double solenoid is connected
to the PCM (in our case, 1 and 2).
*/
private DoubleSolenoid doubleSolenoid;
/**
* Creates a new PneumaticsSubsystem.
*/
public PneumaticsSubsystem() {
super(); //add this
try {
doubleSolenoid = new DoubleSolenoid(0, 1);
} catch(Exception e) {
e.printStackTrace();
}
}
@Override
public void periodic() {
// This method will be called once per scheduler run
}
public void extendPiston() {
//Should extend the piston
doubleSolenoid.set(DoubleSolenoid.Value.kForward);
}
public void retractPiston() {
//Should retract the piston
doubleSolenoid.set(DoubleSolenoid.Value.kReverse);
}
}
‘’’private DoubleSolenoid intakeSolenoid = new DoubleSolenoid(31, 0, 1);// creates the solenoid on CAN id 31
I would suggest adding more tanks and if you haven’t already, make sure to instantiate a double solenoid or compressor won’t turn on. My team has it backed up with a compressor Subsystem to make sure the compressor turns on. We set it to have a default command that would turn it on in case a solenoid fails or something. Make sure the pressure switch is wired correctly.
There is a couple of things I would like to check.
- Are you instantiating your
PneumaticsSubsystem
class? (Sharing your entire code base can help us validate this or find other potential problems) - You mentioned the compressor is correctly connected to the PCM, is the pressure switch also connected?
- Can you confirm using Phoenix Tuner that the PCM does in fact have an ID of 0
- That you have a Driver Station connected to the robot and are enabling the robot (the compressor won’t run otherwise)
- When you try to extend or retract the piston, do the indicator LEDs on the solenoid ports light up? (See attached image)
- When the robot is enabled, does the STATUS LED flash differently (faster) then when the robot is disabled?
- When the robot is enabled, and the pressure is low, is the COMP LED on?
PCM Solenoid Status Indicator LEDs
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.