Compressor

class wpilib.Compressor(self: wpilib.Compressor, pcmID: int = 0) → None

Bases: wpilib.ErrorBase, wpilib.Sendable

Class for operating a compressor connected to a %PCM (Pneumatic Control Module).

The PCM will automatically run in closed loop mode by default whenever a Solenoid object is created. For most cases, a Compressor object does not need to be instantiated or used in a robot program. This class is only required in cases where the robot program needs a more detailed status of the compressor or to enable/disable closed loop control.

Note: you cannot operate the compressor directly from this class as doing so would circumvent the safety provided by using the pressure switch and closed loop control. You can only turn off closed loop control, thereby stopping the compressor from operating.

Constructor. The default PCM ID is 0.

Parameters

module – The PCM ID to use (0-62)

clearAllPCMStickyFaults(self: wpilib.Compressor) → None

Clear ALL sticky faults inside PCM that Compressor is wired to.

If a sticky fault is set, then it will be persistently cleared. Compressor drive maybe momentarily disable while flags are being cleared. Care should be taken to not call this too frequently, otherwise normal compressor functionality may be prevented.

If no sticky faults are set then this call will have no effect.

enabled(self: wpilib.Compressor) → bool

Check if compressor output is active.

Returns

true if the compressor is on

getClosedLoopControl(self: wpilib.Compressor) → bool

Returns true if the compressor will automatically turn on when the pressure is low.

Returns

True if closed loop control of the compressor is enabled. False if disabled.

getCompressorCurrent(self: wpilib.Compressor) → float

Query how much current the compressor is drawing.

Returns

The current through the compressor, in amps

getCompressorCurrentTooHighFault(self: wpilib.Compressor) → bool

Query if the compressor output has been disabled due to high current draw.

Returns

true if PCM is in fault state : Compressor Drive is disabled due to compressor current being too high.

getCompressorCurrentTooHighStickyFault(self: wpilib.Compressor) → bool

Query if the compressor output has been disabled due to high current draw (sticky).

A sticky fault will not clear on device reboot, it must be cleared through code or the webdash.

Returns

true if PCM sticky fault is set : Compressor Drive is disabled due to compressor current being too high.

getCompressorNotConnectedFault(self: wpilib.Compressor) → bool

Query if the compressor output does not appear to be wired.

Returns

true if PCM is in fault state : Compressor does not appear to be wired, i.e. compressor is not drawing enough current.

getCompressorNotConnectedStickyFault(self: wpilib.Compressor) → bool

Query if the compressor output does not appear to be wired (sticky).

A sticky fault will not clear on device reboot, it must be cleared through code or the webdash.

Returns

true if PCM sticky fault is set : Compressor does not appear to be wired, i.e. compressor is not drawing enough current.

getCompressorShortedFault(self: wpilib.Compressor) → bool

Query if the compressor output has been disabled due to a short circuit.

Returns

true if PCM is in fault state : Compressor output appears to be shorted.

getCompressorShortedStickyFault(self: wpilib.Compressor) → bool

Query if the compressor output has been disabled due to a short circuit (sticky).

A sticky fault will not clear on device reboot, it must be cleared through code or the webdash.

Returns

true if PCM sticky fault is set : Compressor output appears to be shorted.

getModule(self: wpilib.Compressor) → int

Gets module number (CAN ID).

Returns

Module number

getPressureSwitchValue(self: wpilib.Compressor) → bool

Check if the pressure switch is triggered.

Returns

true if pressure is low

initSendable(self: wpilib.Compressor, builder: wpilib.SendableBuilder) → None
setClosedLoopControl(self: wpilib.Compressor, on: bool) → None

Enables or disables automatically turning the compressor on when the pressure is low.

Parameters

on – Set to true to enable closed loop control of the compressor. False to disable.

start(self: wpilib.Compressor) → None

Starts closed-loop control. Note that closed loop control is enabled by default.

stop(self: wpilib.Compressor) → None

Stops closed-loop control. Note that closed loop control is enabled by default.