Example Code

Sine Wave Addition

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview:

This VI allows a user to add sine waves programmatically.  It displays a graph of each individual wave as well as the sum of the two.

 

Description:

This program generates two sine waves and plots them with settable frequency, amplitude and phase.  A third curve is generated by adding the two generated waves together.  This demonstration shows the properties of "standing wave cancellation" and other consequences of combining 2 signals on one line by changing the offset of the 2 generated sine waves.  Beyond the basic obervations, a user has the opportunity to save the sine waves to a file and realize the peak to peak difference between signals.

 

Requirements:

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Set Sensor 1 Frequency and Amplitude
  2. Set Sensor 2 Frequency and Amplitude
  3. Adjust the phase knob control to desired value
  4. Run the VI

 

Additional Information or References

VI Snippet:

 

1.png

 

 

**This document has been updated to meet the current required format for the NI Code Exchange. For more details visit this discussion thread**

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

Comments
BetaCommunityCo
Member
Member
on

Great example!

This is a really cool example! I like the saving feature as well. Great documentation on the block diagram, and I really like the peak searching bit.

One little little thing: right now the reinitialization that occurs to the left outside the while loop has no dataflow enforced to ensure that it executes first when the VI begins. Just wiring the Dynamic Data Type wire to form a tunnel on the while loop will cause the while loop to wait for the execution of the initialization portion. You wouldn't use the data from the tunnel inside the while loop.

Other than that, fantastic example!

BetaCommunityCo
Member
Member
on

THANKS for the nice comment

and i updated theblock diagramas you suggested.. thank YOU for the tip

I have been an enbedded software engineer for 27 years BUT I just learned labview about 4 weeks ago... I am a CONVERT.... stuff I used to do in C (and I am NO SLACKER in C coding)that would probably take DAYS take HOURS in labview

BetaCommunityCo
Member
Member
on

Wow, fast response!

Good grief, that maintenance fix was quick!

Again, very nice example.

BetaCommunityCo
Member
Member
on

Kudos to the new users

4 weeks ago? Even more impressive! Keep up the good work!

BetaCommunityCo
Member
Member
on

FFT

Just thinking out loud here...

You could also throw on an express Spectral Measurements VI and do an FFT of the waveform after it leaves the Merge Signals and have a separate display of the FFT of the signals.

Good work on the VI, simple and effective.