Moku is a software-defined instrumentation platform for developing, testing, and controlling new technology and designs. Combining instrument integration with unrivaled flexibility, Moku’s intuitive workflow helps scientists, students, and engineers boost efficiency and de-risk projects.
Signal Delay Generation
Precisely adjusting the delay of a signal can be important in many applications. For example, in high-speed signal transmission it is important to balance and compensate for the delays between different signal paths induced by cable length mismatches, differences in signal processing time, and many other factors. The most common way to generate delay digitally is to use a delay register to temporarily store the input signal and then output the signal in the next clock cycle. The amount of delay can be adjusted simply by chaining additional delay registers in between the signal path. The minimum delay is limited by the clock speed. For digital signals, increasing clock speed is relatively low cost. However, for analog signals the price for a high-speed ADC can be significantly higher. The extra sampling rate and bandwidth may also introduce additional noise to the system.
Figure 1: Digital delays can be generated by a delay register.
To introduce a delay that is not an integer multiple of the clock period can be more complicated. For sinusoidal signals, delay can be generated by a phase-locked loop (PLL). The Phasemeter can be configured as a PLL capable of tracking a sinusoidal signal from 1000 Hz to 200 MHz and output a phase-locked copy of the input signal with an arbitrary phase shift. However, the output is limited to sinusoidal waveforms. The triggered output function on the Arbitrary Waveform Generator can be used to generate delays by outputting a shifted preloaded signal. However, this method would only work for well-defined repetitive signal. In this article, we will demonstrate how to use Moku:Lab’s FIR Filter Builder to generate fractional delays for arbitrary analog inputs. This method can be implemented with Moku:Go and Moku:Pro FIR Filter Builders as well.
Finite Impulse Response (FIR) Filters and Integer Delay
Finite impulse response (FIR) filters are used for implementing a band selection filter on digitized data. The filter is typically defined by a discrete impulse response function. The system conducts a numerical convolution of the input signal with a user-defined impulse response function on each sampling cycle and continuously outputs the convolved result. This time-domain convolution process can be considered as a multiplication process (of the Fourier transform function) in the frequency domain. By designing the shape of the impulse response function, we can effectively perform frequency band selection in the time domain. For example, if the impulse response of the system is a delta function, the Fourier transform of the delta function is a constant, and therefore gives a flat response in the frequency domain. After the multiplication in the frequency domain, the spectrum of the input signal remains unchanged. Therefore, a delta impulse response function corresponds to an all-pass filter.
Figure 2: A delta impulse response function generates an all-pass frequency response.
By adding additional zeros before the impulse, we can add integer delay (with respect to the clock speed) to our system. Moku:Lab’s FIR Filter Builder instrument can deploy two FIR filters at a time with up to 14,819 coefficients (length of the impulse response function). It allows users to deploy predefined impulse functions or upload impulse response functions from a file. To demonstrate the effect of integer delay, a 10 kHz sine wave was sent to Input 1 of a Moku:Lab with the FIR Filter Builder instrument deployed. The control matrix in the FIR Filter Builder combines, rescales, and redistributes the input signal to the two independent filter paths. The output vector is the product of the control matrix multiplied by the input vector:
The control matrix was set [1, 0; 1, 0] to route Input 1 to both filter paths as shown in Figure 3 below. An impulse response of [0, 1] was used on the top (green) filter, and [0,0,1] was used on the bottom (purple) filter. Both filters were running at 122.1 kHz. At the output probe point, we could see a delay of 1/122.1 kHz was generated between the two channels.
Figure 3: Integer clock delay generated with Moku:Lab’s FIR Filter Builder
From Integer to Fractional Delay
While it is easy to generate integer delay by adding zeros before the delta function, it may not be apparent at first glance how fractional delays can be generated by the FIR filters. The first step is to expand the single point delta function to a finite/windowed sinc function. Although the sinc function has a finite rectangular response in the frequency domain, which limits the bandwidth of the filter compared to the delta function all-pass filter (sampling rate limited), this gives us additional non-zero points in the time domain to generate a delay for the filter. Let us assume the delayed output , the Fourier transform of can be written as:
Similarly, the Fourier transform of the delayed filter can be written as:
When the input signal convolves with the delayed filter , the output in the frequency domain can be expressed as:
To convert everything back to the time domain, this can be described with the following equation:
Therefore, we can effectively generate a fractional delay by convolving the signal with a delayed filter. A more detailed derivation can be found in reference 1.
However, there is one limitation to this approach. The sinc impulse response function is a doubled-sided even function. Therefore, it is not possible to place the center of the impulse response at time 0. Otherwise, the system would need to start responding before the signal arrives at the input. This is considered a non-casual filter. To make the filter casual, we need to shift the entire impulse response to a later point in time (to the right). Therefore, the total input and output latency (group delay) is limited by the number of points in the impulse response.
Figure 4: The overall process for generating a fractional delay impulse response function
There are several tools that can generate fractional delay FIR coefficients. In the following demonstration, we used MATLAB’s designFracDelayFIR function and generated a 16-coefficient fractional delay filter with a delay of 0 and 0.5. The filters were generated using the following MATLAB code:
Next, the 0 delay and 0.5 delay filter coefficients were uploaded to the top (green) and bottom (purple) FIR filters, respectively. The same 10 kHz sine wave was sent to Input 1 of the Moku:Lab. At the output, a 4.095 μs delay (1/2 sampling cycle) was observed.
Figure 5: A 0.5 fractional delay was generated by Moku:Lab’s FIR Filter Builder.
Tradeoff between Total Delay, Impulse Response Length, and Filter Bandwidth
By increasing the length of the impulse responses function, given the same sampling rate, we can effectively narrow the impulse response in the time domain. Therefore, the passband of the fractional delay filter increases. On the other hand, a longer filter requires a larger shift in the time domain to make the filter casual. Therefore, the total input-to-output latency increases. To demonstrate this effect, we implemented two 0.5 fractional delay filters with 16 and 64 coefficients. A Moku:Go Frequency Response Analyzer was used to characterize the frequency response of the filter. Channel 1 (blue) showed the frequency and phase response of the 16-coefficient filter, and channel 2 (orange) showed the frequency and phase response of the 64-coefficient filter. The 64-coefficient filter had a wider passband (closer to the Nyquist frequency), and the 16-coefficient filter had a shorter group delay.
Figure 6: Frequency and phase responses of 16 and 64-coefficient FIR filters.
Reference and Further Readings
- Valimaki, V. P. (1998). Discrete-time modeling of acoustic tubes using fractional delay filters.
- Valimaki, Vesa, and Timo I. Laakso. “Principles of fractional delay filters.” In 2000 IEEE International Conference on Acoustics, Speech, and Signal Processing. Proceedings (Cat. No. 00CH37100), vol. 6, pp. 3870-3873. IEEE, 2000.
- Shaddock, Daniel A., Brent Ware, Robert E. Spero, and M. Vallisneri. “Postprocessed time-delay interferometry for LISA.” Physical Review D 70, no. 8 (2004): 081101.
- Design of fractional delay FIR filters. Design of Fractional Delay FIR Filters. Retrieved November 1, 2021, from https://www.mathworks.com/help/dsp/ug/design-of-fractional-delay-fir-filters.html.
Have questions or want a printable version?
Please contact us at [email protected]