APPLICATION NOTE 6631

Abstract: This application note discusses how to get more accurate readings from ultrasonic transducers used in liquid and gas flow meters. It describes a software compensation technique used to overcome flow-rate readings that might be inaccurate because of characteristic differences between measurement devices.

This application note describes a software compensation technique that reduces time-offset errors over temperature. Ultrasonic transducers used for flow measurement can have substantial characteristic differences from one device to the next. In applications that require high accuracy, such as liquid and gas flow meters, these differences can impart temperature-dependent offsets in the time-difference measurements that time-to-digital converters—such as the MAX3510x devices—return. This results in calculated flow rates that are often offset from the actual flow rate.

Zero-flow, constant temperature experiments with 500kHz gas transducers, for example, have registered time offsets (Δ_{τ}) of as much as 50ns; offset changes from 10°C to 40°C registered as high as 10ns.

MAX3510x devices apply an excitation signal to the transmitting transducer. The signal is a square wave of programmable frequency and duration. The transducer responds to this signal by vibrating in a way that is not only dependent on the input frequency spectrum (predominately odd harmonics) but also on internal characteristics. The resulting acoustic waveform contains a frequency spectrum that is different from the source.

A similar situation exists with the receiving transducer. The received acoustic waveform and the electrical spectrum emitted by the receiving transducer are also different. The aggregate of these differences manifests itself in the time domain as a dynamic delay.

If both transducers have identical characteristics, then this delay error is the same in both directions. They would, therefore, cancel out during the delta-time calculation that is required to determine the flow rate. Transducers of the same model and manufacturing batch, however, have been found to have significantly different electromechanical characteristics. Moreover, the predominate transducer characteristics are sensitive to temperature. These deviations from ideal behavior require per-unit compensation for most flow-measuring applications.

Equation 1 expresses the problem mathematically, as follows:

Δ_{τ} = (τ_{u} + τ_{u𝑒}) − (τ_{d} + τ_{d𝑒})

where,

Δ_{τ} = time difference measurement necessary for flow calculations, TOF_DIFF, from the MAX3510x

τ_{u} = actual time of flight in the Up direction

τ_{d} = actual time of flight in the Down direction

τ_{u𝑒} = aggregate time error in the Up direction

τ_{d𝑒} = aggregate time error in the Down direction

In perfectly matched transducers, τ_{u𝑒} = τ_{d𝑒}, and therefore they fall out of the equation. In actual transducers, the second equation indicates it is expected that τ_{u𝑒} − τ_{d𝑒} can be approximated by a function of temperature specific to the transducer pair:

ƒ_{𝑒}(τ) = τ_{u𝑒} − τ_{d𝑒}

Combining the first and second equation, then, we have Equation 3, as follows:

Δ_{τ} = ƒ_{𝑒}(τ) + τ_{u} − τ_{d}

Therefore, to obtain actual time-of-flight difference, Δ′τ, we compensate Equation 3 with −ƒ_{𝑒}(τ), as Equation 4 below shows:

Δ′τ = Δ_{τ} − ƒ_{𝑒}(τ)

The phenomena represented by τ_{u𝑒} and τ_{d𝑒} are complex. Instead of attempting to develop a rigorous model, we use an experimental approach based on the hypothesis presented above.

Initial tests consisted of four test devices (no. 10, no. 11, no. 12, and no. 16). Each test device comprised a closed, air-filled tube with a 500kHz generic transducer at either end, driven by a MAX32625MBED board with a MAX35104EVKIT2 Arduino shield. The closed tube ensured that net material flow within the tube was practically zero. The temperature was maintained at approximately 10°C ± 0.5°C over a 7.5-hour period, and Δ_{τ} was recorded. **Figure 1** shows the baseline results for the four test devices.

*Figure 1. 10C baseline.*

Table 1 shows that the results revealed that ƒ_{𝑒}(τ) was constant with less than 3ns standard deviation, but significantly different for each unit under test. Further, when the polarity of the tube was reversed (the Up transducer swapped with the Down transducer in each tube), the sign of ƒ_{𝑒}(τ) changed accordingly.

**Table 1. Results from the 10C Baseline Tests**

DUT ID# | ƒ_{𝑒}(10) |
Standard Deviation (ns) |
---|---|---|

10 | -53.2E-09 | 2.12E-09 |

11 | -1.63E-09 | 1.41E-09 |

12 | 5.83E-09 | 2.50E-09 |

16 | 18.4E-09 | 2.93E-09 |

The initial test was repeated at 40°C, and the value of ƒ_{𝑒}(τ) changed substantially for each unit under test, although the specific value remained constant throughout the test.

A third test was run at 25°C, and the results were compared to the previous two tests. The comparison indicated that ƒ_{𝑒}(τ) could be reasonably approximated by a linear function, as shown in Equation 5 below.

ƒ_{𝑒}(τ) = c_{1}t + 𝑐_{2}

Therefore, Equation 6 is as follows:

Δ′τ = Δ_{τ} − c_{1}t − 𝑐_{2}

c_{1} and 𝑐_{2} are constants that can be obtained by a two-point linear calibration method on a per-unit basis, as described below in Equation 7 and Equation 8.

c_{1} = (Δ_{τ2} − Δ_{τ1})/(τ_{1} − τ_{2})

𝑐_{2} = (τ_{2}Δ_{τ1} − τ_{1}Δ_{τ2})/(τ_{1} − τ_{2})

