Skip to content

Pneumatics

Allen edited this page Jan 17, 2025 · 5 revisions

Pneumatics

For pneumatics, you work with two parts:

Compressor- Fills the system with air.

Solenoid- a valve that open/closes to emit air into pistons for movement.

Ports:

  • both the compressor and solenoids are wired to the Pneumatics Hub module.
  • The compressor has a dedicated slot that does require a port.
  • The solenoids with each require a port number on the hub.

Compressors:

Basic Compressor overview

  • CTRE Pneumatics Control Module (CTREPCM)
  • REV Robotics Pneumatics Hub (REVPH)

An example REV compressor setup:

private final Compressor compressor;

compressor = new Compressor(PneumaticsModuleType.REVPH);

Compressors have an auto-enabled digital closed-loop control setting that must be kept on. This will automatically fill it and shut it off when needed. Disabling this will allow for more advanced control and data but it is not recommended.

see the compressor documentation for more information

Solenoids:

Basic Solenoid overview

There are two options for solenoids: Solenoid, which includes one usable open/close valve for single-direction flow, and DoubleSolenoid, which has a directional valve for two-directional flow. The latter is more commonly used.

  • Both solenoid types use the .toggle() method which takes in no parameters but switches the solenoid from one value to the other. For single solenoids this switches them on and off, but for double solenoids it changes the path from forward to reverse. Also, since double solenoids default to off, they must be set to kForward or kReverse before they can be toggled since it does nothing if it's off.

  • Both solenoid types also use the .get() method which returns the current value of the solenoid. True or false for single solenoids and kForward or kReverse for double solenoids.

Solenoids can pulse, more in the full documentation

Single Solenoids

Single solenoids are controlled by the Solenoid class. To construct the Solenoid object, the desired port number and pneumatics module type or CAN ID must be inputted.

  // In this case, it's connected to channel 0 of a PH with the default CAN ID.
  private final Solenoid m_solenoid = new Solenoid(PneumaticsModuleType.REVPH, 0);

To set the value of the solenoid call .set(true) or .set(false) to enable or disable the solenoid output respectively. The set method can take in whether or not a button is pressed.

    m_solenoid.set(m_stick.getRawButton(kSolenoidButton));

Double Solenoids

Double Solenoids are controlled by the DoubleSolenoid class. They are constructed similarly but now take in 2 different ports, a forward channel which comes first, and a reverse channel which comes second.

  // In this case, it's connected to channels 1 and 2 of a PH with the default CAN ID.
  private final DoubleSolenoid m_doubleSolenoid =
      new DoubleSolenoid(PneumaticsModuleType.REVPH, 1, 2);

The state of the valve can be set to either kOff (neither output activated), kForward (forward channel enabled), or kReverse (reverse channel enabled) with the .set(value) method. Since these values come from the DoubleSolenoid class, DoubleSolenoid.Value must come before the output in the method as seen below.

      m_doubleSolenoid.set(DoubleSolenoid.Value.kForward);
      m_doubleSolenoid.set(DoubleSolenoid.Value.kReverse);

Clone this wiki locally