1 - Beginnings
3 - Hello World
4 - More On GPIO
5 - Interrupts
7 - Timers
10 - Buttons and Bouncing
Would you like to be notified by email when Jason Sachs publishes a new blog?
I got my oscilloscope today.
Maybe that was a bit of an understatement; I'll have to resort to gratuitous typography:
Those of you who are reading this blog may remember I made a post about two years ago about searching for the right oscilloscope for me. Since then, I changed jobs and have been getting situated in the world of applications engineering, working on motor control projects. I've been gradually working to fill in gaps in the infrastructure available to me and my coworkers, and one of those has been an oscilloscope I can use in my office. Our group's budget recently allowed us to fill in some of those gaps. So:
I got my oscilloscope today! And it's even the one I asked for!
No, wait — it's better than the one I asked for! Here's why:
The oscilloscope I asked for was an MSOX3024A. When I got a quote from a distributor, they said there was a promotion from Agilent, and they could offer me a lower price. Agilent has a deal ("Supercharge Your Bandwidth!") that runs until March 31. Most oscilloscope models come in series, with different bandwidth options. You want a less expensive scope? Pick the lowest bandwidth. You want something with a high bandwidth? It'll cost you. So the Agilent deal offers you the scope you want at the price of the next lower bandwidth. I would get a MSOX3024A (200MHz) at the normal price of an MSOX3014A (100MHz). Net savings: about $350. Yay! Quote obtained, forwarded on to manager, no problem, back to work.
And then I got this funny nagging hunch in the back of my mind. MSOX3024A at the normal price of the MSOX3014A... hmmm... hmmm... what about the MSOX3034A at the normal price of the MSOX3024A? I checked Agilent's list prices for the MSOX3000 series:
Goodness, I could save $3500! I called the distributor back and asked if the promotion applied to the MSOX3034A. Yep. Some quick discussions and pleading with my manager and we got the order in for the MSOX3034A. Woot!
So I got my oscilloscope today. (Did I mention that yet?) First action of the day: put the probes on the scope along with the little color coded bands to help you keep the channels from getting mixed up, and compensate the scope probes.
What? You've never compensated an oscilloscope probe before? It's easy. You connect the probe to the calibration signal post on the front panel. It's a precision square wave. Then you zoom up the vertical scale so you can see the transients. Here's the deal: The scope comes with BNC connectors, and most scopes these days allow you to configure the input impedance with one of two choices. If you are doing high frequency measurements, they're typically 50Ω characteristic impedance to avoid reflections. If you are doing lower frequency measurements on high-impedance nodes of a circuit, you don't want the oscilloscope loading down the input, so you pick the other option, which is usually 1MΩ input impedance. But that's not good enough for most applications, and usually you want a probe with a voltage divider so you can get the input impedance higher, and have a higher acceptable input voltage range. Typical scope probes are 10x probes, which mean they have a 10:1 voltage divider inside, and are therefore 10MΩ input impedance.
Now, both the probe tip and the oscilloscope itself have parasitic input capacitance. If these aren't matched with the resistor divider, the probe will give you a transfer function that is frequency-dependent, and the waveforms you see on the scope will be distorted. So oscilloscope probe manufacturers usually put a variable capacitor in the probe, either near the probe tip or near the BNC end of the probe, so they can match the input network and make it close to frequency independent. If you connect the probe to a square wave, you can tune the variable capacitor so that the square wave has edges that are square, and not rounded off or with an overshoot. The variable capacitor has a slotted adjustment screw, and usually you want to use a nonconducting nonferrous screwdriver to prevent the signal from being altered while you're turning the screw. Scopes usually come with a little plastic mini-screwdriver you can use to adjust the capacitor screw.
I talked a little bit about waveform data transfer in my 2012 article. Gone are the days of DB9 RS232 connections (get out your null modems and gender changers!) and floppy disk drives. Now everything's either thumb drive or USB or Ethernet. The MSOX3000 series offers all three, but only the USB host (for thumb drive) and USB device connectors are built-in to the oscilloscope; Ethernet connector ("LAN port") costs extra.
As far as application software: yeah, you can buy some software from Agilent, but I learned long ago that most software from oscilloscope manufacturers isn't very good. (WaveStar ring a bell for anyone out there with a Tektronix scope?) And I'm a big fan of Python, if you haven't figured that out already from previous columns. So of course I looked around for a Python program to download the Agilent waveforms.
I quickly found an IPython notebook on interfacing to Agilent oscilloscopes using their VISA libraries and the pyvisa Python library. Cool!
It took me a while to get things running, but I was able to connect to my oscilloscope via USB and interact with it in IPython. A couple of stumbling blocks:
pyvisa is a low-level library which only facilitates the communication with a scope. You still have to use the required ASCII command/response protocol given in Agilent's programming guide, which looks like this:
scope = instrument("TCPIP0::18.104.22.168::inst0::INSTR")
# Connect to the scope using the VISA address (see below) scope.ask("*IDN?") # Query the IDN properties of the scope sa_rate = float(scope.ask(":ACQ:SRAT:ANAL?"))
# Get the scope's sample rate
This just screams for someone to write a higher-level library to interface with these series of oscilloscopes. I'll probably end up writing one that is mediocre and not something I can share outside my company. It's really something that Agilent should provide: they don't seem to realize that there is a whole scientific community out there which likes using Python rather than Visual Basic or C#.
In any case, I haven't finished downloading waveforms yet, but one cool thing is that you can set the time scale of the oscilloscope with the
Shazaam! Your scope is now set to 10 μs/division. But that's not all! Let's say you want exactly 3.21 μs/division. You can do that with these scopes, but it's a pain to do, you need to fiddle with the coarse and fine time adjustment knobs. Or:
Pow! It just works!
Anyway, that's what I've been up to so far. If I run into something else cool, I'll share it in a future article.
Thanks to Microlease for giving us a good price on these scopes. If you're buying stuff from Agilent, give them a holler — don't just settle for the Agilent list prices.
Update on Mar 6:
I stand corrected: Agilent does include some sample Python code to interface with the MSOX3000 oscilloscopes. It's on p. 1221 of the Programming Guide, and uses pyvisa — well, an earlier version of it, at least. (By the way, those weird
:TIM:SCALE commands are called SCPI)
But it's not very "pythonic"; it looks like a Visual Basic programmer was told "You! Translate this into Python! We need Python sample code!" There are global variables and redundant function calls and then there's a sys.exit() call in the middle of a function. Sigh. (Someone should teach this guy about the
raise keyword.) But at least they tell you how to decode waveform data:
© 2014 Jason M. Sachs, all rights reserved.
There are no comments yet!
Add a Comment