DSPRelated.com
Forums

Usage of windowing for FFT order analysis

Started by MedievalMan October 1, 2008
Hi;

I have an algorithm in VBA that:

-takes the sampled (500-1000 Hz) Torque signal, and splits it up into
sections that correspond to each revolution of the machine.

- For each revolution of torque data, I interpolate the data to fit a
power of 2 samples for the FFT algorithm.

- I take the FFT of each revolution of torque data, and then chop all but
the 1st 4 orders of the spectrum.

- I then take the IFFT to obtain the reconstructed torque signal (1st 4
orders only).

-The purpose of this routine is to determine the maximum variation in the
reconstructed torque signal (called brake torque variation) for each
revolution of the machine.

This has worked well many times in the past, but recently I discovered
sets of data which cause the "spectral leakage" problem, causing spikes
near the beginning and end of the reconstructed signal.    

If I apply a heavy enough low pass filter to the original torque signal
(before I take the FFT) it also remedies this problem but this is not a
permanent solution (as heavy low pass filtering of the data skews the
result).

I know proper windowing can remedy this problem, but I am not sure what
windowing strategy to apply for this order analysis/tracking problem.

Any suggestions of what to do or where to look for answers would be much
appreciated.

-Matt


On Oct 1, 4:02&#4294967295;pm, "MedievalMan" <lawsom...@gmail.com> wrote:
> Hi; > > I have an algorithm in VBA that: > > -takes the sampled (500-1000 Hz) Torque signal, and splits it up into > sections that correspond to each revolution of the machine. > > - For each revolution of torque data, I interpolate the data to fit a > power of 2 samples for the FFT algorithm. > > - I take the FFT of each revolution of torque data, and then chop all but > the 1st 4 orders of the spectrum. > > - I then take the IFFT to obtain the reconstructed torque signal (1st 4 > orders only). > > -The purpose of this routine is to determine the maximum variation in the > reconstructed torque signal (called brake torque variation) for each > revolution of the machine. > > This has worked well many times in the past, but recently I discovered > sets of data which cause the "spectral leakage" problem, causing spikes > near the beginning and end of the reconstructed signal. &#4294967295; &#4294967295; > > If I apply a heavy enough low pass filter to the original torque signal > (before I take the FFT) it also remedies this problem but this is not a > permanent solution (as heavy low pass filtering of the data skews the > result). > > I know proper windowing can remedy this problem, but I am not sure what > windowing strategy to apply for this order analysis/tracking problem. > > Any suggestions of what to do or where to look for answers would be much > appreciated. > > -Matt
I think there are some terminology issues here. What do you mean by the "1st 4 orders" of the spectrum? Are you taking the first 4 bins and zeroing the rest? Are you folding the spectrum by four? Spectral leakage isn't used to refer to time-domain reconstruction errors; it refers to the "leakage" of tonal signals into the frequency domain when the signal is truncated to a finite length. Windows can be used to control spectral leakage, yes, but it's not clear that your problem is related to that. Any reference to "chopping" in the frequency domain makes me think that you might just be dealing with time-domain artifacts from applying a filter mask with too sharp of a transition region. It's best to include with requests for help like these a statement of exactly what you're trying to accomplish. You say you're trying to measure the variation between the measured signal and your reconstructed one. What is it exactly that you're trying to do to the signal in the FFT-modify-IFFT chain? Are you trying to suppress some sort of interference, or enhance the signal of interest in some way? Jason
>On Oct 1, 4:02=A0pm, "MedievalMan" <lawsom...@gmail.com> wrote: >> Hi; >> >> I have an algorithm in VBA that: >> >> -takes the sampled (500-1000 Hz) Torque signal, and splits it up into >> sections that correspond to each revolution of the machine. >> >> - For each revolution of torque data, I interpolate the data to fit a >> power of 2 samples for the FFT algorithm. >> >> - I take the FFT of each revolution of torque data, and then chop all
but
>> the 1st 4 orders of the spectrum. >> >> - I then take the IFFT to obtain the reconstructed torque signal (1st
4
>> orders only). >> >> -The purpose of this routine is to determine the maximum variation in
the
>> reconstructed torque signal (called brake torque variation) for each >> revolution of the machine. >> >> This has worked well many times in the past, but recently I discovered >> sets of data which cause the "spectral leakage" problem, causing
spikes
>> near the beginning and end of the reconstructed signal. =A0 =A0 >> >> If I apply a heavy enough low pass filter to the original torque
signal
>> (before I take the FFT) it also remedies this problem but this is not
a
>> permanent solution (as heavy low pass filtering of the data skews the >> result). >> >> I know proper windowing can remedy this problem, but I am not sure
what
>> windowing strategy to apply for this order analysis/tracking problem. >> >> Any suggestions of what to do or where to look for answers would be
much
>> appreciated. >> >> -Matt > >I think there are some terminology issues here. What do you mean by >the "1st 4 orders" of the spectrum? Are you taking the first 4 bins >and zeroing the rest? Are you folding the spectrum by four? Spectral >leakage isn't used to refer to time-domain reconstruction errors; it >refers to the "leakage" of tonal signals into the frequency domain >when the signal is truncated to a finite length. Windows can be used >to control spectral leakage, yes, but it's not clear that your problem >is related to that. Any reference to "chopping" in the frequency >domain makes me think that you might just be dealing with time-domain >artifacts from applying a filter mask with too sharp of a transition >region. > >It's best to include with requests for help like these a statement of >exactly what you're trying to accomplish. You say you're trying to >measure the variation between the measured signal and your >reconstructed one. What is it exactly that you're trying to do to the >signal in the FFT-modify-IFFT chain? Are you trying to suppress some >sort of interference, or enhance the signal of interest in some way? > >Jason >
Hi Jason, Thanks for your help. Yes, I am " taking the first 4 bins and zeroing the rest?". Once I do this, I take the IFFT to reconstruct that signal. The reason I'm doing this is I'm interested in the variation in the signal due to the 1st 4 orders only. I then take the variation (max-min) of the reconstructed signal, that is what I am trying to measure. I'm not trying to enhance or do anything else with the signal. The time domain artifacts occur at the beginning and/or end as spikes, which obviously throws off the result. Thanks again for any help. -Matt
>On Oct 1, 4:02=A0pm, "MedievalMan" <lawsom...@gmail.com> wrote: >> Hi; >> >> I have an algorithm in VBA that: >> >> -takes the sampled (500-1000 Hz) Torque signal, and splits it up into >> sections that correspond to each revolution of the machine. >> >> - For each revolution of torque data, I interpolate the data to fit a >> power of 2 samples for the FFT algorithm. >> >> - I take the FFT of each revolution of torque data, and then chop all
but
>> the 1st 4 orders of the spectrum. >> >> - I then take the IFFT to obtain the reconstructed torque signal (1st
4
>> orders only). >> >> -The purpose of this routine is to determine the maximum variation in
the
>> reconstructed torque signal (called brake torque variation) for each >> revolution of the machine. >> >> This has worked well many times in the past, but recently I discovered >> sets of data which cause the "spectral leakage" problem, causing
spikes
>> near the beginning and end of the reconstructed signal. =A0 =A0 >> >> If I apply a heavy enough low pass filter to the original torque
signal
>> (before I take the FFT) it also remedies this problem but this is not
a
>> permanent solution (as heavy low pass filtering of the data skews the >> result). >> >> I know proper windowing can remedy this problem, but I am not sure
what
>> windowing strategy to apply for this order analysis/tracking problem. >> >> Any suggestions of what to do or where to look for answers would be
much
>> appreciated. >> >> -Matt > >I think there are some terminology issues here. What do you mean by >the "1st 4 orders" of the spectrum? Are you taking the first 4 bins >and zeroing the rest? Are you folding the spectrum by four? Spectral >leakage isn't used to refer to time-domain reconstruction errors; it >refers to the "leakage" of tonal signals into the frequency domain >when the signal is truncated to a finite length. Windows can be used >to control spectral leakage, yes, but it's not clear that your problem >is related to that. Any reference to "chopping" in the frequency >domain makes me think that you might just be dealing with time-domain >artifacts from applying a filter mask with too sharp of a transition >region. > >It's best to include with requests for help like these a statement of >exactly what you're trying to accomplish. You say you're trying to >measure the variation between the measured signal and your >reconstructed one. What is it exactly that you're trying to do to the >signal in the FFT-modify-IFFT chain? Are you trying to suppress some >sort of interference, or enhance the signal of interest in some way? > >Jason >
Note that these "spikes" occur in the reconstructed signal even if I do not chop the spectrum (i.e. leave it intact).
On Oct 1, 6:28&#4294967295;pm, "MedievalMan" <lawsom...@gmail.com> wrote:
> >On Oct 1, 4:02=A0pm, "MedievalMan" <lawsom...@gmail.com> wrote: > >> Hi; > > >> I have an algorithm in VBA that: > > >> -takes the sampled (500-1000 Hz) Torque signal, and splits it up into > >> sections that correspond to each revolution of the machine. > > >> - For each revolution of torque data, I interpolate the data to fit a > >> power of 2 samples for the FFT algorithm. > > >> - I take the FFT of each revolution of torque data, and then chop all > but > >> the 1st 4 orders of the spectrum. > > >> - I then take the IFFT to obtain the reconstructed torque signal (1st > 4 > >> orders only). > > >> -The purpose of this routine is to determine the maximum variation in > the > >> reconstructed torque signal (called brake torque variation) for each > >> revolution of the machine. > > >> This has worked well many times in the past, but recently I discovered > >> sets of data which cause the "spectral leakage" problem, causing > spikes > >> near the beginning and end of the reconstructed signal. =A0 =A0 > > >> If I apply a heavy enough low pass filter to the original torque > signal > >> (before I take the FFT) it also remedies this problem but this is not > a > >> permanent solution (as heavy low pass filtering of the data skews the > >> result). > > >> I know proper windowing can remedy this problem, but I am not sure > what > >> windowing strategy to apply for this order analysis/tracking problem. > > >> Any suggestions of what to do or where to look for answers would be > much > >> appreciated. > > >> -Matt > > >I think there are some terminology issues here. What do you mean by > >the "1st 4 orders" of the spectrum? Are you taking the first 4 bins > >and zeroing the rest? Are you folding the spectrum by four? Spectral > >leakage isn't used to refer to time-domain reconstruction errors; it > >refers to the "leakage" of tonal signals into the frequency domain > >when the signal is truncated to a finite length. Windows can be used > >to control spectral leakage, yes, but it's not clear that your problem > >is related to that. Any reference to "chopping" in the frequency > >domain makes me think that you might just be dealing with time-domain > >artifacts from applying a filter mask with too sharp of a transition > >region. > > >It's best to include with requests for help like these a statement of > >exactly what you're trying to accomplish. You say you're trying to > >measure the variation between the measured signal and your > >reconstructed one. What is it exactly that you're trying to do to the > >signal in the FFT-modify-IFFT chain? Are you trying to suppress some > >sort of interference, or enhance the signal of interest in some way? > > >Jason > > Note that these "spikes" occur in the reconstructed signal even if I do > not chop the spectrum (i.e. leave it intact).
So if you just take your data and pass it through an FFT-IFFT chain, you don't get the original signal back (within the tolerance of your computational error)? If you don't, then you've got a bug in your code somewhere. With that said, zeroing all but a certain subset of bins in the frequency domain is going to cause ringing in the time-domain. Essentially, you're convolving your original signal with a sinc-shaped filter (the time-domain equivalent of the rectangular window), resulting in bad-looking transient behavior in the result. Also, there's another phenomenon that is likely biting you: the FFT-multiply- IFFT approach to convolution implements *circular* convolution, not linear convolution (i.e. FIR filtering). To make sure you get the equivalent of filtering the signal in the time domain, you need to zero-pad the input signal to allow room in the output for the transients that are unavoidable with single-pass FIR filtering. Jason
On 1 Okt, 22:02, "MedievalMan" <lawsom...@gmail.com> wrote:
> Hi; > > I have an algorithm in VBA that: > > -takes the sampled (500-1000 Hz) Torque signal, and splits it up into > sections that correspond to each revolution of the machine. > > - For each revolution of torque data, I interpolate the data to fit a > power of 2 samples for the FFT algorithm. > > - I take the FFT of each revolution of torque data, and then chop all but > the 1st 4 orders of the spectrum. > > - I then take the IFFT to obtain the reconstructed torque signal (1st 4 > orders only).
From other posts in this thread I understand that you do this in order to apply what is essentiially a low-pass filter.
> -The purpose of this routine is to determine the maximum variation in the > reconstructed torque signal (called brake torque variation) for each > revolution of the machine.
OK. Lots of stuff going on in your routine above, which might influence the results, but consitency with experience and historical data might outweigh formal accuracy.
> This has worked well many times in the past, but recently I discovered > sets of data which cause the "spectral leakage" problem, causing spikes > near the beginning and end of the reconstructed signal. &#4294967295; &#4294967295;
Not at all surprising.
> If I apply a heavy enough low pass filter to the original torque signal > (before I take the FFT) it also remedies this problem but this is not a > permanent solution (as heavy low pass filtering of the data skews the > result).
Depending on what you mean by 'skew the result', you might want to test 0-phase filtering instead: Design a low-pass filter (a FIR filter will be most convenient in your case) both-prepend and append zeros to your signal, and apply the 0-phase filter. You will get some initial and end transients, but they will be expected, understood, and whatever else happens in your signal will not be shifted in time. Rune
>On 1 Okt, 22:02, "MedievalMan" <lawsom...@gmail.com> wrote: >> Hi; >> >> I have an algorithm in VBA that: >> >> -takes the sampled (500-1000 Hz) Torque signal, and splits it up into >> sections that correspond to each revolution of the machine. >> >> - For each revolution of torque data, I interpolate the data to fit a >> power of 2 samples for the FFT algorithm. >> >> - I take the FFT of each revolution of torque data, and then chop all
but
>> the 1st 4 orders of the spectrum. >> >> - I then take the IFFT to obtain the reconstructed torque signal (1st
4
>> orders only). > >From other posts in this thread I understand that you do this >in order to apply what is essentiially a low-pass filter. > >> -The purpose of this routine is to determine the maximum variation in
the
>> reconstructed torque signal (called brake torque variation) for each >> revolution of the machine. > >OK. Lots of stuff going on in your routine above, which might >influence the results, but consitency with experience and >historical data might outweigh formal accuracy. > >> This has worked well many times in the past, but recently I discovered >> sets of data which cause the "spectral leakage" problem, causing
spikes
>> near the beginning and end of the reconstructed signal. =A0 =A0 > >Not at all surprising. > >> If I apply a heavy enough low pass filter to the original torque
signal
>> (before I take the FFT) it also remedies this problem but this is not
a
>> permanent solution (as heavy low pass filtering of the data skews the >> result). > >Depending on what you mean by 'skew the result', you might >want to test 0-phase filtering instead: Design a low-pass >filter (a FIR filter will be most convenient in your case) >both-prepend and append zeros to your signal, and apply the >0-phase filter. > >You will get some initial and end transients, but they will >be expected, understood, and whatever else happens in your >signal will not be shifted in time. > >Rune >
Hello again, Thank you for all of your suggestions. And yes, what I am doing is essentially a low pass filter, but since it's applied to 1 revolution of data as the speed of the machine is changing, it's not the same as just taking a low pass filter of the entire signal. Anyway, a related question: If I'm taking each revolution of data of the torque signal, and I want to minimize initial and end transients, how should I "pad" the signal to fit power of 2 samples? Should I linearly interpolate the signal to fit the power of 2 samples, or should I zero pad? I want to minimize initial/end transients as I'm taking measuring the greatest difference (max-min). Thanks again for the help, -Matt