Table of Contents

www.ti.com

Application Report

USS Water Flow Rate Calibration

Eddie LaCost, Srinivas Lingam

MSP430 Applications
ABSTRACT

Accuracy measurements for ultrasonic water flow metering are affected by temperature, particularly at flow rates
lower than 100 lph. These errors can be as large as 10-15% for 5-55°C, where as the target specification isapproximately ±1% accuracy.
For flow rates greater than 100 lph the temperature sensitivity is lower, presumably since the flow is alreadyturbulent. This application report presents off-line calibration and on-line compensation techniques to meet the±1% accuracy requirements across all temperatures and flow rates in the 5-55°C range using theMSP430FR604x ultrasonic sensing microntrollers. This accuracy is achieved by a two-dimensional polynomial
lookup table across temperature and flow. The coefficients are generated using a bilinear fit to quadrilaterals
including measurements across multiple meters. An efficient ray casting algorithm is then presented that is usedduring runtime for searching the appropriate interpolation coefficients. Measurement results show that the target
accuracy can be achieved by these algorithms. The calibration discussed in this document is available in USSLib
version 2.30.00.xx or later and can be downloaded from: https://software-dl.ti.com/msp430/
msp430_public_sw/mcu/msp430/USSSWLib/USSSWLibWater/latest/index_FDS.html

Table of Contents
1 Flow Calibration Without Temperature Compensation....................................................................................................... 22 Calibration Algorithms........................................................................................................................................................... 2
3 Calibration Procedure............................................................................................................................................................ 8
4 Results and Conclusions.......................................................................................................................................................85 References.............................................................................................................................................................................11

List of Figures
Figure 2-1. Typical Ultrasonic Water Meter..................................................................................................................................2Figure 2-2. Typical Waveform Arrival and Definition of Absolute Time of Flight.......................................................................... 2Figure 2-3. Flow Error Curves for 10°C and 45°C DN20 Meter...................................................................................................3Figure 2-4. Temperature vs. Sound velocity in water...................................................................................................................4Figure 2-5. Representative Quadrilateral Figure......................................................................................................................... 5Figure 2-6. 3D View With Several Spools Tested........................................................................................................................ 6Figure 4-1. Calibration Quadrilaterals..........................................................................................................................................9Figure 4-2. Calibrated and Uncalibrated Volume Flow Error at 30°C........................................................................................ 10Trademarks
All other trademarks are the property of their respective owners.

SLAA959 – OCTOBER 2020
Submit Document Feedback

USS Water Flow Rate Calibration
Copyright © 2020 Texas Instruments Incorporated

1

www.ti.com

Flow Calibration Without Temperature Compensation

1 Flow Calibration Without Temperature Compensation
In applications where the temperature range is minimal or temperature changes do not affect the flow rateaccuracy greatly, a multiple or single point calibration can be implemented without the use of temperaturecompensation. Details of this implementation can be found in the USS Design Center Users Guide in thecalibration section.

2 Calibration Algorithms
Figure 2-1 shows a typical ultrasonic water flow meter.

Figure 2-1. Typical Ultrasonic Water Meter
The basic flow meter equation for absolute time of flight is given in Equation 1.

T12cLv cos

T21FLY FRV(1)

Where T12 is the absolute time of flight in transducer 1->2 direction and T21 is the absolute time of flight in thetransducer 2 → 1 direction. c is the speed of sound in the medium (water), L is the spacing between thetransducers, and v is the flow rate of the medium.
Texas Instruments has developed a solution for water flow metering using the ADC approach of capturing thereceived waveforms. A typical analog to digital (ADC) captured received waveform for an ultrasonic water flow
meter, using 1 MHz transducers and 20 pulses for transmission is shown in Figure 2-2.

Figure 2-2. Typical Waveform Arrival and Definition of Absolute Time of Flight

2USS Water Flow Rate Calibration

SLAA959 – OCTOBER 2020
Submit Document Feedback
Copyright © 2020 Texas Instruments Incorporated

Calibration Algorithms

www.ti.com

The velocity of water flow can be solved with Equation 2.

v

L § 1u¨2 ¨© T121 ·¸
T 21 ¸¹

L § T 21 T12 ·u¨¸2 ¨© T 21T12 ¸¹L § 'T ·u¨¸2 ¨© T 21T12 ¸¹(2)Based on the cross sectional area the volume flow rate (F) is now proportional to the velocity v of fluid. This
proportionality constant can be calculated based on the calibration velocity at room temperature (25°C).
Similarly the velocity of sound in water can be solved with Equation 3.

