Main Content

addTriggerConnection

(Not recommended) Add trigger connection

This session object function is not recommended. Use DataAcquisition object functions instead. See Compatibility Considerations.

Description

example

addTriggerConnection(s,source,destination,type) establishes a trigger connection from the specified source device and terminal to the specified destination device and terminal, of the specified connection 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.

example

tc = addTriggerConnection(s,source,destination,type) 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.

example

[tc,idx] = addTriggerConnection(s,source,destination,type) 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 and the connection index in idx.

Examples

collapse all

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')

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')

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

collapse all

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 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 the ExternalTriggerTimeout value to Inf.

  • '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 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'}.

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

collapse all

The trigger connection that you add, returned as an object of trigger connection information. The object contains the following properties.

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

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

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

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.

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'.

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 R2012a

collapse all

R2020a: 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.