Example Code

NI-DAQmx: Retriggerable Analog Output -- LabVIEW

Code and Documents

Attachment

Overview


This example shows how to use the onboard counters available on a National Instruments Multifunction DAQ device to perform retriggerable analog output. The counters are used to generate a retriggerable finite pulse train that is used as the analog output sample clock since the onboard analog output sample clock cannot be retriggered directly.

 I.    Description:
This example shows how to use the onboard counters available on a National Instruments Multifunction DAQ device to perform retriggerable analog output.  The counters are used to generate a retriggerable finite pulse train that is used as the analog output sample clock since the onboard analog output sample clock cannot be retriggered directly.

II.   Instructions for Running:
1. Select the Physical Channel to correspond to where your signal is output on the DAQ device.
2.  Enter the Minimum and Maximum Voltage Ranges
3.  Enter the Counter Channel to generate a pulse train for the sample clock
4.  Select the Clock Source to be the Internal Output of the counter chosen in the previous step.  If you cannot see this option, right-click on the control, choose I/O Name Filtering …, and select "Include Advanced Terminals" 
5.  Select the Trigger Source to correspond to the terminal on which the trigger will be received
6.  Select the Trigger Edge to be rising or falling
7.  Specify the Desired Frequency of the output Waveform
8.  Enter the Waveform Information.  See the documentation of the Waveform Buffer Generation SubVI for information on each parameter.

III.  Block Diagram Steps:
Steps:
1. Create an Analog Output Voltage channel and a Counter Output Frequency channel.
2. Use the Waveform Buffer subVI to create the waveform. 
3. Call the DAQmx Timing (Implicit) VI which sets the sample clock rate based on the frequency of the pulse train, and set the sample mode to finite.  The number of Sample per Buffer corresponds to the number of samples per channel the counter output channel will produce.  Set the DAQmx Timing (Sample Clock) VI to use the Internal Output of the counter as its Clock Source and set the sample mode to continuous.
4. Call the DAQmx Start Trigger VI to set the Source and Trigger Edge.
5. Write the waveform to the output buffer.
6. Use the DAQmx Trigger Property Node to allow retriggerable operation for the counter.
7. Call the Start VI for the Analog Output task.
8. Call the Start VI for the Counter Output task.
9. Loop continuously until the user presses the Stop button. Check for errors every 100 ms using the Is Task Done? VI
10. Clear the Task
11. Use the popup dialog box to display an error or warning if any.

IV.  I/O Connections Overview:
Make sure your signal output terminal matches the Physical Channel I/O Control. For further connection information, refer to your hardware reference manual.

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

Contributors