CL § 1u¨2 ¨© T121 ·¸T 21 ¸¹(3)The water flow metering regulations [2] require an error in volume flow calculation of ±5% for low flow rates ofapproximately 100 lph and ±2% for higher flow rates. However, some applications and standards can havetighter requirements like ±2% for low flow rates and ±1% for higher flow rates. We present the general
methodology for improving the final accuracy. In general, the calibration table used here will be larger for tighter
requirements.
Measurements of the volume flow for a 20-mm diameter DN20 meter as a function of flow and for different
temperatures is given in Figure 2-3.

Figure 2-3. Flow Error Curves for 10°C and 45°C DN20 Meter
SLAA959 – OCTOBER 2020
Submit Document Feedback

USS Water Flow Rate Calibration
Copyright © 2020 Texas Instruments Incorporated3

www.ti.com

Calibration Algorithms

Note
In general, the error curves are dependent on the specifics of the water meter body design. The error
curve is for the specific meter body used in the testing to give a general idea of the dependency of theerror curve on the flow rate and temperature and should be used to understand the general steps
required for calibration. A different meter can have an error curve that looks different.
As can be seen from Figure 2-3, the errors increase significantly for flow rates under approximately 100 lph,
remaining quite tight for higher flow rates. The above effect occurs because the water flow rate turns turbulent
higher than 100 lph, depending on the temperature, while remaining laminar for lower flow rates. Due to thelarge errors as given in Figure 2-3 for low flow rates at different temperatures, a temperature- and flow-based
compensation has been implemented. The velocity of water as a function of the temperature is approximated bya Bilaniuk and Wong [3] 5th order polynomial equation given in Figure 2-4. In general, a temperature sensor canbe used to obtain the temperature of the medium, but if a temperature sensor is not available, the T12, T21 canbe used to estimate the temperature. Using Equation 3, the velocity of sound in water can be calculated andthen a lookup table can be used to calculate temperature – for temperatures up to approximately 60°C, given themonotonic nature of the curve in this region. This estimated temperature, along with the estimated flow rate isthen used to compensate the measured flow at the measured temperature.

Figure 2-4. Temperature vs. Sound velocity in water
The sections below describe the temperature, flow based calibration table generation, and compensation
algorithm to reduce the volume calculation error given in Figure 2-3.

4

USS Water Flow Rate Calibration

SLAA959 – OCTOBER 2020
Submit Document Feedback
Copyright © 2020 Texas Instruments Incorporated

Calibration Algorithms

www.ti.com

A. Calibration table for water flow metering
To generate the two dimensional calibration table, the reference flow measurement is done at multiple flow rates,
at different temperatures and across multiple spools for a given meter design. The two dimensional error (seeFigure 2-5) for a given calibration spool would then look as follows, the measured temperatures(onMSP430FR60xx) T0, .., TN and the measured flow volume (on MSP430FR60xx) f0, f1, .., fM (the reference flow atwhich these measurements are done is on the Z axis). The maximum temperature in the table TN is expected tobe less than 60degC because of the limitation of identifying the temperature beyond this value because of theshape of the velocity of temperature curve as shown in Figure 2-4.
Note
A water meter body is also called a spool and the terms are used interchangeably in this document.

Note
This figure is generated during calibration for measured flow versus measured temperature (reference
flow is on the Z axis).
Figure 2-5. Representative Quadrilateral Figure
For M reference flow measurements and L reference temperature measurements there will be (L-1)*(M-1) suchquadrilaterals. There could be several spools used for calibration (for example 20). Even for a given water meterbody design, each individual body or spool can have small variations and it is important to get sufficientmeasurements across a few spools to get a good calibration table that works across a large number of spools of
the same meter body design. A 3-D pictorial view of this is given in Figure 2-6.

SLAA959 – OCTOBER 2020
Submit Document Feedback

USS Water Flow Rate Calibration
Copyright © 2020 Texas Instruments Incorporated5www.ti.com

Calibration Algorithms

Figure 2-6. 3D View With Several Spools Tested
For each such quadrilateral (an example shown by A, B, C, D or C, D, E, F), for a given reference flow andtemperature measurement let {f 1 1,f 2 1, ..,f N 1,f 1 2,f 2 2,..,f N 2,f 1 3,f 2 3,..,f N 3,f 1 4,f 2 4,..,f N 4 } be the flowmeasurements.
Let {t 1 1,t 2 1,..,t N 1,t 1 2,t 2 2,..,t N 2,t 1 3,t 2 3,..,t N 3,t 1 4,t 2 4,..,t N 4 } be the measured temperatures.
Let z={z 1 1,z 2 1,..,z N 1,z 1 2,z 2 2,..,z N 2,z 1 3,z 2 3,..,z N 3,z 1 4,z 2 4,..,z N 4 } be the corresponding actual(reference) values of the flow, the notation used is f i j where i is the spool number and j is vertex number on thequadrilateral. (N is the total number of spools -- we assume the measurements for a given spool at a given flowrate and temperature is averaged. Thus N, is the number of measurement points corresponding to a particularquadrilateral). The coefficients m0, m1, m2, m3 are computed by the generalized form of standard bi-linear fit [4]using least square equation:
N4¦¦ §¨© zji

