LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sinusoidal Waveform in labview

Hello! I need to create a VI that generates a continuous composite sinusoidal waveform,Vo. It will have two frequencies f1 and f2 with voltage amplitudes A1 and A2. This should have input terminals to input the numerical values of A1, A2, f1 and f2, and an output chart that displays the waveform Vo. I've created the input numerical value and the waveform but I am not sure how to make it as a continuous composite sinusoidal waveform as the picture below. Would I have to use the sine waveform and how would I connect it?

Use A1 = 1, A2 = 2, f1 = 1 Hz, and f2 = 2 Hz.

Help please and thank you!

irenedgl_0-1664138608530.png

0 Kudos
Message 1 of 4
(1,857 Views)

You can do this with functions from the Waveform palette.

 

  1. Generate a waveform for A1 and F1 for 1 cycle or equivalent of 1 cycle duration
  2. Generate a waveform for A2 and F2 for 1 cycle or equivalent of 1 cycle duration
  3. Concatenate waveforms from #1 and #2 to create the composite waveform
  4. In a loop keep concatenating the waveform from #3 for the total duration required

You will find all functions required to accomplish the above hints from the waveform palette

santo_13_0-1664146028615.png

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 2 of 4
(1,833 Views)

LabVIEW is (literally) an "Engineering Workbench" (that's the "EW" in "LabVIEW").  If (as an engineer) you want to generate a Waveform, you'd do it digitally, which means that you'll be specifying a waveform by specifying its value at equally-spaced intervals of time (called "dt" in LabVIEW's Waveform terminology).

 

If you are already familiar with (and have used) the Waveform type in LabVIEW, then @santo_13's method should work for you.  Of course, you'll need to make sure that both Waveform A1 and A2 have the same value of "dt" (which might or might not fit your Problem statement).  Note that you'd use the Append Waveform function in the "Analog Wfm" sub-Palette to make a single A1+A2 "wave", then you can simply "play" that Waveform over and over as much as you want.

 

Otherwise, you should be able to find some tutorial material on LabVIEW's Waveform type.  Once you get the idea that a Waveform is simply a LabVIEW-defined cluster with three (four, actually) major components, T0, a TimeStamp when the Waveform starts (which is probably unimportant to you), "dt", the Sampling Interval, and Y, the points in a single cycle, you can even build the Waveform yourself.  Decide on what Period you want for A1 + A2 (let's call this "Period").  Decide on the number of Samples you want in this period (let's call this "N").  Define "dt" as Period / N.  Now generate one A1+A2 Waveform as follows:

  • You'll be generating an Array (call it "Y") of size N.  Do this with a For Loop, with N wired to the For Loop's "N" input.
  • Compute t = i * dt (where i is the For Loop index.
  • If t < A1 Period,
    • Generate Y(i) as A1 Amplitude * sin (2 pi t /(A1 Period))
  • otherwise
    • Generate Y(i) as A2 Amplitude * sin (2 pi (t - A1 Period) / (A2 Period))
  • You now have the elements of a Waveform Cluster.  Set T0 to 0, dt to dt, and Y to Y.

[It is possible I missed a step somewhere, but if you code this up and then plot the Waveform on a Chart, it should be trivial to see (and fix) the bug.  That's one of the really nice things about LabVIEW, how easy it is to write little pieces of code and check that they really work.]

 

Bob Schor

 

P.S. -- just did what I suggested -- got what I expected.

0 Kudos
Message 3 of 4
(1,752 Views)

@Bob's method will give you better performance than mine as you don't continuously build arrays.

 

Comparatively, both methods take around the same time to code (if you are familiar with the functions).

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 4 of 4
(1,745 Views)