Academic Company Events Community Support Solutions Products & Services Contact NI MyNI
This Document is not yet Rated

Configuring a Stop Trigger using DAQmx for LabVIEW NXG

Primary Software: LabVIEW Development Systems>>LabVIEW NXG
Primary Software Version: 1.0
Primary Software Fixed Version: N/A
Secondary Software: Driver Software>>NI-DAQmx
Hardware: Multifunction DAQ (MIO)

I have an NI DAQ device, and I want to use NI-DAQmx with support for LabVIEW NXG to send a signal to the device telling it when to start and stop acquiring data. How can I do this?

DAQmx does not provide a direct way to generate a stop trigger; however, by using a reference trigger and modifying the read position, you can create the equivalent of a stop trigger in LabVIEW NXG. 

To accomplish this, you will need to set up a finite acquisition that is configured to acquire N samples before and after a reference trigger.  This is useful because, in order to provide pre-trigger samples for a reference trigger, the DAQmx task will be continually acquiring data while it waits for the reference trigger.  This continually-acquired data can still be read using DAQmx Read, even though it is not explicitly part of the configured acquisition.

See the snippet below as an example of how to implement a reference trigger as a stop trigger:

[+]Enlarge Image

Figure 1: DAQmx Application using Start and Stop Triggers in LabVIEW

In the example above, an analog input task is created with DAQmx and configured to use two triggers: a start digital edge trigger, and a reference digital edge trigger.  

The start trigger determines when the task will begin acquiring samples in preparation for the reference trigger, and the reference trigger determines when the task will send the finite number of pre-trigger and post-trigger samples originally requested before stopping the task.

Note: The start and reference triggers can be set up to arrive on the same PFI line if desired, because the DAQmx driver will not wait for the reference trigger until after the start trigger has occurred. 

Configuring a Reference Trigger

Reference triggers require an additional input parameter called pretrigger samples per channel:

Figure 2:  Pretrigger Samples Parameter in LabVIEW

The number of pretrigger samples defines how many of the total samples acquired during the finite acquisition are from before the reference trigger occurred.  The rest of the samples in the acquisition are considered post-trigger samples.

Implicitly, the number of post-trigger samples is equal to:

Post-Trigger Samples = samples per channel (DAQmx Timing input) - pretrigger samples per channel (DAQmx Trigger input)

For example, to configure a task that will acquire the minimum number of pretrigger samples (2), followed by 40 post-trigger samples, you would use 42 for samples per channel as an input for DAQmx Timing, and 2 as pretrigger samples per channel on the DAQmx Reference Trigger.  The final output of the finite acquisition would look like so:

Figure 3:  Visualization of Final DAQmx Read Output with a Reference Trigger

Note: When setting up the timing of the task, there must be at least 2 pre-trigger and 2 post-trigger samples for the reference trigger. Consequently, you will still receive at least two samples after the reference trigger has occurred even if using a reference trigger as a stop trigger -- however, these can be thrown away in post-processing if they are not desired.

Acquiring Continuously with a Reference Trigger

By default, DAQmx will pick a buffer size exactly big enough to fit the total number of samples to read (e.g. the buffer will be size 42 in the example described above). 

In order for the DAQmx application to be able to pull continuous samples from the buffer while waiting for the reference trigger, two other modifications are necessary:

  1. Set the property DAQmx Buffer»Input»Buffer Size to manually change the buffer size of the DAQmx application after configuring the timing properties. 

  2. Set the property DAQmx Read»Relative To to modify the read position. By default, this property is set to First Pretrigger Sample when using a reference trigger. By setting it to Current Read Position, DAQmx Read will read samples that are being put into the buffer after the start trigger occurs, just . If this is not changed, the DAQmx Read will wait until the reference trigger is received before it was can retrieve samples from the buffer.

Related Links:
KnowledgeBase 3HGAJLTY: Configuring a Stop Trigger using DAQmx in LabVIEW
White Paper: DAQ Triggering Modes
Product Manual: DAQmx Trigger (G Dataflow)


Report Date: 10/18/2017
Last Updated: 10/20/2017
Document ID: 7QHE5LSZ

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit