Capturing lowdutycycle pulsed signals with high quality is crucial for many applications in optics and photonics, nanotechnology and materials science, quantum technologies, scanning probe microscopy, and sensing. Boxcar averagers are attractive tools to achieve a high signaltonoise ratio (SNR) in a minimal amount of measurement time when working with lowdutycycle signals. Such signals contain relevant information in a short time interval, while the rest of the period contains only noise. A boxcar averager captures the signal from a welldefined temporal window in each period, meaning that all signal components outside of that window are rejected.
Principles of Boxcar Averaging  Zurich Instruments Tutorial
Video credit: Zurich Instruments
Unlike a digitizer or an oscilloscope, the measurement results are immediately available in the digital domain and as analog signals with a userdefined offset and scaling factor. Moreover, integrated PID controllers can process the results to create feedback loops and a lockin amplifier unit can perform demodulation on the boxcar results if an additional modulation is present.
In this article, we illustrate the working principle of a digital boxcar averager, discuss the relevant measurement parameters, and provide guidelines for the best choice of measurement technique when working with periodic signals.
Basic Working Principle
In a typical periodic pulsed signal the information is contained in a short time interval T_{p}, with a significant waiting time between individual pulses, as shown in Figure 1 (a). The signal can be characterized by its duty cycle d = T_{p}/T_{rep}, where T_{rep} = 1/f_{rep} is the inverse of the repetition rate f_{rep} of the pulses. If the duty cycle is low, measuring continuously in time results in a low SNR, as the time intervals between individual pulses contribute to the captured noise but not to the signal.
With a boxcar averager the signal can be acquired during the pulse duration, while the time intervals between the pulses are ignored. This corresponds to a multiplication of the input signal with a boxcar function, which is a rectangular pulse train as shown in Figure 1 (b). By matching the period of the boxcar function T_{rep}, the boxcar window width T_{box}, and its position with respect to the signal pulses, the noise between signal pulses can be discarded as illustrated in Figure 1 (c). The signal is then integrated over the duration of T_{box}. Finally, the integrated signal is averaged over N periods as indicated in Figure 1 (d).
Figure 1. Working principle of a boxcar averager. (a) Typical input signal from a pulsed experiment, where T_{p} is the pulse width and T_{rep} is the repetition period. (b) Schematic illustration of a boxcar function, also known as rectangular pulse train, with a pulse width T_{box}. (c) Resulting signal after the multiplication of the input signal with a boxcar function. Noise contributions outside of the boxcar window are rejected. (d) The signal is integrated during each boxcar window, and finally, the result is averaged over N periods. Image Credit: Zurich Instruments AG
Boxcar Parameters and Their Effects
Boxcar Window
The width of the boxcar window T_{box} and its position with respect to the signal pulses are important parameters when optimizing the SNR. Assuming white noise, the ideal boxcar window width can be calculated for a known pulse shape and repetition rate. In Figure 2 (a) we show one period of a periodic signal with Gaussian pulses given by p(t) = A exp(0.5t^{2}/σ^{2}), where σ = 0.04T_{rep} is the root mean square width. We can now calculate the fraction of the signal s_{box} captured when the signal is integrated over a boxcar window of width T_{box}. For a rectangular boxcar window centered at the Gaussian pulse, s_{box} is given by

(1) 
and increases with T_{box} until the full pulse is captured. However, the captured noise also increases with T_{box}. In the case of white noise, the captured noise n_{box} increases proportionally to the square root of the boxcar window width, namely n_{box} ∝ √T_{box}.
Figure 2 (b) shows examples of s_{box}, n_{box}, and SNR = s_{box}/n_{box} as functions of T_{box}. Here, the noise was scaled such that SNR = 0.6 if the whole period is captured, i.e., when T_{box} = T_{rep} . One can observe that the captured signal increases with the boxcar window width until it approaches an amplitude of 1 when the full pulse is captured by the boxcar window. Once the signal is completely captured, the SNR scales with √(T_{rep}/T_{box}) due to the rejection of noise outside of the boxcar window. The maximum SNR can be achieved by choosing a boxcar window that does not capture the full pulse. In this example, the SNR is maximized when 84% of the signal is captured, which corresponds to T_{box} ≈ 2.8σ ≈ 0.11T_{rep} as illustrated in Figure 2 (a).
In a real measurement, it is convenient to optimize the SNR by starting with a large boxcar window and then reduce its width until the maximum SNR is found.
Figure 2. Boxcar window optimization. (a) Gaussian pulse with standard deviation σ = 0.04T_{rep} and a boxcar window with ideal width. (b) Signal, noise and SNR for the Gaussian pulse as functions of the boxcar width σ. Measuring the full period results in SNR = 0.6. With an ideal boxcar window width of T_{box} ≈ 2.8σ ≈ 0.11T_{rep}, SNR ≈ 1.5 can be achieved. Image Credit: Zurich Instruments AG
Averaging Periods
After discarding the noise contributions between pulses, the signal is integrated over the duration of each boxcar window and then averaged over multiple periods using a moving average filter. Instead of defining an averaging time T_{avg}, it is convenient to define the number of boxcar periods N = T_{avg}/T_{rep} over which the signal is averaged. Assuming a white noise floor and an ideal boxcar window, the captured signal increases linearly with N, whereas the noise contribution increases as the square root of the sum of the squares of the captured noise. For N boxcar periods, the resulting SNR is therefore given by

(2) 
where we assume that the signal s_{box} and noise n_{box} are the same in each period.
Spectral Response
The output of the boxcar averager Out_{box} can be calculated in the time and the frequency domains using the Plancherel theorem [1]:

(3) 
where B(t) and S(t) are the boxcar function and the input signal in the time domain, respectively, and B̂(ω) and Ŝ(ω) are their Fourier transforms. To account for the finite number of averaging periods, we introduced B̂_{N}(ω) as the Fourier transform of a boxcar function with N pulses. To understand the spectral response of a boxcar averager, we discuss B(t), B̂(ω), and B̂_{N}(ω) in more detail.
We start by considering an infinite number of averaging periods and use the Fourier theorem stating that a periodic function can be expressed as a sum of sine and cosine terms. The boxcar function B(t) can thus be expressed as

(4) 
where the sine terms are zero because B(t) is an even function.
The fundamental frequency ω_{0} = 2π f_{rep} is determined by the repetition rate of the pulses. The coefficient a_{0} = d = T_{box}/T_{rep} corresponds to the duty cycle, and the coefficients a_{m} are given by

(5) 
Hence the Fourier transform of a boxcar function corresponds to a series of delta peaks at the harmonics of the fundamental frequency f_{rep}, weighted by the coefficients a_{m}. Equation 3 elucidates that a boxcar averager captures the signal  and the noise  contained in the harmonics, and it efficiently rejects other frequency components.
For a large number of averaging periods, B̂_{N}(ω) approaches B̂(ω). Figure 3 (a) shows an example of B̂_{N}(ω) for N = 200 with almost deltalike peaks at the harmonics. The envelope of the Fourier transform, i.e., the weighting of the peaks given by a_{m}, can be identified as the normalized sinc function sinc(x) = sin(π x)/(π x), with zero points given by f/f_{rep} = 1/d. To illustrate the effect of the duty cycle, we show Equation 5 for three different values of duty cycle: d = 0.05, d = 0.1 and d = 0.2 (see Figure 3 (b)). It can be observed that a lower duty cycle puts more relative weight on contributions from higher harmonics.
For a finite number of averaging periods, each peak of B̂_{N}(ω) turns into a sinc functions itself, with a distance between zeros given by f_{rep}/N. Figure 3 (c) provides an example of B̂_{N}(ω) with N = 5 periods. The signal is captured at the harmonics, but the side lobes of the sinc function can result in leakage of noise components into the measured signal. Adjusting the number of averaging periods is therefore crucial for the SNR. Without any averaging, i.e., for N = 1, the sum of sinc functions becomes a single sinc function corresponding to the envelope plotted in Figure 3 (b).
The measurement bandwidth f_{3dB} is defined as the frequency where the signal is attenuated by 3 dB, corresponding to approximately 0.71 of the amplitude. For a boxcar averager, f_{3dB} can be calculated from the amplitude decrease of the sinc function centered at zero frequency:

(6) 
which gives

(7) 
with c = sinc^{1}(√(10^{3/10})) ≈ 0.44. The measurement bandwidth depends linearly on the averaging periods N and the repetition rate f_{rep}.
Figure 3. Spectral and temporal response. (a) Fourier transform of a signal with a duty cycle of d = 0.1 and N = 200 periods. (b) Envelope functions of the Fourier transform. The coefficients a_{m} are shown as a function of frequency for three different values of duty cycle: d = 0.05, d = 0.1 and d = 0.2. (c) Fourier transform of a signal with a duty cycle of d = 0.1 and N = 5 periods. (d) Temporal response. Due to the moving average over N periods, the response of the boxcar averager is linear in time and reaches the new value after N periods. Image Credit: Zurich Instruments AG
Temporal Response
The temporal response of a boxcar averager is determined by the calculation of the average over N periods. For a moving average filter, the temporal response is linear in time, with a slope determined by N as illustrated in Figure 3 (d). After a change in the signal, 100% settling is obtained after N pulses. For imaging applications, zero crosstalk between pixels can be achieved by choosing a measurement time equal or larger than NT_{rep} per pixel. A digital implementation enables to monitor the signal continuously by providing intermediate results during the calculation of the moving average over N periods.
Summary of Boxcar Parameters and Their Effects
 Boxcar window: The window width T_{box} and its position determines the captured signal and noise. Assuming white noise, the SNR increases approximately with √(T_{rep}/T_{box}). The SNR is often maximized for a window width smaller compared to the full width of the input signal pulse.
 Averaging periods N: The integrated signal is averaged over N periods using a moving average filter. Assuming white noise, the SNR increases proportionally to √N.
 Spectral response: A short boxcar window T_{box} puts more relative weight on contributions from higher harmonics. The number of averaging periods N determines the width of the sinc function peaks at the harmonics.
 The measurement bandwidth f_{3dB} scales linearly with f_{rep}/N.
 Temporal response: The response of a boxcar averager is linear in time with a slope determined by the number of averaging periods N and the repetition period T_{rep}.