m0

m 1f i ji 1 j 1m 2 t ijm 3 f i j t ij

2·¸¹(4)This equation can be solved by equating the derivatives with respect to the constants m0, m1, m2, m3 to zero andis given by Equation 5.

ªm 0 º« »«m1 »«m »« 2»«¬m 3 »¼

M 1V
(5)

Where,

6USS Water Flow Rate Calibration

SLAA959 – OCTOBER 2020
Submit Document Feedback
Copyright © 2020 Texas Instruments Incorporated

Calibration Algorithms

www.ti.com
i=N, j=4
i=N, j=4i=N, j=4ªºj
j4Nft
f i j t ij »¦¦¦ii«
i=1, j=1i=1, j=1i=1, j=1«»
i=N,
j=4i=N,
j=4i=N,
j=4i=N,j=4«»
22jjf i j t ij ¦ f i j t ij »« ¦ fi ¦ fi¦
i=1, j=1i=1, j=1i=1, j=1« i=1, j=1»
M = «i=N, j=4»
i=N, j=4i=N, j=4i=N, j=42j2 j« ¦ t i ¦ f i j t ij ¦ t ijt i fi »¦« i=1, j=1»
i=1, j=1i=1, j=1
i=1, j=1«i=N, j=4»
i=N, j=4
i=N, j=4i=N, j=4j jj2 jj2j2 j2 »«¦j=1 f i t i i=1,¦j=1 f i t i i=1,¦j=1 t i f i i=1,¦j=1 f i t i »«¬ i=1,¼ª i=N, j=4 j º« ¦ zi »« i=1, j=1»«i=N, j=4 j j »« ¦ fi z i »« i=1, j=1»
V = «i=N, j=4»« ¦ t i z ij »« i=1, j=1»«i=N, j=4
»j jj»«¦j=1 f i t i z i »«¬ i=1,¼
B. Flow calculation based on measurements during real time operation
For a given flow measurement the estimated flow calculation can now be calculated by the following steps:(1) Using Equation 1, Equation 2, calculate the flow velocity vi, sound velocity Ci and the volume Fi for the givenmeasurement. The i is to indicate the individual measurement.
(2) Then using the Figure 2-4 calculate the temperature tĩ corresponding to the sound velocity Ci.
(3) We now have the temperature tĩ and the volume flow fi.̃ Please note that if an external temperature sensor isavailable, steps (1) and (2) can be skipped and just use the temperature estimate/value from the sensor directly.
(4) Each measurement of the measured flow and measured temperature is binned in the appropriate
quadrilateral in the Figure 2-5 and then the corrected flow for measurement point { fi,̃̃ tĩ} is given by Equation 6.

m0~

m1fi~

m2 ti~ ~m3 fi t i(6)C. Algorithm for binning, finding the quadrilateral for a given measurement point
We now consider the algorithm that will be used to find out for a given flow and temperature measurement {fi,̃̃ tĩ}(see Figure 2-5 for such example points) which quadrilateral the point lies in. If the point falls outside of all thequadrilaterals then the closest one is to be found. At the heart of the algorithm is the key problem to solve thatfor a given point and the vertices of the quadrilateral, how to find whether the point is in the quadrilateral or not.
This problem can be solved with a ray casting algorithm [5]. The basic idea of a ray casting algorithm is todetermine if a ray from a given point in a given direction intersects the polynomial in even or odd points todetermine if the point is outside or inside the polynomial respectively. A normal ray casting algorithm however
has the drawback that a point on the edge and the vertices of a quadrilateral will be declared as outside it.
Hence we modify the algorithm to first check this condition. The algorithm works as follows by searching for theclosest topmost and leftmost quadrilateral to the given point. Refer to Figure 4-1, where the leftmost quadrilateralpoint represents the smallest flow and the topmost quadrilateral points represent the highest temperature.

SLAA959 – OCTOBER 2020
Submit Document Feedback

USS Water Flow Rate Calibration
Copyright © 2020 Texas Instruments Incorporated7www.ti.com

Calibration Procedure

Assumptions:•••••••

Measurement point is (fi,̃̃ tĩ)M flow and L temperature measurements
row=0 and col=0
Let FT[NxL] includes (flow, temperature) point.
F(row,col) = FT[row*N+col]F(row,col)[0] = flow and F(row,col)[1] = temp
An API rcMethod(meas_point, 4 corner points) returns true or false

