Daqarta for DOS Contents



Free Registration

Contact Us
Daqarta for DOS
Data AcQuisition And Real-Time Analysis
Shareware for Legacy Systems
(Use Daqarta for Windows with modern systems)

From the Daqarta for DOS Help system:



The FFT function treats the N samples that it receives as though they formed the basic unit of a repetitive waveform: It assumes that if we took more samples they would repeat exactly, with the (N + 1) sample being identical to the first sample, and so on. In other words, we should be able to reproduce that repetitive input by playing back our N samples, looping from the last sample back to the first, over and over continuously. In reality, this is only true if the input is a repeating waveform and its basic frequency is an exact multiple of the sample rate divided by N.

Real signals are rarely that cooperative. The usual case is that if our N samples start at one point in a cycle, they end at some other point, so that if we really did play these back in a loop we would get a discontinuity or "glitch" between the last sample and the first. If the original signal was a pure sine wave, our replica would have a buzz added to it, and the bigger the discontinuity, the louder the buzz would sound. The buzz would have a frequency of the sample rate divided by N, which would not be a harmonic of the input wave and would thus sound very bad.

And this is exactly what the FFT spectrum shows. Try this with the Virtual Source: Set a sine wave to show an exact integer number of cycles on the waveform display, and flip to the FFT display. You will see a single line at the sine wave frequency if you tuned things just right. Flip to Y-log to get a better view of the lower levels.

Now adjust the frequency slowly and watch the leakage "skirts" of the peak broaden as you move farther from the optimum value, then drop back down again as you get nearer to the next integer number of cycles... which you can verify by flipping back to see the waveform. Set the frequency so that the waveform ends on a positive or negative peak, and when you flip to the FFT you will find the broad skirts again, indicating lots of energy at frequencies other than the one we set.

Be careful when trying to set an integer number of cycles at high (relative) frequencies. The goal is not to make the last point on the trace line up with the first point, but to make the last point match the one JUST BEFORE the first point. As you get more cycles on the trace, the signal moves farther between samples, so the sample just before the zero-cross may be well below (or above) zero. When in doubt, trust the FFT to show this... when you get the lowest skirts, you are closest to the integer alignment.

The FFT shows us something besides an increase in bogus "skirt" signal when we don't have an integer number of cycles: We have also lost some of the true signal energy from the peak. How can we get an accurate reading of our signal? The obvious and best way is to adjust the sample rate (or the signal itself, if that is an option) to get integer alignment. But with a changing signal, or one that contains more than one component frequency, that may not be possible.

The problem comes from that glitch where the end of the trace should wrap back to the start. Hmmmm... what if we could somehow taper both ends of the set of samples down to zero, so they always lined up perfectly if we looped them? What would that do to the spectrum?

Consider what would happen if the signal was amplitude modulated (AM) with a sinusoid whose period exactly matched our N-points sampling interval. The signal would smoothly go from zero to full-strength and back to zero, once per cycle. Those already familiar with AM may recall that the spectrum has two sidebands, one above and one below the carrier frequency, separated from it by the modulating frequency. This tells us what to expect from our tapered-samples spectrum:

In our case, the modulating frequency is one cycle per N points, which is the line spacing of the FFT output. So instead of just the spectral line at our desired "carrier" frequency, we will see that one, plus one on each side of it. Our ability to resolve the true frequency is thus reduced, but if we can get rid of the large leakage skirts without needing to fiddle with the sample frequency, this might be a bargain.

Let's use the Virtual Source to see what happens: Set Wave to Sine and Level to half of full scale. With an X-axis sampling frequency of 20 kHz and N = 512, one cycle per N samples is 20000 / 512 or 39.0625 Hz. Set AM Hz to 39 and AM Pct to 100. The waveform should look very bouncy, since it is still being triggered on the "carrier", and the AM wave is not synchronized to it.

