2008:102 MASTER'S THESIS

72
2008:102 MASTER'S THESIS A Practical Two-Transducer Ultrasonic Flow Meter Amin.G. Saremi Luleå University of Technology Master Thesis, Continuation Courses Electrical engineering Department of Computer Science and Electrical Engineering Division of EISLAB 2008:102 - ISSN: 1653-0187 - ISRN: LTU-PB-EX--08/102--SE

Transcript of 2008:102 MASTER'S THESIS

Page 1: 2008:102 MASTER'S THESIS

2008:102

M A S T E R ' S T H E S I S

A Practical Two-TransducerUltrasonic Flow Meter

Amin.G. Saremi

Luleå University of Technology

Master Thesis, Continuation Courses Electrical engineering

Department of Computer Science and Electrical EngineeringDivision of EISLAB

2008:102 - ISSN: 1653-0187 - ISRN: LTU-PB-EX--08/102--SE

Page 2: 2008:102 MASTER'S THESIS

2

Page 3: 2008:102 MASTER'S THESIS

Preface

Nowadays ultrasonic transducers are extensively used. Many industrial systemscarry out their measurement process by taking the advantage of ultrasoundwaves. Sound of frequencies above audible range is called ultrasound, ultrasonicwaves are classified under category of mechanical waves. Likewise all othermechanical waves, ultrasound needs material environment called medium topropagate through by moving the particles. Since the end of seventies, ultrasonicflow meters have been widely designed and applied in different industrial plansmainly related to fluid mechanics, chemistry, oil industry, etc. However, theinitial motive of this thesis was to design a reliable mass flow meter applicablein controling the precise amount of energy transferred through gas pipe lines.

The mass flow meter presented in this thesis is based on a two-transducerultrasonic measurement set up where both transducers emit ultrasonic beamsimultaneously. In this thesis we will describe how by checking the amplitudesand timings of the received echoes many valuable physical properties of theflowing liquid can be revealed. In other words, we are able to calculate thespeed of sound in the liquid, the flow velocity as well as the liquid’s acousticimpedance and its density by only investigating the amplitudes and timings ofthe received ultrasonic echoes. Moreover, we show that frequency behaviour ofthe system and the liquid can be illuminated thoroughly.

As a master thesis, this project partially stands on previous works in thisfield and mainly on the works done by Dr. Jan van Deventer and Dr. JonnyJohansson and various scientific publications. In coming discussions not onlydo we systematically take advantage of previous thoughts, designs and resultsin order to explore further achievements, but also we present many new solu-tions. This thesis is aiming towards raising new electronic solutions and signalprocessing techniques to reduce the uncertainty of the estimations and to speedup the computation.

Acknowlegements

Firstly, I’d like to appreciate my lovely parents for all the sincere sacrificesthey made all through their lives in order to provide me with good educationalchances.

Secondly, I must thank the nice staff at department of computer science andelectrical engineering, Lulea University of technology, Sweden. Speciall thanksto Dr. Jan van Deventer, Dr. Johan Carlson, Dr. Jonny Johansson and all thosewho generously helped the author accomplish this project.

i

Page 4: 2008:102 MASTER'S THESIS

ii

Page 5: 2008:102 MASTER'S THESIS

Contents

Preface iAcknowlegements . . . . . . . . . . . . . . . . . . . . . . . . . . . i

0.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1Physical and electrical properties of ultrasonic transducers

31.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 A glance at the acoustic world . . . . . . . . . . . . . . . . . . . 3

1.2.1 Acoustic impedance and reflection . . . . . . . . . . . . . 31.2.2 Attenuation . . . . . . . . . . . . . . . . . . . . . . . . . . 41.2.3 Diffraction . . . . . . . . . . . . . . . . . . . . . . . . . . 41.2.4 Frequency dependence . . . . . . . . . . . . . . . . . . . . 4

1.3 The piezoelectric transducer . . . . . . . . . . . . . . . . . . . . . 51.3.1 Mechanical-Electrical properties . . . . . . . . . . . . . . 51.3.2 Ultrasonic transducers versus the microphones . . . . . . 61.3.3 Sensor design . . . . . . . . . . . . . . . . . . . . . . . . . 7

1.4 Modeling of the ultrasound system . . . . . . . . . . . . . . . . . 71.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2The experimental set up

112.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112.2 The physical scheme of the measurement system . . . . . . . . . 112.3 The electronics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2.3.1 Exciting electronic circuit . . . . . . . . . . . . . . . . . . 122.3.2 Listening electronic circuit . . . . . . . . . . . . . . . . . . 142.3.3 Combined transmission and reception . . . . . . . . . . . 142.3.4 ASIC: application specific integrated circuit . . . . . . . . 14

2.4 A/D conversion and the list of the measured signals in this project 162.5 Calculation of the flow velocity and the sound speed in the flow . 17

2.5.1 Calculation of the flow velocity . . . . . . . . . . . . . . . 182.5.2 Calculation of the sound speed . . . . . . . . . . . . . . . 19

2.6 Calculation of the acoustic impedance, density and mass flow rate 202.6.1 Reflection coefficients and Calculation of Acoustic impedance 212.6.2 Calculation of the density . . . . . . . . . . . . . . . . . . 232.6.3 Calculation of the mass flow rate . . . . . . . . . . . . . . 23

iii

Page 6: 2008:102 MASTER'S THESIS

iv

3Signal processing solutions to estimate the flight times

253.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253.2 Block diagram of the signal processing unit . . . . . . . . . . . . 25

3.2.1 Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253.2.2 The methods . . . . . . . . . . . . . . . . . . . . . . . . . 283.2.3 Compute and display . . . . . . . . . . . . . . . . . . . . 29

3.3 Method 1: Cross correlation solution . . . . . . . . . . . . . . . . 303.3.1 Time-domain cross correlation . . . . . . . . . . . . . . . 303.3.2 Frequency domain Cross correlation . . . . . . . . . . . . 313.3.3 Frequency domain versus Time domain . . . . . . . . . . 313.3.4 Sub-sample precision . . . . . . . . . . . . . . . . . . . . . 32

3.4 Method 2: Optimization solution . . . . . . . . . . . . . . . . . . 333.4.1 The ideal model of the ultrasonic signals . . . . . . . . . . 333.4.2 Generation of the ideal model in MATLAB . . . . . . . . 343.4.3 Least mean square algorithm . . . . . . . . . . . . . . . . 353.4.4 Performance, Advantages and drawbacks of the optimiza-

tion solution . . . . . . . . . . . . . . . . . . . . . . . . . 363.5 Method 3: Phase Unwrapping solution . . . . . . . . . . . . . . . 36

3.5.1 Frequency response of non-ideal ultrasonic system . . . . 363.5.2 Phase unwrapping . . . . . . . . . . . . . . . . . . . . . . 373.5.3 Advantages, drawbacks and corrections . . . . . . . . . . 38

3.6 Results and Conclusions . . . . . . . . . . . . . . . . . . . . . . . 39

4frequency investigation of the system

414.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

4.1.1 Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414.2 Calculation of the frequency response . . . . . . . . . . . . . . . 44

4.2.1 Computation of RPL, the reflection factor . . . . . . . . . 444.2.2 Simulation in MATLAB . . . . . . . . . . . . . . . . . . . 44

4.3 Valuable information obtained from the frequency response . . . 464.3.1 Amplitude of the frequency response . . . . . . . . . . . . 464.3.2 Phase of the frequency response and the flight time . . . . 464.3.3 Non-linearity of the phase curve . . . . . . . . . . . . . . 464.3.4 Frequency dependence of the sound speed in the liquid . . 47

4.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

5Density estimation and the mass flow meter

495.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495.2 Estimation of the acoustic impedance of the liquid . . . . . . . . 495.3 Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

5.3.1 Why do the probes give out different results? . . . . . . . 515.3.2 Averaging the results from each of the probes . . . . . . . 525.3.3 Computaion of the flow rate, m . . . . . . . . . . . . . . . 53

5.4 Electronic impementation . . . . . . . . . . . . . . . . . . . . . . 53

Page 7: 2008:102 MASTER'S THESIS

v

5.5 Advatages, drawbacks and conclusions . . . . . . . . . . . . . . . 54

6Results, Conclusion and future works

576.1 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576.2 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576.3 Future works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

Page 8: 2008:102 MASTER'S THESIS

vi

Page 9: 2008:102 MASTER'S THESIS

List of Figures

1.1 Diffraction effect . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.2 Side view of a single element transducer. The arrows show the

displacement movement of the transducer and the cap. . . . . . . 51.3 Capacitive microphone, the moving plate is displaced due to strength

of the existing acoustic pressure field . . . . . . . . . . . . . . . 61.4 A piezoelectric transducer made up in a plastic container and

together with the backing layer . . . . . . . . . . . . . . . . . . . 81.5 Echo signal produced by a transducer with poorly matched backing

(a) and with well-matched backing (b). Note that the ringingswings have been canceled in (b) however the amplitude of thepassed pressure field is lower than in (a) . . . . . . . . . . . . . 8

1.6 the Leach equivalent circuit of a piezoelectric device . . . . . . . 9

2.1 Cross section of the system. The left probe is complete whilst theright probe is a cross section view. The liquid flows through theinlet-outlet pipe along the path BC (or reversely CB) . . . . . . . 12

2.2 The outer look of the system. . . . . . . . . . . . . . . . . . . . . 132.3 A popular push-pull system for generating the square driving pulses

[2] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142.4 Block shcematic of the complete chip outlining the main blocks

and external connections. Control signal inputs can be bondeddirectly on the chip. [2] . . . . . . . . . . . . . . . . . . . . . . . 15

2.5 Chip functionality illustrated by the behaviour of the voltage onthe transducer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

2.6 The useful signals in our samples numbered according to the text . 172.7 Cross section of the system. The left probe is complete whilst the

right probe is a cross section view. The liquid flows through theinlet-outlet pipe along the path BC (or reversely CB) It’s obviousthat if the other direction is the case then all our results will besimply multiplied by a minus sign. . . . . . . . . . . . . . . . . . 19

2.8 The reflection of the interface between environment1 and 2. . . . 212.9 One of the probes, the steps inside it and the probe-liquid interface 23

3.1 The diagram of the signal processing unit . . . . . . . . . . . . . 263.2 Pre-processed samples obtained by sampling the measured signals

at each of the channels (transducers) . . . . . . . . . . . . . . . . 26

vii

Page 10: 2008:102 MASTER'S THESIS

viii

3.3 The Amplitude of the Fourier transform (a representetive of PowerSpectrum Density (PSD)) of each of the received signals by trans-ducer(a) and by transducer(b). This shows how strong are the lowfrequency terms. our favourite ultrasonic data exits around 2Mhz 27

3.4 The amplitude of the Fourier transform of each of the measure-ments being zoomed around 2Mhz versus our designed 6th or-der FIR filter. Our band pass filter is with central frequencyfc = 2.062Mhz and -3db cut off frequencies of fl = 1.9375Mhzand fh = 2.1875Mhz.) . . . . . . . . . . . . . . . . . . . . . . . . 28

3.5 The output of the bandpass filter seen in figure 3.4. The un-wanted terms are cancelled and the ultrasonic pulses look clearlyoutstanding. Compare this figure with figure 2.6 to see how wename each of the pulses.) . . . . . . . . . . . . . . . . . . . . . . 29

3.6 The extracted (gated) ultrasonic pulses , e1a, e1b, e2a, e2b, e3a,e3b, e4a, e4b . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

3.7 The result of time domain cross correlation of e4a with e4b. Themaximum represents the number of shifts by which the sequenceshave the match with each other. Note that the length of the re-sulting correlation of x and y is (length of (x))+(length of (y)) -1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

3.8 The result of frequency domain cross correlation of e4a with e4b.The maximum represents the number of shifts by which the se-quences have the match with each other. Note that it is identicalto previous figure, the only difference is it is performed 126 timesfaster! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

3.9 The impulse response of the ideal model defined in equation (3.4) 343.10 the equivalent of figure 3.8 in frequency domain, H(ω) is called

