Example Code

DAQmx Retriggerable AI Using Retriggerable Counter

Overview

This example demonstrates how to generate a finite retriggerable digital pulse train from a Counter to be used as the clock for Analog Input.

Description

 

Requirements: LabVIEW NXG 1.0 or compatible

Instructions:
1. Select the physical channel to correspond to where your signal is input on the DAQ device.
2. Enter the minimum and maximum signal ranges.
Note: For better accuracy, try to match the input range to the expected voltage level of the measured signal.
3. Select the Counter Channel which corresponds to the counter you want to generate your AI clock from.
4. Select the Source of the Clock for the acquisition as the output of the counter you chose in step 3.
5. Set the Rate at which the counter will generate.
Note: The Rate should be at least twice as fast as the maximum frequency component of the signal being acquired.
6. Enter the number of Samples per Channel to acquire. This will also be the number of pulses generated by the counter.
7. Select the Source of the Digital Start Trigger for the acquisition.
8. Select the edge, rising or falling, on which to trigger.
9. Click Stop to stop the VI

Hardware and Software Requirements

M Series DAQ Card

X Series DAQ Card

Steps to Implement or Execute Code

1. Create an analog input voltage channel. Also, create a Counter Output channel to produce a Pulse in terms of Frequency. If the Idle State of the pulse is set to low the first transition of the generated signal is from low to high.
2. Define the parameters for an External Clock Source. Additionally, define the sample mode to be continuous. Also, use the DAQmx Timing VI (Implicit) to configure the duration of the pulse generation and the number of pulses to generate.
3. Use the DAQmx Trigger VI to configure a counter trigger to start on a digital edge.
4. Configure a buffer which is 1000 plus the number of samples per channel. This is necessary when simulating retriggerable finite transfers with a continuous acquisition because DMA needs a slightly larger buffer than the Samples per Channel.
5. Use a DAQmx Trigger Property Node to set the operation for retriggerable.
6. Call the Start VI to begin the acquisition and to arm the counter which begins the pulse train generation.
7. Use the DAQ Read property node --> AvailSampPerChan to see how many samples have been acquired. If 'Samples per Channel' number of samples have been acquired, as you can set on the front panel, then Read the data, otherwise continue looping. This allows the user to stop the program by pressing the 'STOP' button at any time.
8. Read the waveform data in a loop until the user hits the stop button or an error occurs.
Note: This example reads data from one or more channels and returns an array of data. Use the Index Array function to access an individual channel of data.
9. Call the Clear Task VI to clear the counter Task.
10. Call the Clear Task VI to clear the AI Task.
11. Use the popup dialog box to display an error if any.

Additional Information or References

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