SetTrigger()

Selects the trigger source and sets up its parameters. This trigger is used to initiate a scan using the following Universal Library for .NET methods:

Member of the MccBoard class.

Function Prototype

VB .NET

Public Function SetTrigger(ByVal trigType As MccDaq.TriggerType, ByVal lowThreshold As Short, ByVal highThreshold As Short) As MccDaq.ErrorInfo



Public Function SetTrigger(ByVal trigType As MccDaq.TriggerType, ByVal lowThreshold As System.UInt16, ByVal highThreshold As System.UInt16) As MccDaq.ErrorInfo




C# .NET

public MccDaq.ErrorInfo SetTrigger(MccDaq.TriggerType trigType, short lowThreshold, short highThreshold)



public MccDaq.ErrorInfo SetTrigger(MccDaq.TriggerType trigType, ushort lowThreshold, ushort highThreshold)

Parameters

trigType

Specifies the type of triggering based on the external trigger source. Set it to one of the constants specified in the Type column listed in the trigType parameter values section below.

lowThreshold

Selects the low threshold used when the trigger input is analog. The range depends upon the resolution of the trigger circuitry. Must be 0 to 255 for 8-bit trigger circuits, 0 to 4,095 for 12-bit trigger circuits, and 0 to 65,535 for 16-bit trigger circuits. Refer to the Analog Trigger Notes listed below.

When the trigger input is a digital pattern, lowThreshold selects the pattern value.

highThreshold

Selects the high threshold used when the trigger input is analog. The range depends upon the resolution of the trigger circuitry. Must be 0 to 255 for 8-bit trigger circuits, 0 to 4,095 for 12-bit trigger circuits, and 0 to 65,535 for 16-bit trigger circuits. Refer to the Analog Trigger Notes listed below.

When the trigger input is a digital pattern, highThreshold selects the port mask.

Returns

trigType parameter values

All of the trigType settings are MccDaq.TriggerType enumerated constants. To set a variable to one of these constants, you must refer to the MccDaq object and the TriggerType enumeration (variable = MccDaq.TriggerType.GateNegHys, variable = MccDaq.TriggerType.GatePosHys, and so on.)

Trigger Source TypeExplanation
AnalogGateNegHysScanning is enabled as long as the external analog trigger input is more positive than highThreshold. Hysteresis is the level between lowThreshold and highThreshold.
GatePosHysScanning is enabled as long as the external analog trigger input is more negative than lowThreshold. Hysteresis is the level between lowThreshold and highThreshold.
GateAboveScanning is enabled as long as the external analog trigger input is more positive than highThreshold
GateBelowScanning is enabled as long as the external analog trigger input is more negative than lowThreshold.
GateInWindowScanning is enabled as long as the external analog trigger is inside the region defined by lowThreshold and highThreshold.
GateOutWindowScanning is enabled as long as the external analog trigger is outside the region defined by lowThreshold and HighThreshold.
TrigAboveScanning begins when the external analog trigger input transitions from below highThreshold to above. Once conversions are enabled, the external trigger is ignored.
TrigBelowScanning begins when the external analog trigger input transitions from above lowThreshold to below. Once conversions are enabled, the external trigger is ignored.
TrigRisingScanning begins when the external analog trigger input transitions from below LowThreshold to above HighThreshold. Once conversions are enabled, the external trigger is ignored.
TrigFallingScanning begins when the external analog trigger input transitions from above HighThreshold to below LowThreshold. Once conversions are enabled, the external trigger is ignored.
Analog Trigger Notes
  • The value of the threshold must be within the range of the analog trigger circuit associated with the board. Refer to the board-specific information in the Universal Library User's Guide. For example, on the PCI-DAS1602/16 the analog trigger circuit handles ±10 V. A value of 0 corresponds to –10 V, whereas a value of 65,535 corresponds to +10 V.
  • If you are using signed integer types, the thresholds range from –32,768 to 32,767 for 16-bit boards, instead of from 0 to 65,535. In this case, the unsigned value of 65,535 corresponds to a value of –1, 65,534 corresponds to –2, …, 32,768 corresponds to –32,768.
  • For most boards that support analog triggering, you can pass the required trigger voltage level and the appropriate range to FromEngUnits() to calculate the highThreshold and lowThreshold values.
  • For some boards, you must manually calculate the threshold: first calculate the least significant bit (LSB) for a particular range for the trigger resolution of your hardware, then use the LSB to find the threshold in counts based on an analog voltage trigger threshold. Refer below to the Manually calculating the threshold example for details. For board-specific information, refer to the Universal Library User's Guide section of the Help.
DigitalGateHighScanning is enabled as long as the external digital trigger input is 5V (logic HIGH or '1').
GateLowScanning is enabled as long as the external digital trigger input is 0V (logic LOW or '0').
TrigHighScanning begins when the external digital trigger is 5V (logic HIGH or '1'). Once conversions are enabled, the external trigger is ignored.
TrigLowScanning begins when the external digital trigger is 0V (logic LOW or '0'). Once conversions are enabled, the external trigger is ignored.
TrigPatternEqScanning begins when the digital port value AND bitwise mask are equal to the Pattern value AND bitwise mask. Once conversions are enabled, the external trigger is ignored.
TrigPatternNeScanning begins when the digital port value AND bitwise mask are not equal to the Pattern value AND bitwise mask. Once conversions are enabled, the external trigger is ignored.
TrigPatternAboveScanning begins when the digital port value AND bitwise mask are greater than the Pattern value AND bitwise mask. Once conversions are enabled, the external trigger is ignored.
TrigPatternBelowScanning begins when the digital port value AND bitwise mask are less than the Pattern value AND bitwise mask. Once conversions are enabled, the external trigger is ignored.
TrigPosEdgeScanning begins when the external digital trigger makes a transition from 0V to 5V (logic LOW to HIGH). Once conversions are enabled, the external trigger is ignored.
TrigNegEdgeScanning begins when the external digital trigger makes a transition from 5V to 0V (logic HIGH to LOW). Once conversions are enabled, the external trigger is ignored.
Digtal Trigger Notes
  • For pattern trigger types, the lowThreshold parameter represents the pattern value, and the highThreshold parameter represents the port mask. Use SetPatternTrigPort() to set the pattern trigger port.

Returns


Manually calculating the threshold

To calculate the threshold, do the following:

  1. Calculate the least significant bit (LSB) by dividing the full scale range (FSR) by 2resolution.
  2. FSR is the entire span from –FS to +FS of your hardware for a particular range. For example, the full scale range of ±0 V is 20 V.
  1. Calculate how many times you need to add the LSB calculate in step 1 to the negative full scale (–FS) to reach the trigger threshold value.
  2. The maximum threshold value is 2resolution – 1. The formula is shown here:

Abs (–FS – threshold in volts) ÷ (LSB) = threshold in counts

Here are two examples that use this formula — one for 8-bit trigger resolution, and one for 12-bit trigger resolution.