the frequency response and is the Fourier transform of the impulseresponse, h[n] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

3.11 x[n] versus y[n] where y is shifted 344.86 samples and attenuated0.75 times. In other words, y[n] = 0.75 x[n− 344.86] . . . . . . . 35

3.12 The initial guesses are τ = 310 and A = 1. The optimizationalgorithm converges to tau=344.86 and A=0.75. The real y[n]versus the estimated one by optimization solution. They perfectlymatch! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

3.13 The blok diagram of our non-ideal system. h[n] is the impulseresponse whilst H(jω) is called the frequency response of the system 37

3.14 The time of flight for ideally-modeled x and y in samples, whichis precisely true . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

4.1 The block diagram of our ultrasonic system (shown in fig2.1) infrequency domain when transducer(a) is being excited and trans-ducer(b) listening . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

4.2 The block diagram of our ultrasonic system (shown in fig2.1) infrequency domain when transducer(b) is being excited and trans-ducer(a) listening . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

4.3 The beam while being reflected from the probe-liquid interface . . 444.4 Frequency response of the liquid for the first configuration shown

in figure4.2, the frequency response conveys very valuable infor-mation which will is discussed down here. . . . . . . . . . . . . . 45

Page 11: 2008:102 MASTER'S THESIS

ix

4.5 Due to the figure 4.4, the liner approximation of the frequencyresponse of the liquid will look like this. The attenuation factoris 0.13 and the delay is 1.968e-6 [s]. However the true frequencyresponse is the one in figure 4.4 in blue. . . . . . . . . . . . . . 46

4.6 Frequency dependance of the sound speed . . . . . . . . . . . . . . 47

5.1 The density estimation by data from probe(a) versus probe(b) . . 515.2 The Output of the Schmitt trigger circuit . . . . . . . . . . . . . 525.3 The estimated density of water, the red line is the average of the

results from the probes which looks reasonable for water at 23◦C. 525.4 The electronic schematic of the designed densitometer . . . . . . 535.5 The output of the amplifier stage . . . . . . . . . . . . . . . . . . 54

Page 12: 2008:102 MASTER'S THESIS

x

Page 13: 2008:102 MASTER'S THESIS

1

0.1 Introduction

One can think of many applications for ultrasonic systems in modern industry,ranging from toothpaste manufacturing to space engineering. However the ini-tial motivation for starting current project was the application of an ultrasonicflowmeter in gas industry. In harsh winters of Lapland the temperature easilyreaches -30◦C. Some days in summer on the other hand, the temperature ex-ceeds +30◦C. This enormous temperature difference has a drastic influence ondensity of oil products and consequently on oil pricing.

In other words, filling our car tanks at gas statations in summers costs morethan doing it during winters, for the same amount of energy! If we supply thegas stations with flow meters we will be able to pay for the actual mass of gasinstead of paying for the temperature-dependant volume of it. Note that it is themass of the gas which acounts for the absolute amount of energy it can producenot necessarily its volume. In a much larger scale, the ultrasonic mass flowmeterscan confidently control the flow rate of the oil passing through the pipe linesfrom oil-producing countries to the consumers. Without mass flowmeters mostof oil producers might have serious arguements with their costumers about thereal amount of the delivered energy. Using a reliable flowmeter can directlyimprove the oil pricing formulas.

In this project, the measurement is carried out by means of a set up based ona two-transducer measurement system illustrated in figure 2.1. The two trans-ducers simultaneously emit ultrasonic beams aiming towards the flow. Accord-ing to the timing and amplitude of the echoes received, we manage to computethe flow rate of the liquid together with many valuable information on physicalproperties of the liquid.

To achieve the above goals, in chapter 1, we raise some brief theoreticalaspects of the transducer as an electronic component. In chapter 2, we lookinto the specific measurement system that we exploit in order to obtain oursamples and the hardware used. It also shows how we can determine the densityand the flow rate based on mechanical formulas. Chapter 3 discusses the signalprocessing techniques that are applied to extract the desirable information fromthe signals which are necessary for computing the flow speed and the soundspeed according to the discovered formulas in previous chapter. Chapter 4investigates the frequency response of the system. Chapter 5 shows how wepractically estimate the density and flow rate of the liquid. Eventually chapter6 summerizes the results, performances, properties and eventually presents thefinal conclusions. Moreover, it proposes some future works that can be done inthis area.

Page 14: 2008:102 MASTER'S THESIS

2

Page 15: 2008:102 MASTER'S THESIS

Chapter 1

Physical and electricalproperties of ultrasonictransducers

1.1 Overview

In this chapter, some physical properties of an ultrasonic system have brieflybeen introduced. Besides, the electro-mechanical behaviour of such a piezoelec-tric and its equivalent electrical circuit is justified. Since ultrasound wave iscategorized under the class acoustic waves, one needs to have a sufficient back-ground of physical aspects of the wave propagation and acoustic environment.Secondly, a practical investigation of the piezoelectric disc and its mechanical-electrical interpretation must be considered.

Unlikely to light beam, both sound and ultrasound are mechanical waves thatneed a medium to propagate through. In this chapter some essential aspects ofsuch propagations are clarified.

1.2 A glance at the acoustic world

An acoustic wave is an energy disturbance that travels through a medium. Massis displaced and the medium tries to return to its normal or undisturbed state.As it does that, the disturbance moves on in the medium.

1.2.1 Acoustic impedance and reflection

Once a propagating ultrasonic wave crosses an interface seperating two media,a proportion of the wave will be reflected, another part will pass through theinterface towards the next medium and a percentage of the wave energy willbe absorbed. Since many years ago, scientist have been measuring the acousticimpedance, determining acoustic reflection factord, the absorption factor, a, fordifferent materials at different frequencies. The results have been publishedin tables and are available. The acoustic impedance of a material Za can becalculated as below:

3

Page 16: 2008:102 MASTER'S THESIS

4

Figure 1.1: Diffraction effect .

Za = ρ×c (1.1)

where ρ is the density and c is the speed of sound in the medium.

1.2.2 Attenuation

As it happens with any other mechanical wave, when an acoustic wave propa-gates, energy is converted into heat due to the friction in the medium which isbeing compressed and expanded. This is also known as viscoelatic loss, whichis the major loss contributor. Other, less significant, effects are losses due torelaxation and thermal conductivity. The pressure amplitude of a plane wavepropagating in the −→r direction decays exponentially. Therefore one could state

| Ar |=| A0 | e−α.|−→r | (1.2)

Where A0 is the initial pressure amplitude in the origin −→r = 0 , α is theattenuation constant which differs for different media and is a certain value and| Ar | is the pressure amplitude in typical point of r=−→r .

1.2.3 Diffraction

Another source of attenuation in an ultrasonic system is diffraction or beamspreading. This causes the energy in the ultrasonic beam to spread over an in-creasing frontal area as it propagates through the medium as shown in figure1.1.

1.2.4 Frequency dependence

It will be shortly shown in the thesis that many of the physical attributes thatwe are dealing with in this project are totally frequency dependent. Sound speedfor instance, varies a lot with frequency. Because it has been proved that thehigh frequency harmonics of a sound travel faster than the low-frequency ones.Besides, acoustic impedance is also relevantly frequency varying. Later on, wewill investigate this phenomenon deeply in this thesis.

Page 17: 2008:102 MASTER'S THESIS

5

Figure 1.2: Side view of a single element transducer. The arrows show thedisplacement movement of the transducer and the cap.

1.3 The piezoelectric transducer

1.3.1 Mechanical-Electrical properties

A device which converts one type of energy to the other is a sensor. By defini-tion, a transducer is a device that is not only capable of converting one type ofenergy or physical attribute to another but also can do it vice versa. In fact, atransducer can be regarded as a double-way sensor.

A piezoelectric material has an asymmetric atomic lattice likewise figure 1.2.When it is subject to an electric field, the material changes its dimension. Theprocess is reversible, such that if the material is strained or compressed, anelectrical field is generated. Hence, there is coupling between mechanical andelectrical properties. According to G. S. Kino in [7] this coupling is describedby the piezoelectric constitutive relation.

T = CES − eE (1.3)

D = εSE + eS (1.4)

Equation (1.4) couples the stress T in the material to mechanical strain S.Due to Johan P. Bentley in [5], stress is defined by force/area while the appliedstress produces strained in the body which is officially defined by (change inlength) over (original unstressed length). Elastic modulus is Stress

Strain which givescertain value for certain materials including our piezoelectric transducer. Backto the equation (1.3), E stands for the applied Electrical field.

Equation (1.4) couples the electrical displacement D in the material to theapplied electrical field and the strain. The constant CE is the elastic stiffnessat constant electrical field, εS is the free permittivity, and e is the piezoelectriccoupling constant.

Page 18: 2008:102 MASTER'S THESIS

6

Figure 1.3: Capacitive microphone, the moving plate is displaced due to strengthof the existing acoustic pressure field

1.3.2 Ultrasonic transducers versus the microphones

Microphones are a type of sensors that do convert acoustic pressure fields toelectrical energy. Due to this definition, microphones are similar to ultrasonictransducers since both deal with acoustic pressure fields. However, they are verydifferent devices in the sense that an ultrasonic transducer, as it goes by thename transducer, is a double-way sensing device which not only does convert theacoustic pressure field to electrical energy but also is able to conversely convertelectrical signals to acoustic pressure fields.Moreover, microphones are meant to work with musical (sound) acoustic fieldsin the audible range of 20HZ to 20KHZ whilst ultrasonic devices work withfrequencies way above audible frequencies.

Microphones are mainly classified into two different categories of dynamicmicrophones and capacitive microphones. The capacitive microphones are ableto respond to very high audio frequencies, and they are usually much moresensitive than their dynamic counterparts. Therefore we discuss the capacitormicrophones here, only.

A capacitive microphone depicted in figure 1.3 is a variable capacitor thatconsists of a fixed plate in parallel with a diaphragm which accounts for its vari-able plate and a small air gap between these two plates. The diaphragm whichis just some microns thick and often fabricated from mylar moves backwardsand forwards relative to variation of the acoustic pressure in the environment.This change in the distance between the plates of the capacitor ∆d, causes thecapacitance to vary due to equation (1.5).

∆c =ε.A

∆d(1.5)

Where A is the area of the plates and ε0 is permittivity of the air. Ifa fixed charge V is placed across the capsule, the change in the capacitanceleads to generation of a small electrical current, i, according to equation (1.6),equation(1.7).

Page 19: 2008:102 MASTER'S THESIS

7

∆Q = V×∆c (1.6)

i =∆Q∆t

(1.7)

Where ∆Q is the charge variation, V is the fixed voltage applied on thecapacitor. ∆t, on the other hand, is the time duration under which these changeshave occurred. Therefore, one can state that the change in acoustic pressurefields leads to generation of electrical current and consequently electrical energy.Besides, here another subtle difference between such microphones and ultrasonictransducer becomes clear. As stated above getting the microphone to work weneed to apply a fixed voltage, V across the plates. This so called fixed voltageis also interpreted as bias voltage in electronic world.

However, for an ultrasonic transducer, there is no need for such a bias volt-age. That’s because as explained in 1.3.1, in an ultrasonic sensing element theconversion happens by change of the shape of the asymmetric lattices.

1.3.3 Sensor design

A common way to build a transducer is to use a disc made of an artificial ce-ramic such as lead zirconium titanate (PZT). The disc is equipped with thinmetal electrodes on each surface to form a transducer. Once a voltage source isconnected to the electrodes an E field is generated, and the disc either increasesor decreases its thickness depending upon the polarity of the applied field. Thetransducer will also work the other way around, i.e. when subject to a mechan-ical deformation, a voltage will develop across the electrodes of the transducer.This is used for reception or sensing the ultrasonic pressure fields.

For both generation and reception of ultrasonic pulses, the vibration mustbe coupled between the transducer and the medium in which the ultrasoundis supposed to propagate. If the medium has got acceptably similar acousticimpedance as of the transducer, a fairly good coupling can be accomplished bycreating a good mechanical contact between the surfaces using a couplant suchas glycerin. Otherwise, if the acoustic impedance of the transmitter and themedium, a matching layer is needed which must have an acoustic impedance inbetween the transmitter and the medium.

