addTriggerConnection
(Not recommended) Add trigger connection
This session
object function is not recommended. Use DataAcquisition
object functions instead. See Version History.
Syntax
Description
addTriggerConnection(
establishes a trigger connection from the specified source device and terminal to
the specified destination device and terminal, of the specified connection
type.s
,source
,destination
,type
)
Note
You cannot use triggers with audio devices.
Tip
Before adding trigger connections, create a session using daq.createSession
, and add
channels to the session.
establishes a trigger connection from the specified source and terminal to the
specified destination device and terminal, of the specified connection type and
displays it in the variable tc
= addTriggerConnection(s
,source
,destination
,type
)tc
.
[
establishes a trigger connection from the specified source device and terminal to
the specified destination device and terminal of the specified connection type, and
displays the connection in the variable tc
,idx
]
= addTriggerConnection(s
,source
,destination
,type
)tc
and the connection
index in idx
.
Examples
Add External Start Trigger Connection
Create a session and add an analog input channel from
Dev1
to the session.
s = daq.createSession('ni') addAnalogInputChannel(s,'Dev1','ai0','Voltage');
Add a trigger connection from an external device to terminal PFI1 on Dev1
using the 'StartTrigger'
connection type.
addTriggerConnection(s,'external','Dev1/PFI1','StartTrigger')
Export Trigger to External Device
To Add trigger connection going to an external destination, create a
session and add an analog input channel from Dev1
to the
session.
s = daq.createSession('ni') addAnalogInputChannel(s,'Dev1','ai0','Voltage');
Add a trigger from terminal PFI1
on
Dev1
to an external device using the
'StartTrigger'
connection type.
addTriggerConnection(s,'Dev1/PFI1','external','StartTrigger')
Save Trigger Connection
Add a trigger connection from terminal
PFI1
on Dev1
to terminal
PFI0
on Dev2
using the
'StartTrigger'
connection type and store it in
tc
.
To display a trigger connection in a variable, create a session and add an
analog input channel from Dev1
and
Dev2
to the session.
s = daq.createSession('ni') addAnalogInputChannel(s,'Dev1','ai0','Voltage'); addAnalogInputChannel(s,'Dev2','ai1','Voltage');
Save the trigger connection in tc
.
tc = addTriggerConnection(s,'Dev1/PFI1','Dev2/PFI0','StartTrigger');
Input Arguments
s
— Data acquisition session
session object
Data acquisition session, specified as a session object. Create the
session object using daq.createSession
. Use the data
acquisition session for acquisition and generation operations. Create one
session per vendor and use that vendor session to perform all data
acquisition operations.
source
— Source of trigger connection
character vector or string
Source for the trigger connection, specified as a character vector or string. Valid values are:
'external'
— for a trigger based on an external event. A session with an external trigger source has a timeout determined by the ExternalTriggerTimeout property; to disable the timeout, set theExternalTriggerTimeout
value toInf
.'deviceID/terminal'
— for a trigger sourced on a specific terminal on a device in your session. For example,'Dev1/PFI1'
, for more information on device ID see Device. For more information on terminal see step 4.'chassisId/terminal'
— for a trigger sourced on a specific terminal on a chassis in your session, for example,'cDAQ1/PFI1'
. For more information on terminal see step 4.
You can have only one trigger source in a session.
destination
— Destination of trigger connection
character vector or string
Destination for the trigger connection, specified as a character vector or string. Valid values are:
'external'
— for a trigger source connected to an external device.'deviceID/terminal'
— for a trigger source connected to another device in your session, for example,'Dev1/PFI1'
. For more information on device ID see Device. For more information on terminal see step 4.'chassisId/terminal'
— for a trigger source connected to a chassis in your session, for example,'cDAQ1/PFI1'
. For more information on terminal see step 4.
You can also specify multiple destination devices as an array, for
example, {'Dev1/PFI1','Dev2/PFI1'}
.
type
— Trigger connection type
character vector or string
The trigger connection type, specified as a character vector or string.
'StartTrigger'
is the only connection type available
for trigger connections at this time.
Output Arguments
tc
— Trigger connection
1-by-n object array
The trigger connection that you add, returned as an object of trigger connection information. The object contains the following properties.
Destination
— Trigger destination terminal
char
This property is read-only.
Device and terminal to which you connect a trigger destination.
Example
Create a session with a trigger connection and examine the connection properties.
s = daq.createSession('ni'); addAnalogInputChannel(s,'Dev1', 0, 'voltage'); addAnalogInputChannel(s,'Dev2', 0, 'voltage'); addTriggerConnection(s,'Dev1/PFI4','Dev2/PFI0','StartTrigger')
ans = Start Trigger is provided by 'Dev1' at 'PFI4' and will be received by 'Dev2' at terminal 'PFI0'. TriggerType: 'Digital' TriggerCondition: RisingEdge Source: 'Dev1/PFI4' Destination: 'Dev2/PFI0' Type: StartTrigger
Source
— Trigger source terminal
char
This property is read-only.
Device and terminal to which you added a trigger source.
Example
Create an external clock connection and view the connection properties.
s = daq.createSession('ni'); ch = addDigitalChannel(s,'Dev1','Port0/Line2','InputOnly'); s.addClockConnection('External','Dev1/PFI0','ScanClock')
ans = Scan Clock is provided externally and will be received by 'Dev1' at terminal 'PFI0'. Source: 'External' Destination: 'Dev1/PFI0' Type: ScanClock
TriggerCondition
— Condition that must be satisfied before trigger executes
'RisingEdge'
(default) | 'FallingEdge'
Specify the signal condition that executes the trigger, which
synchronizes operations on devices in a session. Set the trigger
condition to RisingEdge
or
FallingEdge
.
For more information, see Synchronization.
Example
Create a session and add channels and a trigger to the
session. Change the trigger condition to
FallingEdge
.
s = daq.createSession('ni'); addAnalogInputChannel(s,'Dev1', 0, 'voltage'); addAnalogInputChannel(s,'Dev2', 0, 'voltage'); addTriggerConnection(s,'Dev1/PFI4','Dev2/PFI0','StartTrigger');
connection = s.Connections(1)
connection.TriggerCondition = 'FallingEdge'
s = Data acquisition session using National Instruments hardware: Will run for 1 second (1000 scans) at 1000 scans/second. Trigger Connection added. (Details) Number of channels: 2 index Type Device Channel MeasurementType Range Name ----- ---- ------ ------- --------------- ---------------- ---- 1 ai Dev1 ai0 Voltage (Diff) -10 to +10 Volts 2 ai Dev2 ai0 Voltage (Diff) -10 to +10 Volts
Click (Details)
to see the trigger
connection details.
Start Trigger is provided by 'Dev1' at 'PFI4' and will be received by 'Dev2' at terminal 'PFI0'. TriggerType: 'Digital' TriggerCondition: FallingEdge Source: 'Dev1/PFI4' Destination: 'Dev2/PFI0' Type: StartTrigger
TriggerType
— Type of trigger executed
'digital'
(default)
This property is read-only.
Type of trigger that the source device executes to synchronize
operations in the session. Currently all trigger types are
digital
.
Type
— Operation of trigger executed
'StartTrigger'
(default)
This property is read-only.
Operation of the trigger that the source device executes to
synchronize operations in the session. Currently the only value
is 'StartTrigger'
.
idx
— Channel index
numeric
Channel index returned as a numeric value. Through the index you can access the array of the session object Channels property.
Version History
Introduced in R2012aR2020a: session
object interface is not recommended
Use of this function with a session
object is not recommended. To
access a data acquisition device, use a DataAcquisition
object
with its functions and properties instead.
For more information about using the recommended functionality, see Transition Your Code from Session to DataAcquisition Interface.
See Also
Functions
Topics
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)