|On this page…|
Use triggers to simultaneously start all devices in the session. You connect a trigger source to a trigger destination, A trigger source can be either external, where the trigger comes from a source outside a session, or on a device and terminal pair within a session. Trigger destination devices can be external, where the signals are received outside the session, or devices within the session. To understand source and destination devices, see Source and Destination Devices.
You can configure devices in a session to receive an external trigger. To use an external trigger source, your connection parameters must correctly specify the exact device and terminal pairs to which the external source is connected. Two circumstances of externally clocked and triggered synchronization are:
An external hardware event that controls the operation of one or more devices in a session object. For example, opening and closing a switch starts a background acquisition on a session.
An external hardware event synchronizes multiple devices in a session. For example, opening and closing of a switch starts a background operation across multiple devices or CompactDAQ chassis in a session.
This example shows how to use a falling edge digital trigger, which occurs when a switch closes on an external source. The trigger is connected to terminal PFI0 on device Dev1 and starts acquiring sensor voltage data.
Step 1. Create a data acquisition session and add channels.
s = daq.createSession('ni');
Add one voltage input channel from NI USB-6211 with device ID 'Dev1'.
Step 2. Add a trigger connection.
Connect the switch to terminal 'PFI0' on NI USB-6211. The trigger comes from the switch, which is an external source.
ans = Start Trigger is provided externally and will be received by 'Dev1' at terminal 'PFI0'. TriggerType: 'Digital' TriggerCondition: RisingEdge Source: 'External' Destination: 'Dev1/PFI0' Type: StartTrigger
Step 3. Specify the trigger condition.
Set TriggerCondition property to 'FallingEdge'.
c = s.Connections(1). c.TriggerCondition = 'FallingEdge';
Step 4. Acquire data.
Acquire data and store it in dataIn. The session waits for the trigger to occur, and starts acquiring data when the switch closes.
dataIn = startForeground(s);