LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Signal generation from number of harmonics

Hi,

i'm Paola Tavernise

i'm new to Labview. I'd like to plot sum of i-th harmonics, where i stands for number of harmonics. I've attached a picture where there're the plots i'd like to see on output waveform. On output waveform i'd like to see the harmonics and the sum of the first i-th harmonics too.

 

Any help would be kindly appreciated.

 

 

Thank you so much for helping me.

0 Kudos
Message 21 of 50
(1,368 Views)

Hi, Paola.

 

How would you do this with pencil and paper?  You didn't say whether you want this waveform to be finite or infinite, but let's assume infinite (i.e. "generate the waveforms until I tell you to stop").

 

I'm sure you realize that you are generating a series of points at discrete time intervals.  So one of the things you need to define is the time interval, let's call it "dt".  Your picture shows a method for describing a sinusoid, i.e. ak * sin(twopi * f * k * t), where "k" represents the harmonic, "ak" is the amplitude of that harmonic, and "f" is the fundamental (fixed) frequency.

 

So what is "t", and how is it related to "dt"?  How would you do this with pencil and paper?  What if I asked what the first point would be?  the second point?  the nth point?

 

Do you see a way to generalize this and generate "as many points as you want until I say to stop"?  Similarly, do you see a way to generate the points for all of the harmonics at a particular time "t" at the same time, making it easy to sum them to get the sum of the harmonics?

 

Once you understand how to do the problem with pencil and paper, try to translate this into LabVIEW code.  Don't worry at first about plotting anything (though that shouldn't be too difficult).  If you get stuck, come back to the Forum and post your code (do not attach a picture, but attach your .VI file so we can really see what you are doing and can make suggestions based on the Version of LabVIEW you are using and your level of sophistication).

 

Bob Schor

0 Kudos
Message 22 of 50
(1,327 Views)

This is the VI i've just created but i'd like to see the sum of this harmonics so i suppose i need to use shift register. How can i do?Please help me.

 

Thank you so much

0 Kudos
Message 23 of 50
(1,318 Views)

Hi ptavernise,

 

You need to add your waveforms.

That's all I can say without having LabVIEW at hand...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 24 of 50
(1,221 Views)

please send me modified VI so at least i can better understand the problem using context help for every block you insert in the modified VI.

 

Thank you so much.

 

I hope you can help me!!!!

0 Kudos
Message 25 of 50
(1,218 Views)

Since you are struggling to learn LabVIEW, I was hoping to "teach" you to "solve this problem by hand", rather than use the already-implemented LabVIEW "signal generation VIs" to do all of the "thinking" for you.

 

As you've seen, it is great at generating a waveform of a finite length, which might be what you want.  However, it doesn't demonstrate much understanding of How to Do Things in LabVIEW (you apparently don't appreciate "neat" Block Diagrams, and don't use the Clean Up tool, the "Broom" icon on the Block Diagram, which would turn your code into this:)

Signal Generation.pngWhat you now have is an array of Waveforms.  What you want is another Waveform that is the "sum" of the previous Waveforms.  Unfortunately, Waveforms are a LabVIEW data structure that you can't simply "add" together, so you'll have to do some "research" (or "learning") to learn how to do this.

 

Or you can go back to my previous post and generate the signals yourself, one point at a time.  When you have the N points representing the value of the N harmonics at time "t" all in an array, it is really simple to add those array elements together and get the sum of those harmonics (there's a convenient Function on the Numeric Palette that adds Array Elements together).

 

Bob Schor

 

0 Kudos
Message 26 of 50
(1,296 Views)

@ptavernise2345 wrote:

 

I hope you can help me!!!!


I hope you are willing to "help yourself" by trying to solve your own homework assignment.  Note that it is usually OK to consult with your fellow students, and is certainly OK to ask your professor.

 

Bob Schor

0 Kudos
Message 27 of 50
(1,212 Views)

I have to use a shift register?How must i do?

0 Kudos
Message 28 of 50
(1,207 Views)

If you could add Waveforms together (which you should have found you cannot), you could (in principle) use a Shift Register to hold the sum, then add the Waveforms, one at a time, to this Sum until they were all summed.  To understand how this works, solve the following simpler problem -- using a For Loop, create an Array of numbers from 0 to 9 (I could have chosen 1 .. 10, but I wanted to make this as simple as possible).  You should be able to do this with only a For loop, no other functions.

 

Now that you have an array of numbers coming out of your For loop, write another piece of code (I'm not going to tell you how, but will say it should include a For loop and a Shift Register) that gives you the sum of the 10 numbers (check that you get 45 as the answer).  If you can't do this, you really need to go back to the LabVIEW Basics and learn about Shift Registers.

 

Bob Schor

0 Kudos
Message 29 of 50
(1,203 Views)

You seem to have several posts for exactly the same problem.  No wonder you are confused!  I just answered a question from you about Shift Registers, but in this string, you aren't asking about Shift Registers (and now I'm confused ...).

 

As I noted in that other post, you can't (directly) add Waveforms.  My earlier advice was to abandon the "canned LabVIEW" solution using their Signal Generator function and "write your own" (both because it is easy to do, but will also teach you something about loops, arrays, etc., and will leave you with a data structure that is almost trivial to sum).  Just for fun, I took the little Snippet I created from your code (after I used Diagram Cleanup), added a few loops and things, and got the following graph for Frequency = 1 and Harmonics = 5:

Sum of Sines.png

The rest of the Block Diagram is left as "an exercise for the Reader".  It took me 7 LabVIEW "constructs" (i.e. Structures or Functions, 8 if you count a Constant) ...

 

Bob Schor

0 Kudos
Message 30 of 50
(1,285 Views)