Example Code

Archived: NI-DAQmx: Continuous Analog Input with Both Start and Reference (Stop) Triggers

Code and Documents



This document has been archived and is no longer updated by National Instruments.

This example program demonstrates how to continuously acquire data (a waveform) using an internal clock and a digital start and reference trigger.

Example Category:

Instructions for Running:
1. Select the physical channel to correspond to where your signal is input on the DAQ device.
2. Enter the minimum and maximum voltage ranges. Note: For better accuracy try to match the Input Ranges to the expected voltage level of the measured signal.
3. Select the number of Samples per Channel to acquire.
4. Set the Rate of the acquisition.
Note: The Rate should be AT LEAST twice as fast as the maximum frequency component of the signal being acquired.
5. Set the Source of the Start and Reference trigger as well as the polarity of the Start and Reference Edges.

1. Create a task.
2. Create an analog input voltage channel.
3. Define the parameters for an Internal Clock Source. Additionally, define the sample mode to be Finite.
4. Define the parameters for a Digital Edge Start Trigger and a Digital Edge Reference Trigger.
5. Call the Start function to start the acquisition.
6. Set the next relative read position
7. Use the Read function to retrieve the waveform. Set a timeout so an error is returned if the samples are not returned in the specified time limit. Do Read until task is done
8. Read remaining data in the buffer.
9. Call the Clear Task function to clear the Task.
10. Display an error if any.

I/O Connections Overview:
Make sure your signal input terminal matches the Physical Channel I/O Control. Also, make sure your digital trigger terminals match the Trigger Source controls. For further connection information, refer to your hardware reference manual.

Recommended Use:
1. Call Configure and Start functions.
2. Call Read function.
3. Call Stop function at the end.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.