There are a number of various applications where determining the time-of-flight (TOF) of a signal is required. These applications include laser range finders, ultrasonic level detectors, and ultrasonic flow meters. In general, a system for determining TOF can take two forms: pitch-catch and pulse-echo.
A simple threshold technique might be used to determine time-of-flight. However, in many systems this will provide a less than desirable resolution.
For example, when a system employs ultrasonic transducers, these transducers are resonant devices with a limited bandwidth, and therefore the signal has an associated envelope with a rise and fall time. Any additive noise in the system could cause false readings by either accelerating or decelerating the threshold crossing. This is commonly referred to as cycle slip. A number of techniques have been used to improve the resolution of the TOF measurement including demodulating the envelope and cross-correlation methods. However, the former technique still relies heavily on the amplitude information in the signal and the latter technique is easily corrupted by noise in the signal.
Achieving a required degree of accuracy in the time-of-flight measurement is both critical and difficult.
What is needed, therefore, is an accurate method of determining the time-of-flight of a signal. What is also needed is a system which can accurately measure the time-of-flight of a signal.
In an example embodiment, a method comprises: receiving a signal having a first series of first pulses each having a fundamental period T and each being substantially at zero degrees in phase with respect to each other, and having a second series of second pulses following in time after the series of first pulses, the second pulses also having the fundamental period T and each being shifted in phase with respect to the first pulses; (1) providing a window having a width substantially the same as the fundamental period T; (2) aligning the window with a wth interval of the received signal within the first series of first pulses; (3) multiplying the received signal by the window to produce a product for the wth interval of the received signal; (4) determining a magnitude and phase of the product for the Wth interval at a fundamental frequency F=1/T; (5) incrementing w by one, delaying the window by one fundamental period, and repeating steps (2) through (4) to produce N sets of magnitude and phase data at the fundamental frequency F for N intervals of the received signal spanning at least one of the first pulses and at least one of the second pulses; (6) from the N sets of magnitude and phase data, determining when a phase transition occurs in the received signal due to a transition from the first pulses to the second pulses; and (7) determining a time-of-flight of the signal from a time when the phase transition occurs in the received signal.
In another example embodiment, a method comprises: receiving a signal having a series of pulses of period T, the series of pulses having a phase transition provided therein; windowing the received signal with a window having a width substantially the same as T to determine a magnitude and phase of the windowed signal at a frequency F=1/T; sliding the window in time, one period T at a time, with respect to the received signal to produce N sets of magnitude and phase data at the frequency F; from the N sets of magnitude and phase data, determining a time when the phase transition occurs in the received signal; and determining a time-of-flight of the signal from the time when the phase transition occurs in the received signal.
In yet another embodiment, a system, comprises: a receiver configured to receive a signal having a series of pulses of period T, the series of pulses having a phase transition provided therein; and a processor configured to execute an algorithm. The algorithm comprises: windowing the received signal with a window having a width substantially the same as T to determine a magnitude and phase of the windowed signal at a frequency F=1/T; sliding the window in time, one period T at a time, with respect to the received signal to produce a plurality of N sets of magnitude and phase data at the frequency F; from the N sets of magnitude and phase data, determining a time when the phase transition occurs in the received signal; and determining a time-of-flight of the signal from the time when the phase transition occurs in the received signal.
The example embodiments are best understood from the following detailed description when read with the accompanying drawing figures. It is emphasized that the various features are not necessarily drawn to scale. In fact, the dimensions shown in the drawings may be arbitrarily increased or decreased for clarity of discussion. Wherever applicable and practical, like reference numerals refer to like elements.
In the following detailed description, for purposes of explanation and not limitation, example embodiments disclosing specific details are set forth in order to provide a thorough understanding of an embodiment according to the present teachings. However, it will be apparent to one having ordinary skill in the art having had the benefit of the present disclosure that other embodiments according to the present teachings that depart from the specific details disclosed herein remain within the scope of the appended claims. Moreover, descriptions of well-known apparati and methods may be omitted so as to not obscure the description of the example embodiments. Such methods and apparati are clearly within the scope of the present teachings.
Unless otherwise noted, when a first device is said to be connected to a second device, this encompasses cases where one or more intermediate devices may be employed to connect the two devices to each other. However, when a first device is said to be directly connected to a second device, this encompasses only cases where the two devices are connected to each other without any intermediate or intervening devices. Similarly, when a signal is said to be coupled to a device, this encompasses cases where one or more intermediate devices may be employed to couple the signal to the device. However, when a signal is said to be directly coupled to a device, this encompasses only cases where the signal is directly coupled to the device without any intermediate or intervening devices.
In a beneficial arrangement, embodiments of a time-of-flight (TOF) measurement system use a short-time or transient Fourier transform technique to extract the magnitude and phase of a transmitted signal in a transient nature so as to determine a time tφRx when the phase transition is received. By comparing the time tφRx to a known time tφTX when the phase transition 230 was transmitted, the time-of-flight tTOF of the signal can be determined.
In embodiments described in greater detail below, the received signal is digitized and sampled to produce digital samples of the received signal. A window (beneficially, a square window) of width equal to the fundamental period T is multiplied by the digital samples of the received waveform, and a fast Fourier transform (FFT) of the product is computed. The window is then sequentially stepped through the received signal, one fundamental period T at a time, and the process is repeated for each window position. This process builds up a dataset of magnitude and phase values of the received signal at the fundamental frequency F. From this dataset, the window where the phase transition is received can be determined, and for this, the time-of-flight tTOF of the signal can be determined.
Note that due to the resonant nature of the system in this embodiment, the pulses in received signal 310 are sinusoidal in nature. The magnitude and phase of the FFT are easily calculated by the following formulas:
where X is the complex result of the FFT operation, w is the window index {0, N−1} and k is the frequency at which the FFT was calculated.
As can be seen in
The index w of the window interval during which the maximum 525 of the absolute value of the derivative of the phase of the FFT at the fundamental frequency F is located, is considered to be the window index wφRX in which the received phase transition 425 occurred in received signal 310. This value can be turned into the time tφRX of the received phase transition 425 by:
t
φRX
=T*w
φRX (3)
Since, the time tφTX of the transmitted phase transition 230 can be precisely controlled by the initiating circuit in the transmit circuitry (e.g. a microcontroller, FPGA, DSP, etc.), the time-of-flight, tTOF, of the signal can be determined by:
t
TOF
=t
φRX
−t
φTX (4)
The resolution of the time-of-flight tTOF determined by this procedure as described thus far is limited by the period of the window 320, which is the fundamental period T. Thus the TOF that can be determined from the procedure described thus far can only be as accurate as T.
In a step 605, a time-of-flight measurement procedure is initiated.
In a first step 610, a window 320 is created with period equal to the fundamental period T of the pulses in the received signal 310.
In a step 615, a selected period or interval of the received signal—or more precisely digital samples of the received signal—is multiplied by the window 320. The initial period or interval of the received signal is selected to be prior to the received phase transition 425.
In a step 620, a fast Fourier transform (FFT) is calculated for the product of window 320 and received signal 310 at the current window interval.
In a step 625, the magnitude and phase of the FFT data for the product of window 320 and received signal 310 at the current window interval at the fundamental frequency F is saved for later processing, as will be explained below.
In a step 630, it is determined with the last interval or period of received signal 310 has been reached. For example, when N window intervals (i.e., window index wε(0, N−1)) of received signal 310 are to be analyzed, then step 630 determines if w=N−1.
If not, then the process proceeds to step 635 where the window index w is incremented, and then the process returns to step 615.
Once all of the N window intervals are processed, then the process continues to step 640. In step 640, the derivative of the phase data at the fundamental frequency F as a function of window index w is calculated with respect to the window index w.
Then, in step 645, the magnitude of the derivative of the phase data at the fundamental frequency F as a function of window index w is calculated.
In step 650, the index W the window interval in which the maximum 525 of the absolute value of the derivative of the phase of the FFT at the fundamental frequency F is located.
In step 655, the window wφRX is converted into time tφRX of the received phase transition 425 using equation (3) above.
In step 660, the time-of-flight tTOF of the signal is determined using equation (4) above.
Finally, in step 665, the process ends.
Due to hardware limitations, cost-constraints, calculation efficiency, or speed, it may be undesirable to calculate an FFT for each windowed data set. A more efficient algorithm involves multiplying the windowed data set by a cosine and sine waveform as explained below.
The equation for the discrete Fourier transform of a data set, x, is:
where k corresponds to frequency in (radians/second), L is the length of the windowed data set, and i is the imaginary number SQRT(−1).
Since the fundamental frequency F of the transmit waveform is known, k is set to this frequency. The complex exponential can be rewritten as:
e
−ix=cos(x)−i sin(x) (6)
Thus, the Fourier transform can be rewritten:
and can be separated into real and imaginary components, given by:
The magnitude and phase of the signal can easily be calculated from the real and imaginary terms using the formulas in the previous algorithm. Thus, the calculation of the magnitude and phase of the signal can be simplified by multiplying the windowed data set by a cosine and sine term of proper frequency to find the real and imaginary components, rather than performing the FFT in the data set. So in some embodiments, the method 600 can be modified by changing step 620 to multiply the windowed data set by a cosine and sine waveform as explained above, instead of calculating the FFT. The subsequent steps in method 600 would remain the same.
In yet another alternative algorithm, a wavelet transform can be substituted for the Fourier transform in step 620. The wavelet transform may be advantageous when both improved frequency and time resolution is required of the short-time FFT. After computation of the complex data set via the wavelet transform, the algorithm would follow the remaining steps in method 600.
In some applications it may be desirable or necessary to provide a time-of-flight accuracy greater than the fundamental period T of the pulses in the transmitted signal. One solution to enhance the accuracy is to perform multiple passes through the algorithm while successively increasing the starting point of the first window. This improves the time-of-flight accuracy to that of the sampling rate, FSAMP, of the received signal. A detailed description follows.
Let M, be the number of sampled data points in each period T of received signal 310. The multi-pass algorithm begins the same as the method 600 by performing steps 605-650 to determine the window wφRX0 in which the phase transition 425 in received signal 310 occurs. Then, the start time of the initial window period (w=0) is shifted to the right by one sampled data point (NOT one period T) in received signal 310, and steps 605-650 are repeated to determine the window wφRX1 in which the phase transition 425 occurs. This process is repeated until wφRX(m-1) is determined. From this data, wφRX be plotted versus pass number as shown in
Another embodiment of a method for determining the time-of-flight tTOF of a signal improves the resolution of the measurement using the phase information of received signal 310. Utilizing the initial phase of received signal 310 as determined by the FFT can give subsample resolution of the time-of-flight tTOF of the signal.
As the time-of-flight of a signal varies slightly due to temperature, density, flow, etc., the initial phase of the signal will vary. This variation in phase can be used to enhance the accuracy of the time-of-flight measurement for the signal. One method is to average the phase, PHAVG, of the windows 320 prior to the phase transition 425 as determined by a method such as method 600. If we again have M sampled data points of the received signal per fundamental period, then the time tφRX of the received phase transition 425 is given by:
where PHAVG is given in degrees and a negative phase means a time lag of the signal.
In method 900, a data fitting routine is employed to match the measured phase response to an ideal phase response. Beneficially, this technique can provide subsample resolution.
Steps 905-935 of method 935 are the same as steps 605-635 of method 600 described above, and so a description thereof will not be repeated here.
In step 940, a mathematical formula representing an ideal phase vs. window curve is generated as:
where:
and where φ0 is an initial phase, and x is a parameter that is set based on the number of window intervals that the phase takes to reach its final phase shift (e.g., 180 degrees).
Once the mathematical formula representing an ideal phase vs. window curve is generated in step 940, and the phase data for each window index w is generated by the steps 905-935, then in step 945 a data fitting routine such as least mean squares fits g(w) to the measured data by finding values for φ0 and wd.
In step 950, the fitted delay wd (which can be non-integer) is saved. The fact that wd can be non-integer improves the resolution of this embodiment beyond the resolution of method 600. Then the time tφRX of the received phase transition 425 is calculated as:
t
φRX
=T*w
d (15)
In step 960, the time-of-flight tTOF of the signal is determined using equation (4) above.
Finally, in step 965, the process ends.
Another alternative embodiment uses a cross-correlation technique to find the index w of the window 320 where phase transition 425 occurs in received signal 310. As opposed to an algorithm that attempts to cross correlate the amplitude of the received signal to an ideal representation of the received signal, this embodiment cross-correlates the windowed phase data from the received signal 310 with an ideal windowed phase curve. As the ideal phase response is stepped through the sampled data from received signal 310, the maximum of the cross-correlation, CMAX, a gives the location of phase transition 425. Thus:
t
φRX
=T*c
MAX (16)
Steps 1005-1035 of method 1000 are the same as steps 605-635 of method 600 described above, and so a description thereof will not be repeated here.
In step 1040, an ideal windowed phase curve is generated based on the transmitted signal.
In step 1045, the windowed phase data from the received signal 310 is cross-correlated with the ideal windowed phase curve, and the index w of the window 320 having the cross-correlation maximum or peak, wφRX is established as the window 320 where phase transition 425 occurs in the received signal.
From wφRX in step 1050 the time-of-flight tTOF of the signal is determined using equations (3) and (4) above.
Finally, in step 1055, the process ends.
In some embodiments, receive transducer 1105 and transmit transducer 1150 are each acoustic transducers—for example, ultrasonic transducers.
Processor 1125 may be a general purpose digital signal processor (DSP), microcontroller, programmable logic device, programmable gate array, custom ASIC, or a general purpose microprocessor executing a computer program, the executable code for which may be stored, for example, in memory 1130. Beneficially, processor 1125 generates either a digital transmit signal or an analog transmit signal via an on-board digital-to-analog converter (DAC). This signal may be routed to drive circuit 1130 which amplifies the signal or otherwise converters it for application to transmit transducer 1135. The received signal from receive transducer 1105 may be amplified by preamplifier 1110, and then (optionally) is filtered by filter 1115 and then sampled with ADC 1120. In an alternative embodiment, the analog-to-digital-conversion function may be performed with processor 1125.
In some embodiments, the sampled receive data may require further manipulation or processing before the TOF measurement methods described above may be performed.
The process starts at step 1205.
At step 1210, processor 1125 initiates or generates the transmit waveform (see, e.g.,
In some cases, the receive signal 310 may be such that areas of received signal 310 far from the actual phase transition time 425 provide erroneous data that causes false positives in the algorithm.
Accordingly, in an optional step 1235, the sampled receive data set may be limited by one or more means. In one embodiment, a TOF seed value is employed, based on user or system input as a region to look for phase transition 425. This seed may be made adaptive based on past values of the TOF and/or phase transition 425 or it may employ feedback from some other sensor or input. In another embodiment, all receive data that is below a certain amplitude threshold is simply ignored, thereby eliminating unreliable data. In yet another embodiment, the receive data set is limited by performing a cross-correlation of the amplitude to find a likely region for phase transition 425, and that is employed as a TOF seed.
Turning back again to method 1200, in step 1250 a method such as any of the methods described above (for example with respect to
Then in step 1245, the process ends.
While example embodiments are disclosed herein, one of ordinary skill in the art appreciates that many variations that are in accordance with the present teachings are possible that remain within the scope of the appended claims. The embodiments therefore are not to be restricted except within the scope of the appended claims.