# DaqSetTrigger()

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

Member of the MccBoard class.

## Function Prototype

VB .NET

Public Function DaqSetTrigger(ByVal trigSource As MccDaq.TriggerSource, ByVal trigSense MccDaq.TriggerSensitivity, ByVal trigChan As Integer, ByVal chanType As MccDaq.ChannelType, ByVal gain As MccDaq.Range, ByVal level As Single, ByVal variance As Single, ByVal trigEvent As MccDaq.TriggerEvent) As MccDaq.ErrorInfo

C#.NET

public MccDaq.ErrorInfo DaqSetTrigger(MccDaq.TriggerSource trigSource, MccDaq.TriggerSensitivity trigSense, int trigChan, MccDaq.ChannelType chanType, MccDaq.Range gain, float level, float variance, MccDaq.TriggerEvent trigEvent)

## Parameters

trigSource

Specifies the type of triggering based on the external trigger source.

All of the trigSource settings are MccDaq.TriggerSource enumerated constants. Set it to one of the constants in the trigSource parameter values section below.

trigSense

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. Often, it defines the way in which the trigger input signal(s) should be compared to the trigger level parameter value.

All of the trigSense settings are MccDaq.TriggerSensitivity enumerated constants. Set it to one of the constants in the trigSense parameter values section below.

trigChan

The trigger channel. This channel must be a configured channel in the channel array (refer to DaqInScan()).

chanType

The channel type. All of the chanType settings are MccDaq.ChannelType enumerated constants. chanType should match the channel type setting for the trigger channel configured using the DaqInScan() method.

gain

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 the DaqInScan() method. The gain parameter is ignored if trigChan is not an analog channel.

level

A single precision floating point value which represents, in engineering units, the level at or around which the trigger event should be detected.

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

A single-precision floating point value which represents, in engineering units, the amount that the trigger event can vary from the level parameter.

While the TrigSense 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.

trigEvent

Specifies the trigger event type. Valid values indicate either a start trigger event (MccDaq.TriggerEvent.Start) or a stop trigger event (MccDaq.TriggerEvent.Stop).

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.

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.

## Returns

- An ErrorInfo object that indicates the status of the operation.

### trigSource parameter values

TrigImmediate | Start trigger event only. Acquisition begins immediately upon invocation the DaqInScan() method. No pre-trigger data acquisition is possible with this trigger type.
TrigExtTTL | 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.
TrigAnalogHW | Start trigger event only. Acquisition begins upon a selectable criteria of the input signal (above level, below level, rising edge, etc.) trigChan must be defined as the first channel in the channel scan group. No pre-trigger data acquisition is possible with this trigger type.
TrigAnalogSW | Post-trigger data acquisition begins upon a selectable criteria of the input signal (above level, below level, rising edge, etc.)
TrigDigPattern | Post-trigger data acquisition beings upon receiving a specified digital pattern on the specified digital port.
TrigCounter | Post-trigger data acquisition begins upon detection of specified counter criteria.
TrigScanCount | Stop trigger event only. Stops collecting post-trigger data when the specified number of post-trigger scans are completed.

### trigSense parameter values

RisingEdge | Triggers when the signal goes from low to high (TTL trigger), or rises through a specified level (hardware analog, software analog, and counter).
FallingEdge | Triggers when the signal goes from high to low (TTL trigger), or falls through a specified level (hardware analog, software analog, and counter).
AboveLevel | Triggers when the signal is above a specified level (hardware analog, software analog, counter, and digital pattern).
BelowLevel | Triggers when the signal is below a specified level (hardware analog, software analog, counter, and digital pattern).
EqLevel | Triggers when the signal equals a specified level (hardware analog, software analog, counter, and digital pattern).
NeLevel | Triggers when the signal does not equal a specified level (hardware analog, software analog, counter, and digital pattern).
HighLevel | Triggers when the signal is 5V (logic HIGH or "1").
LowLevel | Triggers when the signal is 0V (logic LOW or "0").

### Trigger levels

The actual level at which the trigger event is detected depends upon trigger sensing and variability. The various ranges of possible values for the level parameter based on the trigger source are:

- TrigAnalogHW: The voltage used to define the trigger level. Trigger detection is performed in hardware.
- TrigAnalogSW: The voltage used to define the trigger level. Trigger detection is performed in software.
- TrigDigPattern: 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.
- TrigCounter: Selects either Pulse or Totalize counter values (0.0 – 65,535).
- TrigImmediate: Ignored
- TrigScanCount: 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 (trigSource) | Trigger Sensitivity (trigSense) | Trigger Start/Stop Criteria
TrigAnalogHW (Start trigger event only) | RisingEdge | Triggers when the signal value < (level – variance). Then, the signal value > level.
FallingEdge | Triggers when the signal value > (level + variance). Then, the signal value < level.
AboveLevel | Triggers when the signal value > (level).
BelowLevel | Triggers when the signal value < (level).
TrigAnalogSW | RisingEdge | Triggers/stops when the signal value < (level – variance). Then, the signal value > level.
FallingEdge | Triggers/stops when the signal value > (level + variance). Then, the signal value < level.
AboveLevel | Triggers/stops when the signal value > (level).
BelowLevel | Triggers/stops when the signal value < (level).
EqLevel | Triggers/stops when (level – variance) < signal value < (level + variance).
NeLevel | Triggers/stops when the signal value < (level – variance) OR when the signal value > (level + variance).
TrigDigPattern | AboveLevel | Triggers/stops when the (digital port value AND (bitwise) variance) > (level AND (bitwise) variance).
BelowLevel | Triggers/stops when the (digital port value AND (bitwise) variance) < (level AND (bitwise) variance).
EqLevel | Triggers/stops when the (digital port value AND (bitwise) variance) = (level AND (bitwise) variance).
NeLevel | Triggers/stops when the (digital port value AND (bitwise) variance) != (level AND (bitwise) variance).
TrigCounter | RisingEdge | Triggers/stops when the counter channel < (level – variance). Then, the counter channel > level.
FallingEdge | Triggers/stops when counter channel > (level + variance). Then, the counter channel < level.
AboveLevel | Triggers/stops when the counter channel > (level – variance).
BelowLevel | Triggers/stops when the counter channel < (level + variance).
EqLevel | Triggers/stops when (level – variance) < counter channel < (level + variance).
NeLevel | Triggers/stops when the counter channel < (level – variance) OR when the counter channel > (level + variance).