TELKOM NIKA , Vol. 11, No. 9, September 20 13, pp.  5293 ~52 9 8   ISSN: 2302-4 046           5293      Re cei v ed Ap ril 5, 2013; Re vised J une 1 0 , 2013; Acce pted Ju ne 21,  2013   A Signal Pre-processin g  Algorithm Applied for  Ultrasonic Flow-meter      Rang -ding Wang * 1 , Qiang Liu 1 , Chen-to u Du 1 , Ling Yao 1 School of Infor m ation Sci enc e and En gi neer ing,  Ni ngb o Un iversit y , N i n g b o  315 21 1, Chin a   2 Ning bo W a ter Meter CO. L T D, Ningb o, 315 0 00, Chi n a   *Corres p o ndi n g  author em ai l: w a ngr ang di n g @n bu.ed u.cn       A b st r a ct   In order to solv e the prob le of time differ e n c ultraso n ic fl ow  meter s low  accuracy, aga inst the   basic ch aracte ristics of the sampl e   data, a data-pr ocessi n g  alg o rith m is  prop osed. F i rst, w e  use shell sort   do  a d a ta  pre- process i ng  to t he s a mpl e s, th en r e move  the  error  of the  s a mpl e  sp ace  b y  co mpl e dig i ta l   filter, and use the error co mp ensati on  al gori t hm to get the final sa mp le  re sults. Amon g the m , the comp l e x   digit a l filter  is ma inly c o mp o s ed  by  medi an  filtering  al gorit hm, sl idi ng w i ndow , Peters  alg o rith m a nd  the   w e ighted  av era ge  alg o rith m. T h is ki nd  of d a ta  proc essi n g  a l g o rith m ca effectively filter  o u t the  error  of th e   sampl e  space.  It can also mak e  a larg e i m pro v ement to  the accuracy of ultr ason ic flow  me ter w h ile ensur e   the stabil i ty an d real-ti m e.    Ke y w ords ultr ason ic flow  me ter, sort metho d , digita l filter, error co mp ens ation     Copy right  ©  2013 Un ive r sita s Ah mad  Dah l an . All rig h t s r ese rved .       1. Introduc tion  In the indu strial and  ag ricu ltural ap plications , flo w  me ter is  gen eral ly used fo re al-tim e   measurement  of fluid, so i n  the  co urse  of their work  it was u s u a lly affected by random fa cto r s,  su ch a s  environmental fa ct ors  and h u m an facto r s.  T he data  sign al whi c h was measure d  from  flow meter  contain s  a large part of n o ise.  When t hose noi se s mix with measure d  sig n a l,  accuracy will   be se riou sly   affected, even can not  work by the  st rong i n terfe r e n ce  of n o ise s   [ 1 ].  For the abov e rea s on s, d a ta pro c e ssi n g  to the si gn al measure d  by flow meter is beco m ing  th e   essential p a rt  in the desig n  process.   This arti cle a nalyze d  abou t the features of di gital signal of the time differen c e u l traso n ic  flow meter  whi c h is ba sed on MSP430F44 chi p , and prop osed data so rting method a n d   filtering meth od [2] comm only use d  wh ich a r e corre s po nde d to it, summa rized  and integ r at ed  the variou s t y pes of o p timal algo rith ms, and  im pl emented i n   softwa r e, fin a lly got the  digital  pro c e ssi ng al gorithm s to m eet the requi re ments of me asu r em ent sy stem a c cura cy.      2. Data F eatures of  the T i me Differ e n ce Ultr asoni c Flo w   M e te r   The time  differen c e  ultrasonic flow met e use s  the ti me differen c e bet wee n  ul traso n ic  wave s in  the  fluid  downst r eam  an d u p s trea m in  the  sa me  dista n c e,  while  thi s  time diffe ren c has a  relatio n s hip  with the  rate of fluid flow, so  flo w  rate can  be drawn if the tim e  differen c e h a been  mea s u r ed, we  can  a l so  cal c ulate   the fluid flo w ,  the b a si c p r i n cipl e i s  sho w n i n  Fig u re   1 .   H1, H2 i s  a pair of rotati on tran smitting and recei v ing ultrasoni c tran sdu c e r s, D is the p i pe  diamete r , V is the fluid flow rate, and    is the angl e betwe en  chann el and t he axis of th e   pipeline.         Figure 1. The  Basic Prin cip l e of Ultrasoni c Flow M e ter  Evaluation Warning : The document was created with Spire.PDF for Python.
                               ISSN: 23 02-4 046   TELKOM NIKA  Vol. 11, No . 9, September 201 3:  529 3 – 5298   5294 Assu ming  the  sp eed  of ultraso n ic in th meas ured flui d is C, time  from  H1  to  H2 is  1 t from H2 to H1 is   2 t 0  is the circuit del ay time, which is f a r less than p r opa gation ti me, then:    0 1 sin cos / V C D t                                                                                     (1)     0 2 sin cos / V C D t                                                                                     (2)     2 2 2 1 2 sin 2 V C DVtg t t t                                                                        (3)     In gene ral i n d u strial  mea s u r eme n t, pro p agation vel o ci ty of ultraso n i c  in th e liquid  (ab out  1450m / s in  the water) i s  larg er than  the liquid’s,  which i s   2 2 2 sin V C  , s o  the time   differen c e ca n be simplifie d as:     tg C DV t t t 2 1 2 2                                                                              (4)      Therefore, th e basi c  eq uat ion of the inst antane ou s flow rate  can be  written a s   t Dtg C V 2 2                                                                                          (5)    Then, the inst antane ou s flow rate i s   t tg DC K V D K V S K Q 8 4 2 1 2 1 1                                                     (6)    And 1 2 2 1 n n K , n  ha s a  re lationship  with the  Reynol ds n u mb er,  S  is t he P i p e   cro s s - sect io na l   area.   It can  be  see n  from  (6 ), a s  lo ng a s   we  get the  mea s ured tim e t , the in stanta n e o u s   flow ca n be calcul ate [3].  As ca n be se en from Fig u re 2, the actua l  samplin g time differen c e  has fou r  very  distinct   cha r a c teri stics; these a r e disp ersion, di sorde r , rand o m ness an the limited. If  use the di re ctly  measured time differen c e data to cal c ulatio n the  correspon ding  velocity and flow, the result is   boun d to make a great e rro r.      Figure 2. The  Actual Time  Differen c e u n der Static      0 10   15   20   25   30 35 -8      -6      -4      - 2               8   Sa m p le nu mber   t             Evaluation Warning : The document was created with Spire.PDF for Python.
