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,
Sending property is automatically
On and queued data is output from the engine
to the hardware subsystem.
Properties associated with analog output triggers are as follows:
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.
TriggerFcn, these trigger-related
properties are discussed in the following sections.
discussed in Events and Callbacks.
Defining a trigger for an analog output object involves specifying
the trigger type with the
You can think of the trigger type as the source of the trigger. The
TriggerType values are given below.
Table 8-7. Analog Output TriggerType Property Values
The trigger occurs just after you issue the
The trigger occurs just after you manually issue the
Trigger types can be grouped into two main categories:
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 (
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.
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
For an analog output trigger to occur, you must follow these steps:
Queue data in the engine.
Configure the appropriate trigger properties.
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.
For analog output objects, only one trigger can occur. You can
determine if the trigger event occurred by returning the value of
the trigger event did not occur. If
then the trigger event occurred. Event information is also recorded
EventLog property. A convenient
way to access event log information is with the
For example, suppose you create the analog output object
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'); addchannel(ao,1); data = sin(linspace(0,1,8000))'; putdata(ao,data) start(ao)
the number of triggers executed.
ans = 1
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.
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
t = fix(abstime); sprintf('%d:%d:%d', t(4),t(5),t(6))
ans = 10:43:25
As shown in the preceding section, you can also evaluate the
absolute time of the trigger event with the
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.
When using National Instruments hardware, there is an additional analog output trigger type available to you — digital triggering.
TriggerType is set to
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'); addchannel(ao,0:1); ao.TriggerType = HwDigital
With this trigger configuration,
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.