The HP3325B is an early 1990's product. Frequency accuracy is excellent. It will generate Sine, Square, Triangle and Ramp waveforms. Depending on the options installed and the configuration, it will generate output frequencies between 1 uHz and 20 MHz with variable output voltage and offset. The instrument uses R2D2 language GPIB but direct readbacks with a ? following the command name work. This tool will convert the R2D2 into human readable language. Sending commands and reading configuration are straight forward. Communication with the HP3325B can be via RS232 or GPIB. This tool only supports GPIB.

There are a lot of commands and modes that need to be tracked on this instrument. Critical instrument configuration is read when the program starts up and is stored in a structure that is passed into the command parser for error checking. Some of the configuration stuff is too messy to check, so all of the instrument commands are followed by a status read to verify that the instrument accepted the command and parameters.

All of the GPIB specific commands listed in the programming section of the manual are supported. Commands can be supplied to the tool on the shell command line, from a script file, or from an internal shell-like mode. Arbitrary delays between commands can be set. There are a few "macro" commands that use multiple low level commands to deal with some of the complex operations related to frequency sweeps. With those few exceptions, each of the commands here generate one GPIB command.

This tool reuses the architecture of the project #HP34401A Meter Command Line Control Software Tool . Both tools share a lot of their source code. GPIB interface tasks are handled by the linux-gpib library that is available via Source Forge and other places. Linux-gpib supports many different interface boards and dongles. Development was done under Fedora 40 and tested on several other Fedora versions. You must install the linux-gpib package before building this tool.

Both the linux-gpib library and the National Instruments NI488-2 libraries are compatible with each other with minor exceptions. It is possible to build this package to run under Windows using the NI488-2 library. More information on this is at the bottom of the "Details" section.

In order to build this project on a Linux machine, you must already have the linux-gpib package installed. There is a .h file needed at compile time and a library that is needed at link time for this package to compile successfully. Create a working directory to build the tool in and copy the .tgz file into it. Un-tar the file and type make:

> mkdir HP3325B_ctl

> cd HP3325B_ctl

> cp wherever/HP3325B_ctl_xx_xx_xxxx.tgz  .

> tar -xzvf HP3325B_ctl_xx_xx_xxxx.tgz

> make

and the software should build with no errors or warning messages. Finally, copy or link 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.

The default address for the HP3325B (currently 17) is stored in the file HP3325B.h. If your instrument is not configured for that GPIB address, you can edit the file and re-compile or you can use the -d command line option with the correct address.

Typing ./HP3325B_ctl    with no parameters will give you a command listing. Arguments shown in square brackets [ ] are optional. Most of the commands getting a numeric argument need a unit value too. These are shown in the list below.

Usage: HP3325B_ctl [-d dev_addr] CMD1 [arg1] [CMD2]...

where CMDn [argn] is one of: 

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

System Commands

HELP [cmd_name] without a command shows this same list of commands. With a command name, it shows the command name followed by any arguments required (the same as the list shown above) .

READ_CMDFILE CMDFILENAME  allows reading multiple commands from a text file. This is a "system command" . Most response messages shown will indicate the line number of the file to make it easier to find and fix script problems. Commands are sent to the HP3325B as they are encountered. Any errors in commands or parameters or instrument responses will terminate the command file execution.

INTERACTIVE {TOLERANT] allows running multiple commands without the program disconnecting from the meter. This means that you don't have to prefix each meter command with the program name. The default mode of error handling is to exit the program on finding an error. If you add the TOLERANT option, you get the error messages, but the program continues in INTERACTIVE mode. This is useful to avoid aggravation if one is not a "precision" typist :). Commands are sent to the HP3325B as they are encountered. This is a "system command".

SLEEP_MS NmilliSeconds inserts a delay between commands. Most GPIB instruments are not especially fast by modern standards, so command files will usually need a delay of 10 to 100mS inserted between commands. Delays are generated in the Linux operating system and are not super accurate. This is a "system command".

Basic Function Generator Commands

GET_ERROR reads the error status from the HP3325B and clears any pending error.

GET_AMPLITUDE reads the waveform amplitude from the HP3325B. Units will be the same as the units used when setting the amplitude.

SET_AMPLITUDE vvv.vv Vpp/mVpp/Vrms/mVrms/dBVrms/dBmVrms sets the waveform amplitude. You must supply the units for the amplitude with a space between the numeric portion and the units. Units may be:

    Vpp   Volts Peak to Peak

    mVpp  milliVolts Peak to Peak

     Vrms  Volts RMS

     mVrms milliVolts RMS

     dBVrms dB with 1.0 VRMS reference

     dBmVrms dB with 1.0 mVRMS reference

GET_OFFSET reads the DC offset of the output waveform from the HP3325B.

SET_OFFSET vvv.vv V/MV sets the DC offset of the output waveform.  Units are Volts or milliVolts.

GET_FREQUENCY reads the output frequency from the HP3325B.

