Main Content

Working with Triggers

This example shows how to use the different types of triggering and how to configure other trigger properties.

Configuring Trigger Properties

To obtain a list of configurable trigger settings, use the TRIGGERINFO function with the video input object. TRIGGERINFO will return all possible trigger configurations supported by the image acquisition device associated with the video input object. Possible configurations consists of a valid trigger type, trigger condition, and trigger source combination.

Note: All image acquisition devices support immediate and manual trigger types. A hardware trigger type is available only if it is supported by the image acquisition device.

%访问图像采集设备。vidobj = videoinput('matrox', 1);% Display all valid trigger configurations.triggerinfo (vidobj)
Valid Trigger Configurations: TriggerType: TriggerCondition: TriggerSource: 'immediate' 'none' 'none' 'manual' 'none' 'none' 'hardware' 'fallingEdge' 'digitalTrigger' 'hardware' 'fallingEdge' 'optoTrigger' 'hardware' 'fallingEdge' 'timer1' 'hardware' 'fallingEdge' 'timer2' 'hardware' 'risingEdge' 'digitalTrigger' 'hardware' 'risingEdge' 'optoTrigger' 'hardware' 'risingEdge' 'timer1' 'hardware' 'risingEdge' 'timer2'

要为图像采集设备配置触发设置,请将TriggerConfig函数与所需的触发类型,触发条件和触发源一起使用。

triggerconfig(vidobj,'硬件','fallingEdge','optoTrigger')% View the current trigger configuration.CurrentConfiguration = triggerConfig(vidobj)
currentConfiguration = TriggerType: 'hardware' TriggerCondition: 'fallingEdge' TriggerSource: 'optoTrigger'

Note: Configuring trigger settings requires a unique configuration to be specified. If specifying the trigger type uniquely identifies a configuration, no further arguments need to be provided to TRIGGERCONFIG.

Hardware triggers are the only trigger type that typically have multiple valid configurations.

Immediate Triggering

By default, a video input object's trigger type is configured for immediate triggering. Immediate triggering indicates that data logging is to begin as soon as the START function is issued.

% Configure the trigger type.triggerconfig(vidobj,'immediate')% Initiate the acquisition.start(vidobj)% Wait for acquisition to end.wait(vidobj, 2)% Determine the number frames acquired.frameslogged = vidobj.FramesAcquired;
框架= 10

Manual Triggering

Manual triggering requires that the TRIGGER function be issued before data logging is to begin.

% Configure the trigger type.triggerconfig(vidobj,“手动”)% Initiate the acquisition.start(vidobj)% Verify no frames have been logged.frameslogged = vidobj.FramesAcquired;
framesLogged = 0
% Trigger the acquisition.trigger(vidobj)%等待收购结束。wait(vidobj, 2);% Determine the number frames acquired.frameslogged = vidobj.FramesAcquired;
框架= 10

Hardware Triggering

Hardware triggering begins logging data as soon as a trigger condition has been met via the trigger source.

In this example, we have connected an opto-isolated trigger source from a function generator to our image acquisition device. The image acquisition device will begin logging data upon detecting a falling edge signal from the source.

% Configure the trigger settings.triggerconfig(vidobj,'硬件','fallingEdge','optoTrigger')

Initially, no signal is sent from the source to the image acquisition device.

% Initiate the acquisition.start(vidobj)%验证什么都没有获得。frameslogged = vidobj.FramesAcquired;
framesLogged = 0

A square wave signal will now be sent from the trigger source to the image acquisition device.

%等待收购结束。wait(vidobj, 10)% Verify frames were acquired.frameslogged = vidobj.FramesAcquired;
框架= 10
% Once the video input object is no longer needed, delete% it and clear it from the workspace.delete(vidobj) clearvidobj