TELKOM NIKA   ISSN:  2302-4 046       A Signal Pre-pro c e ssi ng Al gorithm  Applied for  Ultraso n ic Flo w -m eter (Ran g-di ng  Wang   5295 Time differen c e m e a s ured  is n o t a  con s tant  value,  namely, ther e are ma ny reason s,   mainly from  the followin g  aspe cts. 1 )  Ultra s oni c tra n sd ucers. 2) The wo rki n g con d ition s . 3)  Secon d a r y in strum ent a n d  so  on. Exce pt the ha rd ware  proce s sin g , we  sh ould  use rea s on a b le   softwa r e alg o r ithm to impro v e the accura cy of flowmet e r.       3. The Desig n  of Digital P r oces sing Al gorithm   There are m any pro c e s si ng metho d for  mea s u r e m ent data,  based on th e sig nal  cha r a c teri stics of the time difference u l traso n ic  flo w meter, de sig ned a more pra c tical di gital  sign al p r e - proce s sing  alg o rithm s . Th at the te st  data  ca n b e   so rte d , filtered,  error  com pen sat ed.  Thro ugh the s e three p r o c e ssi ng sta g e s, we  ca n get an ideal  measure m e n t data for flow  measurement .     3.1. Sorting Algorithm   There i s  a  l o t of  sortin g  algo rithm s   with th e time effic i enc y  is very different. More  comm on so rt ing algo rithm s  are b ubble  sort, inse rtion so rt, shell  sort, heap  sort, qui ck  sort,  sele ction  sort , merge sort, and so on. Assumin g   n  is the numbe r of data sh ould b e  sorte d , then   )) ( ( ) ( n g O n f                                                                                         (7)      ) ( n f is the times o f  exchang e,  )) ( ( n g O is the complexity, while  ) ( n g is  a function of  n In the resea r ch  pro c e ss of time differen ce ult r a s oni c flowm e ter, co nsid e r ing the  system' s  p o wer a nd me asu r eme n t accu racy, t he n u m ber  of sa mple s is set to 10,  namely 10 n , during  cal c ulating the  complexity of the so rti ng al gorithm, al so  took into a c cou n t the sa mple  space. Can be  obtai ned by  cal c ulat ing the  compl e xity of the algor ithm,  Hill  sort i s  the lowest  averag com p lexity, that is ) ( 25 . 1 n O . This  so rtin g meth od i s   particula rly suitable fo small a n d   medium am o unts of data, and very ea sy to implement.      3.2. Digital Filtering Algo rithm  For  the ch ara c teri stics of  si ngle-chi p  system,  here m a in research   several  digital   filtering  method are   as foll ows. 1 )  Medi a n  filtering. 2 )   Weig hted ave r ag e  filtering  met hod. 3 )  M o ving  averag e filteri ng method. 4 )  Peters filtering method   [4-6]. Here  we us e the Peters formula     1 / 2 1 n n x x s n i i                                                                        (8)           In this  formula,  s  is the sa mple stan da rd deviation,  i x is the NO.i sa mpled data,  x is  the average  of mea s u r e m ents  n  times, the l a st  measurement , and  n  is th e num be r of   measurement s, if there is:     s x x new 3                                                                                            (9)    The re sult s of this mea s urem ent is e ffective, otherwi se, mea s u r eme n t results is the   rand om e rro r,  shoul d be  re moved. In this form ula,  new x the last mea s u r eme n t, if the numbe r of  measurement s 10 n , then (9) sh ould be rewrit ten as:     s x x new 2                                                                                          (10)    If we o n ly u s e on e of th ese filtering  met hod s to  deal   with the  a c tu al mea s u r em ent data,  it is difficult to  meet the syst em requi rem ents. The r efo r e, in th is re search, we ha ve used medi an   Evaluation Warning : The document was created with Spire.PDF for Python.
                               ISSN: 23 02-4 046   TELKOM NIKA  Vol. 11, No . 9, September 201 3:  529 3 – 5298   5296 filtering meth od, the weig h t ed averag e filter, mo ving a v erage filteri n g method an d  Peters filtering   to form  a  co mposite  filter,  it can  en sure  the  stability  and  accu ra cy  whil e in crea sing the  real-ti m e   data pro c e s si ng, thus in cre a sin g   the use f ulness of the  test system   [7 - 1 0 ]   3.3. Error Co mpensa tion Metho d   Erro r com p e n satio n  can  be achieved  th rough a v a riety of ways, depe nding  on the  prin ciple  ca n be  divide d into a r ith m etic ave r a ge meth od,  wei ghted  averag e met hod,  interpol ation  method an d so on [10].  This article took care of the stability and  real -time requirement s of measurement results  whi c h the  sy stem requi re d into con s id eration,   use d  the wei ghte d  avera ge m e thod fo r error  comp en satio n , at the  sa me time,  ea ch  sa mple  value  of  weig ht co efficient  ca be  adj usted   according to  conditions to  get a different error  com p ensation value, improved the flexibility of the  system. After the erro r compen satio n  the m easu r ed data ha s been fully able to meet  th e   measurement  requireme nts of flow meter,  and th en obtaine d  final fluid flow thro ugh  the   measurement  formula.       4. Data Pro c essing Algo r i thms   In this  pap er, microcontro ller MSP4 30 F449 i s  th core of  the t r an sit-time  ul traso n ic  flowmete r system in the hard w a r e, und er IAR Embe dded Workb e n ch envi r onm ent, using C4 30  in the  softwa r e to  achieve  the d a ta  sorting, f iltering,  and  erro compen satio n  algo rithm. T h e   referen c e cod e s are as foll ows.    4.1. Hill Sort Algorithm     void  shell s o r t( sign ed lon g  *shell D ata[1 0 ], int CONT )  {   int k = CONT/2;  //CONT i s  sa m p le space, and CONT =1 0;  while(k>0)  {  for(int i=k ; i<CONT;i++ {   signed lo n g   t=shell D at a[i];  int  j=i-k;   while( j>=0  &&  t<shellData[j] )  {   shellData[j+k] =  shell D at a[j];  j=j-k;  shell D ata[j + k]  = t;  k= k/ 2;     4.2. Peters F iltering    cha r  Peters(signed lo ng *p eter[9])  {  signe d long  sum = 0;   for(int i=1;i<9; i++)  sum + =ab s Fu ction(pete r  [i]-peter[0]);   sum  = sum > > 1 ;   if(sum >a bsF u ction(pete r [8]-pete r [0]))  return 1;  else   return 0;    4.3. The Error Corre ction  Algorithm     sign ed long  JQYes(si gne d long *Ye s [9])  {  signe d long  JQY;  Yes [ J ][8] =  Yes [ 8]<< 2;   Evaluation Warning : The document was created with Spire.PDF for Python.
TELKOM NIKA   ISSN:  2302-4 046       A Signal Pre-pro c e ssi ng Al gorithm  Applied for  Ultraso n ic Flo w -m eter (Ran g-di ng  Wang   5297 J Q Y = (Yes [4] + Yes [ J ][5]+ Y e s [ 6]+ Y es [7] + Yes [ 8])>> 3 ;   Yes[8] = Yes[ 8]>>2;  return J Q Y;   sign ed long  JQOk(signe d long *O k[9])  {   signed lo n g  JQO;   JQO = (O k[ 5] + O k[ 6] + O k[ 7] + O k[ 8] ) > >2;   return J Q O;  sign ed long  JQNo (si gne d long *No[9])  {   signed lo n g  JQ N;  JQ N=(No[5]+No[6]+N o[6] +No[7])>>2;   return J Q N;     5. Analy s is o f  Experimen t al Results   The test pla tform is 150 mm diamete r  time difference ultra s o n ic flowm e te r while   microcontroll er MSP430 F 449 is a s  t he MCU.  In accordan ce  with nation a l metrolo g ical  verification,  we have g o t seven flow  poi nts’ a c tual  ca librat i on re sul t s,   1m³/ h, 1.3 m ³/ h, 1.6m ³/h,  75.48m ³/h, 176.12m ³/h, 250m³/h,  26 5 m ³/h, and show the a n a ly sis di agra m  of 1.3m³/h,  75.48m ³/h, 176.12m ³/h flow point s.            Figure 3. Und e r Static  Figure 4. Und e r 1.3m ³/h           Figure 5. Und e r 75.48 m³/h   Figure 6. Und e r 176.1 2 m³/ h       The  stand ard  deviation  of t he time  difference fo r ea ch  flow  point i s   in Tabl e 1,  in cludi ng  both before a nd after the di gital pro c e ssi ng.            3                 10   2.6     2.7     2.8     2.9     3     3.1   3.2   x 1 0 4     t    Sam p le num ber  af t e r   b e fore       3                 10   2.6     2.7     2.8     2.9     3     3.1   3.2   x 1 0   4         t      Sam p le num ber  af t e r b e fore   1       3       5             10    600    650    700    750    800    850    900        Sam p le num ber  b e fore   af t e r   t 2     3   4   5   6   7   8     9   10   - 30     - 25     - 20     - 15     - 10   -5     0     5      10     15     20     Sam p le num ber  t           af t e r b e fore   Evaluation Warning : The document was created with Spire.PDF for Python.
                               ISSN: 23 02-4 046   TELKOM NIKA  Vol. 11, No . 9, September 201 3:  529 3 – 5298   5298 Table 1. Anal ysis of the Standa rd Devia t ion to the Time Differe nce  Fl ow  point  Original Standar deviation   Ne w  Standa rd  deviation  static 15.63   9.64  1.3m³/h  63.46   28.72   75m³/h  1466.18   323.09   175m³/h  899.34   381.00       6. Conclusio n   This a r ticle  mainly analy z ed a bout th e feature s  of  time differe nce d a ta of  the time   differen c ultrasoni c flo w   meter  whi c h   is b a sed o n   MSP430F4 4 9  chi p , an d variou s type of  cla ssi cal  data  pro c e s sing  a l gorithm co rresp ondi ng  wi th it, desi gne d an d impl em ented  pra c tical  digital si gnal  pre - processin g  algo rithm,  proved  by  a c tual test resul t s, usin g thi s   method  ca be   very effective in removing  error of the  sampl ed  data,  improving th e me a s urem ent accu ra cy of  flow meter, e nhan cin g  the stability  and real-time of th e test system     Ackn o w l e dg ement  This  wo rk i s   sup porte d by  Zhejian g   sci ence & techn o logy preferred p r oje c ts  o f  China  (201 0C110 25 ), Zhejian g  province e d u c a t ion depa rtme nt key proje c t  of China (Z D2009 012 ).        Referen ces   [1]  E Mansard, E Kouam e, R. Battault. T r ansit time ul traso n ic  flo w meter: vel o cit y  Profil e esti mation.  IEEE  Internatio na l Ul trasonics Sy mposi u m . 200 5: 763- 766.   [2]  Contro lotron ’s  w i de be am. Ca vit y -free  u l tras onic  flo w m e ter s  ach i eve  g a s  custod y tr ans fer accur a c y   performa nce.  Pipe lin e an d Gas Journ a l . 20 03; 230( 4): 93- 95.   [3]  Willatzen   M.  Fl o w  acoustics  mode lin g and   i m plic ati ons  for  ultras onic  flo w  meas ureme n base d   on t h e   transit-time me thod.   Ultrasonics . 2004; 41: 8 05-8 10.   [4]  Nori yuk i  F u ru ic hi, Hir oshi S a t o , Yoshi y a  T e rao. A n e w  ca li bratio n facil i t y   for  Water flo w   rate at high  Re yn olds n u m ber.  F l ow  Measure m e n t and I n strumentati o n . 2009; 20: 38- 47.   [5]  Yang  Hu, W a n g  Ch en g. Sim u lati on  Rese ar ch o n  Ultras o n i c Guid ed  Waves Det e ction  o f  Metal R o d   Buffer S y stem  Bon d in g Qu al it y .   T E LKOMN I KA Indo nesi a n Jo urna of E l ectrical  En gin eeri n g . 20 13 11(3): 12 51- 12 57.   [6]  MW Li, GS Lv , YG Hu.  Research o n  i m pr ovin g the accu racy of  the ultrason ic flow -me t er w i th time   differenc e method . Intern atio nal co nfere n ce  on electric al  a nd contro l en gi neer ing. 2 010:  256- 259.   [7]  S Kother Moh i de en, S Arumuga Per u mal ,  M  Mohamed  Sathik. Image De-n oisi ng  usin g Discrete   Wavelet transform.  Internati o nal J our nal  of  Co mp uter Sci e nce  and  Netw o r k Security . 2 0 08; 8( 1): 21 3- 216.   [8] J  Carlson.  Ultrasonic particle velocime try in m u ltiphase flows . Proceedin g s of the IEEE internati o n a l   ultraso n ics s y mposi u m. 200 2: 740-7 43.   [9]  Paul us Insa Santosa. C o st  and B e n e fit of In formation  Search  usin g  T w differe nt Strategies .   T E LKOMNIKA Indon esi an Jou r nal of Electric al Eng i ne eri n g .  2010; 8(3): 1 9 6 -19 9 [10]  Roy  BVB S i m o rangkir, Achmad Munir. Numerica l Design of  Ultra -Wideband Print e d Antenna for   Surface P enetr a ting  Ra dar A pplic atio n.  T E L K OMNIKA Indones ian  Jour n a l of  E l ectrica l  Engi ne erin g 201 1; 9(2): 341 -350.   Evaluation Warning : The document was created with Spire.PDF for Python.