Go to the Trigger control menu and set Source to AM. You'll see a flat-nosed whale whose nose starts at half of full scale, back rises to full scale and swoops down to zero, and tail rises back to half-scale... we are triggering on the modulator, and modulator zero is the original half-scale signal level. Instead, set the trigger Level to minus full scale: The negative modulator peak is where the output goes to zero, so now our trace starts at zero, and yes, ends at zero as well... just what we wanted.

Now flip FFT on and look at the spectrum: A slightly fatter peak with skirts almost as low as when we had the sine wave set for exact integer cycles. Change the frequency and the peak moves to match, changing only slightly in level with nothing much happening to the skirts. Problem solved!

The formal name for this process is "windowing", and the "window function" is the shape that we multiply the data by. In our AM case this is a sinusoid, and with our trigger arrangement it is really a cosine wave raised up so the negative peaks are at zero. For true AM, the positive peaks are at twice the carrier level, but this would force us to always limit our input level to half of full scale. Instead, we can make our raised cosine half as large, so the positive peak goes only to unity. Now when we multiply our data samples by this window, we will never need to worry about overloading anything, and we can just multiply the final spectrum magnitudes by two to correct for this.

This raised cosine is called a Hanning window, but there are many more shapes in use. Most are based on variants of this, usually with an additional cosine component at twice the frequency. Which one is the best?

As it turns out, none of the other windows is really all that much better than our first try, the Hanning window. There are tradeoffs, however, and for critical work it could make a difference. Ideally, we would like to have no leakage skirts at all, but the best we can do is control their shape.

The Hamming window (not to be confused with Hanning!) gives a narrower spectral peak than the Hanning at higher levels, in exchange for flaring skirts farther down. The Blackman, and its derivatives Blackman Exact and Blackman-Harris, give a wider peak than the Hanning but with even lower skirts. A Flat Top gives the widest peak, with skirts about like Hamming, but the top of the peak is flattest for the most accurate level readings with changing frequencies.

To familiarize yourself with these different windows, use the Virtual Source with AM Pct set to zero. (Set the trigger source back to Main and the trigger level to zero if they are still set from the above AM experiment.) Set Freq to give the widest spectral skirts in Y-log FFT mode, then activate the window (Windo) with the W-key. Use CTRL-W to bring up the Window control menu, and select each different window type in turn as you watch the shape of the spectrum. Change the frequency around and toggle Windo off and on, and try toggling Trig off and on as well to get the big picture.

You can see the actual shape of the window function itself by flipping to the waveform display while the window menu is active. The shape will be shown superimposed over the waveform. Note that the signal waveform is shown unwindowed unless you specifically activate Windo in the waveform mode... even if it was previously active in FFT mode. Daqarta keeps these states separate between modes.

OK, so now that we see how wonderful windows are, we can just pick a decent window type and always leave it on in FFT mode, right? WRONG! There are other aspects to windowing that we have not considered: The effect on transient signals, and on broadband signals like noise.


Suppose our signal consisted of a transient spike that decayed away sinusoidally over many samples... perhaps the acoustic response of a bell or plucked string, or the acceleration of a mechanical structure after a test impact. Clearly we would have a problem if we windowed this data, since if the spike is at the start (the usual case) we might window it away completely!


Each spectral line in the FFT represents the output of a filter... 256 of them for a 512 point FFT. Even though we see the output as a single narrow line, each filter actually accepts frequencies over a finite bandwidth that overlaps with adjacent filters. For a broadband noise signal, with equal energy at all frequencies, adjacent filters exactly complement each other's responses ("Nice looking skirt!" "Thanks, yours too!") so that the output of each is correct for total power when no window is used.

Unfortunately, the use of a window function has the effect of widening each filter so that it sees too much adjacent energy. Its output for broadband inputs is thus larger than it should be. In the case of the Hanning window, for example, the noise bandwidth of each filter is 50% wider than normal, so its power output is 1.5 times larger, or 1.76 dB greater.

For this reason it is necessary to use a special bandwidth correction factor when measuring broadband responses with a window. Of course, if the signal is only broadband, then there is no need for a window in the first place, because there are no regular waveforms to be off-integer.


