Acquire Voltage Data Using a Digital Trigger

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.

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


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

Set TriggerCondition property to 'FallingEdge'.

c = s.Connections(1);
c.TriggerCondition = 'FallingEdge';

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

Related Examples

More About