No Spectrum Analyser? No Problem!

In the Bad Old Days, a spectrum analyser was a big piece of expensive machinery that you’d have on your bench next to your oscilloscope. And while good ones still cost a ton of money, [rheslip] shows you how to turn your VISA-compatible scope into a decent spectrum analyser for the low, low price of nothing. Watch it in action in the video below the break.

pyvisa-shot0002_tnIf your scope is relatively recent, like this side of the late 1990s, it might support National Instrument’s VISA: virtual instrument software architecture. [rheslip]’s Rigol scope does, and he uses PyVisa, a Python wrapper for the NI-VISA libraries to download the raw samples from the ‘scope and then crunches the FFTs out on his laptop.

There are definitely drawbacks to this method. The sampling depth of the scope is eight bits, which limits his maximum signal-to-noise ratio, and the number-crunching and data transfer are slow, resulting in a 2 Hz refresh rate. But once the data has made it across to his laptop, [rheslip] can run the FFTs at whatever sample length he wants, resulting in very high frequency resolution.

Indeed, we’re thinking that there’s all sorts of custom filters and analysis that one could do with raw access to the oscilloscope’s data. Why haven’t we been doing this all along? Any of you out there have cool VISA tricks that you’d like to share?

You might also be interested in this video where he plots the 0-200MHz spectrum so that he can better isolate his local FM radio stations. Not too shabby for an antenna plugged into an inexpensive scope and some software.

Thanks to [fridgefire] for the tip!

