Package edu.wpi.first.wpilibj
Class PneumaticHub
java.lang.Object
edu.wpi.first.wpilibj.PneumaticHub
- All Implemented Interfaces:
PneumaticsBase,AutoCloseable
Module class for controlling a REV Robotics Pneumatic Hub.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a PneumaticHub with the default ID (1).PneumaticHub(int module) Constructs a PneumaticHub. -
Method Summary
Modifier and TypeMethodDescriptionintcheckAndReserveSolenoids(int mask) Check to see if the solenoids marked in the bitmask can be reserved, and if so, reserve them.booleancheckSolenoidChannel(int channel) Check if a solenoid channel is valid.voidClears the sticky faults.voidclose()voidDisables the compressor.voidenableCompressorAnalog(double minPressure, double maxPressure) Enables the compressor in analog mode.voidEnables the compressor in digital mode using the digital pressure switch.voidenableCompressorHybrid(double minPressure, double maxPressure) Enables the compressor in hybrid mode.voidfireOneShot(int index) Fire a single solenoid shot.doubleReturns the current voltage of the regulated 5v supply.doublegetAnalogVoltage(int channel) Returns the raw voltage of the specified analog input channel.booleanReturns whether the compressor is active or not.Returns the active compressor configuration.doubleReturns the current drawn by the compressor in amps.Returns the faults currently active on this device.doubleReturns the current input voltage for this device.intGet module number for this module.doublegetPressure(int channel) Returns the pressure read by an analog pressure sensor on the specified analog input channel.booleanReturns the state of the pressure switch.intGet a bitmask of disabled solenoids.intGets a bitmask of solenoid values.doubleReturns the total current (in amps) drawn by all solenoids.doubleReturns the current voltage of the solenoid power supply.Returns the sticky faults currently active on this device.Returns the hardware and firmware versions of this device.Create a compressor object.makeDoubleSolenoid(int forwardChannel, int reverseChannel) Create a double solenoid object for the specified channels.makeSolenoid(int channel) Create a solenoid object for the specified channel.booleanReserve the compressor.voidsetOneShotDuration(int index, int durMs) Set the duration for a single solenoid shot.voidsetSolenoids(int mask, int values) Sets solenoids on a pneumatics module.voidUnreserve the compressor.voidunreserveSolenoids(int mask) Unreserve the solenoids marked in the bitmask.
-
Constructor Details
-
PneumaticHub
public PneumaticHub()Constructs a PneumaticHub with the default ID (1). -
PneumaticHub
Constructs a PneumaticHub.- Parameters:
module- module number to construct
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfacePneumaticsBase
-
getCompressor
Description copied from interface:PneumaticsBaseReturns whether the compressor is active or not.- Specified by:
getCompressorin interfacePneumaticsBase- Returns:
- True if the compressor is on - otherwise false.
-
getCompressorConfigType
Description copied from interface:PneumaticsBaseReturns the active compressor configuration.- Specified by:
getCompressorConfigTypein interfacePneumaticsBase- Returns:
- The active compressor configuration.
-
getPressureSwitch
Description copied from interface:PneumaticsBaseReturns the state of the pressure switch.- Specified by:
getPressureSwitchin interfacePneumaticsBase- Returns:
- True if pressure switch indicates that the system is not full, otherwise false.
-
getCompressorCurrent
Description copied from interface:PneumaticsBaseReturns the current drawn by the compressor in amps.- Specified by:
getCompressorCurrentin interfacePneumaticsBase- Returns:
- The current drawn by the compressor.
-
setSolenoids
Description copied from interface:PneumaticsBaseSets solenoids on a pneumatics module.- Specified by:
setSolenoidsin interfacePneumaticsBase- Parameters:
mask- Bitmask indicating which solenoids to set. The LSB represents solenoid 0.values- Bitmask indicating the desired states of the solenoids. The LSB represents solenoid 0.
-
getSolenoids
Description copied from interface:PneumaticsBaseGets a bitmask of solenoid values.- Specified by:
getSolenoidsin interfacePneumaticsBase- Returns:
- Bitmask containing the state of the solenoids. The LSB represents solenoid 0.
-
getModuleNumber
Description copied from interface:PneumaticsBaseGet module number for this module.- Specified by:
getModuleNumberin interfacePneumaticsBase- Returns:
- module number
-
fireOneShot
Description copied from interface:PneumaticsBaseFire a single solenoid shot.- Specified by:
fireOneShotin interfacePneumaticsBase- Parameters:
index- solenoid index
-
setOneShotDuration
Description copied from interface:PneumaticsBaseSet the duration for a single solenoid shot.- Specified by:
setOneShotDurationin interfacePneumaticsBase- Parameters:
index- solenoid indexdurMs- shot duration
-
checkSolenoidChannel
Description copied from interface:PneumaticsBaseCheck if a solenoid channel is valid.- Specified by:
checkSolenoidChannelin interfacePneumaticsBase- Parameters:
channel- Channel to check- Returns:
- True if channel exists
-
checkAndReserveSolenoids
Description copied from interface:PneumaticsBaseCheck to see if the solenoids marked in the bitmask can be reserved, and if so, reserve them.- Specified by:
checkAndReserveSolenoidsin interfacePneumaticsBase- Parameters:
mask- The bitmask of solenoids to reserve. The LSB represents solenoid 0.- Returns:
- 0 if successful; mask of solenoids that couldn't be allocated otherwise
-
unreserveSolenoids
Description copied from interface:PneumaticsBaseUnreserve the solenoids marked in the bitmask.- Specified by:
unreserveSolenoidsin interfacePneumaticsBase- Parameters:
mask- The bitmask of solenoids to unreserve. The LSB represents solenoid 0.
-
makeSolenoid
Description copied from interface:PneumaticsBaseCreate a solenoid object for the specified channel.- Specified by:
makeSolenoidin interfacePneumaticsBase- Parameters:
channel- solenoid channel- Returns:
- Solenoid object
-
makeDoubleSolenoid
Description copied from interface:PneumaticsBaseCreate a double solenoid object for the specified channels.- Specified by:
makeDoubleSolenoidin interfacePneumaticsBase- Parameters:
forwardChannel- solenoid channel for forwardreverseChannel- solenoid channel for reverse- Returns:
- DoubleSolenoid object
-
makeCompressor
Description copied from interface:PneumaticsBaseCreate a compressor object.- Specified by:
makeCompressorin interfacePneumaticsBase- Returns:
- Compressor object
-
reserveCompressor
Description copied from interface:PneumaticsBaseReserve the compressor.- Specified by:
reserveCompressorin interfacePneumaticsBase- Returns:
- true if successful; false if compressor already reserved
-
unreserveCompressor
Description copied from interface:PneumaticsBaseUnreserve the compressor.- Specified by:
unreserveCompressorin interfacePneumaticsBase
-
getSolenoidDisabledList
Description copied from interface:PneumaticsBaseGet a bitmask of disabled solenoids.- Specified by:
getSolenoidDisabledListin interfacePneumaticsBase- Returns:
- Bitmask indicating disabled solenoids. The LSB represents solenoid 0.
-
disableCompressor
Disables the compressor. The compressor will not turn on untilenableCompressorDigital(),enableCompressorAnalog(double, double), orenableCompressorHybrid(double, double)are called.- Specified by:
disableCompressorin interfacePneumaticsBase
-
enableCompressorDigital
Description copied from interface:PneumaticsBaseEnables the compressor in digital mode using the digital pressure switch. The compressor will turn on when the pressure switch indicates that the system is not full, and will turn off when the pressure switch indicates that the system is full.- Specified by:
enableCompressorDigitalin interfacePneumaticsBase
-
enableCompressorAnalog
Enables the compressor in analog mode. This mode uses an analog pressure sensor connected to analog channel 0 to cycle the compressor. The compressor will turn on when the pressure drops belowminPressureand will turn off when the pressure reachesmaxPressure.- Specified by:
enableCompressorAnalogin interfacePneumaticsBase- Parameters:
minPressure- The minimum pressure in PSI. The compressor will turn on when the pressure drops below this value. Range 0-120 PSI.maxPressure- The maximum pressure in PSI. The compressor will turn off when the pressure reaches this value. Range 0-120 PSI. Must be larger then minPressure.
-
enableCompressorHybrid
Enables the compressor in hybrid mode. This mode uses both a digital pressure switch and an analog pressure sensor connected to analog channel 0 to cycle the compressor.The compressor will turn on when both:
- The digital pressure switch indicates the system is not full AND
- The analog pressure sensor indicates that the pressure in the system is below the specified minimum pressure.
The compressor will turn off when either:
- The digital pressure switch is disconnected or indicates that the system is full OR
- The pressure detected by the analog sensor is greater than the specified maximum pressure.
- Specified by:
enableCompressorHybridin interfacePneumaticsBase- Parameters:
minPressure- The minimum pressure in PSI. The compressor will turn on when the pressure drops below this value and the pressure switch indicates that the system is not full. Range 0-120 PSI.maxPressure- The maximum pressure in PSI. The compressor will turn off when the pressure reaches this value or the pressure switch is disconnected or indicates that the system is full. Range 0-120 PSI. Must be larger then minPressure.
-
getAnalogVoltage
Returns the raw voltage of the specified analog input channel.- Specified by:
getAnalogVoltagein interfacePneumaticsBase- Parameters:
channel- The analog input channel to read voltage from.- Returns:
- The voltage of the specified analog input channel.
-
getPressure
Returns the pressure read by an analog pressure sensor on the specified analog input channel.- Specified by:
getPressurein interfacePneumaticsBase- Parameters:
channel- The analog input channel to read pressure from.- Returns:
- The pressure read by an analog pressure sensor on the specified analog input channel.
-
clearStickyFaults
Clears the sticky faults. -
getVersion
Returns the hardware and firmware versions of this device.- Returns:
- The hardware and firmware versions.
-
getFaults
Returns the faults currently active on this device.- Returns:
- The faults.
-
getStickyFaults
Returns the sticky faults currently active on this device.- Returns:
- The sticky faults.
-
getInputVoltage
Returns the current input voltage for this device.- Returns:
- The input voltage.
-
get5VRegulatedVoltage
Returns the current voltage of the regulated 5v supply.- Returns:
- The current voltage of the 5v supply.
-
getSolenoidsTotalCurrent
Returns the total current (in amps) drawn by all solenoids.- Returns:
- Total current drawn by all solenoids in amps.
-
getSolenoidsVoltage
Returns the current voltage of the solenoid power supply.- Returns:
- The current voltage of the solenoid power supply.
-