Square Wave and Sawtooth Wave Generation with HF2LI Lock-in Amplifier

Normally, HF2LI users only generate sinusoidal waveforms with the HF2LI lock-in amplifiers. The HF2LI can also generate square and sawtooth waves, although this is not a supported feature. This blog will go through the setups necessary for doing just that. Like the blog for using the HF2LI as a 4-channel lock-in amplifier, HF2LI users must be aware that the unsupported features described here do come with certain limitations and these will also be explained.

Square Wave Generation

Generating a TTL square waveform on the DIO0/1 connectors actually been possible since July 2012. Here is a more detailed explanation. The frequency of the TTL output is essentially the same as the reference sine wave frequency. It can be defined under the Lock-in tab, under the heading Frequency as shown below. Here, we are using channel 2 to generate the TTL  signal.


Then, under the Auxiliary I/O tab, one should select the DIO connector that will be used for the TTL output (DIO0 or DIO1), as well as the demodulator for which the reference frequency was defined. In this case, the channel 2 reference refers to demodulator 4, 5 and 6. So the users can select any of these three demodulators in the drop down list as shown below.


Note: If the HF2LI-MF Multi-frequency is installed, then each demodulator can have its own reference frequency. The selection of the demodulator field must then be made accordingly.


The upper limit of the TTL frequency is 50 MHz just as in the normal reference output. There are basically two limitations that users should be aware of. The first limitation is the edge uncertainties i.e. jitter. The jitter will be no better than 5 ns. Also note that this does not take into account other effects like external noise coupling and supply noise. The second limitation is the output driver impedance. The DIO connectors are bi-directional drivers that are not 50 Ω terminated. Therefore, for driving TTL frequencies higher than 1 MHz, it is recommended that one uses a 3rd-party, 50 Ω, TTL line driver. This will greatly reduce the problem of reflections due to impedance mismatches in the transmission line.

Sawtooth Wave Generation

The sawtooth waveform generation is relatively more complicated. The complete setup is shown in the diagram below. Basically, in order to generate a sawtooth waveform with the HF2LI, one needs to generate a phase ramp that gets re-initialized to zero at 180o every time. This can be done by adding two frequencies with a small frequency offset Δf. This is easily achieved using the Add connector with one of the HF2LI signal output ports.



Once this is done, the summed output should be fed back to one of the HF2LI signal input ports. By demodulating the input signal at f1 (or even f2), one will then obtain a phase sawtooth waveform as shown below. In this example, f1=10 kHz and f2=10.01 kHz are used. The sawtooth waveform then has a frequency of 100 Hz. Note that the filter bandwidth must be much higher than Δf when demodulating the summed signal.

To use this sawtooth waveform as the drive signal, one can simply output the demodulated phase to one of the four auxiliary outputs as the diagram shown above. The auxiliary input can also be used as an external reference input. All the necessary ziControl settings are highlighted below.



The upper sawtooth frequency basically comes from the demodulation filter bandwidth used to demodulate the phase oscillating at Δf. To get a nice sawtooth waveform, the filter bandwidth should be quite a bit higher than Δf in order not to round off the sawtooth edges. However, when the bandwidth is too high the unfiltered noise can make the sawtooth to be too jittery to be of any use. Measurements made during the writing of this blog showed that a decent sawtooth waveform frequency that can be generated by the HF2LI is realistically no higher than 1 kHz.


Besides the de-facto sine wave generation, it is shown in this blog that HF2LI can also generate TTL and sawtooth waveforms. Although not a replacement for a function generator, the demonstrated capabilities provide more flexibility in an existing setup with no additional cost. Hopefully HF2LI users can benefit from these unofficial features.

Update October 26, 2016

The HF2LI is also able to output an square wave-signal with adjustable amplitude and frequency through API programming. For activating the square wave feature following node need to be addressed over the API (Matlab, LabView, Python or C):

sigouts/0/waveforms/0 1

Users should take care that at large amplitudes 10V and high frequencies the signal amplitude can be attenuated. More information can be found in the user manual of the HF2LI Lock-in Amplifier