Compressor

class wpilib.Compressor(module=None)[source]

Bases: wpilib.SensorBase

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 the 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.

Makes a new instance of the compressor using the provided CAN device ID.

Parameters:module – The PCM CAN device ID. (0 - 62 inclusive)
clearAllPCMStickyFaults()[source]

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

If a sticky fault is set, then it will be persistently cleared. The compressor might momentarily disable while the flags are being cleared. Doo not call this method too frequently, otherwise normal compressor functionality may be prevented.

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

enabled()[source]

Get the enabled status of the compressor.

Returns:True if the compressor is on
Return type:bool
getClosedLoopControl()[source]

Gets the current operating mode of the PCM.

Returns:True if compressor is operating on closed-loop mode
Return type:bool
getCompressorCurrent()[source]

Get the current being used by the compressor.

Returns:Current consumed by the compressor in amps
Return type:float
getCompressorCurrentTooHighFault()[source]
Returns:True if PCM is in fault state : Compressor Drive is disabled due to compressor current being too high
getCompressorCurrentTooHighStickyFault()[source]
Returns:True if PCM sticky fault is set : Compressor is disabled due to compressor current being too high
getCompressorNotConnectedFault()[source]
Returns:True if PCM is in fault state : Compressor does not appear to be wired, i.e. compressor is not drawing enough current.
getCompressorNotConnectedStickyFault()[source]
Returns:True if PCM sticky fault is set : Compressor does not appear to be wired, i.e. compressor is not drawing enough current.
getCompressorShortedFault()[source]
Returns:True if PCM is in fault state : Compressor output appears to be shorted
getCompressorShortedStickyFault()[source]
Returns:True if PCM sticky fault is set : Compressor output appears to be shorted
getPressureSwitchValue()[source]

Get the pressure switch value.

Returns:True if the pressure is low
Return type:bool
setClosedLoopControl(on)[source]

Set the PCM in closed loop control mode.

Parameters:on (bool) – If True sets the compressor to be in closed loop control mode (default)
start()[source]

Start the compressor running in closed loop control mode.

Use the method in cases where you would like to manually stop and start the compressor for applications such as conserving battery or making sure that the compressor motor doesn’t start during critical operations.

stop()[source]

Stop the compressor from running in closed loop control mode.

Use the method in cases where you would like to manually stop and start the compressor for applications such as conserving battery or making sure that the compressor motor doesn’t start during critical operations.