DigitalOutput¶
-
class
wpilib.
DigitalOutput
(channel)[source]¶ Bases:
wpilib.DigitalSource
Writes to a digital output
Other devices that are implemented elsewhere will automatically allocate digital inputs and outputs as required.
Create an instance of a digital output.
Parameters: channel – the DIO channel for the digital output. 0-9 are on-board, 10-25 are on the MXP -
disablePWM
()[source]¶ Change this line from a PWM output back to a static Digital Output line.
Free up one of the 6 DO PWM generator resources that were in use.
-
enablePWM
(initialDutyCycle)[source]¶ Enable a PWM Output on this line.
Allocate one of the 6 DO PWM generator resources.
Supply the initial duty-cycle to output so as to avoid a glitch when first starting.
The resolution of the duty cycle is 8-bit for low frequencies (1kHz or less) but is reduced the higher the frequency of the PWM signal is.
Parameters: initialDutyCycle (float) – The duty-cycle to start generating. [0..1]
-
get
()[source]¶ Gets the value being output from the Digital Output.
Returns: the state of the digital output Return type: bool
-
getAnalogTriggerTypeForRouting
()[source]¶ Get the analog trigger type.
Returns: false Return type: int
-
getPortHandleForRouting
()[source]¶ Get the HAL Port Handle.
Returns: The HAL Handle to the specified source
-
isAnalogTrigger
()[source]¶ Is this an analog trigger.
Returns: true if this is an analog trigger Return type: bool
-
isPulsing
()[source]¶ Determine if the pulse is still going. Determine if a previously started pulse is still going.
Returns: True if pulsing Return type: bool
-
pulse
(pulseLength, *args)[source]¶ Generate a single pulse. There can only be a single pulse going at any time.
Parameters: - channel – Unused. Deprecated 2017.1.1.
- pulseLength (float) – The length of the pulse.
-
pwmGenerator
¶
-
set
(value)[source]¶ Set the value of a digital output.
Parameters: value (bool) – True is on, off is False
-
setPWMRate
(rate)[source]¶ Change the PWM frequency of the PWM output on a Digital Output line.
The valid range is from 0.6 Hz to 19 kHz. The frequency resolution is logarithmic.
There is only one PWM frequency for all channnels.
Parameters: rate (float) – The frequency to output all digital output PWM signals.
-
updateDutyCycle
(dutyCycle)[source]¶ Change the duty-cycle that is being generated on the line.
The resolution of the duty cycle is 8-bit for low frequencies (1kHz or less) but is reduced the higher the frequency of the PWM signal is.
Parameters: dutyCycle (float) – The duty-cycle to change to. [0..1]
-