LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

fourier transform of step function

Attached are my screenshots of employing 2 different FFT VI's (1 from the signal processing toolkit & the other from waveform measurement).  I fed into the input a step function & the resulting output you see in the screenshot.  By the way, the 1st element of the array is ZERO & all the subsequent elements are = 1.0.  As I change the dT to construct the waveform for the WAVEFORM FFT the 1st element magnitude changes accordingly which you would expect since the pulse width of the dirac delta is affected by this.  Despite any change in dT the imaginary parts essentially remain unchanged & essentially = 0.  I also included the analytical expression of the transform which clearly indicates the imaginary component is proportional to 1/freq.

 

The results on the screenshot do not reflect this behavior, why???  In fact the VI from the signal processing toolkit says the imaginary component is ALWAYS ZERO.

 

Do I need to scale the outputs by df to obtain this dependence & if so why is it not done within the VI's themselves?

 

This behavior is causing me problems in correctly analyzing the dynamic data of some servo-motors to which I apply a step voltage input.  Is FFT not the way to perform this analysis?  Should I actually be utilizing the formal definition of the the Fourier transform itself & if so is there such a VI that does this because everything I saw in the EXAMPLES finder employed FFT's exclusively?

 

 

Download All
0 Kudos
Message 1 of 21
(5,965 Views)
I don't know if this helps, but I ran into problems with the point-by-point FFT VI on one of my apps.  My test input data was a sine wave with a known frequency, so I couldn't figure out why the amplitude spectrum didn't show the peak where I knew it had to be.  I figured out that if I centered my data around 0 (so I had + and - amplitudes), the problem went away.  When I saw your signal was 0 to 1, I wondered if that could be the issue...Maybe try -1 to 1 and see what happens?
0 Kudos
Message 2 of 21
(5,952 Views)

Are you applying any window function. I guess your problem is related to that. Try to use the rectangle window. You could also see what is happening inside the FFT Spectrum (Real-Im) VI . Use a probes and track the result. A quite annoying factor is that you can not use the "save as" option with this VI, or its sub VIs. So you have to do a select all in the diagram then copy everything to a new blank VI. Then you rebuild the connector block. Post again if you have problems

 



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 3 of 21
(5,927 Views)
As far as windowing concerns I tried all of the options to no avail.  Regarding the suggestion of adjusting the amplitude to go from -1 to 1 instead of 0 to 1 I do not see how that will help but I will try it since it is an easy adjustment but by know means is a step function symmetric about the time or amplitude axis in reality.
0 Kudos
Message 4 of 21
(5,903 Views)

OK, I created my own VI based on the formal definition of the Fourier Integral transform & compared the output against the output of the FFT VI's for the input of a step function.  The output of my VI concurs with the analytical expression for the transform of the unit step function; whereas, the FFT's do not.

 

I attached my VI as version 8.5 for those who might not have 8.6 & I included the analytical expression of the transform.  Anyone have any clues as to the problem with the FFT's or am I misusing them?

Download All
0 Kudos
Message 5 of 21
(5,894 Views)
The FFT package in LV appears to be operating exactly as it should and giving the exact results you should expect.  You are confusing the Fourier Transform of a continuous function which extends to infinite time with a Finite (or Discrete) Fourier transform.  There is a correspondence, but you have to carefully consider the effects of two operations in creating your finite approximation, sampling and the windowing in time.   Take your theoretical input function and multiply it by a train of evenly spaced impulses, that is sampling and the (continuous) FT of a product is a convolution.   Work through the details and you'll see that is how you get evenly spaced frequencies in the finite FT.  The windowing operation is a little more complex, but the simplest case is a flat-top window.  The FT of the flat-top window is a Sinc function which you have to convolve with the FT of your input.  Consult your textbook on DSP for all of the details.
0 Kudos
Message 6 of 21
(5,867 Views)
Darin, it is good to hear that the FFT's are performing correctly & it is my use or lack of understanding of the FFT's is the source of the problem.  I found an example VI named "FFT & Power Spectrum Units".  I presume this might be informative for me.  What I found in running that VI is that both the magnitudes & freq peak locations are affected by my selections of sampling freq & the size of the array.  I presume that since the stimulus is a sinusoid of presecribed freq & amplitude I should know the exact location of the peaks & what the magnitudes are.  So I play with my sampling to get the correct freq. plot.  Do you know of any effective NI tutorials on this subject matter that might bring me up to speed moreso than wading through a textbook?
0 Kudos
Message 7 of 21
(5,849 Views)

