Overview:
Demonstrates on continuously generating waveform using the internal sample clock.
Description:
This example allows the user to regulate the output waveform frequency on-the-fly by multiplying the Analog Input Voltage with a multiplication factor, N.
Automatic data regeneration has been disabled which means that new data has to be provided throughout the duration of the continuous Analog Output operation.
This allows the generation of any arbitrary frequency as this VI computes new data for each iteration of the loop, maintaining phase continuity of the signal.
Requirements:
LabVIEW 2012 or compatible.
NI-DAQmx 15.5.1 or compatible.
Steps to Implement or Execute Code:
- Select the Physical Channel to correspond to where your signal will be output from the DAQ device. Ensure the signal output terminal matches the Physical Channel I/O Control.
For further connection information, refer to your hardware reference manual.
- Enter the Minimum and Maximum Voltage range.
- Specify the desired Sample Clock Rate of the output Waveform. Higher sample clock rates will produce a smoother waveform.
- Specify the Analog Output buffer size in number of samples. A larger buffer would help non-regenerative operations to avoid errors due to occasional high CPU load.
Note: The Analog Output buffer has to be at least as big as the amount of data being written to the board per iteration.
The recommended buffer size would be at least twice the amount of data being written to the board per iteration.
- Specify the type of waveform to be generated including the Waveform Information.
Block Diagram Steps:
- Create an Analog Input and Output Voltage channel(s).
- Configure the task to prohibit the automatic regeneration of data.
- Call the DAQmx (Sample Clock) VI to set the sample clock rate. Additionally, set the sample mode to Continuous.
- Read the actual sample clock rate (eventually coerced depending on the hardware used).
- Overwrites the automatic output buffer allocation that NI-DAQmx performs.To minimize latency, the smallest buffer size possible should be used that prevents the Analog Output task from underflowing.
- Call the Start VI. This is only needed when the loop is executed for the first time.
- Reads the Analog Input Voltage readings and multiply by the Multiplication Factor, N to regulate the output waveform frequency. Every loop iteration computes the frequency and writes a new waveform to the buffer.
- Compute the desired waveform using the buffer size and the actual update rate.
- This VI keeps track of the phase of the waveform to ensure that the generated signal is continuous.
- Write the waveform to the output buffer.
- Stop the loop when the user presses on the Stop button or when any error occurs.
- Clears the tasks and displays error, if any.


**This document has been updated to meet the current required format for the NI Code Exchange.**