Configure Analog Output Triggers

Analog Output Trigger Properties

An analog output trigger is defined as an event that initiates the output of data. As shown in the figure below, when a trigger occurs, the Sending property is automatically set to On and queued data is output from the engine to the hardware subsystem.

Properties associated with analog output triggers are as follows:

Property Name



Indicate the absolute time of the first trigger.


Specify the callback function to execute when a trigger occurs.


Indicate the number of triggers that execute.


Specify the type of trigger to execute.

Except for TriggerFcn, these trigger-related properties are discussed in the following sections. TriggerFcn is discussed in Events and Callbacks.

Define Trigger Types

Defining a trigger for an analog output object involves specifying the trigger type with the TriggerType property. You can think of the trigger type as the source of the trigger. The analog output TriggerType values are given below.

Table 8-7. Analog Output TriggerType Property Values

TriggerType Value



The trigger occurs just after you issue the start function.


The trigger occurs just after you manually issue the trigger function.

Trigger types can be grouped into two main categories:

  • Device-independent triggers

  • Device-specific hardware triggers

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 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 digital signal.

Device-specific hardware triggers for National Instruments® 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 output object for continuous output, by using an immediate trigger and setting RepeatOutput to inf.

To see how to set up continuous analog input acquisitions, refer to the Continuous Acquisitions Using Analog Input example.

Manual Trigger

If TriggerType is Manual, the trigger occurs immediately after the trigger function is issued.

Execute Triggers

For an analog output trigger to occur, you must follow these steps:

  1. Queue data in the engine.

  2. Configure the appropriate trigger properties.

  3. Issue the start function.

  4. Issue the trigger function if TriggerType is Manual.

Once the trigger occurs, queued data is output to the hardware, and the device object stops executing when all the queued data is output.

    Note   Only one trigger event can occur for analog output objects.

How Many Triggers Occurred?

For analog output objects, only one trigger can occur. You can determine if the trigger event occurred by returning the value of the TriggersExecuted property. If TriggersExecuted is 0, then the trigger event did not occur. If TriggersExecuted is 1, then the trigger event occurred. Event information is also recorded by the EventLog property. A convenient way to access event log information is with the showdaqevents function.

For example, suppose you create the analog output object ao for a sound card and add one channel to it. ao is configured to output 8,000 samples using the default sampling rate of 8000 Hz.

ao = analogoutput('winsound');
data = sin(linspace(0,1,8000))';

TriggersExecuted returns the number of triggers executed.

ans =

You can use showdaqevents to return information for all events that occurred while ao was executing.

1 Start               ( 10:43:25, 0 )
   2 Trigger             ( 10:43:25, 0 )
   3 Stop                ( 10:43:26, 8000 )

For more information about recording and retrieving event information, refer to Record and Retrieve Event Information.

When Did the Trigger Occur?

You can return the absolute time of the trigger with the InitialTriggerTime property. Absolute time is returned as a clock vector in the form

[year month day hour minute seconds]

For example, the absolute time of the trigger event for the preceding example is

abstime = ao.InitialTriggerTime
abstime =
1.0e+003 *
    1.9990    0.0040    0.0170    0.0100    0.0430    0.0252

To convert the clock vector to a more convenient form, you can use the sprintf function.

t = fix(abstime);
sprintf('%d:%d:%d', t(4),t(5),t(6))
ans =

As shown in the preceding section, you can also evaluate the absolute time of the trigger event with the showdaqevents function.

Device-Specific Hardware Triggers

Most data acquisition devices possess the ability to accept a hardware trigger. Hardware triggers are processed directly by the hardware and are typically transistor-transistor logic (TTL) signals. Hardware triggers are used when speed is required because a hardware device can process an input signal much faster than software.

The device-specific hardware triggers are presented to you as additional property values. Hardware triggers for National Instruments devices are discussed below and in the properties.

Note that the available hardware trigger support depends on the board you are using. Refer to your hardware documentation for detailed information about its triggering capabilities.

National Instruments

When using National Instruments hardware, there is an additional analog output trigger type available to you — digital triggering.

If TriggerType is set to HwDigital, the trigger is given by an external TTL signal that is input directly into the hardware device. The following example illustrates how to configure a hardware digital trigger.

ao = analogoutput('nidaq','Dev1');
ao.TriggerType = HwDigital

With this trigger configuration, ao will not start outputting data until the TTL signal is detected by the hardware on the appropriate pin.

The diagram below illustrates how you can connect a digital trigger signal to an MIO-16E Series board. PFI6/WFTRIG corresponds to pin 5.

Was this topic helpful?