Example Code

Archived: NI-DAQmx: Acquire Analog Input Data Using an Analog Trigger - Multiple Times

Code and Documents

Attachment

Overview


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

I. Description
This VI retrieves the specified amount of data from one or more analog input channels each time an analog trigger occurs. It shows how to start a triggered acquisition multiple times while avoiding the overhead of configuration and buffer allocation each time. This is a timed acquisition, meaning that a hardware clock is used to control the acquisition rate for fast and accurate timing. It is also a buffered acquisition, meaning that the data is stored in an intermediate memory buffer after the data is acquired from the DAQ board. When the pretriggering is disabled, the analog trigger circuitry on the board causes the board to acquire data when the trigger parameters are met. When the pretriggering is enabled, data is continuously acquired by the board, but the data is not transferred to a software buffer until after the analog trigger parameters are met. Once met, the data is transferred to the software buffer. Data is retrieved from that buffer and displayed after the appropriate amount (before and after the trigger) has been acquired. The vertical cursor on the graph indicates where the trigger occurred. With each iteration of the while loop, the VI waits for the next trigger, then reads the same amount of data again from the same channels at the same rate.

II. 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 range.
Note: For better accuracy try to match the input range to the expected voltage level of the measured signal.
3. Set the number of samples to acquire per channel.
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 trigger. By default this is PFI0
6. Set the slope and level of desired analog edge condition.
7. Set the number of pretrigger samples if necessary.

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

Contributors