I am a fan of the NI examples, but I can't say I have tried out any of the FFT ones.  In this case I think you are already performing the necessary steps.  You are generating an input waveform and passing it into the FFT.  It is up to you, but in my opinion, if you are looking to use these VIs as black boxes then the examples might help.  If you really want to understand what is going on I think you need to read up on the math behind the FFT, not the algorithm (unless you are really interested), but of discrete Fourier transforms.  If you are "wading" through a textbook, then I think you have picked the wrong one.  One problem you are up against is different normalization conventions, LV picks one, Mathematica has another, your textbook may have yet another one.  You should be able to read the context help in LV and know which one they have chosen.  Deciding where to put N in the DFT is like deciding where to put Pi in the continuous FT.

 

Another thing you will learn in the textbook is the phenomenon of bin leakage.  When the sampling frequency is commensurate with the signal frequency, all of the power ends up in a single bin and you wind up with what you call the "correct" freq. plot.  When you change the sampling frequency, power spills into adjacent (and sometimes many adjacent) bins.   This can all be described (look for a section on windowing), and as you said, you should know the exact location of the peaks.  It is just that these locations are not always as simple as you imagine.

 

If I find them on Monday I'll post some VIs where I did some experimenting along these lines, otherwise, I'll try to answer a question or two for you.  Keep plugging away.

  

0 Kudos
Message 8 of 21
(5,842 Views)

Darin,

To summarize my observations of the "FFT & Power Spectrum Units" example VI to further aid in my comprehension of the DFT vs continuous transform is that I presume windowing refers to the time period which the sampling of the continuous waveform spans.  This time period is = to the ratio of the array size & the sampling frequency.  So if I have 100 samples @ 100 Hz I am observing the continuous waveform over a 1 second timeframe which would be acceptable for waveforms say 10 Hz or higher.  If my waveform is @ 1 Hz or lower I need to observe over a longer time period?

 

Now having said that I am bringing every bit of knowledge I have of transforming singnals into the freq domain that I have, the continuous waveform vs the window type each have their own transform?  The result of convolving the 2 is the product of the 2 in the freq domain?  So if my window is rectangular & as you stated that is the sinc function in the freq domain I will observe absolute 0's in the resulting output of the FFT's on a periodic basis based on the width of my window?  This seems to be what I am observing because I get 0+0j in the array output but what is a bit confusing is that if my continuous waveform is a sinusoid that should be 0 as well everywhere but @ the harmonic freq.  When I inspect the array output I see very small values 10^-15 for both the REAL & COMPLEX components everywhere except @ the ZEROS I mentioned earlier & the hamonic freq.  Is this due to the fact that the stimulus sinusoid is not actually analog & is being represented discretely as well?  The end result is that these incremental steps of the stimulus are actually stair steps induce noise @ all freq's; hence, the ZEROS only occur @ the sinc function ZEROS?

 

Moreover, the magnitude of the peaks are effected by the length of the array since more multiplication & summation operations are being performed for larger arrays?  The sampling freq effects the location of the peaks due to its effect on freq resolution?

 

Alot of ??'s but my verbalizing my ??'s help me digest the concept.

 

0 Kudos
Message 9 of 21
(5,828 Views)

Sorry my suggestion didn't help solve your problem.  But just to clarify... I know the -1 to 1 thing SHOULDN'T work, but for some reason that was the only way I could get the correct amplitude spectrum out of the function.  The following images show the behavior I was talking about.  I just took NI's realtime amplitude spectrum example and added a constant to the input sinewave to create an offset.  You can see the behavior in the front panel is quite different...The peak at ~0.3 is present in both cases, but when I add the offset I get a bogus peak at the low end. 

 

Jason

Download All
0 Kudos
Message 10 of 21
(5,827 Views)