LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generation of inclined Sine wave

Hello GerdW and Bob,

 

I am really grateful to your help. I have learnt a lot from your comments.

 

Just to look into another approach, can I use formula waveform.vi to create such signal? 

 

I have equations ready in excel file to plot this.

 

I have attached the screen shots. 

 

Final signal (mold position vs time) seen in screen shot (8) is constructed by using the formula.

 

I think the program can be created using arrays and formula waveform. Or am I wrong? Could you please help me on that?

 

Best Regards,

Muhammad

0 Kudos
Message 21 of 24
(290 Views)

Thank you for the pictures -- it makes it very clear to me what you are trying to do (and seeing the label "Mold decent", which should really be "Mold descent") explains "why" you are creating this waveform.

 

So you have two signals.  One is a straight line where Time goes from 0 to T-End in steps of Delta-t.  You know that the equation for a straight line is y = mx + b (where "x" is really Time, m is the slope, and b is the y intercept, or the value of y when x = 0).

 

The other signal is a sinusoid, W(t) = a + gain (2 pi f t + phase), where W(t) is the "wiggle", a is the DC component when the gain is 0, f is the frequency of the sinusoid in Hz, and phase determines what part of the sinusoid curve you are on at t = 0.

 

If you don't want to use the Waveform formulas on the Waveform Palette, you can certainly write a For Loop that lets you generate an array of numbers for the linear ramp, an array of numbers for the sinusoid, add the two arrays (or add the linear piece + sinusoid piece at each moment of time) and you'll have your Array representing the inclined Sine wave.

 

Don't give up now -- you almost have it ...

 

One final hint if you do want to "build it yourself".  Determine a "sampling frequency".  Let's say 1 kHz.  Determine the duration of your signal.  Let's say 5 seconds.  Then you need to generate 5000 points.  So you want a For Loop with 5000 wired to N.

 

So where do you get the time, "t"?  It is simply the loop index, "i" times the time interval, 1/(1 kHz) = 0.001 (seconds).  If we assume your straight line starts at 0 (b = 0 in the linear formula), then the point corresponding to the linear part is (loop index) * 0.001.  The sinusoid is equally simple, but you need a Sine function.  Look at the Palette on the Block Diagram -- I don't have LabVIEW open right now, but you should see some options in the list below the top part of the Palettes that say "Mathematics", or something like that.  It will have "Elementary Functions", including Sine.  You can right-click the Sine function (when you drag it to the Block Diagram) and view its Help to learn how to use it.

 

Bob Schor

Message 22 of 24
(274 Views)

Hello Bob,

 

Thanks a lot for your detailed explanation. 

 

Another question:

 

I am generating a velocity signal that will move the system. So, by generating the signal, the inclined sine wave will give velocity vs time plot. However, I actually need position vs time data of the system for further analysis from the experiment. What might be an easier way to solve the issue?

 

I know the integration of velocity vs time will give us position vs time. However, the inclined sine wave itself is a plot of velocity vs time. Any idea on that how to solve the dilemma?

 

Best regards,

Muhammad

0 Kudos
Message 23 of 24
(269 Views)

A couple of points.  I thought I understood the meaning of the waveform you were generating, but now you say it is a plot of velocity, not position.

 

So I'm confused.  Let's leave out the sinusoid, and only consider the "incline" part, namely a straight line increasing as time increases.  Is this really a plot of velocity?  Is the item moving twice as fast at 2 seconds than at 1 second?  And 5 times as fast at 5 seconds?

 

Once you have a plot of the signal, if it is a velocity plot, you can "integrate it" by simply computing a running sum.  Suppose you had an array of 10 points, 0, 1, 2, ... 9.  If you bring it into a For Loop, it will produce an "Indexing" tunnel that will give you the numbers one at a time.  Put a Shift Register on the Tunnel to hold the sum, and initialize it by wiring the number 0 to the left-hand register (wire from the outside, of course).  So inside the For Loop, you add the contents of the Shift Register (the "running sum") with the content of the data point coming in from the indexing tunnel, i.e. the next Array element, and wire the output to both the Shift Register (so you'll have the sum for the next pass) and a separate wire to the right edge of the For Loop, where another indexing tunnel turns it into an Array representing the integral (or "running sum") of the input.  You should see 0, 1, 3, 6, 10, 15, 21, ...

 

Bob Schor

0 Kudos
Message 24 of 24
(254 Views)