This blog post is part of a collection,/roadTestReviews/ here for links to the entire set, and a/roadTestReviews/ of the products.


Most test gear comes with remote connectivity options, and the Agilent N9322C Spectrum Analyzer (SA) is no different. It can be connected up via IEE-488 (available as an option) or via USB or Ethernet (available as standard).

For some screenshots of the SA, click here.


The SA is supplied with some nice client software described below but it is also possible to use third party software or make your own. It integrates into existing test beds using a supplied library discussed below.

This post briefly examines the connectivity options and how to programmatically control and manage the SA.

This post also provides a quick working example for program control for the N9322C but the concepts translate to other instruments too - plug in your instrument into the network (Ethernet port) or directly into your PC using a USB cable and you can control it using your own software in a dozen lines of code. It can be that simple.



Why would you want to do this?

There are many reasons. For engineers, documentation and recording of results is highly important. For test beds, automated control and measurement is needed.  Furthermore with a good implementation it becomes possible to have just as good an experience (if not better) using the instrument from your PC as it is from the instrument control panel.

Why would you want custom software control? It too is important for automated test of course, but also allows you to log data at periodic intervals, feed data directly into software, generate alarms or alerts, and also allows you to configure your instrument exactly the same way each time. It’s very cool.


Agilent Remote Control Software

Here is an example screenshot from the client software (known as Agilent BSA PC Software) that comes with the N9322C SA:


Once the software is installed, it is a quick process to get it working with the spectrum analyzer. It auto-detects the SA if it is plugged into a USB port on the PC, or if the SA is in the local area network. See the screenshots further below for further information.


The client software is fast and is not an identical repeat of the graphical user interface on the instrument. Instead, it makes the best use of the PC screen, scales up and allows you to use a mouse to drag to position markers quickly. Here is a very short (1 minute) video showing the basic spectrum analyzer view, a spectrogram view and manual marker positioning (there are auto peak detect options but I wanted to show the mouse drag behaviour):


The video above shows the screen scaled down, however on a large monitor the image scales gracefully as can be seen in this screenshot:



The BSA PC software is a very nice example of well executed remote control client software. I wouldn’t say it is perfect (and Linux and Mac client software is not available) however I can see it being the single most important application for most users to get installed if they plan on using this spectrum analyzer. It won’t be for everyone (some people may require third party software such as NI LabView for logging or post-processing purposes) but for design engineers the BSA PC software is great – it is quick and easy to use.


Although not explored here, the BSA PC software also allows the export of data into CSV files for processing using software such as Excel or MATLAB or GNU Octave, and for accessing files stored on the spectrum analyzer too.


For those installing the software, here are some screenshots of what to expect during the instrument discovery:




Programmable Behavior

As with most test gear, the Agilent / Keysight N9322C Spectrum Analyzer (SA) supports configuration and management/monitoring through a standard software abstraction known as Virtual Instrument Software Architecture (VISA).


In a nutshell it allows you to control your SA from your PC using Agilent, third party or your own custom software.


Sometimes it is hard finding concrete examples per test instrument, so I spent some time deciphering it now, so that I’m prepared if I ever need to do any automation or logging.


Even if you have a different instrument such as a multimeter or oscilloscope, you may be interested to know how to access it from your own software so it is good to spend time examining the programmer’s manual with your test instrument.


Here is a working example for Windows for the spectrum analyzer (the example in the user docs has a few unfortunate errors):


* Test Program for Agilent / Keysight N9322C
* Revision 1 - shabaz Aug 2014
* To compile: C:\MinGW\bin>gcc.exe c:\MySourceCode\agilent\satest.c -o satest -I "C:\Program Files\IVI Foundation\VISA\Win64\agvisa\include" -L "C:\Program Files\IVI Foundation\VISA\Win64\agvisa\lib\msc" -lagvisa32

#include "visa.h"
#include <stdio.h>
#include <stdlib.h>

#define VIERRORMSG(V,M) if ((V)!=VI_SUCCESS) { fprintf(stderr, "[ERROR] " M "\n"); exit(1); }

  char buf[300];
  ViSession viN9322C;
  ViStatus viStatus;
  ViSession defaultRM;

  printf("N9322C Test Program\n");
  // Open session to USB device
  VIERRORMSG(viStatus, "viOpenDefaultRM");
  VIERRORMSG(viStatus, "viOpen");
  // Initialize device
  viStatus=viPrintf(viN9322C, "*RST\n");
  VIERRORMSG(viStatus, "viPrintf RST");
  // Send an *IDN? string to the device
  viStatus=viPrintf(viN9322C, "*IDN?\n");
  VIERRORMSG(viStatus, "viPrintf IDN");
  // Read results
  viStatus=viScanf(viN9322C, "%t", buf);
  VIERRORMSG(viStatus, "viScanf");
  // Print results
  printf("Instrument ID string: %s\n", buf);
  // Close the sessions



Here is how to get it working:


1. Install MinGW

2. Install Agilent IO Libraries Suite (it is on the supplied CD)

3. From the Windows Start button, run Agilent Connection Expert to get the instrument name (see the earlier screenshot above)

4. Edit the test program so that it contains the instrument name

5. Open up a Windows command prompt

6. Go to the C:\MinGW\bin folder and type the following line to compile the program:

gcc.exe c:\MySourceCode\agilent\satest.c -o satest -I "C:\Program Files\IVI Foundation\VISA\Win64\agvisa\include" -L "C:\Program Files\IVI Foundation\VISA\Win64\agvisa\lib\msc" -lagvisa32

Note that the paths may be different. My PC already had a VISA library installed for Tektronix instruments, so the Agilent version automatically installed as a secondary set.

7. Run the program by typing:



When the program is run, output similar to this will be seen:

N9322C Test Program
Instrument ID string: Agilent Technologies,N9322C,CN1234A567,A,04,47


The red ‘Remote’ LED indicator on the SA will also light up. To release remote operation and take back control of the SA front panel, press the Enter key and the Remote indicator will extinguish.


This is just a basic example showing how to send a command and how to retrieve the result of a query. More complex programs can be built of course.



The remote control client software and programming options are great. The Ethernet interface comes as standard, which is good to see. This is an instrument that is just as easy (if not more easy) and fun to use via remote control as it is via the in-built user interface.


Since “thinking” about how to attack a problem can take a long time, it’s actually quite nice to walk away from the SA and still be able to fully deep-dive into the configuration and monitoring from a more comfortable place!