LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Derivative to Instaneous Frequency

Solved!
Go to solution

Hi,

 

What kind of frequency range are you looking for with the sine wave?  This might be possible if you generate an output sine wave at a much higher sample rate than your square wave, depending on how much resolution you want.  For example, you could map each point by point derivative from the square wave to 1000 points on a sine wave, and combine them all together.  You might need some kind of windowing at the edges to get the resulting waves to line up evenly. 

 

 

 

Regards,

Jeremy_B

Applications Engineer
National Instruments
0 Kudos
Message 11 of 21
(1,580 Views)

The square wave is running at 1 kHz and the sine is running near 5 kHz.

 

How would I map the point by point derivative to the sine wave and combine them? Also what kind of windowing are you refering to?

 

Forgive my ignorance.

0 Kudos
Message 12 of 21
(1,568 Views)

We are still having trouble understanding exactly what you are trying to do.

 

I think part of your problem is that the signals you are using in your program have different sampling rates or different numbers of samples. All of the simple means of combining arrays, waveforms, or dynamic data in LV work with identical sampling rates and sample counts.

 

Do you have a mathematical formula describing how the two signals are to be combined?  If we go back to the fundamentals, we can probably find a way to do what you want.

 

I could not run the VI you posted because I  do not have the hardware. Were the datafiles you posted earlier derived from this same process?  Can they be used to test your "combining"?

 

Lynn 

0 Kudos
Message 13 of 21
(1,555 Views)

Hi,

 

What I meant was that you could map each derivative point to a set of samples of a generated sine wave.  For example for each point, generate 100 samples of a sine wave at a frequency based on the current derivative of your square wave.  Combine each set together, and there is your sine wave.

 

A windowing function is used most often with FFTs. An FFT acts as if the data set you are analyzing is periodic, so if the first and last samples don't line up, you get a discontinuity that will result in extraneous high frequencies being present in the FFT, even though they aren't present in the actual signal.  If you follow the scheme I detailed above, you could end up with the same problem, since each successive set of sine waves may not line up evenly with the next set.  Applying a windowing function such as a Hamming window is a good way to mitigate this effect.  The goal of a good windowing function is to line up the first and last samples of a signal without significantly changing the frequency content of the original signal.

Message Edited by Jeremy_B on 11-11-2008 10:09 AM
Regards,

Jeremy_B

Applications Engineer
National Instruments
0 Kudos
Message 14 of 21
(1,549 Views)

Lynn,

 

If h(t) is the square wave, or power enevlope, as described in the squarewave.lvm I gave you and sine(t) is a simple sine wave, then the resultant wave I want out is

 

=sine({f+dh/dt}*t)*h(t)                              where f is approximately 5 kHz

 

Currently the sampling rates and number of samples are the same for both the sine and square waves, as require to modulate them {sine(ft)*h(t)}.

 

Yes, you should be able to use the  unfilteredsquarewave.lvm file I gave as to replace the DAQ.

 

Jeremy, 

 

That makes sense about the Hamming filter. I thought maybe when you refer to windows you were discussing some timing structure. I guess the problem I don't understand is that in order to modulate the two wave, I must have the same number of data points. So if I oversample the sine wave, how can I modulate the two waves?

0 Kudos
Message 15 of 21
(1,541 Views)
Solution
Accepted by boomchild06

I modified your VI to more directly implement the formula you posted above.

 

I took out anything that I did not use to avoid confusion.  I put a Read from Spreadsheet file VI to use the data sets you posted earlier in the thread.

 

This calculates the derivative using the newer dx/dt VI. It then calculates sin({f+dh/dt}*i*dt + phase) and creates an array.  A switch allows the user to choose FM only or simultaneous AM and FM.  This was done because I was looking at the FM only during debugging.  An event structure was added so that the loop does not spin rapidly calculating the same thing repeatedly.  A side effect is that one of the controls needs to be changed after opening the file to see the first result.  I did not convert the arrays back to the Waveform data type, so the scaling of the graphs may be off.  I added a modulation scale multiplier because the dh/dt magnitude is dependent on the value of dt.

 

Lynn 

0 Kudos
Message 16 of 21
(1,529 Views)
I'm going to look it over and let you know how it works. Thank you.
0 Kudos
Message 17 of 21
(1,522 Views)
Do you need to generate the two waves (square and resulting sine wave) on an analog output?  If that is the case, then you are correct, they will need to be at the same sample rate, so you would need to upsample the square wave to match the sine wave.  There are resampling VIs in the signal processing palette, under the signal operation sub-palette.
Regards,

Jeremy_B

Applications Engineer
National Instruments
0 Kudos
Message 18 of 21
(1,519 Views)

Lynn,

 

After an intial testing of the solution you posted, it did what I wanted. However after further examination, I ran into a kink.

 

It seems to add the summation of all the derivative values to the frequency, rather than the value of the instananeous derivative. I took me a while to notice this because the wave I was mainly measuring was the first modulation area of the "modulated" graph, where the effects of the summation are miniscule. However moving on to subsquent modulation areas, showed the instaneous frequency rapidly growing because the value for the derivative was accumulating.

 

Is there a way to work around this where it is adding the instantaneous derivative rather than the summation?

 

Thanks

 

 

P.S. Other than this the vi works well. Thank you.

0 Kudos
Message 19 of 21
(1,448 Views)

I am not sure I understand what you are asking.

 

The VI I posted adds the derivative to the frequency.  By definition the derivative is instantaneous.

 

Does the "modulated" signal you are trying to use include an integration of some constant (even an offset) which, when differentiated, recovers that constant and gets added to the frequency?

 

Can you point out an example in one of the datasets you posted earlier or post one which shows the effect? 

 

Lynn 

0 Kudos
Message 20 of 21
(1,428 Views)