Then the algorithm is:
1. Find column based on quad top side, where one of the following statement is true:
Fp < F(0,0)[0] then col’ = 0, is row 0 the top side row?
Fp > F(0,N-1) then col’ = N-2
Col’ where F(row,col’)[0] <= Fp < F(row,col+1)[0]2. Find row based on quad left side, where one of the following statement is true:
Tp > F(0,row)[1] then row’ = 0
Tp > F(L-1,row) then row’ = L-2
row where F(row’,col’)[1] <= Tp < F(row’+1,col’)[1]
3. Around the {row’, col’) that is found, search for neighboring rows and columns such that min(coli) <= x0 <=max(coli) and (min(rowj) <= y0 < = max(rowj)), where the coli and rowj are the rows and columns neighboringto row’ and col’.
4. Execute Rays Casting method on all the rows, columns that satisfy the condition in step 3.
If none of the selected quadrilaterals in step (3) satisfy the ray casting then the point is outside thequadrilaterals and then pick one of the quadrilaterals that satisfied the step (3).

3 Calibration Procedure
The flow and temperature VFR calibration procedure is described in the USS Design Center Users Guide.
NoteFlow and temperature VFR calibration is only available in USS Water Demo application version
2.30.00.xx or later.

4 Results and Conclusions
Calibration measurements were done on an Audiowell DN20 pipe at 10°C, 25°C, and 55°C at different flow rates
as shown in Figure 4-1. Then flow measurements were done at 30°C and the resulting error with respect toreference flow measurement with and without calibration is shown in Figure 4-2. As can be seen from the figure,the calibration significantly reduces the error in measured flow volume to approximately ±3% at 100-150 lph.

8USS Water Flow Rate Calibration

SLAA959 – OCTOBER 2020
Submit Document Feedback
Copyright © 2020 Texas Instruments IncorporatedResults and Conclusions

www.ti.com

Figure 4-1. Calibration Quadrilaterals

SLAA959 – OCTOBER 2020
Submit Document Feedback

USS Water Flow Rate Calibration
Copyright © 2020 Texas Instruments Incorporated

9www.ti.com

Results and Conclusions

Figure 4-2. Calibrated and Uncalibrated Volume Flow Error at 30°C

10

USS Water Flow Rate Calibration

SLAA959 – OCTOBER 2020
Submit Document Feedback
Copyright © 2020 Texas Instruments Incorporated

www.ti.com

References

5 References
1. http://www.ti.com/product/MSP430FR6047
2. ISO 4064-1/EEC directive 75/33
3. http://resource.npl.co.uk/acoustics/techguides/soundpurewater/speedpw.pdf
4. https://en.wikipedia.org/wiki/Bilinear_interpolation
5. https://www.cs.princeton.edu/~rs/AlgsDS07/16Geometric.pdf
6. USS Design Center Users Guide

SLAA959 – OCTOBER 2020
Submit Document Feedback

USS Water Flow Rate Calibration
Copyright © 2020 Texas Instruments Incorporated

11

IMPORTANT NOTICE AND DISCLAIMER
TI PROVIDES TECHNICAL AND RELIABILITY DATA (INCLUDING DATASHEETS), DESIGN RESOURCES (INCLUDING REFERENCEDESIGNS), APPLICATION OR OTHER DESIGN ADVICE, WEB TOOLS, SAFETY INFORMATION, AND OTHER RESOURCES “AS IS”
AND WITH ALL FAULTS, AND DISCLAIMS ALL WARRANTIES, EXPRESS AND IMPLIED, INCLUDING WITHOUT LIMITATION ANYIMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT OF THIRDPARTY INTELLECTUAL PROPERTY RIGHTS.
These resources are intended for skilled developers designing with TI products. You are solely responsible for (1) selecting the appropriate
TI products for your application, (2) designing, validating and testing your application, and (3) ensuring your application meets applicablestandards, and any other safety, security, or other requirements. These resources are subject to change without notice. TI grants youpermission to use these resources only for development of an application that uses the TI products described in the resource. Other
reproduction and display of these resources is prohibited. No license is granted to any other TI intellectual property right or to any thirdparty intellectual property right. TI disclaims responsibility for, and you will fully indemnify TI and its representatives against, any claims,damages, costs, losses, and liabilities arising out of your use of these resources.
TI’s products are provided subject to TI’s Terms of Sale (www.ti.com/legal/termsofsale.html) or other applicable terms available either onti.com or provided in conjunction with such TI products. TI’s provision of these resources does not expand or otherwise alter TI’s applicablewarranties or warranty disclaimers for TI products.
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2020, Texas Instruments Incorporated