State of the Art
The first analog boxcar averagers were built following the principle of boxcar averaging described by Blume and collaborators in 1961 [2]. More recently, the development of analogtodigital converters with high speed, resolution and linearity has enabled the realization of digital instruments where all calculations are carried out numerically by digital signal processing on a fast fieldprogrammable gate array (FPGA). The Zurich Instruments UHFBOX Boxcar Averager shown in Figure 4 (a) is the only digital boxcar averager on the market today. It enables deadtimefree operation up to a repetition rate of 450 MHz, and offers additional features such as a periodic waveform analyzer (PWA) and the possibility for baseline suppression. Control and readout of all instrument settings and measurement parameters are achieved thanks to the LabOne^{®} user interface shown in Figure 4 (b) or through application programming interfaces (APIs).
Figure 4. Zurich Instruments UHFBOX Boxcar Averager [3]. (a) The instrument provides two signal input and two signal output channels with 600 MHz bandwidth, as well as multiple trigger and auxiliary channels and a 32bit DIO port. (b) Screenshot of the LabOne® User Interface. The Boxcar Averager tool is shown in the top panel: the boxcar window and reference window can be set using the PWA. The bottom panel shows the Plotter tool, where the boxcar result is displayed over a period of 10 s. The math tab of the Plotter tool allows users to calculate relevant information from the visualized result such as average, standard deviation and SNR. Image Credit: Zurich Instruments AG
A simplified block diagram of the UHFBOX Boxcar Averager is shown in Figure 5 (a). The signal is phaselocked to an internal oscillator so that the boxcar window is defined in terms of the phase. The phasesynchronous data processing of a periodic signal is insensitive to trigger jitter and drift, and is patented by Zurich Instruments [3]. The boxcar averager results can be routed internally to other tools, for example to the lockin amplifier unit if the duty cycle of the signal is subject to an additional modulation, or to the internal PID controllers for creating feedback loops. Thanks to the digital calculation of the moving average, intermediate results of the boxcar averager output can be obtained and used to implement fast feedback loops.
Periodic Waveform Analyzer
Choosing the width and the position of the boxcar window can be challenging if the signal is buried in noise. The UHFBOX Boxcar Averager facilitates this process by providing a periodic waveform analyzer (PWA) tool displaying a single period of the input signal. If the SNR is low, the input signal can be averaged over many periods. In Figure 5 (b), the boxcar window is defined with respect to the phase of the reference oscillator. With the PWA users can also calculate the Fast Fourier Transform of the input signal and thereby display and analyze the weighting of the harmonics with respect to the fundamental frequency.
Figure 5. Features of the Zurich Instruments UHFBOX Boxcar Averager. (a) Simplified block diagram. The signal is phaselocked to an internal oscillator, which enables to define the boxcar and reference windows in terms of the phase. (b) Periodic waveform analyzer showing one period of the input signal. The boxcar and the reference window are highlighted in grey. Image Credit: Zurich Instruments AG
Baseline Suppression and Arithmetic Operations
In the UHFBOX Boxcar Averager, inaccuracies due to DC components and variable offsets can be removed thanks to a reference window in the time interval between pulses. This socalled baseline suppression also enables the rejection of disturbing input signals that are phaseshifted with respect to the signal of interest at the fundamental frequency, such as electronic reflections in the cables. The position of the reference window can be chosen using the PWA, as shown in Figure 5 (b).
The concept of a reference window is ideal for experiments where the information of interest is only present in every other pulse, as is the case in pumpprobe spectroscopy with pumpinduced transmission change. By setting two filter windows in the time domain, individual signal components can be successfully isolated.
The UHFBOX Boxcar Averager offers two independent boxcar units, each with baseline suppression, and a builtin Arithmetic Unit. The Arithmetic Unit can provide realtime results based on a combination of two parallel boxcar measurements with arbitrary scaling factors, for example to capture dI/I on a shottoshot basis by normalizing the result with a second boxcar measurement.
Boxcar Averager vs. Lockin Amplifier
Lockin amplifiers and boxcar averagers use different methods to measure a periodic signal. A boxcar averager captures information from the fundamental frequency of the signal and many harmonics, whereas a lockin amplifier performs a selective measurement at a single frequency. The latter is achieved by multiplying the input signal with a reference signal that is typically sinusoidal, followed by adjustable lowpass filtering. The spectral response, measurement speed and temporal response depend on the bandwidth and the order of the lowpass filter as described in the lockin detection white paper.
When establishing which measurement approach is better suited to a given experiment, some important considerations are:
 What is the waveform of the input signal? Is it a sine wave, a square wave, a train of periodic pulses, or a more complex waveform?
 What is the duty cycle of the input signal?
 How low is the SNR of the input signal? What are the properties of the noise?
 What are the requirements in terms of acquisition speed and settling time?
