Controlling Zurich Instruments Devices with LabVIEW

This blog entry supports the installation and use of the LabVIEW programming interface as contained in the ziAPI package of Zurich Instruments. It assumes that the ziBase package has been correctly installed and that the getting started instructions have been performed (please refer to Chapter 7.3 of the HF2 User Manual).

Other programming interfaces are explained in Controlling the HF2LI Lock in with Matlab  and in Controlling the HF2LI Lock in with Python. LabVIEW has a different concept than these two languages due to its graphical programming interface, but the underlying communication scheme is similar. Since the ziControl user interface itself is based on LabVIEW, many useful functional building blocks and sophisticated examples are included in the LabVIEW driver.


The LabVIEW API is included in the ziBase installation, which can be downloaded from our website. To inte­grate the driver within LabVIEW, you need to extract from API/LabVIEW in your Zurich Instru­ments program folder to the instr.lib folder in the LabVIEW program folder. After restarting Lab­VIEW, the added functions are found in LabVIEWs func­tion palette, as illustrated below.

Function Palette

The Instrument Driver Functionality

The VI tree shown below depicts the drivers capabilities.

As can be seen in the tree, ziOpen and ziClose are mandatory functions to initialize and close the connection to the Instrument. Then, there are three subgroups, whose elements are freely arrangeable to fulfill your desired measurement task.


The configuration functions give reading and writing access to the parameters of the ZI device. This capability to define the critical parameters and settings for specific measurements directly within LabVIEW guarantees reproducible measurement conditions.

Besides parameter access, the configuration subgroup also provides functions to read a single instantaneous measurement value. One can choose between all possible readings of the Instrument, which are 6 demodulators, 2 analog auxiliary inputs and 1 digital input with up to 32 bits for the HF2LI. It is furthermore possible to set the values for the auxiliary outputs. For experiments requiring only a few measurement readings, these simple functions are sufficient.


The data functions stream sequential data and are essential if every measurement sample needs to be processed. To choose the input to be streamed, subscribe and unsubscribe functions are provided. Once there is a subscription, the buffered data stream is read out with The data rate is specified by the user and high data rates up to 230kS/sec are possible. Later in this blog, there is a Poll Data example, which demonstrates the proper use of the subscribe and poll functions.


The utility functions provide a set of functions to use setting files to save/load the instrument configuration, work with multiple ZI devices, use frequency sweeping functions to measure transfer functions and perform unit conversions.

LabVIEW Examples

LabVIEW examples give a guideline on how the functions can be used. Upon proper installation of the driver, the examples can be found by searching for HF2 within LabVIEWs example finder. Inexperienced LabVIEW users furthermore find a getting started [drain file 1 url here] for download, which uses easy to understand examples to guarantee programming success.

Poll Data Example

For demonstration purposes, I provide an example performing basic parameter setup and measurement data streaming with the HF2LI. The block diagram is shown in the figure below. The vi is taken from the Zurich Instruments LabOne LabVIEW API. If you want to explore this VI yourself, you will find it amongst the other Zurich Instruments examples, which come with the LabVIEW driver. In the following, I explain the program flow according to the text labels shown in the bottom of the block diagram.

Web Example

Labels: Initialize a connection / Initialize settings

The program flow starts with ziOpen, which initializes the connection to the Instrument. Thereafter, I initialize three parameters within a for loop. Within each loop iteration, one of the three node/value pairs from the array is unbundled and routed to ziSetValueDouble. This function writes the value to the parameter addressed by its node definition. Here I use the following node definitions

 1. oscs/0/freq to set the frequency of the first oscillator to 13.5 kHz
 2. sigouts/0/amplitudes/6 to set the output voltage of the first signal output to 1 V
 3. sigouts/0/on to activate the first output

The quickest way to find out a parameters node definition is within the ziControl application. Every time you change a parameter in ziControl, you see the parameters node definition with the new value in the history bar in the bottom of the ziControl window.

Label: Subscribe required nodes

To setup data streaming, we use ziSubscribe to get a subscription to the first demodulator channel, which is addressed by demods/0/sample.

Label: Poll and plot data

In the subsequent poll loop, data is continuously read  from the ziServer buffer and plotted in the graph. If the buffer has no new data upon request, ziPollData waits for new data until the specified timeout expires, which is here set to 100 ms. Such cases only occur with slow sample rates and it is recommended to always guarantee functionality of your program by adding a case structure that treats a possible timeout event. In the current example, this case structure is labeled with Timeout? and assures that no data is plotted in case of a timeout. As can be seen inside the case structure, each measurement sample read by ziPollData contains the following records:

 1. Timestamp (ticks) Sample timestamp in ticks. ziTicks2S converts ticks into seconds
 2. X (Vrms) Demodulator RMS reading of the in-phase signal (X)
 3. Y (Vrms) Demodulator RMS reading of the quadrature signal (Y)
 4. Osc. Phase (deg) Actual phase of the demodulation oscillator
 5. Freq (Hz) Frequency of the demodulation oscillator
 6. DIO Digital input reading
 7. Aux In 0 (V) Auxiliary input 0 reading
 8. Aux In 1 (V) Auxiliary input 1 reading

In this basic example, I only use the demodulators X and Y reading to calculate and plot the corresponding absolute value.

Label: Close Connection

At the end of the program, ziClose closes the connection to the device.

Loop-back Lock-in Measurement

If I physically feed the output signal back to the input, I perform a simple loop-back experiment. If I then run the example program, the front panel appears as shown below. The data graph correctly shows a straight line corresponding to the RMS value of 1/√2. To avoid remaining open connections to the Instrument, program execution must be aborted with the STOP button instead of LabVIEWs own abort button. Otherwise, too many unclosed connections left in the memory could hamper your computing performance and a LabVIEW restart is needed to release the occupied memory.

Loopback Measurement

LabVIEW Driver Summary

Altogether the LabVIEW driver offers you far reaching possibilities towards measurement automation and measurement reproducibility due to the following features

  1. Full control over instrument parameters
  2. Fast measurement data streaming
  3. Flexible interface to control complex measurements