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
and starts acquiring sensor voltage data.
Create a DataAcquisition object for NI devices.
d = daq("ni");
Add a voltage input channel from NI USB-6211 with device ID
Physically connect the switch to terminal
PFI0 on NI
USB-6211. The trigger comes from the switch, which is an external source.
Programmatically add the trigger to the DataAcquisition, indicating source,
destination, and device PFI terminal.
t = addtrigger(d,"Digital","StartTrigger","External","Dev1/PFI0")
t = DigitalTrigger with properties: Source: 'External' Destination: 'Dev1/PFI0' Type: StartTrigger Condition: 'RisingEdge'
Set the trigger
Condition property to
t.Condition = 'FallingEdge';
Acquire data and store it in
DataAcquisition waits for the trigger to occur, and starts acquiring data
when the switch closes.
dataIn = read(d,seconds(1),"OutputFormat","Matrix");
- Multiple-Device Synchronization Using USB or PXI Devices
- Multiple-Chassis Synchronization with CompactDAQ Devices