18 thoughts on “No Spectrum Analyser? No Problem!

    1. There’s no reason it couldn’t be included on a digital scope, as it’s just a bit of software. And it should be included.

      But maybe the manufacturer has omitted or limited it in an attempt to get you to buy a more expensive scope, we’ve seen plenty of examples posted here. Or maybe the interface on the scope isn’t designed so well and troublesome to use.

      FFT is really just an example anyway. The real point is showing how to extend scope functionality by using it as a data acquisition device. Once you’re able to get that data out, you can do anything with it you like.

    1. What dynamic range are they getting out of it? A decent RF spectrum analyzer can easily give you a 90dB dynamic range. How many bits of resolution do you get with a general-purpose oscilloscope? Eight, if you are lucky? If you use what Tek calls “ET” on their oscilloscopes on a repetitive waveform, you may get 11 bits. That’s only 66dB, far short of what an RF spectrum analyzer can offer. For communications work, you will need at least 70dB of dynamic range.

      1. Yeah, but for those of us who need something similar to a spectrum analyzer in function but not in price, this is perfect. RTL-SDRs can also be put to use, though their bandwidth is a lot smaller (less than 3 MHz vs 250 MHz or more).
        Not all of us can afford to buy decent test equipment, not even at ham fest pricing. Not all of us need 70dB of dynamic range. If a signal is 20dB above the noise floor, who cares about the other 50 dB? Yes, for precise measurement work, a calibrated analyzer is needed. For the average hobbyist however, this is more than adequate.

      2. I agree with you about dynamic range. I’m used to seeing the noise floor drop by 10 dB when you decrease the resolution bandwidth by a decade. In the example on the video, the noise floor stays about the same when he switches from a bandwidth of about 3 kHz to 190 Hz. So you’re not going to see any signals “down in the dirt” looking at a DSO-based spectrum display.

        But even before you consider dynamic range, what about basic frequency range? One of the big advantages of “bad old days” spectrum analyzers was their bandwidth. In the days when oscilloscopes were limited to about a gigahertz and most lab-grade scopes topped-out somewhere between 100 and 300 MHz, there were spectrum analyzers that could do 20 GHz into the front panel connector, or hundreds of GHz using external mixers. Sure, you can get upwards of 20 GHz oscilloscopes (or “mixed-signal” instruments that are basically digital oscilloscopes with DSPs to do the FFT conversion to frequency domain) today, but they’re not cheap by any standard.

        I laugh when I see “spectrum analyzer” apps for my cell phone – these are strictly audio-frequency range, being based on the audio chip in the phone, and while there’s a use for that, I think there should be different names for 20 kHz and 20 GHz analyzers. The only impressive thing about them is that since they use 16-bit ADCs, they DO get excellent dynamic range.

        And then there are the USB-TV-tuner-based spectrum analyzers that are limited in dynamic range and the lower limit to the frequency range. I’d rather have a 30-year-old REAL spectrum analyzer, thank you.

        1. ” I’d rather have a 30-year-old REAL spectrum analyzer, thank you.”
          So would I, but anything I spend that much money on has to be able to drive my family around inside of it. Beggars can’t be choosers.
          I have a Rigol scope. I have a couple of RTL-SDRs. I have a computer. Having some of the functionality of a spectrum analyzer without costing me any more money than what I’ve already spent is a huge plus in my eyes.
          If you want to call using a scope this way something other than a spectrum analyzer, try “band scope” or “panadapter”. Both of those work if you are too picky to refer to this by its proper name. They all do essentially the same thing, with different levels of precision.

          1. It all depends on your application. Why do you need/want a spectrum analyzer? If you’re an amateur radio operator, you have to be able to ensure that your transmitter isn’t putting out any spurious emissions greater than 43 dB below the carrier. This means having sufficient dynamic range AND being able to see frequencies beyond at least the 5th harmonic of your transmission. If you’ve got a project you’d like to actually produce and sell as a product at some point, you’re going to want to prepare yourself for getting it compliance tested at some point. If you’re looking to see where in the spectrum you can transmit without interfering with others (or having others interfere with your communication), or want to see where there might be some interesting signals in your neighborhood to snoop into, a digital scope and some FFT software may fit the bill perfectly. Heck, if you just want to see how clean an audio amplifier you’re building is, or want to play around with speech recognition, the free spectrum analyzer software for your phone may even be sufficient. I’ve used that app myself for measuring how effective some sound insulation I was installing was.

            I didn’t mean to say that FFT software that processes the samples from a DSO is useless, nor that everybody needs to see the spectrum out there way beyond 200 MHz. I meant that for ME, many of the things being sold as spectrum analyzers don’t come anywhere close to what I mean when I say “spectrum analyzer”.

            So knock yourself out – use the cheap tools where they’ll do the job well enough.

  1. Heh, I’ve got a scope on *that* side of 1990 that can send its samples via RS-232 at allegedly 9600baud, but 4800 is more reliable… 2Hz refresh wouldn’t be a huge stretch even at that baud rate, judging by how few samples it takes. Maybe throw a relay on the “hold” and “plot” buttons… And lo and behold, I actually wrote a labview interface for it years back, merely for the sake of printing screen-captures (which fell by the way-side since the advent of digital-cameras). But whoa, duh, those samples could be *processed* on a computer. Woot!
    Maybe I’ll (continue to) put off that digital-board upgrade project I’ve been mulling over.

  2. I guess I don’t understand this one either.

    The expense of buying a logic analyzer is easily met by passing FCC Part 15 testing. If your product has an AC-DC power supply that you developed on your own you still need to pass FCC Part 15B for conducted and radiated emissions. Conducted emissions testing goes from about 150kHz to 30MHz.

    FCC testing for unintentional radiators is about $1500 per test trial. How many failures can you take before buying the right equipment makes sense?

      1. I don’t know if YOU’ve noticed where you are, but I’ve seen a number of articles around here that involve turning a winning project into a sellable product, and in that context, [evad]’s comment is valid. Of course, if you don’t think you’ll ever come up with an idea that could be made into a product, feel free to ignore things like emissions compliance. The much simpler “does my TV go apeshit when I turn this thing on” test is probably good enough.

  3. You haven’t seen this before because the firmware in my Rigol DS 1102E won’t transfer data fast enough to be useful. I’m told that a newer version will solve this, but Rigol still hasn’t furnished any release notes for the new firmware. I’m an old signal processing and programming guy. I don’t like software updates that don’t have release note. But the math and software are familiar. I’ve done it many times, just not with ‘scope data via the VISA interface.

    If you want wider bandwidth, just put a mixer and DDS LO in front. On the other hand a Rigol SA is ~$1500.

    This is NOT a replacement for an SA, but if all you want to do is check harmonic output on an oscillator or HF ham transmitter, it will do a pretty good job.

    The built in FFT in the Rigol is OK, but the sample depth is much less than what you can get offloading to a PC. It’s all engineering compromises. There is only so much you can do at a $400 price point.

  4. By the way, the VISA software was not invented by NI. It along with SICL was invented by the programmable instruments division of HP, who before their multiple name change also invented the HPIB, who’s also called the GPIB. As they sailed along to become Keysight, they advanced the methods of communicating that way, their VEE software is vastly superior to the stuff written by NI. (Even though NI is staffed by a great bunch of people.) But otherwise a great idea if you can make it work.

Leave a Reply to DainBramageCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.