The HP5334 frequency counter is a fairly old instrument, dating back to the late 1980's. The GPIB interface language predates the SCPI language that is in common use now. The old GPIB language is referred to as R2D2 language and is not particularly human readable. This tool translates human readable commands into and out of the old language. It also has functions to capture large numbers of data samples and store them to a .csv file for later use.

The architecture used in this tool is the same as the architecture used by my #HP E3634A Power Supply Control Software  project. Both tools share a lot of the same code. These tools were developed to use the linux_gpib library and have been tested on multiple versions of Fedora Linux. You must install the linux_gpib library before attempting to build this tool.

Both the linux_gpib library and National Instruments NI488-2 libraries are pretty much compatable with each other. There are a few minor differences that are described in detail in my project #HP545xx Data Acquisition Software including how to build this software to run on a Microsoft operating system.

In order to build this project for Linux, install the linux_gpib library on your machine. There is a .h file that is used by the code and a library file that is required at link time in the linux_gpib package. Next, create a working directory to build the software in and un-tar the source file, then run make:

> mkdir HP5334_tool

> cd HP5334_tool

> tar -xzvf ../HP5334_ctl_6_1_2023.tgz

> make

and the software should build with no errors or warning messages. Finally, copy the executable program to a convenient directory in your executable path like ~/bin. There should be no need to do any of these tasks as root unless you want to put the executable in a directory off the /usr tree.

Supported Commands:

All of the commands supported by the tool can be viewed by entering the tool with no command line parameters and the tool will respond with the list:

> ./HP5334_ctl Usage: HP5334_ctl [-d dev_addr] CMD1 [arg1] [CMD2]...  where CMDn [argn] is one of:

The configuration options (starting with -) must all
be before the first instrument command.

Instrument commands may be typed on the command line. Multiple instrument commands can be on the command line and they are executed in the order of appearance. Commands are not case sensitive, so get_period_a works as well as GET_PERIOD_A.

> HP5334_ctl SET_INPUT_ATTEN A X10  SET_INPUT_FILTER OFF SET_AUTO_TRIGGER OFF

will set the input X10 attenuator on channel A, turn off the input filter and the auto trigger options.

A text file with commands in it can also be used with the READ_CMDFILE command. If you created a text file cfg_chA containing:

SET_INPUT_ATTEN A X10

SET_INPUT_FILTER OFF

SET_INPUT_COUPLING A  AC

and then issued the following command:

> HP5334_ctl READ_CMDFILE cfg_chA GET_FREQUENCY A the counter will execute these commands in sequence.

Syntax for the command file is the same as the syntax for the command line with the exception that you cannot change the GPIB address in the command file.

Some error checking is done in the tool but it is possible to send a command that the HP5334 that will cause an error. The error can be fetched and cleared with the GET_ERROR command:

> HP5334_ctl GET_ERROR

Note that a number of the options on configuring the counter inputs require that the auto trigger option be turned off. Some of the commands require that the DACs be turned off too. These situations are explained in the HP5334 user manual.

The two GET_MULTIPLE commands are:

GET_MULTIPLE_PERIOD_A Nvalues Tdwell Outfilename

where:

 Nvalues is the number of values to capture
 Tdwell is the amount of time to wait between measurements in milliSeconds

  Outfilename is the name of the output data file

GET_MULTIPLE_FREQUENCY A/B/C Nvalues Tdwell Outfilename

where:

  A/B/C is the input channel to make the measurement on.

All the other parameters are the same as above.

These functions request measurements, and store them to a .csv file with field 1 containing the measurement number and field 2 containing the measurement value. It is possible to capture files larger than a spreadsheet program will handle with these commands. LibreOffice Calc seems to have trouble with files larger than about 8000 lines.

This program is written in layers, the top level main() and command parsing, the low level command translation and GPIB handling and some GPIB specific functions. It was written this way so that the low level command translation and GPIB stuff could be used in a GUI program or as part of automating some larger operation.