Pneumatic#
Introduction#
The Pneumatics system uses an air pump and solenoid to control compressed air for moving cylinders. It can turn the pump on or off and extend or retract cylinders through code.
Below is a list of available methods:
Methods – Compress or decompress air with an air pump.
extend – Extend a cylinder.
retract – Retract a cylinder.
pump_on – Turn on the air pump.
pump_off – Turn off the air pump.
pump – Set the on or off state of the air pump.
installed – Returns whether or not a solenoid is connected to the Brain.
Constructors – Manually initialize and configure Pneumatics.
Pneumatic – Creates a Pneumatics object.
For the examples below, the configured Pneumatics will be named pneumatic_1
and will be used in all subsequent examples throughout this API documentation when referring to Pneumatic class methods.
Methods#
extend#
extend
extends a cylinder.
Usage:
extend(cylinder)
Parameters |
Description |
---|---|
cylinder |
The cylinder to extend:
|
# Extend and retract the cylinder
pneumatic_1.extend(CYLINDER1)
wait(2, SECONDS)
pneumatic_1.retract(CYLINDER1)
retract#
retract
retracts a cylinder.
Usage:
retract(cylinder)
Parameters |
Description |
---|---|
cylinder |
The cylinder to retract:
|
# Extend and retract the cylinder
pneumatic_1.extend(CYLINDER1)
wait(2, SECONDS)
pneumatic_1.retract(CYLINDER1)
pump_on#
pump_on
turns the air pump on.
Usage:
pump_on()
Parameters |
Description |
---|---|
This method has no parameters. |
# Extend and retract the cylinder
pneumatic_1.pump_on()
wait(1, SECONDS)
pneumatic_1.extend(CYLINDER1)
wait(2, SECONDS)
pneumatic_1.retract(CYLINDER1)
pump_off#
pump_off
turns the air pump off.
Usage:
pump_off()
Parameters |
Description |
---|---|
This method has no parameters. |
# Extend and retract the cylinder
pneumatic_1.pump_on()
wait(1, SECONDS)
pneumatic_1.extend(CYLINDER1)
wait(2, SECONDS)
pneumatic_1.retract(CYLINDER1)
wait(0.5, SECONDS)
pneumatic_1.pump_off()
pump#
pump
turns the air pump on or off.
Usage:
pump(state)
Parameters |
Description |
---|---|
state |
The air compressor state:
|
# Extend and retract the cylinder
pneumatic_1.pump(True)
wait(1, SECONDS)
pneumatic_1.extend(CYLINDER1)
wait(2, SECONDS)
pneumatic_1.retract(CYLINDER1)
wait(0.5, SECONDS)
pneumatic_1.pump(False)
installed#
installed
returns a Boolean indicating whether the solenoid is connected to the Brain.
True
- The solenoid is connected to the Brain.False
- The solenoid is not connected to the Brain.
Usage:
installed()
Parameters |
Description |
---|---|
This method has no parameters. |
# Display if the pneumatics are installed
if pneumatic_1.installed():
brain.screen.print("Installed!")
Constructors#
Constructors are used to manually create Pneumatic
objects, which are necessary for configuring Pneumatics outside of VEXcode.
Pneumatics#
The Pneumatic
constructor creates a Pneumatic object in the specified Smart Port:
Usage:
Pneumatic(port)
Parameter |
Description |
---|---|
|
Which Smart Port that the solenoid is connected to as |
# Construct a Pneumatic System "pneumatic_1" with the
# Pneumatic class
pneumatic_1 = Pneumatic(Ports.PORT1)
pneumatic_1.extend(CYLINDER1)
wait(2, SECONDS)
pneumatic_1.retract()