Solenoid

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

Bases: wpilib.SolenoidBase, wpilib.Sendable

Solenoid class for running high voltage Digital Output (PCM).

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

Overloaded function.

  1. __init__(self: wpilib._wpilib.Solenoid, channel: int) -> None

Constructor using the default PCM ID (0).

Parameters

channel – The channel on the PCM to control (0..7).

  1. __init__(self: wpilib._wpilib.Solenoid, moduleNumber: int, channel: int) -> None

Constructor.

Parameters
  • moduleNumber – The CAN ID of the PCM the solenoid is attached to

  • channel – The channel on the PCM to control (0..7).

get(self: wpilib.Solenoid) → bool

Read the current value of the solenoid.

Returns

The current value of the solenoid.

initSendable(self: wpilib.Solenoid, builder: wpilib.SendableBuilder) → None
isBlackListed(self: wpilib.Solenoid) → bool

Check if solenoid is blacklisted.

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

@see ClearAllPCMStickyFaults()

Returns

If solenoid is disabled due to short.

set(self: wpilib.Solenoid, on: bool) → None

Set the value of a solenoid.

Parameters

on – Turn the solenoid output off or on.

setPulseDuration(self: wpilib.Solenoid, durationSeconds: float) → None

Set the pulse duration in the PCM. This is used in conjunction with the startPulse method to allow the PCM to control the timing of a pulse. The timing can be controlled in 0.01 second increments.

@see startPulse()

Parameters

durationSeconds – The duration of the pulse, from 0.01 to 2.55 seconds.

startPulse(self: wpilib.Solenoid) → None

Trigger the PCM to generate a pulse of the duration set in setPulseDuration.

@see setPulseDuration()

toggle(self: wpilib.Solenoid) → 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.