The HP8116A function generator is a fairly old product. It is an analog function generator that HP added a GPIB interface to. It will output a range of 0.1mHZ to 50MHz with sine, square, pulse and triangle wave outputs. The instrument is old enough that the GPIB language is not SCPI, but R2D2. This tool will convert the R2D2 into human readable language. Read back capabilities are somewhat primitive.

Pretty much all of the GPIB commands listed in the Programmers 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.

This tool shares the architecture of the project #HP E3634A Power Supply Control Software . 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 32 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. Instructions to do so can be found in my #HP545xx Data Acquisition Software project.

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 HP8116_ctl

> cd HP8116_ctl

> cp wherever/HP8116_ctl_xx_xx_xxxx.tgz  .

> tar -xvf HP8116_ctl_xx_xx_xxxx.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.

Typing ./HP8116_ctl    with no parameters will give you a command listing:

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

HELP                                            cmd_name
READ_CMDFILE                          cmdfilename
INTERACTIVE                              [TOLERANT]
SLEEP_MS                                  NmilliSeconds
DEV_CLR                                    No Parameters
GET_STATUS                              No Parameters
GET_ERROR                               No Parameters
SET_TRIG_MODE                       NORM/TRIG/GATE/EXT_WID/INT_SWP/EXT_SWP/INT_BUR/EXT_BUR
SET_TRIG_CTL                           OFF/+/-
SET_MODULATION                    OFF/FM/AM/PWM/VCO
SET_WAVEFORM                        DC/SINE/TRIANGLE/SQUARE/PULSE
SET_START_PHASE                    0/m90
SET_FREQUENCY                       freq.xx
SET_START_FREQUENCY          start_freq.xx
SET_STOP_FREQUENCY            stop_freq.xx
SET_MARKER_FREQUENCY       marker_freq.xx
SET_DUTY_CYCLE                      duty_cycle [1..99]
SET_PULSE_WIDTH                     pulse_width [1nS..1.0S]
SET_REPEAT_INTERVAL              repeat_interval [1nS..1.0S]
SET_SWEEP_TIME                        sweep_time [1mS..100.0S]
SET_BURST_COUNT                    burst_count
SET_AV_ENABLE                          ON/OFF
SET_AV                                          MSB/MID/LSB UP/DN
SET_OUTPUT_LIMITS_ENABLE   ON/OFF
SET_COMP_OUTPUT_ENABLE   ON/OFF
SET_OUTPUT_ENABLE                ON/OFF
SET_AMPLITUDE                           AMPLITUDE.xx
SET_OFFSET                                 OFFSET.xx
SET_HI_LIMIT                                HI_LIMIT.xx
SET_LOW_LIMIT                            LOW_LIMIT.xx
GET_FREQUENCY                         No Parameters
GET_START_FREQUENCY            No Parameters
GET_STOP_FREQUENCY              No Parameters
GET_MARKER_FREQUENCY         No Parameters
GET_PULSE_WIDTH                       No Parameters
GET_REPEAT_INTERVAL                No Parameters
GET_SWEEP_TIME                         No Parameters
GET_DUTY_CYCLE                        No Parameters
GET_BURST_COUNT                     No Parameters
GET_AMPLITUDE                            No Parameters
GET_OFFSET                                   No Parameters
GET_HI_LIMIT                                  No Parameters
GET_LOW_LIMIT                              No Parameters
GET_CFG_DATA                               No Parameters
SHOW_RESPONSE                           Query_String

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

Commands may be entered in upper or lower case:

> SET_FREQUENCY 1.3e6

and

> set_frequency 1.3e6

issue exactly the same command to the function generator.

Instrument commands may be typed on the command line, like:

> HP8116_ctl SET_WAVEFORM SINE SET_FREQUENCY 2.5e3 SET_AMPLITUDE 0.707 SET_OUTPUT_ENABLE ON

to set the output frequency to 2.5KHz, set the amplitude to 0.707V and enable the output. Multiple commands can appear on a single line, separated by space characters.

Text command files can be used to run the same operations numerous times. After creating a text file hptest.txt containing:

SET_WAVEFORM SINE

SET_FREQUENCY 2.5e3 

SET_AMPLITUDE 0.707 

SET_OUTPUT_ENABLE ON

SLEEP_MS 500

SET_OUTPUT_ENABLE OFF

you can run that file:

> HP8116_ctl read_cmdfile hptest.txt

The interactive command reads commands as you type them and executes them after each line feed character. The biggest difference between using the command line method and the interactive method is that the GPIB bus does not disconnect between commands when using the interactive method, while it does disconnect between commands using the command line method.

Using the command line or the read_cmdfile methods will exit with an error if you fat finger a command or parameter. If the TOLERANT parameter in interactive mode is used, the program will not exit on parsing errors.

Also, when using the interactive mode, you don't have to type HP8116_ctl before commands.

One of the main uses for the interactive mode is when this program is exec'd from another program. Connecting to the stdin and stdout of this program in interactive mode allows full control from the calling program. The TOLERANT option will greatly simplify development of these applications.

A couple of debugging commands, SHOW_RESPONSE and SEND_CMD are included to allow sending a command to the 8116 and displaying the full response string, or just sending an arbitrary command.

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 HP8116A.c that assemble the outgoing strings, communicate with the GPIB driver and fetch results. The low level file (HP8116A.c and .h) could be used in a GUI driven program with the GUI software calling the low level command handling functions.