For a purely sinusoidal input signal, lockin detection is generally the method of choice because the experiment can be set up quickly and easily. A boxcar measurement with the same measurement bandwidth can give a slightly higher SNR with an optimized boxcar window and baseline suppression. Optimizing a boxcar measurement requires the control of more parameters compared to setting up a lockin measurement, however, and boxcar averagers are typically more expensive due to the need for a larger signal input bandwidth to capture higher harmonics.
The higher effort of setting up a boxcar measurement becomes valuable for a square wave or a pulsed signal. The lower the duty cycle of the input signal, the more information is contained in the harmonics. A boxcar averager allows experimenters to capture this information by decreasing the boxcar window width, thereby putting more relative weight on higher harmonics. Capturing the information from higher harmonics also leads to additional noise contributions though. Overall, the true advantage of boxcar averaging over lockin detection depends on the properties of the noise background.
Figure 6 (a) shows the typical noise floor of an experiment, consisting of white noise and 1/f noise. The spectral response of a 1storder lowpass filter for a lockin amplifier is indicated around the fundamental frequency f_{rep}. In this example, the noise at the fundamental frequency f_{rep} is dominated by 1/f noise. A lockin amplifier thus captures a significant amount of noise, leading to a small SNR for this measurement. Figure 6 (b) presents the spectral response of a boxcar averager with a duty cycle of d = 0.05 and N = 20 averaging periods with the same noise background: by capturing the information from the harmonics where less noise is present, boxcar averaging results in a significantly higher SNR in this scenario.
Figure 6. Comparison of the spectral response of a lockin amplifier and a boxcar averager. (a) Logarithmic plot of the spectral response of a 1storder lowpass filter centered at the fundamental frequency. The typical noise floor consisting of white noise and 1/f noise is shown with arbitrary amplitude. (b) Logarithmic plot of the spectral response of a boxcar averager with a duty cycle of d = 0.05 and N = 20 periods with the same noise floor. Image Credit: Zurich Instruments AG
Additionally, being able to define a reference window in the time domain offers a very powerful way to avoid systematic measurement errors due to noise sources phaseshifted with respect to the signal of interest, while making it possible to isolate individual signal components as is required when measuring pumpinduced effects, for instance.
Finally, the filter function is a critical aspect for measurement speed. Let's consider a signal with f_{rep} = 10 MHz. Reaching 99.9% settling with a 5thorder lowpass filter and a filter bandwidth of f_{3dB} = 34 kHz takes approximately 26 us (see the lockin detection white paper for the calculation). By contrast, a boxcar averager with a bandwidth of 34 kHz (N = 128 averaging periods) reaches 100% settling after NT_{rep} = 12.8 us. In the case of videorate microscopy, for example, it is therefore easier to avoid crosstalk between pixels with a boxcar averager.
In summary, lockin measurements are easy to set up and less demanding in terms of input bandwidth and sampling rate. Boxcar averaging requires faster electronics and the optimization of several parameters, but this added complexity becomes valuable for lowdutycycle pulsed signals where it enables to push the limits in terms of SNR and measurement speed. The best way to settle on a measurement strategy is a onetoone comparison between a lockin amplifier and a boxcar averager. Alternatively, users can consider implementing both methods simultaneously: this is possible on the Zurich Instruments UHFLI Lockin Amplifier with the UHFBOX Boxcar Averager option.
References
 M. Plancherel and M. Leffler. Contribution à l’étude de la représentation d’une fonction arbitraire par des intégrales définies. Rendiconti del Circolo Matematico di Palermo, 30:289, 1910.
 R. J. Blume. Boxcar integrator with long holding times. Review of Scientific Instruments, 32(9):1016, 1961.
 Zurich Instruments. Lockin amplifier with phasesynchronous processing, 2014. Patent US20140218103A1.
This information has been sourced, reviewed and adapted from materials provided by Zurich Instruments AG.
For more information on this source, please visit Zurich Instruments AG.