Data Acquisition Toolbox    

Defining a Trigger: Trigger Types and Conditions

Defining a trigger for an analog input object involves specifying the trigger type with the TriggerType property. You can think of the trigger type as the source of the trigger. For some trigger types, you might need to specify a trigger condition and a trigger condition value. Trigger conditions are specified with the TriggerCondition property, while trigger condition values are specified with the TriggerConditionValue property.

The analog input TriggerType and TriggerCondition values are given below.

Table 5-7: Analog Input TriggerType and TriggerCondition Values
TriggerType Value
TriggerCondition Value
Description
{Immediate}
None
The trigger occurs just after you issue the start function.
Manual
None
The trigger occurs just after you manually issue the trigger function.
Software
{Rising}
The trigger occurs when the signal has a positive slope when passing through the specified value.
Falling
The trigger occurs when the signal has a negative slope when passing through the specified value.
Leaving
The trigger occurs when the signal leaves the specified range of values.
Entering
The trigger occurs when the signal enters the specified range of values.

For some devices, additional trigger types and trigger conditions are available. Refer to the TriggerType and TriggerCondition reference pages in Base Property Reference, for these device-specific values.

Trigger types are grouped into two main categories:

The trigger types shown above are device-independent triggers because they are available for all supported hardware. For these trigger types, the callback that initiates the trigger event involves satisfying a trigger condition in the engine (software trigger type), or issuing a toolbox function (start or trigger). Conversely, device-specific hardware triggers depend on the specific hardware device you are using. For these trigger types, the callback that initiates the trigger event involves an external analog or digital signal.

Device-specific hardware triggers for National Instruments, Measurement Computing, and Agilent Technologies devices are discussed in Device-Specific Hardware Triggers. Device-independent triggers are discussed below.

Immediate Trigger.   If TriggerType is Immediate (the default value), the trigger occurs immediately after the start function is issued. You can configure an analog input object for continuous acquisition by use an immediate trigger and setting SamplesPerTrigger or TriggerRepeat to inf. Trigger repeats are discussed in Repeating Triggers.

Manual Trigger.   If TriggerType is Manual, the trigger occurs just after you issue the trigger function. A manual trigger might provide you with more control over the data that is logged. For example, if the acquired data is noisy, you can preview the data using peekdata, and then manually execute the trigger after you observe that the signal is well-behaved.

Software Trigger.   If TriggerType is Software, the trigger occurs when a signal satisfying the specified condition is detected on the hardware channel specified by the TriggerChannel property. The trigger condition is specified as either a voltage value and slope, or a range of voltage values using the TriggerCondition and TriggerConditionValue properties.

Example: Voice Activation Using a Software Trigger

This example demonstrates how to configure an acquisition with a sound card based on voice activation. The sample rate is set to 44.1 kHz and data is logged when an acquired sample has a value greater than or equal to 0.2 volt and a rising slope. A portion of the data is then extracted from the engine and plotted.

You can run this example by typing daqdoc5_3 at the MATLAB command line.

  1. Create a device object -- Create the analog input object AIVoice for a sound card. The installed adaptors and hardware IDs are found with daqhwinfo.
  2. Add channels -- Add one hardware channel to AIVoice.
  3. Configure property values -- Define a 2-second acquisition and configure a software trigger. The source of the trigger is chan, and the trigger executes when a rising voltage level has a value of at least 0.2 volt.
  4. Acquire data -- Start AIVoice, acquire the specified number of samples, and extract the first 1000 samples from the engine as sample-time pairs. Display the number of samples remaining in the engine.
  1. Plot all extracted data.

    Make sure AIVoice has stopped running before cleaning up the workspace.

  1. Clean up -- When you no longer need AIVoice, you should remove it from memory and from the MATLAB workspace.

Note that when using software triggers, you must specify the TriggerType value before the TriggerCondition value. The output from this example is shown below.

The first logged sample has a signal level value of at least 0.2 volt, and this value corresponds to time = 0. Note that after you issue the getdata function, 87,200 samples remain in the engine.


  Configuring Analog Input Triggers Executing the Trigger