Networked scopes and MacOS

Scope

The discussion below relates specifically to the Keysight MSO-X 3034A oscilloscope, but I suspect it will apply just as well to other Keysight scopes and perhaps more generally. I’d be interested to hear about other instruments.

On the computer end, although I’ve written this with MacOS in mind, I expect it would work on Linux without modification.

Introduction

Lots of modern test instruments have an Ethernet jack on the back, which means we can connect them to the LAN and control them remotely. Obvious tasks include:

remote control;

data logging;

automation.

For the MacOS user though, much of the online information seems to be Windows specific, which is a nuisance. Further, although software libraries exist to communicate with these devices they seem a bit unwieldy.

For someone using lots of different devices, or who needs a solution which is robust in the face of errors and bizarre happenings, these formal, well-tested systems make sense.

However, more casual approaches seem to work well on MacOS.

The programming guide

Commendably, Keysight publish a programming guide to the 3000 X-Series scopes.1 At over 1200 pages, it is undeniably a thick document, but it seems clear and well-written. I’m working from version 02.38.000 of the document, and all the page numbers below refer to that.

The key insight is that you can control the scope using a command line interface on socket 5024, which is referred to as the ‛Telnet Sockets’ approach. Thus without installing any software at all, you can control the scope from the terminal. Here’s a short example to query the scope’s identification number:

*IDN? is a SCPI2 command which returns the instrument’s identification number. See page 170 of the progammer’s guide for more details.

Given that most of this is text based, Perl seems a convenient choice if we want to automate things. Rather than using port 5024 though, it’s better to use port 5025 which offers an interface without human-helpful prompts.

Grabbing a screen dump

As an example task, let’s dump an image of the oscilloscope’s screen. If you just want the code, grab it from GitHub.3

The key, and most difficult, task is to find a suitable command. After some searching, I found :DISP:DATA? which is described on page 306.

To get an image of the screen in PNG format, all we have to send is:

DISP:DATA? PNG

The data returned are in IEEE-488.2 binary block data format, which is helpfully described on page 70.

It seems convenient to derive a new class from IO::Socket::INET to handle this:

As you see, the code is pretty simple. There might be some sense in abstracting the binary block handling into a library, and perhaps wrapping print and getline to facilitate tracing, but I’ve not yet done that.

Movie making

One particular use for this is to take a series of screen dumps, then combine them into an animated GIF—indeed that’s what led me to explore this.