where,

Δ_{τ1} = the mean Δ_{τ} during stable τ_{1} temperature

Δ_{τ2} = the mean Δ_{τ} during stable τ_{2} temperature

τ_{1} = the first point temperature

τ_{2} = the second point temperature

Equation 6 is problematic because it requires knowing the temperature of the transducers; adding a temperature sensor to the product is an expense to be avoided if possible. Additionally, the measured temperature can be significantly different from the actual temperature of each transducer, depending on the product and its environment.

If ƒ_{𝑒}(τ) describes the aggregate of some phenomena within the transducers with respect to temperature, then it may be that that phenomena could influence other measurable parameters. Considering that the error manifests in the time domain and that the MAX3510x can measure time very accurately, an experiment was devised to measure the received oscillation period in each direction and compare that to temperature. The assumption here is that the received oscillation period is a good indicator of what is happening in the frequency domain based on the original hypothesis.

**Figure 2** shows the results of tests comparing the aggregate oscillation period and temperature. The figure shows a relationship between the aggregate oscillation period and temperature. It is not a strictly linear relationship, but as will be seen later, a linear compensation method still yields results acceptable to most flow-meter applications. If a higher level of accuracy is required, then a higher order compensation function might be required.

*Figure 2. Aggregate oscillation period.*

The MAX35103 and MAX35104 can be programmed to return the time of the zero crossings of up to six waves along with time difference measurement, Δ_{τ}, or TOF_DIFF. The six waves, called "hit waves" hereafter, can be used to measure the aggregate oscillation period, as follows:

p_{α} = h_{u}(n + 1) + h_{d}(n + 1) - h_{u}(n) - h_{d}(n)

where,

p_{α} = the aggregate oscillation period

n = the particular hit wave time value to use in the calculation. 0 < n < 6 (larger n values are typically better).

h_{d} = the hit wave time value in the down direction

h_{u} = the hit wave time value in the up direction

For example, an application can use hit waves No. 6 and No. 5 to calculate p_{α}, as follows:

p_{α} = h_{u}(6) + h_{d}(6) - h_{u}(5) - h_{d}(5)

The aggregate oscillation period is the sum of the received waveform period as measured by the difference of two adjacent hit values.

Note that the aggregate oscillation period, p_{α}, is twice the period of the average transducer oscillation period as seen
by the receiver. Average oscillation period might be a more intuitive measurement, but the constant 2 denominator isn’t
mathematically significant once compensation is applied, so aggregate oscillation period is used instead.

Adapting Equation 7 and Equation 8 to use aggregate oscillation period, we get Equation 8 and Equation 9, as follows:

c_{1} = (Δ_{τ2} − Δ_{τ1})/Pα_{1} − Pα_{2})

c_{2} = (Pα_{2}Δ_{τ1} − Pα_{1}Δ_{τ2})/(Pα_{1} − Pα_{2})

where,

Δ_{τ1} = the mean Δ_{τ} during stable τ_{1} temperature

Δ_{τ2} = the mean Δ_{τ} during stable τ_{2} temperature

p_{α1} = first point aggregate oscillation period

p_{α2} = tsecond point aggregate oscillation period

**Figure 3** shows the final test that was run using the compensation method described in Equation 6 for each device under
test. The figure relates compensated (Δ_{τ},right,orange) and uncompensated (Δ_{τ},left,blue) time difference
measurements.

*Figure 3. Compensation analysis.*

As can be seen, the compensation method presented in this application note reduces transducer-related time errors to within one standard deviation of baseline. The table below provides more detail.

**Table 2. Detailed Results of Compensation Analysis**

DUT ID# | Δ_{t1} error |
Δ′τ error |
---|---|---|

10 | -5.16E-08 | -1.30E-10 |

11 | -1.81E-09 | -1.05E-10 |

12 | 5.45E-09 | -8.71E-12 |

16 | 1.81E-08 | -3.03E-11 |

Close inspection of the results reveal that increased errors occurs during temperature changes. This hints at the possibility of higher-order terms in the transducer time-error phenomenon. Some applications might require high-order compensation functions such as:

ƒ_{e}(τ) = c_{1}t^{2} + c_{2}t + c_{3}

Constant calculation for this equation is not discussed in this application note. The reader is referred to mathematical sources on polynomial curve fitting. Other types of curve fitting might be applicable, as well. It may also be the case t hat there is a temperature differential contributor to aggregate oscillation period.

MATLAB^{®} was used to organize and analyze the transducer data. The transducer data set and MATLAB (2016a or later)
scripts are available for download at the following address:

Alternatively, you can locate the MATLAB package on the MAX35104 product page, under the design resources tab at the following address:

The MATLAB scripts contained in the package contain implementations of the calibration and compensation algorithms presented here.

report.m—This script generates the chart above using cal.m.

dt.m—Extracts delta-t from the given TOF hit value array.

cal.m—Returns a structure containing calibration and compensation information for report.m.

cal_coefs.m—Returns coefficients given delta-t array, aggregate period array, and two-point calibration ranges.

per.m—returns aggregate period array given a TOF hit value array.

comp.m—Returns compensated delta-t given the aggregate period and the calibration coefficients.

quad.mat—contains the raw hit value and temperature data used in the final test.

Differences in paired ultrasonic transducers cause substantial time errors that must be compensated for in software. Temperature and aggregate oscillation period can be used in a two-point linear compensation algorithm to correct for transducer time error.