Measuring Frequency Spectrum with an SB16

2004-04-10 by Jouni Verronen


SB_FFTC, 20 kHz FFT spectrum analyzer

SB_FFTC is a general purpose SA using SB16.

There are FFT SA software available in the net already, but most are just toys. So I tried to make a simple but working one taking some features of earlier measurement programs, which I have written for my own use. It has at least good readable scales and selectable window functions to get most of the 16 bits. The program is not crippled in any way. I don't like that practice and doubt that many others do. Just remember your benefactor in case of bigger business.

In addition to AF measurements this low cost SA can replace a quite expensive RF/microwave spectrum analyzer in some cases when used with a simple accessory to mix down an RF signal to AF.

Fig. 1 shows a typical AF measurement with an SB16 and SB_FFTC program. It is an output spectrum of a tube audio amplifier, 6SN6 and 6L6 in line. I made it once of nostalgic reasons and partly also to study somewhat if there is anything in the SE talk going on, but that is another story. Production of these tubes began in thirties. A HP8903B AF generator feeds 1 kHz signal to the amplifier input and the line input of the SB16 is connected over 4 ohm load resistor with a 22k/1k attenuator.

Fig. 1. AF amplifier 6SN6 + 6L6 output spectrum, 1.6 W to 4 ohms

Program features

As seen, the program shows numerically the relative levels of harmonics if peak search function is on. A low level limit and frequency limits can be set to help to get the peaks of interest.

Also total harmonic distortion is calculated if wanted. In that case the generator frequency must be 1 kHz and the frequency limits of included distortion components are the same as in peak search. This screening makes it possible to clip away low frequency power line interference from the calculation.

There seems to be one dB discrepancy between the distortion value and the harmonic levels printed, which is not completely clear, but anyhow the difference is small.

The program can calculate the spectrum with or without averaging. When averaging is on, three last measurements are taken, highest value discarded (a probable noise peak) and an average calculated of the remaining two.

In hold mode the screen is not wiped clean ahead a new measurement. This is useful in frequency response measurements, for example. In hold measurement, if one also wants a list of peaks, averaging must be enabled. This is a program peculiarity.

There are two frequency spans to select, 0...10 kHz or 0...20 kHz.

For those familiar with fast fourier transform and sampling theory:
The sampling rate is 45000 /s and 2048 samples are taken, which makes bin 21.97 Hz. At 10 kHz range one point on VGA screen corresponds 22.2 Hz or roughly one bin.

There are four windowing functions to select from: Flattop, Hann, Blackman-Harris and Nuttal, which differ in level error, mainlobe form and sidelobe levels. Flattop has smallest amplitude error, 0.01 dB, while the others may have one or two dB. (For more information see National Instruments Application Note 041). Nuttal is good in distortion measurements.

Measured peak frequencies are printed with 10 Hz resolution, allthough bin size limits real resolution to 20 Hz or less.

Dynamic range depends on quality of the soundcard, but is probably around 70 db. The theoretical upper limit for 16 bits is 96 db.

More operating details can be found in the program help.

Hardware and system requirements

A mono 16 bit DMA recording is done from the line input of the soundcard. Maximum input level for low distortion is 0.5 Vrms or less, there may be some variation with different soundcards. There is no input attenuator settings for the user.

A special program, sbrecord.exe by Ethan Brodsky, is used for high speed DMA recording. It makes a raw datafile, which is read into sb_fftc.exe, the main program. To make the fast fourier transform from time data to frequency data another special program is used, qfft.exe by David Copley.

I have used a basic SB16 in development. There are many compatible 16 bit soundcards, and I believe Brodsky's DMA routine will work with most of them. One has to try and see. There is no way to use the program with 8 bit soundcards. I have included Brodsky's original material in this package for reference (brodsky.zip).

The basic system requirements are Pentium, VGA, DOS. A 486 may well work but is slow. For not to complicate things unnecessarily the Sound Blaster settings are those given usually as the first choice for the card and they are set in the autoexec.bat as follows:


        SET BLASTER=A220 I5 D1 H5 P330 T6

In this package there are various executives, which continuously communicate using files. It is essential that a ramdisk is used, because a hard disk slows down the speed not to mention the rattle. To set up a 1 M ramdisk there must be in the config.sys for example

        
        device=c:\dos\ramdrive.sys 1024 256 256/E"

Ramdisk path is then given in the program settings and is saved automatically in program exit. Only if datafile sb_fftc1.dat is lost or the program crashes for some reason the path must be given again.

Don't try using under any windows. There is too much overhead.

For an old Pentium sweep time was about 0.8 s.

Copley's original FFT material is also included in this package for reference (copley.zip).

In the program there is not much error handling. If the given ramdisk is not valid, the program hangs. If Ctrl-Break does not bring back the default starting values with C as the ramdisk and harddisk rattling, delete the small datafile sb_fftc1.dat.

In the soundcard line input there is a blocking capacitor for DC and impedance level is of the order of 47 kohms. The ground is connected to PC ground, which is earthed via the third conductor in the power cord, if the mains connection is properly done. A PC/soundcard measurement system is comparable to a mains powered oscilloscope with all its limitations as to off-ground measurements. If PC is not properly grounded, it can turn lethal in case isolation fails in a wrong place in the power supply. That is the same, not depending on what you are using the PC for, but is especially good to remember when connecting anything to it.

As a record only:

All the usual disclaims.. As this is free information and free software, you are as free to make any idiotic things with it loaded in your PC as you like. If you blow up your soundcard or PC or your ass for that matter, it is your fun, I have no part in it.

More

More on audio measurements and performance

On RF measurements using a down converter


back to the FrontPage