AnalogTrigger

class wpilib.AnalogTrigger(channel)[source]

Bases: builtins.object

Converts an analog signal into a digital signal

An analog trigger is a way to convert an analog signal into a digital signal using resources built into the FPGA. The resulting digital signal can then be used directly or fed into other digital components of the FPGA such as the counter or encoder modules. The analog trigger module works by comparing analog signals to a voltage range set by the code. The specific return types and meanings depend on the analog trigger mode in use.

Constructor for an analog trigger given a channel number or analog input.

Parameters:channel – the port index or AnalogInput to use for the analog trigger. Treated as an AnalogInput if the provided object has a getChannel function.
class AnalogTriggerType

Bases: builtins.object

Defines the state in which the AnalogTrigger triggers

kFallingPulse = 3
kInWindow = 0
kRisingPulse = 2
kState = 1
AnalogTrigger.createOutput(type)[source]

Creates an AnalogTriggerOutput object. Gets an output object that can be used for routing. Caller is responsible for deleting the AnalogTriggerOutput object.

Parameters:type – An enum of the type of output object to create.
Returns:An AnalogTriggerOutput object.
AnalogTrigger.free()[source]

Release the resources used by this object

AnalogTrigger.getInWindow()[source]

Return the InWindow output of the analog trigger. True if the analog input is between the upper and lower limits.

Returns:The InWindow output of the analog trigger.
AnalogTrigger.getIndex()[source]

Return the index of the analog trigger. This is the FPGA index of this analog trigger instance.

Returns:The index of the analog trigger.
AnalogTrigger.getTriggerState()[source]

Return the TriggerState output of the analog trigger. True if above upper limit. False if below lower limit. If in Hysteresis, maintain previous state.

Returns:The TriggerState output of the analog trigger.
AnalogTrigger.port[source]
AnalogTrigger.setAveraged(useAveragedValue)[source]

Configure the analog trigger to use the averaged vs. raw values. If the value is true, then the averaged value is selected for the analog trigger, otherwise the immediate value is used.

Parameters:useAveragedValue – True to use an averaged value, False otherwise
AnalogTrigger.setFiltered(useFilteredValue)[source]

Configure the analog trigger to use a filtered value. The analog trigger will operate with a 3 point average rejection filter. This is designed to help with 360 degree pot applications for the period where the pot crosses through zero.

Parameters:useFilteredValue – True to use a filterd value, False otherwise
AnalogTrigger.setLimitsRaw(lower, upper)[source]

Set the upper and lower limits of the analog trigger. The limits are given in ADC codes. If oversampling is used, the units must be scaled appropriately.

Parameters:
  • lower – the lower raw limit
  • upper – the upper raw limit
AnalogTrigger.setLimitsVoltage(lower, upper)[source]

Set the upper and lower limits of the analog trigger. The limits are given as floating point voltage values.

Parameters:
  • lower – the lower voltage limit
  • upper – the upper voltage limit