A complete sketch of the ultrasonic transducer with matching layer andbacking is depicted in figure 1.4 where the backing layer has been used to tailorthe ringing of the transducer after excitation. However, exploiting a backinglayer will result in fewer reflections passing towards the medium, it has thisadvantage of killing the ringing after the excitation as illustrated in figure 1.5.

1.4 Modeling of the ultrasound system

It is crystal clear that before beginning any electronic design for our project, weshould be able to interpret the electrical-mechanical properties of the piezoelec-tric into a suitable model. The aim of coming up with such a model is to be ableto predict the performance of a system or transducer before it is built. This willenable us to find out the right electronic circuit and finally import it into ourpowerful simulation software, SPICE. By means of SPICE, we will be able toknow almost everything we are looking for and create a firm backbone for our

Page 20: 2008:102 MASTER'S THESIS

8

Figure 1.4: A piezoelectric transducer made up in a plastic container and to-gether with the backing layer

Figure 1.5: Echo signal produced by a transducer with poorly matched backing(a) and with well-matched backing (b). Note that the ringing swings have beencanceled in (b) however the amplitude of the passed pressure field is lower thanin (a)

system design. Ultrasound system can be simulated using various approaches.Using mechanical simulation engines such as FEM or FID, mathematical soft-ware tools such as MATLAB and even some ultrasonic-dedicated software areall possible options on the table.

However, for an electronic engineer working on electronics for an ultrasoundsystem none of the above looks attractive, as they do not simulate electronics.Therefore, the focus on this project and similar ones has been mainly on SPICE.The analogy between mechanical structure and electrical circuits is widely usedfor the analysis of mechanical systems. Using the analogy, forces are replacedby voltage sources and velocities are replaced by electrical currents. Then, anequivalent circuit of the system is constructed. This method even becomes amore powerful tool for the analysis of electromechanical systems where someparts of the system are already in electrical domain. For example, equivalentcircuit analysis was successfully employed for piezoelectric transducers for theirdesign and optimization.

Page 21: 2008:102 MASTER'S THESIS

9

Figure 1.6: the Leach equivalent circuit of a piezoelectric device

The development of models for ultrasound system dates back to 1940 inMasons work. Since then, different teams have used different ways to look atthe case ranging from pure mathematical ways to highly-electronic ones. Forinstance, Lorenzo Capineri in his work [13] looks at the transducer as a blackbox, estimates the zero-pole transform of it. The true reference responses ofthe impedance and transfer function are derived by taking Fourier transformof the measured signal. Then final step optimizes the model parameters byminimizing a mean-square-error cost function between the model functions andthe reference ones. The above optimization algorithm is a very famous one butis purely mathematical. However, we might be more interested in Leach modelwhich results in an Electrical-Mechanical model shown in figure 1.6 accordingto Jonny Johansson in [2]. For briefness, we do not explain the proof in hereyet we will use the result.

Standard SPICE does not allow frequency dependent sources. Thus, thefrequency dependence has been modeled using a different approach in the im-plementation showed in the above figure. When the transducer operates in re-ceiving (listening) mode the impedance of an oscilloscope probe or an amplifieris normally high. In transmitting mode however, the transducer is connectedto a voltage source that supplies the excitation voltage. This voltage sourcenormally has low output impedance.

1.5 Conclusion

In this chapter we took a brief look on concepts such as acoustic impedance andreflection, attenuation and diffraction. Besides, the reader was introduced toultrasonic transducer and the way of designing a suitable transducer. We alsoilluminated differences between a microphone and an ultrasonic transducer.

Page 22: 2008:102 MASTER'S THESIS

10

Page 23: 2008:102 MASTER'S THESIS

Chapter 2

The experimental set up

2.1 Overview

As discussed in previous chapter sound, unlike light, needs a medium to propa-gate through. We take advantage of this phenomenon when we use it to calculateboth the velocity and the speed of sound in the flow using our ultrasonic meter.The questions this chapter addresses are firstly using what sort of set ups ultra-sound can be generated and perceived. Secondly, how the measured ultrasonicechoes could be exploited to compute desirable properties of the flow. Thereforethe first section of the chapter will introduce the measurement set up followedby explanation of the electronics of integrated circuits used in order to excitethe piezoelectric element and also in order to listen to the ultrasonic wave fieldsand echoes.

The third section of the chapter will be dedicated to showing how appropri-ate mechanical equations can be written so that the measured ultrasonic databecome handy in order to calculate the velocity of the passing flow, sound speedin it. It also illuminate a way to compute the density and flow rate of the liquid.

2.2 The physical scheme of the measurementsystem

The main system shown in figure 2.1 below illustrates a cross section of thedevice which was built up as the back bone of our ultrasonic system in thisproject. The system which is made up of an aluminum block consists of twoprobes in which the piezoelectric discs are located. Its inlet and outlet have adiameter of 39 mm and the reduced part has a diameter of 20 mm. The liquid(flow) passes through this inlet-outlet pipe. The reflectors are inserted at thebottom of the figure centers of which are 140 mm apart from each other. (dm= 140 mm)

The two probes on top of which there are the transducers is made up ofpolyetheretherketone(PEEK) polymer rods with a diameter of 20.8 mm. Thetransducers are the two piezoelectric disks fabricated by a Danish provider, Fer-operm with the official central resonance frequency of 2.19 Mhz. We used anappropriate backing layer to support the transducer inside the probe. Some10 mm prior to the probe-liquid interface, as seen in figure 2.1, there is a step

11

Page 24: 2008:102 MASTER'S THESIS

12

Figure 2.1: Cross section of the system. The left probe is complete whilst theright probe is a cross section view. The liquid flows through the inlet-outlet pipealong the path BC (or reversely CB) .

(which can also be regarded as a probe-air interface) that can reflect a small pro-portion of the beam back to the transducers. The probe is based on a design byLynnworth used in a four ultrasonic sensors mass flow meter. Both transducersare fired (excited) simultaneously aiming downwards. Each transducer receivesback two echoes, one from the step and the other one from the probe-liquidinterface.

In adition to those two echoes, each transducer receives a through signalwhich has been transmitted by the other transducer and has passed throughthe flow. Before describing how using the timings of these signals we derive thevelocity and sound speed in the flow, we should firstly investigate the integratedcircuits by which we carry out the signal acquisition of the system.

2.3 The electronics

2.3.1 Exciting electronic circuit

Exciting an ultrasonic transducer is known as a process that causes the piezo-electric disk to oscillate and generate the ultrasonic pressure field which knownas ultrasonic pulse. As stated earlier in equations (1.3) and (1.4) a drasticvoltage change on the piezoelectric element will cause its asymmetric materialto change its dimension which sequentially builds up an ultrasonic mechanicalenergy field.

Page 25: 2008:102 MASTER'S THESIS

13

Figure 2.2: The outer look of the system.

Therefore, to be able to excite the transducer by applying these voltagechanges we need a driving circuit which is supposed to provide the driving signalto the disk. The shape of the resulting ultrasonic pulse is firstly influenced bythe shape of this driving signal and secondly the matching layer.

A short transmitted ultrasonic pulse with high bandwidth is often desiredin pulse-echo system as of ours. Short driving pulse signals are commonly gen-erated using the fundamental oscillating frequency of the transducer.

One often used method is to apply a transient electric pulse to the trans-ducer.This driving pulse is generated by the discharge of a capacitor across theconnectors of the piezoelectric disc. The voltage and the size of the capacitorset the amount of energy transferred into the transducer, deciding the pressureamplitude of the resulting ultrasonic pulse.

Because the driving signal in above case would be the result of a voltagedischarge over a capacitor, it will have different unpredictable harmonics. Tobe able to better control the frequency response of the system one may usethe pulses with controlled shapes such as square waves or parts of sinusoidalwaveform.

A square wave excitation can be achieved with a set of power-stage transis-tors which connect the transducer to the positive and negetive supply voltageas shown in figure below. The logic control unit changes the amplitude of thegate-source bias which makes one of the transistors switch on and the other oneswith off. VDD is the voltage source which determines the amplitude of theexciting pulses.

Page 26: 2008:102 MASTER'S THESIS

14

Figure 2.3: A popular push-pull system for generating the square driving pulses[2] .

2.3.2 Listening electronic circuit

As previously mentioned in (1.3.2) for converting a received ultrasonic beam toelectronic signal we don’t need any biasing circuit. The conversion is carried outby the movement of the asymetric piezoelectric elements. However, the result-ing electronic signal is sometimes too weak and should be amplified carefully.However in this project we do not need to amplify the received signals.

2.3.3 Combined transmission and reception

The transmission and reception can be done at one transducer over a singlewire. The only thing to be noted is that the reception period and the excitationphase should not interfere. Otherwise, a part of the data will be corrupted. Forinstance, while the transducer is excited any recieved echo will be interferingwith the excitation signal in our samples. Therefore, the transmissions shouldbe scheduled so that it takes olace at appropriate times and does not collidewith any of vital echoes.

2.3.4 ASIC: application specific integrated circuit

The driving circuit of the transducers is based on a design by Dr. Jonny Johans-son illustrated in figure 2.4. The design has been performed in a 0.8µm, 50 VCMOS technology provided by austriamicrosystem (AMS).[12]. The producedAISIC is a thumb-size one with a very low power consumption. The design isbased on four main blocks (Control block, Boost converter, Discharge unit and

Page 27: 2008:102 MASTER'S THESIS

15

Figure 2.4: Block shcematic of the complete chip outlining the main blocks andexternal connections. Control signal inputs can be bonded directly on the chip.[2]

Amplifier) as depicted in figure 2.4. The control block is responsible to controlthe functunality of the system according to the paarameters set by the user viathe digital input pads. The boost converter generates the high voltage on thepiezoelectric transducer prior to excitation. Discharge unit is the most impor-tant unit which carries out the excitation of the piezoelectric disks by a rapiddischarge. The amplifier is not used in the current project.

The operation of the chip is examplified by the behaviour of the voltage onthe transducer as shown in figure 2.5. The main phases are:

1. Charge: The transducer is charged to high voltage with the boost con-verter. The charging is done with several pump cycles.

2. Hold : The piezoelectric is held at the high voltage level

3. Discharge: The transducer is rapidly discharged to generate the ultrasonicpulse. Basically, the excitation of the piezoelectric is a consequence of thisdischarge.

4. Wait : is set zero in our project.Amplify : The amplifier powers up the received echoes. In this projectwe do not use the built-in amplifier. Therefore, we set the amplification

Page 28: 2008:102 MASTER'S THESIS

16

Figure 2.5: Chip functionality illustrated by the behaviour of the voltage on thetransducer.

factor one.

5. Off : System is turned off untill next pulse generation.

Using the inductive boost converter, the inductor in figure 3.3 is charged.The charge is transferred on the peizoelectric disk When the charge reaches thehighest level, the pumping phase is stopped. As seen in figure 3.4 the piezoelec-tric is discharged suddenly. According to (1.3), this drastic voltage change willcause the piezoelectric to generate ultrasonic pulse. Then the transducer willbe in listening phase during which the echoes are received. The whole processstarts after 10 milli second. In other words, the flowmeter updates its data every10 ms. Therefore, we can think of our flowmeter as a real time system.

2.4 A/D conversion and the list of the measuredsignals in this project

The Analogue to digital converter (ADC) of our set up is a regular RTI7054oscilloscope A/D device with a sample rate of 156 Mhz. The samples are savedin the cash memory of the device and are later imported to MATLAB with a.mat extension.

To refer to the pulses correctly we used the following notation exy is thexth pulse received by the yth transducer. For instance e3a is the third signal(in the figure) recieved by transducer(a). According to figure 2.6 this would bethe signal number 3 in the plot of fig 2.4 which is the reflection of probe-liquidreflection.

The following useful pieces of data are extracted from it and saved. Theyare the only data sources we have in order to obtain knowledge about anythingrelated to this ultrasonic system.

1. e1a and e1b, the excitation pulses.

