Lesson 20: Using Pneumatics
Pneumatics use compressed air to move cylinders. They are often used for mechanisms that only need two positions: open or closed, up or down, locked or unlocked.
Basic Parts
- The compressor fills the air system.
- Storage tanks hold compressed air.
- Solenoids direct air to cylinders.
- Cylinders turn air pressure into linear motion.
- The pressure switch tells the system when to stop the compressor.
Single Solenoid
A single solenoid has one controlled output. It is usually set to either on or off.
Solenoid shifter;
public void robotInit() {
shifter = new Solenoid(0);
}
public void teleopPeriodic() {
shifter.set(joystick.getRawButton(1));
}Double Solenoid
A double solenoid has two channels. It can move a cylinder forward, reverse, or leave it unchanged.
DoubleSolenoid claw;
public void robotInit() {
claw = new DoubleSolenoid(0, 1);
}
public void teleopPeriodic() {
if (joystick.getRawButton(1)) {
claw.set(DoubleSolenoid.Value.kForward);
} else if (joystick.getRawButton(2)) {
claw.set(DoubleSolenoid.Value.kReverse);
}
}Safety
Never treat pneumatics as "just software." Cylinders can move quickly and with enough force to pinch fingers or damage mechanisms. Test with the robot disabled and communicate with the mechanical team before enabling a new pneumatic action.
Practice
Write a small state machine for a claw with two states: open and closed. Use buttons to request the states, and use a solenoid value to move the cylinder.