Solenoid

class wpilib.Solenoid(*args, **kwargs)

Bases: Sendable

Solenoid class for running high voltage Digital Output on a pneumatics module.

The Solenoid class is typically used for pneumatics solenoids, but could be used for any device within the current spec of the module.

Overloaded function.

  1. __init__(self: wpilib._wpilib.Solenoid, module: typing.SupportsInt | typing.SupportsIndex, moduleType: wpilib._wpilib.PneumaticsModuleType, channel: typing.SupportsInt | typing.SupportsIndex) -> None

Constructs a solenoid for a specified module and type.

Parameters:
  • module – The module ID to use.

  • moduleType – The module type to use.

  • channel – The channel the solenoid is on.

  1. __init__(self: wpilib._wpilib.Solenoid, moduleType: wpilib._wpilib.PneumaticsModuleType, channel: typing.SupportsInt | typing.SupportsIndex) -> None

Constructs a solenoid for a default module and specified type.

Parameters:
  • moduleType – The module type to use.

  • channel – The channel the solenoid is on.

get() → bool

Read the current value of the solenoid.

Returns:

The current value of the solenoid.

getChannel() → int

Get the channel this solenoid is connected to.

initSendable(builder: wpiutil._wpiutil.SendableBuilder) → None
isDisabled() → bool

Check if solenoid is Disabled.

If a solenoid is shorted, it is added to the DisabledList and disabled until power cycle, or until faults are cleared.

@see ClearAllPCMStickyFaults()

Returns:

If solenoid is disabled due to short.

set(on: bool) → None

Set the value of a solenoid.

Parameters:

on – Turn the solenoid output off or on.

setPulseDuration(duration: wpimath.units.seconds) → None

Set the pulse duration in the pneumatics module. This is used in conjunction with the startPulse method to allow the pneumatics module to control the timing of a pulse.

On the PCM, the timing can be controlled in 0.01 second increments, with a maximum of 2.55 seconds. On the PH, the timing can be controlled in 0.001 second increments, with a maximum of 65.534 seconds.

@see startPulse()

Parameters:

duration – The duration of the pulse.

startPulse() → None

%Trigger the pneumatics module to generate a pulse of the duration set in setPulseDuration.

@see setPulseDuration()

toggle() → None

Toggle the value of the solenoid.

If the solenoid is set to on, it’ll be turned off. If the solenoid is set to off, it’ll be turned on.