Page 29: 2008:102 MASTER'S THESIS

17

Figure 2.6: The useful signals in our samples numbered according to the text .

2. e2a and e2b, the echoes which are reflected by the edge of the step (probe-air interface) in each of the probes.

3. e3a,e3b The echoes which are reflection of each of the probe-liquid inter-faces.

4. e4a and e4b, the through signals that have been transmited by each ofthe transducers and received by the other. (e4b is a proportion of thetransmitted ultrasonic beam by transducer (a) makes it to travel alongthe path ABCD to transducer (b) and vice versa a proportion of theemitted ultrasonic beam by transducer (b) which travels along the pathDCBA and makes it to reach transducer(a)), is called e4a).

2.5 Calculation of the flow velocity and the soundspeed in the flow

In this section we will present how the velocity of the flowing liquid and thespeed of sound in the liquid can be computed by only having the mentionedechoes and through signals.

Page 30: 2008:102 MASTER'S THESIS

18

The only essential pieces of data that are necessary to have for these calcu-lations are summarized down here as a remider:

1. Echoes of the probe-liquid interfaces (e3a and e3b)

2. Through signals (e4a and e4b)

These two bunches of signals match number 3 and 4 in figure (2.3). Inthe following subsection we see how we can derive the speed of sound and thevelocity of the flow by only knowing the timing of the above pieces of data.

2.5.1 Calculation of the flow velocity

Figure 2.7 depicts the overall scheme of our ultrasonic system. The purpose ofour calculation is to find the velocity of the flow shown −→V in figure (2.5). In allcalculatiuons in this project we assume that the direction of the flow is alongthe −−→BC. It’s obvious that if the other direction is the case then all our resultswill be simply multiplied by a minus sign.

