Data Acquisition Toolbox    

Trigger Delays

Trigger delays allow you to control exactly when data is logged after a trigger occurs. You can log data either before the trigger or after the trigger. Logging data before the trigger occurs is called pretriggering, while logging data after a trigger occurs is called posttriggering.

You configure trigger delays with the TriggerDelay property. Pretriggers are specified by a negative TriggerDelay value, while posttriggers are specified by a positive TriggerDelay value. You can delay data logging in time or in samples using the TriggerDelayUnits property. When TriggerDelayUnits is set to Samples, data logging is delayed by the specified number of samples. When the TriggerDelayUnits property is set to Seconds, data logging is delayed by the specified number of seconds.

Capturing Pretrigger Data

In some circumstances, you might want to capture data before the trigger occurs. Such data is called pretrigger data. When capturing pretrigger data, the SamplesPerTrigger property value includes the data captured before and after the trigger occurs. Capturing pretrigger data is illustrated below.

You can capture pretrigger data for manual triggers and software triggers. If TriggerType is Manual, and the trigger function is issued before the trigger delay passes, then a warning is returned and the trigger is ignored (the trigger event does not occur).

You cannot capture pretrigger data for immediate triggers or device-specific hardware triggers.

Capturing Posttrigger Data

In some circumstances, you might want to capture data after the trigger occurs. Such data is called posttrigger data. When capturing posttrigger data, the SamplesPerTrigger property value and the number of posttrigger samples are equal. Capturing posttrigger data is illustrated below.

You can capture posttrigger data using any supported trigger type.

Example: Voice Activation and Pretriggers

This example modifies daqdoc5_3 such that 500 pretrigger samples are acquired. You can run this example by typing daqdoc5_4 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. Additionally, 500 pretrigger samples are collected.
  4. Acquire data -- Start AIVoice, acquire the specified number of samples, and extract the first 1000 samples from the engine as sample-time pairs.
  1. Plot all the 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.

The output from this example is shown below. Note that the pretrigger data constitutes half of the 1000 samples extracted from the engine. Additionally, pretrigger data has negative time associated with it because time = 0 corresponds to the time the trigger event occurs and data logging is initiated.


  Executing the Trigger Repeating Triggers