# daq_set_trigger()

Selects the trigger source and sets up its parameters. This trigger is used to initiate or terminate an acquisition using daq_in_scan() if the EXTTRIGGER option is selected. This function only works with boards that support synchronous output.

## Prototype

daq_set_trigger(board_num, trig_source, trig_sense, trig_chan, chan_type, gain, level, variance, trig_event)

## Parameters

board_num (int)

The number associated with the board when it was installed with InstaCal or created with create_daq_device().

trig_source (TriggerSource)

Specifies the type of triggering based on the external trigger source. Set to one of the constants specified in the trig_source parameter values section below.

trig_sense (TriggerSensitivity)

Specifies the trigger sensitivity. The trigger sensitivity normally defines the way in which a trigger event is detected based upon the characteristics of the trigger input signal. However, it often defines the way in which the trigger input signal(s) should be compared to the trigger level parameter value. Set to of the constants specified in the trig_sense parameter values section below.

trig_chan (int or DigitalPortType)

Specifies the trigger channel. The trigger channel must be a configured channel in the channel array; refer to daq_in_scan().

chan_type (ChannelType)

Specifies the channel type, and should match the channel type setting for the trigger channel configured using daq_in_scan().

gain (ULRange)

Specifies the trigger channel gain code. If the device has programmable gain, this parameter should match the gain code setting when the channel is configured using daq_in_scan(). The gain parameter is ignored if trig_chan is not an analog channel.

level (float)

The level at or around which the trigger event should be detected, in engineering units.

This option is used for trigger types that depend on an input channel comparison to detect the start trigger or stop trigger event.

The actual level at which the trigger event is detected depends upon trigger sensing and variability. Refer to the Trigger Levels section below for more information.

variance (float)

The amount that the trigger event can vary from the level parameter, in engineering units.

While the trig_sense parameter indicates the direction of the input signal relative to the level parameter, the variance parameter specifies the degree to which the input signal can vary relative to the level parameter.

trig_event (TriggerEvent)

Specifies the trigger event type. Valid values indicate either a start trigger event (TriggerEvent.START) or a stop trigger event (TriggerEvent.STOP):

TriggerEvent.START: The start trigger event defines the conditions under which post-trigger acquisition data collection should be initiated or triggered. The start trigger event can vary in complexity from starting immediately, to starting on complex channel value definitions.

TriggerEvent.STOP: The stop trigger event signals the current data acquisition process to terminate. The stop event can be as simple as that of a scan count, or as complex as involving a channel value level condition.

### trig_source parameter values

IMMEDIATE | Start trigger event only. Acquisition begins immediately upon invocation the daq_in_scan(). No pre-trigger data acquisition is possible with this trigger type.
EXTTTL | Start trigger event only. Acquisition begins on the selectable edge of an external TTL signal. No pre-trigger data acquisition is possible with this trigger type.
ANALOGHW | Start trigger event only. Data acquisition begins upon a selectable criteria of the input signal (above level, below level, rising edge, etc.) trig_chan must be defined as the first channel in the channel scan group. No pre-trigger data acquisition is possible with this trigger type.
ANALOGSW | Post-trigger data acquisition begins upon a selectable criteria of the input signal (above level, below level, rising edge, etc.)
DIGPATTERN | Post-trigger data acquisition beings upon receiving a specified digital pattern on the specified digital port.
COUNTER | Post-trigger data acquisition begins upon detection of specified counter criteria.
SCANCOUNT | Stop trigger event only. Stops collecting post-trigger data when the specified number of post-trigger scans are completed.

### trig_sense parameter values

RISING_EDGE | Triggers when the signal goes from low to high (TTL trigger) or rises through a specified level (hardware analog, software analog, and counter).
FALLING_EDGE | Triggers when the signal goes from high to low (TTL trigger) or falls through a specified level (hardware analog, software analog, and counter).
ABOVE_LEVEL | Triggers when the signal is above a specified level (hardware analog, software analog, counter, and digital pattern).
BELOW_LEVEL | Triggers when the signal is below a specified level (hardware analog, software analog, counter, and digital pattern).
EQ_LEVEL | Triggers when the signal equals a specified level (hardware analog, software analog, counter, and digital pattern).
NE_LEVEL | Triggers when the signal does not equal a specified level (hardware analog, software analog, counter, and digital pattern).
HIGH_LEVEL | Triggers when the signal is 5V (logic HIGH or "1").
LOW_LEVEL | Triggers when the signal is 0V (logic LOW or "0").

### Trigger levels

ANALOG_HW | The voltage used to define the trigger level. Trigger detection is performed in hardware.
ANALOG_SW | The voltage used to define the trigger level. Trigger detection is performed in software.
DIGPATTERN | Sets the bit pattern for the digital channel trigger. Choices are: 0.0 (no bits set): 255.0 (all bits set) for 8-bit digital ports. 0.0 (no bits set): 65,535.0 (all bits set) for 16-bit digital ports.
COUNTER | Selects either Pulse or Totalize counter values (0.0 65,535).
IMMEDIATE | Ignored
SCANCOUNT | Ignored

### Trigger start and stop criteria

The table below lists the trigger start and stop criteria based on the selected trigger type and sensitivity.

Trigger Start/Stop Source (trig_source) | Trigger Sensitivity (trig_sense) | Trigger Start/Stop Criteria
TRIG_ANALOGHW (Start trigger event only) | RISING_EDGE | Triggers when the signal value < (level – variance). Then, the signal value > level.
FALLING_EDGE | Triggers when the signal value > (level + variance). Then, the signal value < level.
ABOVE_LEVEL | Triggers when the signal value > (level).
BELOW_LEVEL | Triggers when the signal value < (level).
TRIG_ANALOGSW | RISING_EDGE | Triggers/stops when the signal value < (level – variance). Then, the signal value > level.
FALLING_EDGE | Triggers/stops when the signal value > (level + variance). Then, the signal value < level.
ABOVE_LEVEL | Triggers/stops when the signal value > (level).
BELOW_LEVEL | Triggers/stops when the signal value < (level).
EQ_LEVEL | Triggers/stops when the (level – variance) < signal value < (level + variance).
NE_LEVEL | Triggers/stops when the signal value < (level – variance) OR when the signal value > (level + variance).
TRIG_DIGPATTERN | ABOVE_LEVEL | Triggers/stops when the (digital port value AND (bitwise) variance) > (level AND (bitwise) variance).
BELOW_LEVEL | Triggers/stops when the (digital port value AND (bitwise) variance) < (level AND (bitwise) variance).
EQ_LEVEL | Triggers/stops when the (digital port value AND (bitwise) variance) = (level AND (bitwise) variance).
NE_LEVEL | Triggers/stops when the (digital port value AND (bitwise) variance) != (level AND (bitwise) variance).
TRIG_COUNTER | RISING_EDGE | Triggers/stops when the counter channel < (level – variance). Then, the counter channel > level.
FALLING_EDGE | Triggers/stops when the counter channel > (level + variance). Then, the counter channel < level.
ABOVE_LEVEL | Triggers/stops when the counter channel > (level – variance).
BELOW_LEVEL | Triggers/stops when the counter channel < (level + variance).
EQ_LEVEL | Triggers/stops when (level – variance) < counter channel < (level + variance).
NE_LEVEL | Triggers/stops when the counter channel < (level – variance) OR when the counter channel > (level + variance).