SET_FREQUENCY fff.ffffff HZ/KHZ/MHZ  sets the output frequency. Units are HZ, KHZ or MHZ. there must be a space between the numeric portion of the command and the units portion.

GET_FUNCTION reads the output function from the HP3325B.

SET_FUNCTION DC/SINE/SQUARE/TRIANGLE/POS_RAMP/NEG_RAMP sets the output function.

The rest of the function generator commands should be explained by the manual. Most commands with a numeric value need a unit identifier.

Memory Loading Commands

These commands are a cross between "System Commands" and Instrument commands. Both read the contents of a file and load it into the HP3325B, but in different functions.

LOAD_ARB_DATA    ARB_DATA_FILENAME
Loads data from a file for the arbitrary modulation function. File should contain values
from -1.0 to +1.0, one per line in the file and no header line. Can contain up to 4096 values.

LOAD_DISCRETE_SWEEP_CSV  DiscreteSweep_CSV_Filename
Loads up the discrete sweep memory slots from a file. Reads a .csv file containing a header line and data like:
sweep_num, start_freq, units,  stop_freq, units,  sweep_time, units,  marker_freq, units
0,           10,       Hz,      500,      Hz,       10,        sec,   500,          Hz
1,           1.0,      KHz,     5.0,      KHz,      10,        sec,   5.0,          KHz

Can contain up to 99 lines of data.

 GPIB Specific Commands

DEV_CLR is a low level GPIB command that resets the state of the HP3325B to a known (by the manual) configuration.

DEV_LOCAL is a low level GPIB command that tells the HP3325B to accept front panel commands. It is only useful in READ_CMDFILE or INTERACTIVE situations.

GRP_TRIGGER is a low level GPIB command that can be used to start a sweep cycle if the HP3325B is configured for a a single sweep operation.

SERIAL_POLL is a low level GPIB command that fetches the instrument status byte. It returns the status byte value and if the optional DISP parameter is included, shows it on the screen. The Status Byte Mask must be set to show specific errors.

SHOW_RESPONSE cmd_string is a debug command. It allows sending any arbitrary cmd_string and reading back the HP3325B response to that string.

SEND_CMD cmd_string is a debug command. It allows sending any arbitrary cmd_string. It does not read anything back.

SHOW_MSG_BLOCK shows the contents of the internal if_mg_block structure. This is a system command and is mostly for debugging.

Commands may be entered in upper or lower case.

Usage

Multiple commands may be entered on the shell command line:

> HP3325B_ctl set_frequency 200 KHZ   sleep_ms 25   set_amplitude 3.3 VPP   sleep_ms 25   set_offset 1.65 V sleep_ms 25 set_function SQUARE

will set the generator to output a 200 KHZ square wave with an amplitude of 3.3 V and an offset of 1.65 V with 25mS pauses between steps.

The same can be done in a command file. Create a text file foo.txt containing:

   set_frequency 200 KHZ

   sleep_ms 25

   set_amplitude 3.3 VPP

  sleep_ms 25

   set_offset 1.65 V

   sleep_ms 25

   set_function SQUARE  

Run the command file:

> HP3325B_ctl READ_CMDFILE foo.txt

and the same operations will be done.

One of the main uses for the INTERACTIVE mode is when this program is run by exec'ing if from another program. Piping stdin and stdout from this program in INTERACTIVE mode allows the calling program full control over the HP3325B.

The software is written in layers. The main function calls the parse_and_exec  () function that parses the instrument commands. In the parse_and_exec.c file, the individual instrument commands get their parameters parsed and then call low level commands in HP3325B.c that assemble the outgoing strings, communicate with the GPIB driver and read results. The low level file (HP3325B.c and .h) could be used in a GUI driven program with the GUI software calling the low level command handling functions. It could also be used in conjunction with other instrument low level files to automate tests.

Building under Windows in a MINGW environment

This code includes code that I wrote to smooth over the differences between linux-gpib and NI488-2 libraries. Some conditional include files got added to the existing  .c files and a function to map the error numbers to human readable strings that the NI488-2 library lacks.

There is also a make script file: Makefile_MINGW that works under MINGW environments.

Not included are the National Instruments NI488-2 library stuff and a Microsoft file CHKSTK.O. Both of these are copyrighted to someone else. NI488-2 can be downloaded from National Instruments web site. The version that I am running is fairly old, version 14, Windows 7 era which is the latest MS code that I have access to. CHKSTK.O can be found in Microsoft compiler distributions.

Both the ni488-2.obj file and CHKSTK.O should be placed in the directory that you are building HP3325B_ctl in.

Building under MINGW is similar to building under Linux. From a MINGW shell prompt, use the Makefile_MINGW instead of the Linux Makefile:

> make -f Makefile_MINGW

should compile and link everything. There should not be any errors or warning messages from the build.

A few more details can be found in my #HP545xx Data Acquisition Software project.