Overview
Objective: In this exercise, finish the VI from the previous two exercises. Add signal analysis and determine whether the total harmonic distortion (THD) of your signal is within an acceptable range. Figure 1 shows the results of this exercise.
Figure 1. Completed Block Diagram of Exercise 3
Analyze the Acquired Signal
- This exercise builds on the front panel from Exercise 2 – Acquire a Signal from a Simulated Digital-to-Analog (D/A) Conversion.
- If you closed your VI earlier, open Exercise 2.vi to continue.
- Select File » Save As…, select Substitute copy for original, and click Continue…
- Name the VI as Exercise 3.vi and click OK.
- To perform a fast Fourier transform (FFT), use an Express VI.
- Right-click on the block diagram and select Express » Signal Analysis » Spectral Measurements. The Spectral Measurements Express VI generates an FFT based on the simulated output from your simulated signal.

Figure 2. Spectral Measurements Express VI
- Place the Spectral Measurements Express VI to the right of the Simulate Signals Express VI.
- On the resulting configuration dialog, leave everything at the default and click OK.
- Wire the Sine with Uniform output on the Simulate Signals Express VI to the Signals input connector of the Spectral Measurements Express VI.
- Wire the FFT – (RMS) output from the Spectral Measurements Express VI to the FFT graph.
- Right-click on the block diagram and select Express » Signal Analysis » Spectral Measurements. The Spectral Measurements Express VI generates an FFT based on the simulated output from your simulated signal.
- Use an Express VI to perform the THD as well.
- Right-click on the block diagram and select Express » Signal Analysis » Distortion. The Distortion Measurements Express VI calculates the THD on your simulated signal.

Figure 3. Distortion Measurements Express VI
- Place the Distortion Measurements Express VI to the right of the Simulate Signals Express VI.
- On the resulting configuration dialog, uncheck SINAD (dB) and check THD.
- Click OK to exit the configuration dialog.
- Wire the Sine with Uniform output on the Simulate Signals Express VI to the Signals input connector of the Distortion Measurements Express VI.
- Right-click on the block diagram and select Numeric » Multiply to create a Multiply VI.
- Right-click on the top input of the Multiply VI. Select Create » Constant to create a numeric constant.
- Type the value 100 in the numeric constant.
- Wire the THD output from the Distortion Measurements Express VI to the bottom input of the Multiply VI.
- Right-click on the block diagram and select Express » Signal Manipulation » From DDT to add a Convert from Dynamic Data VI. This VI converts waveform data to regular numeric data.

Figure 4. Convert from Dynamic Data VI
- On the resulting dialog, select Singular Scalar and click OK.
- Wire the output of the Multiply VI to the input of the Convert from Dynamic Data VI.
- Wire the output of the Convert from Dynamic Data VI to the input connector of the Actual THD % indicator.
- Right-click on the block diagram and select Express » Signal Analysis » Distortion. The Distortion Measurements Express VI calculates the THD on your simulated signal.
Add Range Checking to the Application
Now that you have the THD of your signal, you need to evaluate whether it is within an acceptable range.
- To check whether the THD is within your acceptable range, create the LabVIEW code for this evaluation.
- Right-click on the block diagram and select Comparison » In Range and Coerce VI. Place the VI to the right of the Minimum and Maximum Accepted THD % controls.

Figure 5. In Range and Coerce VI
- Wire the output of the Maximum Accepted THD % control to the Upper Limit input of the In Range and Coerce VI.
- Wire the output of the Minimum Accepted THD % control to the Lower Limit input of the In Range and Coerce VI.
- Wire the output of the Convert from Dynamic Data VI to the x input of the In Range and Coerce VI.
- Wire the In Range? output of the In Range and Coerce VI to the input of the Accepted Pass indicator.
- Right-click on the block diagram and select Numeric » Divide to add a Divide VI to the block diagram. Place the Divide VI to the right on the Signal Amplitude control.
- Right-click on the top input connector of the Divide VI and select Create » Constant. Set the constant to 25.
- Wire the output connector from the Signal Amplitude control to the bottom input of the Divide VI.
- Wire the output connector of the Divide VI to the input connector of the Maximum Expected THD % indicator.
- Right-click on the block diagram and select Numeric » Divide to add another Divide VI to the block diagram. Place the Divide VI to the underneath of the original Divide VI.
- Right-click on the top input connector of the new Divide VI and select Create » Constant. Set the constant to 14.
- Wire the output connector from the Signal Amplitude control to the bottom input of the new Divide VI.
- Wire the output connector of the new Divide VI to the input connector of the Minimum Expected THD % indicator.
- Right-click on the block diagram and select Comparison » In Range and Coerce VI. Place the VI to the right of the two Divide VIs.
- Wire the output of the first Divide VI to the Upper Limit input of the new In Range and Coerce VI.
- Wire the output of the second Divide VI to the Lower Limit input of the new In Range and Coerce VI.
- Wire the output of the Convert from Dynamic Data VI to the x input of the new In Range and Coerce VI.
- Right-click on the block diagram and select Comparison » In Range and Coerce VI. Place the VI to the right of the Minimum and Maximum Accepted THD % controls.
- Your completed block diagram should look like Figure 6.
Figure 6. Completed Block Diagram
- Now, Run the VI.
- Switch to the Front Panel.
- Click the Run button. Run the VI several times until you receive a few passes and a few failures. You can adjust the amplitude to see the varying effects on the expected THD and the actual THD.
- Save the VI.
Reader Comments | Submit a comment »
exceellent
- dipak sawlani, wipro vlsi. vdsawlani06@yahoo.com - Oct 12, 2007
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