Windowing presents a dilemma for mixed signals, which are really the norm... after all, there is always some noise present, even if we don't want it. How do we read both the sinusoidal components and the background noise? If the source frequency is off-integer, without windowing there will be large leakage skirts which may completely swamp any low level background noise. But even with windowing active the window itself may have skirt energy in the noise area.

The best way to handle this situation is to adjust the source frequency and/or sample rate to get an integer relation. If this is not possible, you must make certain that the window skirts are not obscuring the noise you want to measure.

Be sure to turn off the bandwidth correction factor when you make readings of the spectral peaks, and turn it back on when you read the broadband areas.


The unshifted W-key toggles a window function that is applied to the raw data. Separate states are maintained for waveform and FFT modes, so you can apply the window while viewing the spectrum, but it won't be applied to the waveform display if you flip back to that. However, you can apply the window to the waveform if you want to see the same data that a windowed FFT would get as its input. This can be useful not only to get a feel for how windows work, but also to check that no important aspect near the beginning or end of of a waveform is being overly suppressed by the window.

The spectrum is unaffected by whether or not Windo is active in the waveform mode... it never gets "applied twice" when set in both modes.

When Windo is inactive, the title line above the trace will show Rect to indicate that a Rectangular window is applied to the data... the effective window function is unity for all data points, so the raw data just passes right through. When Windo is active, the title line will show the window type, such as Hann or Hamm, which was previously selected by the Window control menu.


This CTRL-W menu allows selection of a window function type, and allows viewing its shape superimposed on the waveform trace. It also allows a bandwidth correction factor to be applied to the FFT scaling results.


The window type controls the shape of the window function applied to the raw data. The proper name of each type is shown here, followed by the shortened version used to fit in the narrow menu space, then if needed by the 4-character abbreviation used in the title line when the window is active.

Hanning (Hann):

Good resolution of spectral peaks and good rejection of sidelobe leakage "skirts" at low levels for input signals that don't have an integer number of cycles in the N-points data set. A good choice for most uses.

Hamming (Hamm):

Finer resolution of spectral peaks than Hanning, but poorer rejection of sidelobe skirts at low levels.

Blackman (Blkman, Bkmn):

Peak resolution is not as fine as Hanning, but the response shape flares out less at lower levels and rejection of sidelobes is better.

Blackman Exact (Bkm-Ex, BkmX)

Blackman-Harris (Bkm-Hr, BkHr):

Blackman Exact and Blackman-Harris are fairly similar to each other, but are both included for compatibility with existing data sets or preferences. The peak resolution is similar to the regular Blackman, but the response shape flares out even less at lower levels.

Flat-Top (FlaTop, Fltp):

This has the broadest peak resolution, but the best amplitude accuracy of any window here. It has a fairly straight response shape at high and middle levels, then flares out like the Hamming at lower levels with similarly poor sidelobe rejection. Use this to measure spectral peaks where interference from adjacent frequencies is not a problem.

One application for a Flat-Top window is where you are trying to measure the frequency response of a system using Peak mode spectral averaging with a frequency sweep. Because the input frequency is constantly changing, the poor amplitude accuracy of other window types causes a jagged or rippled frequency response: Some frequencies fall near a spectral line and give accurate, narrow peaks; others fall midway between lines and give lower, broader peaks. The Flat-Top has broad peaks for all inputs, and little variation in amplitude.


When this is set to 'On' it activates a special correction factor that accounts for the wider bandwidth overlap of each FFT line when a window is active. Use this only when you want to find the total energy or power with broadband sources such as noise or closely-packed harmonics. The peak amplitudes will be in error, but the energy or power will be correct. You will probably only need this when measuring the broadband portions of mixed narrow and broadband signals, since if the overall signal is broadband, you don't need any window at all.


This just allows the shape of the window to be superimposed over the waveform display. It is left On by default, but you may want to turn it off for special operations like screen printing or to reduce clutter in busy traces.


Questions? Comments? Contact us!

We respond to ALL inquiries, typically within 24 hrs.
25 Years of Innovative Instrumentation
© Copyright 1999 - 2006 by Interstellar Research