Apparently, when the ultrasound beam being emitted by transducer (a)travels from point B to point C (downstream direction) its speed which equalsthe speed of sound added to the speed of the flow. Conversely, when the otherultrasound beam emitted by transducer(b) is traveling from point C to point B(upstream direction)it is opposed by the stream of the flow so its speed is thespeed of the flow subtracted from the spead of sound. The main idea is thatsubtracting the downstream velocity from the upstream velocity gives us thevelocity of the flow due to the following equation.{ −−−−−−−→

Vdonstream = −→C +−→V−−−−−−→Vupstream = −→C −−→V

(2.1)

By subtracting the lines in the above set of equations from each other wecan easily derive −→V the velocity of the flow.

2×−→V = −−−−−−−−→Vdownstream −−−−−−−→Vupstream =⇒ −→V =

dm/2tBC

− dm/2tCB

(2.2)

Where dm is the distance between the reflectors (beween ponits B and C)andtBC is the time it takes for the beam to travel the distance from point B to C.Vice versa tCB is the time it takes for the ultrasonic beam to travel from C toB. It’s very vivid that the tBC can be seen as the result of subtracting tAB andtCD from the time corresponding to the whole distance from A to D or tABCD.The same analysis would be correct for the reverse direction for tCB the time ittakes for the beam to go from point C to B. In other words we can state{

tBC = tABCD − tAB − tCDtCB = tDCBA − tBA − tDC

(2.3)

According to the figure 2.7 the following geometrical equation will be true wheredm is the distance of the reflectors between points B and C. dl is the wholedistance that the beam travels in the liquid, ABCD.{

AB + CD = dl − dmtAB + tCD = dl−dm

C

(2.4)

Page 31: 2008:102 MASTER'S THESIS

19

Figure 2.7: Cross section of the system. The left probe is complete whilst theright probe is a cross section view. The liquid flows through the inlet-outlet pipealong the path BC (or reversely CB) It’s obvious that if the other direction isthe case then all our results will be simply multiplied by a minus sign.

To refer to the pulses correctly we use a similar notation to the one weintroduced in section 2.4 for the arrival times: txy is the time of the xth pulseis received by the yth transducer. Having those time of flights one could state:{

tABCD = t4b − t3a

2 −t3b

2tDCBA = t4a − t3b

2 −t3a

2

(2.5)

Finally, inserting the values from equations (2.4) and (2.5) into the main equa-tion (2.3) will lead to obtaining the result below.{

tBC = t4b − t3a+t3b

2 − dl−dm

C

tCB = t4a − t3b+t3a

2 − dl−dm

C

(2.6)

If we replace tBC and tCB from the above equation (2.6) in equation (2.2)the velocity of the liquid will be precisely estimated.

−→V =

dm2

t4b − t3a+t3b

2 − dl−dm

C

−dm2

t4a − t3b+t3a

2 − dl−dm

C

(2.7)

2.5.2 Calculation of the sound speed

Equation 2.7 states that in order to calculate the flow velocity we need to havethe sound speed −→C in first place. Back to figure 2.7 one way to compute the

Page 32: 2008:102 MASTER'S THESIS

20

sound speed is as seen in equation below.

−→C =

ABCD +DCBA

tABCD + tDCBA=⇒ −→C =

2 ∗ dltABCD + tDCBA

(2.8)

Very identical equations to the ones in previous section can be re-written inorder to eventually end up in the following result.

−→C =

2 ∗ dlt4b − t3a+t3b

2 + t4a − t3b+t3a

2

(2.9)

2.6 Calculation of the acoustic impedance, den-sity and mass flow rate

As seen in last section, in order to calculate the velocity of the flow,−→V andsound speed in that liquid, −→C we only look at the timing of the pulses andwe do not care about their amplitudes at all. However, in this section when itcomes to calculating the acoustic impedance of the liquid, Zl the amplitudes ofother pulses also come to play. In this section we describe how we can derivethe acoustic impedance of the flow (liquid) independantly for each of the probeshaving the following peices of data:

Using the data from probe(a):

1. The excitation pulses of transducer(a), e1a.

2. The echo which has been reflected by the edge of the step (probe-airinterface) in probe(a), e2a.

3. The echo which has been reflected by the probe-liquid interface of probe(a),e3a.

Using the data from Probe(b):

1. The excitation pulse of transducer(b), e1b.

2. The echo which has been reflected by the edge of the step (probe-airinterface) in probe(b), e2b.

3. The echo which has been reflected by the probe-liquid interface of probe(b),e3b.

(Please refer to figure 2.6 to see which pulses are meant above)Another subtle yet important difference is that calculation of the acoustic

impedance can be performed by having the above data from one probe indepen-dantly. However to calculate −→V and −→C we need to consider the through signalstoo and somehow combine the received data of both transducers. According toequation (1.1), having the sound speed C and the acoustic impedance leads us

Page 33: 2008:102 MASTER'S THESIS

21

Figure 2.8: The reflection of the interface between environment1 and 2.

to knowing the density of the liquid. Knowing the velocity of the flow, den-sity of it and the dimensions of our measurement device paves the way towardsestimating the mass flow, m which was the final target of this project. Thecalculations regarding the mass flow metering are introduced in the last subsection of this chapter.

2.6.1 Reflection coefficients and Calculation of Acousticimpedance

2.6.1.1 Pressure reflection coefficient VS. Intensity reflection coeffi-cient

According to Lawrence Kinsler[3], reflection coeffiecient is defined as the ratioof the pressure of the reflected wave to the pressure of incident wave and isshown by R. However, there is also the intensity reflection coefficient which isintroduced as the ratio of intensity instead of the ratio of pressure, this latterdefinition is represented by Rπ.For the interface shown in figure 2.8 the reflection factor would be:{

R = pressure(X2X1

) =⇒ R = amp(X2)amp(X1)

Rπ = intensity(X2X1

) =⇒ Rπ = ( std(X2)std(X1) )2

(2.10)

To justify the above equation we should start by knowing thatAcoustic Intensityof a sound is officially the average rate of flow of energy through a unit areanormal to the direction of propagation. If we have discrete electronic samplesof the ultrasonic pressure field as we really do (let’s call it x[n]), then accordingto Ziomek [4], the intensity of it will be:

Intensity(x[n]) =1N

∑i=1,toN

x2[i] (2.11)

On the other hand, std which stands for standard deviation of the signalstells us how much the amplitude of the elements in that sequence are dispersed

Page 34: 2008:102 MASTER'S THESIS

22

from each other and is defined as below.

std(x[n]) = δx =

√1N

∑i=1

(x[i]− x)2 (2.12)

In above equation, x refers to the mean value of the signal. As in our case,once the mean value of the signal is zero, then we can claim that the inten-sity of the ultrasonic samples equals to the square of the standard deviation.Intensity(x[n]) = δ2

x = 1N

∑i=1 (x[i]− x)2. (the square of the std, δ2

x is alsoknown as variance in many statistical texts).Therefore the equation (2.10) looks correct. Back to equation (1.2), one couldsee that the pressure reflection for figure 2.8 can be written as follows.

R12 =Za2 − Za1

Za2 + Za1(2.13)

In above equation R12 refers to the pressure reflection coefficient for the casethe beam is transmitted inside the medium 1 propagating normally towards theinterface with medium 2. (As illustrated in figure 2.8). According to equation(2.10) the latter equation of (2.13) can be re-written as{

R12 = amp(x2)amp(x1) = Za2−Za1

Za2+Za1

R21 = −R12

(2.14)

2.6.1.2 Pressure transmission coefficient and intensity transmissioncoefficient

The ratio of the sound pressure passing through the interface to the soundpressure of the incident beam will be called the pressure transmission coefficient,T12.Similarly, the intensity transmission coefficient will be the ratio of the intensity,TI12 . If we neglect the scattering phenomonon at the interface this intensitytransmission coeffiecient will be also seen as the power transmission intensity,Tπ12 . If the absorption of the interface can be ignored then the sum of thereflected and transmited energy should be equal to the enegry of the incidentbeam. Besides the law of Continuity of pressure is also true for the interface.These two fundamental laws end up in following set of formulas:{

Rπ + Tπ = 11 +R = T

(2.15)

Now that we have discussed the reflection and transmission factors we can getto calculate the acoustic impedance. Figure 2.9 shows the probe, the steps insideit and of course the probe-liquid interface. When the transducer(a) fires e1a itflies the distance d untill it reaches the step, therefore X1 which is the incidentsignal on the step is x1 = e1a.e

αp.d As a result x2 = R ∗ x1 =⇒ Re1a.eαp.d.

When the echoe gets back to the transducer its amplitude will be estimated asbelow. {

e2a = x2.eαp.d =⇒ e2a = R12.e1ae

αp.2d

=⇒ amp( e2ae1a ) = R12.ξ.e−2αpd (2.16)

where ξ has been multiplied to our previous formulas in order to represent thepercentage of beam the step is exposed to, in compararison to the proportion

Page 35: 2008:102 MASTER'S THESIS

23

Figure 2.9: One of the probes, the steps inside it and the probe-liquid interface

the probe-liquid is. This is mainly due to the physical attributes of the probe(figure 2.9). Obviously the rest of the beam will hit the probe-liquid interface. Ifwe replace the reflection coefficients according to Equation (2.14) for the boththe step reflection and the probe-liquid reflection we will have the following setof equations. {

amp( e2a

e1a) = ξ × Za−Zp

Za+Zp.e−2αpd

amp( e3a

e1a) = (1− ξ)× Zl−Zp

Zl+Zp.e−2αpdp

(2.17)

In the latter equation above, Za, the acoustic impedance of air, zp, αp,(besides e1a, e2a, e3a are all extracted) are all known. This will lead to knowingthe correction ratio ξ. Replacing it in the second equation will enable us toderive zl the acoustic impedance of the liquid.

2.6.2 Calculation of the density

Having the acoustic impedance of the liquid Zl from the previous subsectionand c, the speed of sound in the liquid from subsection 2.5.2, replacing it in thevery begining equation of 1.1 will result in knowing the density of the liquid.

2.6.3 Calculation of the mass flow rate

The mass flow rate is simply defined by m = ρ(−→A.−→Vm) where −→A is the crosssection area of the pipe which the liquid flows through. −→Vm is the volumetricvelocity which is the velocity of the flow (in 2.5.1) per meter square. The ’.’ isthe inner product operand. Knowing the flow velocity from 2.5.1 and the densityfrom 2.6.2 and measuring the A, cross sectional area of our measurement device,we can easily compute the mass flow rate.

Page 36: 2008:102 MASTER'S THESIS

24

Page 37: 2008:102 MASTER'S THESIS

Chapter 3

Signal processingsolutions to estimate theflight times

3.1 Overview

In this chapter, we discuss how we handle the acquaired signal to obtain the tim-ing of the pulses (flight times). For estimation of flight times, we evaluate threetechniques. We will see that cross-correlation is a very straightforward solution.Optimization solution will be introduced and later an exact phase unwrappingsolution will be brought up in details. This phase unwrapping analysis pavesthe way towards a very useful frequency analysis of the system. This frequencybehaviour of our ultrasonic system is explained in the next chapter.The aim of the signal processing unit is to:Step 1: Filter measurement and extrac the favourite pieces of ultrasonic signal.These gated pieces of information account for the echoes and the through signalpulses and almost all information we have about the system.Step 2: Perform the actual signal processing methods to find out timings neededin calculation of the flow speed and the sound speed. Capture the executiontime for each of these methods to see which one is faster to run on a CPU.Step 3: Use the flight times found in previous steps and the formulas mentionedbefore in section we compute the flow speed and the speed of sound in the flow.The above steps can be illustrated in the following block diagram.

3.2 Block diagram of the signal processing unit

3.2.1 Filtering

3.2.1.1 The design of the appropriate band pass filter

The first block in diagram 1 is supposed to purify the samples from the un-wanted terms. The crude pre-processed measurements of both channels looksimilar to fig 3.2 where the first big spikes in the beginning part account for

25

Page 38: 2008:102 MASTER'S THESIS

26

Figure 3.1: The diagram of the signal processing unit

Figure 3.2: Pre-processed samples obtained by sampling the measured signals ateach of the channels (transducers)

the excitation. Remember that as stated previously during excitation a largevoltage is discharged on the transducer. This will look like the spikes seen infigure 3.2 besides one could see that our measurements have an offset of 1 volt.Obviously these spikes are all of low frequency and can be easily deleted. Onthe other hand, one could see in figure 3.1 that high-frequency noises have con-taminated the measurements in various parts of it. By now, our choice is aband-pass filter which can cancel both the high frequency noise terms and thelow frequency spikes at the same time.

We already know that our transducers are excited by a broad band dischargepulse therefore the strength of the spectra of our samples will have strong lowfrequency terms as seen in figure 3.3. Note that we are interested in extractingthe ultrasonic pulses which we already know that occur around the frequency2MHZ (the resonance frequency of the transducers is 2.019 Mhz written on themby the manufacturer). We need to discard the frequencies either lower or higher

Page 39: 2008:102 MASTER'S THESIS

27

Figure 3.3: The Amplitude of the Fourier transform (a representetive of PowerSpectrum Density (PSD)) of each of the received signals by transducer(a) and bytransducer(b). This shows how strong are the low frequency terms. our favouriteultrasonic data exits around 2Mhz

than it. This is typically done by a bandpass filter in electronic world.To specify precisely what the appropriate band should be for our filter, we

need to zoom at the power spectral density or equivalently the amplitude ofthe Fourier transform of the samples around the centre frequency of 2.19Mhzto find the frequency band at which the spectra of the samples are relativelystronger. This band would correspond to the exact frequency range at which ourultrasonic pulses exist. We then design our filter so that it passes the frequencieswithin this band and stops (attenuates) the other frequencies outside of thatband.

Note that the filter above is a common Butterworth filter whose coefficientsare estimated by butter instruction in MATLAB. For design of bandpass filters,there is instruction fir in MATLAB which generates even more ideal frequencyresponse. However the subtle reason behind choosing the butterworth filter isbecause electronic implimentation of a butterworth is easily done by capacitorsand resistors using available tables. This delicate point is important once wedecide to build an electronic embedded system in future.

The output of the filter is depicted in figure 3.5 where one could see thatall the unwanted terms in the measured samples (already shown in figure(3.2))have been removed successfully. Ultrasonic pulses and echoes are vivdly seenin the figure, the SNR (signal to noise ratio) is pleasantly high. The next stepwould be gating these pieces of data.

Page 40: 2008:102 MASTER'S THESIS

28

Figure 3.4: The amplitude of the Fourier transform of each of the measurementsbeing zoomed around 2Mhz versus our designed 6th order FIR filter. Our bandpass filter is with central frequency fc = 2.062Mhz and -3db cut off frequenciesof fl = 1.9375Mhz and fh = 2.1875Mhz.)

3.2.1.2 Extraction of the useful data

This latter figure 3.5 is basically the same as former figure 2.6 where the echoesare labeled. Here, our task is to gate those ultrasonic pulses properly in orderto be used in later. For the specific fs, sample frequency of our A/D unit wecan forsee approximately at what sample these favourite ultrasonic pulses showup in our measurements. What we can easily do is to chop our samples andextract all the favourite pulses into suitable frames. Accept for the excitationpulse which comes at the first sample, we can claim it is logical to assume thatthe step reflections (e2a and e2b) arrive sample offset-edge=5500, probe-liquidechoes (e3a and e3b) approximately arive around the sample offset1 =7000 andthe through signals (e4a and e4b) is received around the sample offset2 =25000.Then we define a value of win-size=3000 samples as the window size for ourframes. The result would have been depicted in series of figure bellow.

3.2.2 The methods

In order to find the time delay between two similar signals in sequences x[n] andy[n], the most straight forward method that one could come up with immediatelyis the cross correlation. Detecting the maximum of the correlation result whichcorresponds to maximum similarity between two sequences will give us the time

Page 41: 2008:102 MASTER'S THESIS

29

Figure 3.5: The output of the bandpass filter seen in figure 3.4. The unwantedterms are cancelled and the ultrasonic pulses look clearly outstanding. Comparethis figure with figure 2.6 to see how we name each of the pulses.)

delay we were looking for. Besides, cross correlation can be also interpretedin frequency domain. Another method is optimization. Its backbone idea is tocreate y (an ideal model for y[n]) based on parameters from x[n] and, then usingthe Least Mean Square algorithm minimize the error between this modeled y andthe real y[n]. Once the error has been minimized all the parameters includingthe time delay between y[n] and x[n] are known.

The third method which we call it Phase unwrapping solution - unlikelyto the two methods mentioned previously- solves the problem for a more gen-eral case where the system is assumed to be a frequency dependent systemconsequently x[n] and y[n] can not be modelled as easily as in the previousoptimization solution. The idea is to take Fourier transform of both sequencesx[n] and y[n] and then investigating the amplitude and phase of the resultingspectra, we will end up in estimating the time delay as well as exploring somevery valuable information which will be used in the next chapter.

3.2.3 Compute and display

Once the timing of the ultrasonic pulses has been discovered, we will simplyreplace them into the equations in (2.5) to compute the sound speed −→C , thevelocity of the flow −→V . The values are then displayed on MATLAB commandwindow. The flight times estimated by those methods will also be used in thefuture chapters to estimate the acoustic impedances, the density of the liquid

Page 42: 2008:102 MASTER'S THESIS

30

Figure 3.6: The extracted (gated) ultrasonic pulses , e1a, e1b, e2a, e2b, e3a, e3b,e4a, e4b .

and finally the mass flow rate.

3.3 Method 1: Cross correlation solution

3.3.1 Time-domain cross correlation

This method is performed in time domain and takes its root from the factthat if we have two sequences x and y, cross-correlation of their absolute val-ues xcorr(x,y), has the maximum value for a certain shift at which the similarforms in x and y overlap each other. Briefly, according to [8] convolution of twosequences x and y is defined as follows:

x[n] ∗ y[n] = Con[n] =∑l

x[l]×y[n− l] (3.1)

Thinking about the formula above a bit thoroughly makes it clear that convolu-tion of two sequences x and y each one having N elements results in a sequence

Page 43: 2008:102 MASTER'S THESIS

31

of size 2N − 1 whose elements are calculated this way:

Con[1] = x[1]×y[1]Con[2] = x[1]×y[2] + x[2]×y[1]

Con[3] = x[1]×y[3] + x[2]×y[2] + x[3]×y[1]. . .

Con[n] = x[1]×y[n] + x[2]×y[n− 1] + . . .+ x[n]×y[1]. . .

Con[2N ] = x[1]×y[1]

(3.2)

By definition cross correlation of two sequences has the following relation withconvolution of them Xcorr(x[n],y[n])=Conv(x[-n],y[n]) Therefore, cross correla-tion is also a shift / multiply / accumulate arithmetic operation.

The function takes two sequences and the sample frequency as inputs, detectsthe similar forms which occur in those two sequences, and returns the numberof delay samples by which the common form is apart in the input sequences.Having the sample frequency we can figure out the actual time correspondingto this number of samples. The time in the original measurement which corre-sponding to a number of samples in the quantized information is calculated inbellow.

T =N

fs(3.3)

Which gives us the equivalent time in seconds corresponding to N number ofsamples. In our measurement set up, sample frequency, fs is 156,248Mhz. Forinstance if the through signal by transducer 1 and the one received by transducer2 be sent to the function, the result of the cross correlation of their absolutevalues would look like figure 3.7. Note at what sample the maximum occurs.

3.3.2 Frequency domain Cross correlation

As stated earlier, the time domain cross correlation method is based on a shift/ multiply / accumulate algorithm shown previously. Multiplication and ac-cumulation are relatively fast operations on a CPU, though shifting is a verytime consuming one. Because of this fact, we look for some other ways to skipshifting operation in the cross-correlation method.

A very famous math theorem comes handy in this respect [8] . ’Convolutionof two vectors in time domain is equivalent to multiplication of their spectra infrequency domain’. We wrote a function which takes the two sequemces x and yand the sampling rate as inputs. Then it, takes the Fourier transform (FFT) ofsuitable length from both input vectors, multiplies of both spectra together in asample-wise way. Taking the inverse Fourier transform (IFFT) from the result,as we supposed before hand, gives us a very identical output as in previousmethod depicted in figure 3.8.

Finally, applying the same idea as before, we figure out the correspondingsample delays and the time.

3.3.3 Frequency domain versus Time domain

Obviously, this method carries out an FFT/ multiply/ IFFT operation. Sincethe FFT and IFFT algorithms are acceptably fast, the current method is at least

Page 44: 2008:102 MASTER'S THESIS

32

Figure 3.7: The result of time domain cross correlation of e4a with e4b. Themaximum represents the number of shifts by which the sequences have the matchwith each other. Note that the length of the resulting correlation of x and y is(length of (x))+(length of (y)) - 1

100 times faster in comparison with the previous time domain solution basedon a Shift/ multiply/ Accumulate operation. That’s mainly because the Shiftoperation is relatively a very time taking arithmetic operation on any CPU. Re-member that all the micro computers ranging from the old Z80 microprocessorsto the most recent ADSP systems or even the desk computers obey very iden-tical TTL logics. Therefore, the above comparison between the two solutionswill be true regardless of what electronic device we choose.

3.3.4 Sub-sample precision

To find the fraction of sample where the maximum occurs in figure 3.7 or 3.8a second order polynomial can be used. After determining the maximum, weextract two of its neighbouring samples from each side. Then by using thefunction polyfit we find the second-order coefficients a, b. c in

y = ax2 + bx+ c

. The maximum will be happening in

Max =−b2a

. This maximum will convey fractions of the sample as well.

Page 45: 2008:102 MASTER'S THESIS

33

Figure 3.8: The result of frequency domain cross correlation of e4a with e4b. Themaximum represents the number of shifts by which the sequences have the matchwith each other. Note that it is identical to previous figure, the only differenceis it is performed 126 times faster!

3.4 Method 2: Optimization solution

3.4.1 The ideal model of the ultrasonic signals

At our measurement set up shown in figure 2.7, if E[n] corresponds to thediscrete signal which excites the transducers then the signal received at anyof the points A, B, C ,D and also the through signals recieved by any of thetransucers (e1a,e1b,e3a,e3b,e4a,e4b which are technically all of the gated signalsshown in fig 3.5 accept for the step reflections) will be a delayed and attenuatedversion of each other. It’s vivid that once the transducer(a) has transmitted,the signal observed at point D is attenuated version of signal observed at pointB with a delay. In other words, for a typical x, the received y will look like:

y[n] = A×x[n− τ ] (3.4)

where A is the attenuation factor, τ is the number of sample delays due to theflight time (both τ and A are scalars). Apparently in such ideal model, A andτ will vary relatively to the distance of the flight. The longer the beam flies thebigger τ grows and the smaller A becomes. Ideally, A and τ are both constantsand do not vary with frequency.

If we want to see the system above in frequency domain instead, we shouldtake Fourier transform of the signals and the impulse response. The Fourier

Page 46: 2008:102 MASTER'S THESIS

34

Figure 3.9: The impulse response of the ideal model defined in equation (3.4)

Figure 3.10: the equivalent of figure 3.8 in frequency domain, H(ω) is called thefrequency response and is the Fourier transform of the impulse response, h[n]

transform of the impulse response H(ω) is called the frequency response of thesystem.

H(ω) = fft(h[n])

. This ideal model, y (defined in equation 3.4) is compared to the measured y[n]in order to estimate the optimal τ and A which fit the best.

3.4.2 Generation of the ideal model in MATLAB

We take one of our measured ultrasonic signals as input x[n] and by definingconstant values for A and τ in equation (3.4), we shift and attenuate the inputso that we get the signal y[n]. Since shifting/multiplying operation is a timeconsuming logical operation, we play with their spectra instead.

In the code bellow we first divide τ by the sample frequency to have the shiftvalue in seconds instead of samples, second we take FFT of the input and saveit in X, then create the model H(ω) of figure 3.10 which is as in equation 3.4bellow.

y[n] = A×e−jω×τ (3.5)

Inverse Fourier transform of Y [n] gives us the y[n] in figure 3.11 which is theideally-modeled received signal. The Matlab code:

tau=-344.86; shifted samplesA=0.75; Attenuation factortau =tau*Ts; shifted time in secondH = A*exp(-j*wcs*tau); The shifting modelY = H.*X;y = real(ifft(Y)); the ideal model for y[n]plot(t,y,’r–’,t,x,’k-’);Title(’theinputsignals’);xlabel(’sample’);ylabel(’Amplitude’);legend(’y[n]’,’x[n]’);

Page 47: 2008:102 MASTER'S THESIS

35

Figure 3.11: x[n] versus y[n] where y is shifted 344.86 samples and attenuated0.75 times. In other words, y[n] = 0.75 x[n− 344.86]

If we take the first echo of probe-liquid of transducer a as the input x[n],and have tau=344.86 samples and A=0.75 then y[n] will look like the followingfigure 3.10.

3.4.3 Least mean square algorithm

The backbone idea here is to create the ideal model y introduced by equa-tion(3.4) (or equvalently 3.5 in frequency domain) and compare it with the y[n]to find the best model parameters (τ and A) that fits the best in the model andmake it as realistic as possible. By using multidimensional unconstrained non-linear minimization (Nadler-Mead) we try to minimize the difference betweenthe modeled signal, y[n] and the true signal y[n].{

y[n] = A×X[n− τ ]J =

∑n |(y[n]− y[n])2| (3.6)

The algorithm would be as follows:1. Make an initial guess for the flight time (τ) and the attenuation factor, A.2. Create the cost function, J as defined in equation (3.6) which is a sum ofsquare of absolute value of difference between the guessed y[n] and true y[n].3. Update our previous guessed parameters using Nadler-Mead minimization(applied by fminsearch insruction in MATLAB) so that the cost function J be-comes smaller.4. Keep on running step 3 (updating guessed values) a certain number of timesto minimize the cost function J as much as possible.

If the initial guesses are not too unrealistic, the algorithm above will finally

Page 48: 2008:102 MASTER'S THESIS

36

converge to an optimal τ and A by which y[n] and y[n] have the most similarityto each other.

The Nadler-Mead minimization in our code is set to 100000 epochs and isperformed by exploiting a MATLAB function, fminsearch which returns theoptimal τ which minimizes the cost function. The initial guess for τ is assumedas the answer from the cross correlation method and initial A is set to one.

3.4.4 Performance, Advantages and drawbacks of the op-timization solution

If the initial guess is chosen reasonably, not too far from the real results, thealgorithm always converges to the very actual answer with a very high sub-sample precision. The simulated signal y=0.75 x[n−344.86] introduced in 3.4.2and depicted in fig 3.11 is fed into our system to check the functionality of ourcode. The initial guesses are τ = 310 and A = 1 The results are shown infigure 3.12, where one could easily see that finally τ converges to 344.8 and A to0.75. This method is able to determine the flight time with a high sub-sampleprecision.

The only drawback is that it gives a constant value for τ and A. However weknow that in dealing with real signals in this project τ and A are constant. Thismeans that the optimization solution at its best case is a more exact solutionthan the cross correlation which also gives a constant value for flight time .

3.5 Method 3: Phase Unwrapping solution

3.5.1 Frequency response of non-ideal ultrasonic system

Referring to the physical sketch of our measurement system shown in figure2.7, It’s crystal clear that once the transducer(a) has transmitted, the signalobserved at point D is attenuated version of signal observed at point B with adelay. We modelled the delay τ and the attenuation factor A in equation (3.4).We then came up with optimization technique. However, If we look at thespectrum of both signals X and Y , it’s proved that our ultrasonic system doesnot attenuate all the frequency terms equally. Besides, the delay also differs fordifferent frequencies.

For our general case we can draw the following block diagram shown bellowwhere h[n] is the impulse response of the system. (note that the block digramis more general version of the one shown in figure 3.9). For the system in figure3.13 One could write the famous equation

y[n] = h[n] ∗ x[n]

where the ’*’ reperesnts the convolution operation. Due to a basic mathematicaltheorem the above equation could be re-written as in Equation (3.7). The term|H(ω)| is called Amplitude of the frequency response and the ϕ(ω) is known asthe phase of the frequency response. Soon we will see that the phase conveysvery important data such as the timing of the signals and the delay. Investigat-ing the phase of the frequency responses is the fundamental idea of the phaseunwrapping solution.

Page 49: 2008:102 MASTER'S THESIS

37

Figure 3.12: The initial guesses are τ = 310 and A = 1. The optimization algo-rithm converges to tau=344.86 and A=0.75. The real y[n] versus the estimatedone by optimization solution. They perfectly match!

Figure 3.13: The blok diagram of our non-ideal system. h[n] is the impulseresponse whilst H(jω) is called the frequency response of the system

{Y (ω) = X(ω)×H(ω)H(ω) = |H(ω)|ejϕ(ω) (3.7)

3.5.2 Phase unwrapping

We claimed in previous sub section that the phase of the frequency responseconveys the information about the delay time. Let us assume that we have x[n],the ultrasonic signal observed at point 1 and y[n] the signal after having passed

Page 50: 2008:102 MASTER'S THESIS

38

to point 2. We can assume that these two signals x[n] and y[n] are respectivelythe input and output of a system.

X(jω) the FFT of x[n] like the Y (jω) the FFT of y[n] is a complex-valuedvector and is typically written X(ω) = |X(ω)|ejϕω and identically for y[n] wewill have Y (ω) = |Y (ω)|ejϕω.

If our X is the spectrum of the probe-liquid echo of probe(a), e3a(ω) thendue to Jan Van Deventer [1] it will have such relation with the spectrum of theexcitation (e1a(ω)) as stated in the following equation.

X(ω) = e3a(ω) = |e1aRpl|e−2αpdp×e−jωt1 (3.8)

dp is the distance between the piezoelectric to the point A (probe-liquid inter-face) and t1 is the flight time corresponding to that distance. All other factorsin equation above have been already mentioned, please refer back if necessary.

If we take e4b, the proportion of the beam transmitted by transducer(a)which eventually reaches the transducer(b) as y[n] then we could similarly writethe following equation.

Y (ω) = e4b(ω) = |e1aTplTlp|e−2αpdpe−αldl×e−jωt2 (3.9)

Where Tpl and Tlp are the transmission factors of probe-liquid and liquid-probeinterfaces. αl and dl are respectively the attenuation factor and the flight dis-tance of the beam in the liquid which is passing through points B and C.

By looking thoroughly one can see that the flight time of the beam in theliquid between point B and C corresponds to t2 − t1 in above equations.Theidea here is to divide X by Y to be able to extract the time interval t2 − t1.Dividing the above X and Y gives us the following:

Y (ω)X(ω)

=e4b

e3a=

|e1aRpl||e1aTplTlp|e−αldl

×ejω×(t2−t1) (3.10)

As shown above the phase of the latter expression in equation (3.10) isjω×(t2 − t1). Therefore if we divide the phase of the above ratio by ω we’ll getthe time of flight.

As a result, the algorithm corresponding to this method would simply betaking Fourier transform of both signals, calculating the ratio of X over Y andthen unwrapping the phase of it. Finally after dividing the phase by ω, we willhave t2− t1, , time of the flight inside the liquid. The instruction unwrap (P) inMATLAB unwraps radian phases P by changing absolute jumps greater than πto their 2π complement. It unwraps along the first non-singleton dimension ofP . P can be a scalar, vector, matrix, or N-D array.

3.5.3 Advantages, drawbacks and corrections

The main advantage of this method is that the result is very exact with cor-rect sub-sample values. The result will show us the time of flight versus thefrequency. However, the big problem comes due to the application of unwrapfunction. That’s because unwrap (P) can not reconstruct the curve if vectorP has is too steep. That means this solution works well as long as the inputargument of ’unwrap’ function, which is jω×(t2− t1) in our case, does not growtoo big. In other words, this method works as long as the flight time t2 − t1 isnot a large value.

Page 51: 2008:102 MASTER'S THESIS

39

Figure 3.14: The time of flight for ideally-modeled x and y in samples, which isprecisely true

To fix this problem, we shift the X towards Y the number of samples corre-sponding to the answer from the cross-correlation method and create Z. Thenthe phase analysis solution mentioned here is applied to X and Z instead. Theresult is then added to the previous shift. This compensation helps the unwrapfunction by decreasing t2 − t1.

To test our code we use the ideally-modeled x and y signals of figure 3.11.In the following figure also shows the compensated signal and the result witchis 344.86 is successfully achieved. The performance of this solution on the realultrasonic signals is carefully investigated in coming sections.

3.6 Results and Conclusions

In this chapter the signal processing strategy towards estimation of the timingsof our pulses was discussed. To estimate the sound speed in the liquid and theflow velocity, we should find the time differences mentioned in equation(2.7)and equation(2.9). To do so, we should merely first find the time differences byapplying any of the three signal processing methods on the gated (extracted)windows depicted in figure (3.5). The output of the MATLAB code for themeasurements of our system with still water (at temperature of around 23◦C)is −→C = 1484.9[m/s] and −→V = 1.137×10−13 which are very realistic results.

We described three different methods for finding the flight times. The firstmethod was auto correlation where the frequency-domain interpretation is muchfaster than the time-domain one.

The second method was the optimization solution which is almost a realisticmethod in most of ultrasonic systems. The third method the unwrapping solu-tion however, is a more general way of solving this case. It paves the way towardsa frequency-investigation of our system which will follow in next chapter.

Page 52: 2008:102 MASTER'S THESIS

40

Page 53: 2008:102 MASTER'S THESIS

Chapter 4

frequency investigationof the system

4.1 Overview

In previous chapter we introduced different solutions for obtaining the timingsof our ultrasonic pulses. We also discussed that when the beam passes throughthe liquid the frequency terms of its spectrum are attenuated differently. Theyare also delayed differently with regard to their frequency terms. This frequencydependence motivated us to try to investigate the frequency model of our system.

In science and technology finding frequency response of a system justifiesmany of the behaviours of that system. In other words knowing frequencyresponse of a system illuminates many aspects of our system and plays a majourrole in system identification approach.

In this chapter we have a new perspective of our experimental set up, spe-cially the flow which is passing through the pipe.

4.1.1 Theory

The idea proposed here is to look at the performance of our system in figure 2.1as a combination of 3 blocks each of which have a separate frequency response.Each of these three blocks corresponds to one part of our ultrasonic system,probe (a) has a frequency response of H1, extending from transducer(a) topoint A, the liquid (together with the reflectors) which lies between points Aand D has a frequency response of H and finally the probe(b) with frequencyresponse of H2 which is from point D and transducer(b).

These three blocks can be seen in only two different configurations shownin following figure 4.1 and figure 4.2. One case is when transducer(a) is be-ing excited and transducer(b) is listening and the other configuration is whentransducer(b) has been excited and transducer(a) is listening. The question ishow much we can understand about the frequency behavior of our measurementsystem by analyzing the extracted information. More specifically, we are inter-ested in knowing the frequency behavior of the liquid. (this corresponds to Hin figure 4.1 and 4.2 if we neglect the effect of the two reflectors.)

One could state the frequency response of the probe(a) as seen in equa-tion 4.1. Note that X1 is the proportion of the beam which passes trough the

41

Page 54: 2008:102 MASTER'S THESIS

42

Figure 4.1: The block diagram of our ultrasonic system (shown in fig2.1) in fre-quency domain when transducer(a) is being excited and transducer(b) listening

Figure 4.2: The block diagram of our ultrasonic system (shown in fig2.1) in fre-quency domain when transducer(b) is being excited and transducer(a) listening

probe(a)-liquid interface into the liquid.

H1 =X1(ω)E(ω)

=E×e−jωtp1e−αpldp1

E= (APL.e−αp1dp1)×e−jωtp1 (4.1)

Where APL is the coefficient of transmission between the probe(a) and theliquid. αp1 is the attenuation factor in probe(a). dP1 is the distance that thebeam travels inside probe(a) from the transducer to the probe-liquid interface,point A. tp1 is the corresponding time for this mentioned flight.

Very similarly H2 can be stated as in following equation 4.2.

H2 =X2(ω)E(ω)

= (APL.e−αp2dp2)×e−jωtp2 (4.2)

In figure 4.1 the frequency responses and the signals have the following relations

Page 55: 2008:102 MASTER'S THESIS

43

with each other. H = X2

X1X1 = E×H1

X2 = E4b

H2

(4.3)

H1 and H2 are known by writing the ultrasonic equations (4.1) and (4.2) abovebut let’s solve the equation set equation (4.3) to see how we can find H.

EQ(4.3)=⇒H =E4b

H2

E×H1=

E4b

E×H1H2(4.4)

What does ’H1H2’ mean? Multiplying H1 and H2 ends up in the followingequation.

H1H2 = AplALP .e−αp(dp1+dp2))×e−jω(tp1+tp2) (4.5)

Due to equation 2.15, we could write APL = 1 + RPL and ALP = 1 + RLP =1−RPL. Assuming that the probes are identical means that the following set ofequations is true. (which is not a realistic assumption in many cases, unluckily). αp1 = αp2 = αp

dp1 = dp2 = dptp1 = tp2 = tp

(4.6)

As a result of the the above assumption, the equation (4.5) can be simplifiedinto below equation.

H1H2 = (1− (RPL)2).e−αp(2dp))×e−jω(2tp) (4.7)

Finally it’s time to figure out what signals we have that can help us find HWe have the probe(a)-liquid echo in our measured data

e3a = e1a×RPLe−2αpdpe−jω(2tp) (4.8)

Which can be comapred to the term ′H1H2′ in equation 4.5 which means thatwe can simply see that the term H1H2 is closely connected to the echo.

H1H2 = E(1−RPL2)

RPLe3a(jω) (4.9)

Replacing this in equation (4.4) gives us a clear expression which connects thefrequency response of the liquid, H with our available data and probe-liquidreflection factor:

H =e4b

E.H1H2=

RPL(1− (RPL)2)

E4b

E3a(4.10)

In equation above E4b is the Fourier transform of the through signal receivedby transducer(b) and E3a is the Fourier transform of probe(a) -liquid echo thathas been received by transducer(a). If we write the equations for the secondconfiguration shown in figure 10 the same manner, we end up in the following.

H =e4a

E.H1H2=

RPL(1− (RPL)2)

e4a

e3b(4.11)

If both of the probes are exactly identical (which is not completely true in oursystem due to very small temperature differences in the probes) equation(4.10)and equation(4.11) should result in a very same curve.

Page 56: 2008:102 MASTER'S THESIS

44

Figure 4.3: The beam while being reflected from the probe-liquid interface

4.2 Calculation of the frequency response

4.2.1 Computation of RPL, the reflection factor

The intensity reflection factor is the fraction of radiant energy that is reflectedback from a surface. According to figure 4.3 the reflection factor Rπ, the am-plitude of the excitation signal (E), amplitude of the received probe-liquid echotogether with X1 and X2 all fall into the following expressions where dp is thedistance between the piezoelectric transducer and probe-liquid interface.

|X1| = |E|.e−αpdp

|e| = |X2|.e−αpdp

RPL = |X2||X1|

(4.12)

If we call the probe-liquid reflections (e3a and e3b) briefly e, solving theequation set above results in the following.

RPL =energy(e)energy(E)

×eαp(2dp) (4.13)

Due to section 2.6.1 we can consider the square of the standard deviation as ameasure of energy of signals. Therefore we’ll have the reflection factor computedas follows.

RPL =std(e)std(E)

2

.eαp(2dp) (4.14)

If we compute the R using the above method for e1 the reflection factorwould be approximately 0.18, the code is discussed in the next section.

4.2.2 Simulation in MATLAB

A function has been written which takes two input signals (x and y), takes theFFT of them and computes the ratio Y/X. To be able to calculate the frequencyresponse defined in equation(4.10) or equation (4.11) we need to calculate thereflection factor using the equation equation (4.14). To do so we first extractthe excitation signal from the rest of the measurement and save it in E. Theecho e3a have already been gated in rodch1. Then using one of the solutionsabove (optimization for instance) we find the time difference between e3a and E

Page 57: 2008:102 MASTER'S THESIS

45

Figure 4.4: Frequency response of the liquid for the first configuration shown infigure4.2, the frequency response conveys very valuable information which willis discussed down here.

which represents 2tp, the time which it takes for the beam to travel the distancefrom transducer(a) to the interface and back again to the transducer.

Multiplying tp1 by cp the sound speed in the probe (which has been givencp = 2410[m/s] by Jan.V. Deventer [1]) gives us dp since dp = c×tp.dp turns out to be 6.53cm in our measurement set up.

On the other hand, αp is claimed to be 28 by Jan Van Deventer. (This isa very temperature-dependant factor though. We assume that the experimenthas been carried out at T=22C)

Replacing all these obtained values in the equation equation (4.14) resultsin RPL = 0.1312.

Provided that X and Y are respectively spectrum of e1 and the spectrum ofecho received by transducers (a), one can easily compute the frequency responseof the liquid based on the equation EQ(4.10).

H =RPL.Y

1−RPL2.X∼=0.1335

Y

X(4.15)

we replace X and Y with e3b and e4a, we can have the frequency responseusing the other configuration shown in figure 3.2 and described by equation(4.11). One can see that these two frequency responses that are for the sameblock (for the liquid) are slightly different to each other. This difference can bejustified because the probes are not fully identical.

Page 58: 2008:102 MASTER'S THESIS

46

Figure 4.5: Due to the figure 4.4, the liner approximation of the frequency re-sponse of the liquid will look like this. The attenuation factor is 0.13 and thedelay is 1.968e-6 [s]. However the true frequency response is the one in figure4.4 in blue.

4.3 Valuable information obtained from the fre-quency response

4.3.1 Amplitude of the frequency response

The amplitude of the frequency response tells us how much the liquid attenuatesthe strength of the beam. We know that the strength of a beam which travelsa distance of dl inside a liquid is decayed by a factor of e−αldl where αl is theattenuation factor of the material (liquid).Figure 4.4 tells us that the amplitude of the beam decays to approximately 0.13times its initial value. Therefore we can claim that:

e−αldl∼=0.13 (4.16)

Knowing from the previous chapter of ’Basic signal processing methods’ thatdl=17.25 cm leads towards finding the attenuation factor of the liquid, αl =11.82 which is a very reasonable result for water.

4.3.2 Phase of the frequency response and the flight time

According to equation (3.10), the phase of the frequency response is ϕ(ω) =ω×(t2 − t1). Therefore, the phase of the frequency response curve has a slopewhich corresponds to t2-t1 (flight time in the liquid). In other words it can bestated that:

d(ϕ)dω

= t2 − t1 = flight− time! (4.17)

The phase curve in the frequency response shown in figure 4.4 is close to astraight line, however comparing the curve with the linear approximation revealsthe existence of non-linearity.

4.3.3 Non-linearity of the phase curve

If the ideal linear approximation is considered as L and the true values of thecurve are saved in L then the non-linearity would be defined in percentage the

Page 59: 2008:102 MASTER'S THESIS

47

Figure 4.6: Frequency dependance of the sound speed

following way.

non− linearity =∑n |L− L||L

(4.18)

The nonlinearity of our system between the points A and D in the liquid willbe calculated 3.826×10−9 percent which is relatively small. If we want to takethe non-linearity into account then the phase of the frequency response shouldbe corrected as in below.

ϕ(ω) = (3.826×10−9)×(ω) + ϕ(ω) (4.19)

Where ϕ(ω) accounts for the nonlinearity of the components and the materialsin our system.

4.3.4 Frequency dependence of the sound speed in theliquid

When it comes to investigation of the frequency behaviour of the flight time,the most straightforward solution which comes to play is the phase unwrappinganalysis. The result will be a vector for each of the flight times. Using the sameequation which is used for calculating the speed of sound based on flight timesand dm (the distance of the reflectors) we find the c which is a variant vectorthis time. The frequency dependence of the speed of sound can be viewed infigure 4.6.

Page 60: 2008:102 MASTER'S THESIS

48

4.4 Conclusion

In this chapter we identified the our system by finding out its frequency response.The frequency response of H in figure 4.1 or 4.2 tell us the frequency behaviourof the liquid (the effect of the reflectors can be neglected) besides of many otheruseful information. Figure 4.4 was the precise frequency response of the liquidand figure 4.5 showed its linear approximation between points A and D.

We saw that the frequency response conveys very valuable pieces of infor-mation. Having the frequency response, we could calculate αl the attenuationfactor of the liquid. We could measure the non-linearity of the phase curve. Itshowed us how the frequency components of the ultrasonic beam have differentflight times when they pass through the liquid.

Page 61: 2008:102 MASTER'S THESIS

Chapter 5

Density estimation andthe mass flow meter

5.1 Overview

Each transducer receives one echo from the steps (probe-air interface) accordingto figure 2.7 and also one echo from the probe-liquid interface. Having thesetwo reflections together with the excitation pulse, each transducer is capableof calculating the density independently due to equations (2.17). The strategyis to compute the density of the flow according to each of these two probesindependently. The results from one probe will turn out to be different to theother. A good idea is to take the average of the results from probe(a) andprobe(b). It is shown this strategy ends up in accurate computation of thedensity of the liquid.

After estimating the liquid density, it’s pretty straightforward to compute theflow rate by considering the equations in section 2.6.3. Note that the velocity ofthe flow has been precisely computed and the area of the pipe can be physicallymeasured.

Moreover, in this chapter we introduce a practical electronic solution for theideas presented. To do so, we need to import the data corresponding to thereflections from MATLAB into Pspice Orcad. Pspice is a powerful simulationtool for analogue electronic design. Our design can be regarded as an openingfor electronic implementation of the whole project.

5.2 Estimation of the acoustic impedance of theliquid

In order to derive Zl, acoustic impedance of the liquid equations (2.17) shouldbe used. There are two equations and two unknowns.***********************************The unknowns are:1. ξ: The proportion of the ultrasonic wave which is reflected back by the step(probe-air interface) over the one reflected by the probe-liquid interface. Ofcourse because we have two probes, the ξ might be slightly different for one

49

Page 62: 2008:102 MASTER'S THESIS

50

probe to the other.2. Zl: The acoustic impedance of the liquid.***********************************The known values are:1. The excitaion pulses (e1a = e2b = E). The step reflection and the probe-liquid reflection for each probe. (e2a, e3a, e2b, e3b)2. The spped of sound in the probes. As stated earlier, The speed of soundin PEEK is assumed to be c = 2720 [m/s] based on figure 6.12 of Deventer’sthesis.3. αp: The attenuation factor of PEEK has been introduced in figure 6.14 ofDr. Deventers doctoral thesis to be 28 [Np/m].4. Za: The acoustic impedance of air is claimed to be 411 [PA/S] due toWikipedia encyclopaedia.5. ρp: The density of PEEK is known to be 1.255 [kg/m3] according to themanufacturer.

5.3 Solution

In equation (2.17) std is the function in MATLAB which computes the standarddeviation which is a measure of intensity of a signal. The energy received byreflection of the step over the energy emitted is expressed as std(e3a)

std(E)

2in that

equation. In equation (2.17) d is the distance between the transducer and thestep and dp is the probe length or the distance between the transducer and theprobe-liquid interface. These flight distances have been figured out as beforeby computing the flight times and multiplying them by the sound speed in theprobe.

Taking the standard deviation should be performed on the samples thatconvey energy in each window. Therefore, we should define a threshold (higherthan the amplitude of the background noise) and ignore all the samples thathave amplitudes below this threshold and extract the real ultrasonic signal fromthe background noise. This operation is carried out in function [init, fin] =energy−presence(sig, threshold). It takes the signal and value of the thresholdas its inputs and returns back the number of the sample where the first none-noise sample exists. It also returns the last none-noise sample number. This isdone by defining a three-state pulse signal as bellow, counting the edges of sucha pulse, the last edge will be the one that is not followed with any other edgeswithin 100 samples after it. |sig| > Threshold. . .1

|sig| < Threshold. . .− 1Otherwise. . ....0

(5.1)

Performing above function on one of our windows will result in the belowfigure. The 3-state pulse (1,0,-1) has been scaled to create a good lookingfigure. We perform the standard deviation only in the period [init, fin] wherethe amplitude of the signal is above the noise threshold.

We solve the equation (2.17) in order to know ξ of the probe which will beas follows for each of the probes:

Page 63: 2008:102 MASTER'S THESIS

51

Figure 5.1: The density estimation by data from probe(a) versus probe(b)

{ξ = 1.3009. . .[kPa/s]. . .P robes(a)ξ = 1.6416. . .[kPa/s]. . .P robe(b) (5.2)

The density of the liquid is very simply estimated by equation (1.1). Thespeed of sound in the liquid has already been calculated very accurately in flowmeter part of this project. As stated earlier the sound speed is a frequencydependant quantity. Therefore, as equation (1,1) predicts, the density will alsovary with frequency. As before, we are only able to see its frequency behaviouronly around 2MHZ.

5.3.1 Why do the probes give out different results?

As one might see the results do in figure 5.1 change drastically from one probeto the other. Well, the dimensions of the probes are not precisely the same. Thedistance between the transducer1 and the step in probe(a), dp1 is 0.494cm whilstthe corresponding distance in probe(b) is 0.0497cm. However the main reasonwhy this drastic change happens is due to small temperature difference betweenthe probes. The attenuation factor is a temperature-dependant quantity. Asmall temperature difference in probes results in a difference in attenuationfactor.

Consequently, this small ∆αp results in a huge difference in the term e2∆αpd

of equation (2.17). For instance with our values a small difference of 0.1Cbetween probes ends up in a 25% variance in the above term. Thermal differ-ences also cause difference in sound speed however this does not make a drasticchange in comparison with the changes in attenuation. One could conclude itsvery essential that both probes be at thermal equilibrium whilst carrying outthe measurements.

Page 64: 2008:102 MASTER'S THESIS

52

Figure 5.2: The Output of the Schmitt trigger circuit

Figure 5.3: The estimated density of water, the red line is the average of theresults from the probes which looks reasonable for water at 23◦C.

5.3.2 Averaging the results from each of the probes

A good solution can be taking the average of the results from the probes.Thisaverage value turns out to be 0.9924 [gr/cm3] which is a reasonable result forwater at 23C (the water is not pure because it has some minerals in it )

Page 65: 2008:102 MASTER'S THESIS

53

Figure 5.4: The electronic schematic of the designed densitometer

5.3.3 Computaion of the flow rate, m

According to the formula m = ρ(−→A.−→Vm) of section 2.6.3, to be able to computethe flow rate we have got to combine the resulted density with the velocity ofthe flow calculated in chapter 3. The area of the pipe is also known to be 20cm2.In our measurements, since the velocity of the liquid is zero (refer to 3.6) theflow rate will be also zero.

5.4 Electronic impementation

The aim of this section is to show how the ideas presented in this thesis can beimplemented by means of embedded systems using a mixture of analogue com-ponents and digital micro processors. This section can be seen as a very briefintroduction to such a big world. The electronic circuit amplifies the echoes,detects the samples which have amplitudes above the pre-defined threshold andgenerates corresponding TTL pulses which can be later processed by a microcontroller. Its analogue section will consist of the following stages:

1. Amplifier : The leftmost stage on figure 5.4 is an amplifier which powers upthe input ultrasonic signal 100 times. The amlification is carried out by anOPAMP (operational amplifier) OP27/AD. the amplification factor is de-termined merely by the values of R2 and R3. (a = R3

R2 = 100K1K = 100). An-

other important thing to consider is the frequency response of the amplifierstage. The frequency response should be so that it includes the frequency

Page 66: 2008:102 MASTER'S THESIS

54

Figure 5.5: The output of the amplifier stage

2.19 MHZ. C3 plays an important role in specifying the high-frequencycut-off frequency, fh so does C4 in determining the low-frequency cut-offfrequency, fl. The corresponding formulas for determining fh and fl aregiving in the following set of equations.{

fl = 12π×C3×(R1+R17)

Av = R3R2×C3×2π×f+1 . . .. . .f = fh−→Av = R3√

2R2

(5.3)

For a suitable frequency response with desirable fh and fl the values ofelectronic components will be chosen as seen in figure 5.4 according toabove equation.

2. Comparator : The second stage in figure 5.4 is a typical schmitt trigger.R6, R7 and R9 determin the upper threshold and the lower threshold.The result will be a series of pulses similar to the figure 5.2.

3. Coupler : The last analogue section is an optical coupler which interpretsthe square pulses (output of the comparator stage) to TTL pulses whichare processable by digital micro controllers.

5.5 Advatages, drawbacks and conclusions

Computing the acoustic impedance of the liquid needed investigation of theamplitudes of the first two echoes received by transducers. We computed theacoustic impedance for each of the probes independantly. We showed the resultsmight vary since the probes are not really identical in all ways, specially a smalltemperature difference between them has a great impact on making the probes

Page 67: 2008:102 MASTER'S THESIS

55

perform differently. Taking the average of the two results always looks like agood solution in such cases. In the end of the chapter we tried to design ananalogue circuit for implementation of our ideas.

Page 68: 2008:102 MASTER'S THESIS

56

Page 69: 2008:102 MASTER'S THESIS

Chapter 6

Results, Conclusion andfuture works

6.1 Results

In this project, we discovered many valuable aspects of the fluid passing throughthe pipe of our mesurement system such as its density, flow rate, acousticimpedance, attenuation factor, etc. However, the author and the supervisorsbelieve that the material presented in sections 2.6, 4.2, 4.3 are of a unique na-ture. The frequency investigation of this ultrasonic system was a new researchtopic that was made to a good level in this thesis work. For instance, figures4.4 and 4.6 can be regarded as valuable outcomes of this project.

The methods were standing more on discrete signal processing point of viewand were performed by different MATLAB codes. In chapter 5, we tried to solveone simple case in analogue electronics and introduce an opening idea towardsimplementation of the mentioned ideas by means of electronic hardware.

6.2 Conclusion

Only having a very few pieces of data (shown in figure 3.5) we could discovermany properties of the flow. Besides, we could identify our system, determine itsfrequency response and the nonlinearity of the phase of the frequency responsewhich has a big affect in flight times.

By proving the functionality of our methods, we can now claim that veryprecise mass flow meters can be buit. Producing reliable mass flow meters cancome handy in oil and energy industry. They can control the flow rate of gasflowing through strategic pipleines from oil producing countries to the consumersin a real time manner.

We compared our methods to each other with respect to exactness, speed ofoperation and computation costs. Depending upon the nature of each of thesemethods, one can choose the optimal solution to be impelemented.

57

Page 70: 2008:102 MASTER'S THESIS

58

6.3 Future works

The author strongly suggests that in future works a broader frequency band beused for excitation of the transducers. This can give us the chance to investigatein a broader frequency range than we did in this project.

To make the presented ideas function in reality, one should think of hardwaresolutiuons. For instance method 1 (cross correlation) mentioned in 3.3 can beimplemented by means of high-performance digital signal processing microcop-uetrs (DSP chips) such as ADSP-2119 or blackfin BF family. However, solutionssuch as method 2 (optimization) in section 3.4 or method 3 (phase unwrapping)in 3.5 are unfortunately computationally too expensive to be performed on reg-ular micro computers with the available technology. For the time being, theycan be only executed on PC by means of power tools like MATLAB.

Implementing the ideas on embedded systems and make them really work,can be a very long way to go through. That is mainly because when it comesto play with real electronic components, we come across with uncertainty. Forinstance, you can imagine how hard it would be to implement a butterworthFIR filter such as shown in figure 3.4 with available nonideal capacitors andresistors! Note that capacitors of series E6 for example have a tolerance of 5percent.

The fundamental aim of carrying out this project was to pave a way towardsmanufacture of very practical and reliable ultrasonic mass flow meters. Westrongly hope this thesis can be helpful in fulfilling that ambition.

Page 71: 2008:102 MASTER'S THESIS

Bibliography

[1] Jan van Deventer, ‘Material investigations and simulation tools towardsa design strategy for an ultrasonic densitometer’, Doctoral thesis, Luleatechnical University, EISLAB, 2001.

[2] Jonny Johansson, ‘Microelecronics for the Thumb-Size-Ultrasound Mea-surement System’, Lulea technical university, department of EISLAB, 2004.

[3] Lawrence E. Kinsler, Austin R. Frey, Alan B. Coppens, James V.Sanders,‘Fundamentals of Acoustics’, Third edition, John Wiley and sons, 1986.

[4] Lawrence J. Ziomek, ‘Acoustic field theory and Space-time signal process-ing’, CRC press, 1997

[5] Johan P. Bentley, ’Measurement systems and instrumentation’, Thridedition, Oxford, 2001.

[6] Malcolm J.W Povey, ’Ultrasonic techniques for fluids characterization’,Academic press, 1997.

[7] G. S. Kino, ’Acoustic waves: Devices, Imaging and Analog Signal Process-ing’, Prentice-Hall, 1988.

[8] Anita Isaksson, ’ Signal Processing First’, Third edition, Wiley and sons,2003.

[9] D.K Cheng, Field and Wave Electronics, Second edition, Addison-Wisely,1989.

[10] Lawrence C. Lynnworth, ’Ultrasonic Measurements for process control,Theory, Tachniques, Applications’, Academic press, 1989.

59

Page 72: 2008:102 MASTER'S THESIS

60

[11] J. Delsing, ’A new type of ultrasonic densitometer, on ultrasonic flowmeters.’, Doctoral thesis, Lund university, 1988.

[12] R. N. Thurnston, A. D. Pierce, E. P. Padakis, Eds. ’Physical acoustics:Ultrasonic instruments and devices’. Academic Press, 1999.

[13] Jonny, Johansson, ’Optimization of a piezoelectric crystal driver stageusing system simulations’, IEEE Int. Ultrasonic symp. 2002.

[14] L. Capineri, L. Masotti, S. Rocchi, ’Ultrasonic transducer as a black box’,IEEE Trans. Ultrason, Ferroelec., November 1993.