Dynamic Synchronous Capture Algorithm for an ... - MDPI

3 downloads 0 Views 5MB Size Report
Apr 10, 2017 - The principle of the electromagnetic flowmeter is based on Faraday's law of induction, ... In accordance with the law of induction, a voltage U.
sensors Article

Dynamic Synchronous Capture Algorithm for an Electromagnetic Flowmeter Yong-Yi Fanjiang * and Shih-Wei Lu Department of Computer Science and Information Engineering, Fu Jen Catholic University, New Taipei 24205, Taiwan; [email protected] * Correspondence: [email protected]; Tel.: +886-2-2905-2444 Academic Editors: Ashutosh Tiwari and Bharati Tudu Received: 9 February 2017; Accepted: 7 April 2017; Published: 10 April 2017

Abstract: This paper proposes a dynamic synchronous capture (DSC) algorithm to calculate the flow rate for an electromagnetic flowmeter. The characteristics of the DSC algorithm can accurately calculate the flow rate signal and efficiently convert an analog signal to upgrade the execution performance of a microcontroller unit (MCU). Furthermore, it can reduce interference from abnormal noise. It is extremely steady and independent of fluctuations in the flow measurement. Moreover, it can calculate the current flow rate signal immediately (m/s). The DSC algorithm can be applied to the current general MCU firmware platform without using DSP (Digital Signal Processing) or a high-speed and high-end MCU platform, and signal amplification by hardware reduces the demand for ADC accuracy, which reduces the cost. Keywords: electromagnetic flowmeter; Gaussian blur; moving average algorithm

1. Introduction The electromagnetic flowmeter has been developed over 70 years since the beginning of the 20th century, and it is used in oil, chemical, metallurgy, textile, food, hydraulic building, industrial measurement, and medical industries [1]. Most of the current flowmeter developments are limited to mechanical measurement in Taiwan. There has been no research performed on the use of electromagnetic flowmeters in the industrial measurement field. Their unit price is high, and due to import problems, a significant amount of time is required to obtain them. Frost & Sullivan and the International Energy Agency (IEA) show that the investment in global basic energy equipment will accumulate to 26 quadrillion US dollars over the period from 2007 to 2030, and the intelligent flow meter market is expected to reach 7.76 Billion US dollars by 2022, at a CAGR (Compound annual growth rate) of 5.4% between 2016 and 2022 [2]. In several places in the world, the infrastructures of electric, oil, and natural gas will need to be replaced by 2030. Facing a competitive environment and the demands of global energy conservation and carbon reduction, various industrial users are devoting more attention to the efficiency of production plants to reduce energy consumption as much as possible and thereby improve competitiveness. Therefore, numerous investments, which are used to raise the level of factory automation, gather field data and monitor real time, can enhance the efficiency of the process control system. In oil, gas, and energy industries, custody transfer facilities need reliable flow measurement equipment. In chemical and pharmaceutical industries, electromagnetic flowmeters require high accuracy. Sensors and field devices, including electromagnetic flowmeters, can be developed in diverse ways or manners. At present, most methods in the electromagnetic flowmeter paper do not specify which algorithm to use in the calculation of the flow. There are many ways to calculate the flow through hardware or sensor architecture improvements, but often it is often found that they use most of the firmware Sensors 2017, 17, 821; doi:10.3390/s17040821

www.mdpi.com/journal/sensors

Sensors 2017, 17, 821

2 of 15

computing platform (MCU) specifications (especially in large quantities using FPGAs [3–6] or DSP [7] and other high-cost hardware components). Therefore, it can be speculated that other methods must be obtained through the more powerful hardware specifications to calculate, resulting in cost increases and also a lack of flexibility. In view of this, it is very practical research to study how to improve the efficiency of algorithm implementation and related signal processing to reduce hardware dependency. This paper proposes a dynamic synchronous capture (DSC) algorithm to calculate the flow rate for an electromagnetic flowmeter. This implementation platform is based on a 32-bit microcontroller unit (MCU), which is inexpensive and easily obtained. This algorithm can meet the requirements for real-time calculations and for conversions of a correct and accurate flow rate signal. Moreover, it can simultaneously avoid noise interference [8]. When calculating the flow rate signal, this algorithm can combine imaging algorithms and statistical methods, which are used to increase the S/N ratio (signal-to-noise ratio) in the limited resources firmware platform to obtain effective results. 2. Background 2.1. Faraday’s Law The principle of the electromagnetic flowmeter is based on Faraday’s law of induction, which states that if a conductor is moved through a magnetic field, then a voltage that is proportional to the velocity of the conductor will be induced. In accordance with the law of induction, a voltage U can be induced in the process liquid that is proportional to the flow velocity v of the process liquid, induction B and the inside tube diameter D as follows: U=

BdA Ddl dφ = =B = BDv dt dt dt

(1)

where B is the magnetic flux density (Wb/m2 ), v is the average speed of the conductive liquid motion (m/s), D is the diameter of the pipe (m), dl is the conductive liquid diameter (m), A is the cross-sectional area (m2 ), and U is the signal electromotive force (V). When Equation (1) is applied to the electromagnetic flowmeter, a calibration factor K is applied, and the signal electromotive force U can be expressed as follows [9]: U = KBDv

(2)

where K is a non-dimensional constant. The signal voltage U is picked up by electrodes that have conductive contact with the process liquid and insulation from the pipe wall [10]. Using QV =

π 4

 D2 · v

(3)

the signal voltage U can be converted by a signal converter into a flow indication QV as follows: QV =

π U ·D· 4 KB

(4)

Furthermore, the flow rate can be converted into standardized signals appropriate to the process. Here, QV is the volume flow rate (m3 /s). This process indicates that the nominal pipe diameter D is a constant value. When the magnetic flux density changes, the flow rate is directly proportional to the signal electromotive force U. Thus, we can observe that the flow measurement of the electromagnetic flowmeter is independent of other physical parameters, which is one of its advantages. Moreover, the above formula was established, and the limited conditions are satisfied from the following section.

Sensors 2017, 17, 821

3 of 15

2.2. Assumptions and Limitations The electromagnetic flowmeter needs to satisfy the following conditions: 1.

2.

3.

4.

Assumption 1: Axis-symmetrical velocity distribution. The profile of the flow velocity is assumed to have an axis-symmetrical distribution. The induced current in the liquid and the electric field are symmetrical and parallel to the axial direction of the liquid. Assumption 2: Uniform, constant distributed magnetic field. The magnetic field is assumed to have a constant and uniform distribution. If this assumption is true, then it can be ignored by the effects of the conductive liquid in the magnetic field generated by movement, i.e., the effect of the induced current on the magnetic field distribution and the effect of the interaction between the induced current and the electromagnetic force with the liquid flow velocity. Both of these effects in the measurement of the liquid metal are not negligible. Assumption 3: Non-magnetic liquid. The measured liquid is assumed to be a non-magnetic liquid, and its permeability µ is consistent with the permeability of the vacuum µ0 . Thus, the effect of the interaction between the magnetic liquid and the magnetic field work for the flow measurement can be ignored. It can be observed that the measured fluid flow holds under the above conditions and hypothesis, and the induced electromotive force U can be considered proportional to the instantaneous volume flow rate QV . Their relationship is completely linear. Assumption 4: Uniform and isotropic liquid conductivity. The conductivity of the liquid is assumed to be uniform and isotropic. It is independent of the electric field or the liquid flow.

2.3. Excitation Mode The different excitation methods used for measuring different liquids in various environments have diverse effects and functions. 2.3.1. DC Excitation The coils of the electromagnetic flowmeter can be powered by either alternating current (AC) or direct current (DC) [11]. The DC excitation uses the direct-current voltage to provide the electromagnetic flowmeter with a steady voltage so that the excitation of the magnetic field can be steady. The DC excitation is reliable and simple. Additionally, it is rarely affected by the electric supply. The problem with the direct-current excitation is that it leads to electric polarization, which results in a weaker flow signal [12]. The electrode’s resistance becomes more significant, and the electric supply drifts at the same time [13,14]. 2.3.2. Sinusoidal Wave Excitation The sinusoid excitation skills can directly replace the direct-current excitation. It can eliminate the surface electric polarization, as well as decrease the influence of the electric charge drift and the internal resistance of the electromagnetic flowmeter [15]. The orthogonal interference of the amplitude and frequency are in direct proportion. Furthermore, they cause same-phase interference and lead to the electromagnetic flowmeter, which does not have drift disadvantages. 2.3.3. Pulsed DC Excitation Low-Frequency Rectangular Wave Excitation The electromagnetic flowmeter is used for low frequency rectangle excitation, whose frequency is that of the electric supply frequency reduced from 1/4 to 1/10 [14]. The DC excitation does not cause eddy currents, orthogonal interferences, same-phase interferences and non-electric polarizations. The signal’s amplification is used for the calculation. This steady excitation can avoid zero drift. Additionally, it can tolerate noise well. It is disadvantageous that the amplitude of the differential interference is directly proportional to the frequency.

Sensors 2017, 17, 821

4 of 15

3. Requirements of DSC Algorithm Design The coil generates the excitation signal and is sensed by the signal at both ends of the electrode, that is, the so-called flow rate original signal Figure 1, by calculating the size of the vibration to calculate the instantaneous flow rate, the flow rate and the signal amplitude. Because the power level Sensors 17, 821 of 15 sensed out2017, of the signal is very small (mV), it is very susceptible to interference and will4 produce differential interference phenomena that need to be overcome. The following steps illustrate how to differential interference phenomena that need to be overcome. The following steps illustrate how to calculate and challenge the project. calculate and challenge the project.

Figure 1. Flow signal waveforms.

Figure 1. Flow signal waveforms.

3.1. Calculating the Flow Rate Signal

3.1. Calculating the Flow Rate Signal

As illustrated in Figure 1, the flow signal’s change depends on the amplitude wave of the

excitation at the senses. flow signal is proportional to the amplitude of the As illustrated inmoment Figure 1,it the flowThe signal’s change depends on the amplitude wave ofexcitation the excitation wave. We should avoid the differential interference when calculating the amplitude [16]. Thewave. at the moment it senses. The flow signal is proportional to the amplitude of the excitation differential interference occurs as a result of the excitation direction of the coil, which is varying. We should avoid the differential interference when calculating the amplitude [16]. The differential Furthermore, the differential interference has a fixed size based on the excitation current. The flow interference occurs as a result of the excitation direction of the coil, which is varying. Furthermore, signal is larger, and the excitation signal’s amplitude is larger as well. Additionally, it can cover the the differential interference has a fixed size based on the excitation current. The flow signal is wave of differential interference. larger, and the excitation signal’s amplitude is larger as well. Additionally, it can cover the wave of differential interference. 3.2. Comparison of Different Flow Rate Signals For theof high and low excitation waves of the flow signal, it is apparent that the excitation waves 3.2. Comparison Different Flow Rate Signals

are different. The flow signal is high due to the large excitation signal’s amplitude. The differential

For the highwill andbe low excitation waves of the it is apparent that the will excitation waves interference covered by the signal. In aflow lowsignal, flow velocity, the excitation produce differential interference signals, so we need to simultaneously conform to the high and low flow are different. The flow signal is high due to the large excitation signal’s amplitude. The differential signals’ will algorithm. interference be covered by the signal. In a low flow velocity, the excitation will produce differential interference signals, so we need to simultaneously conform to the high and low flow signals’ algorithm. 3.3. Noise Suppression

3.3. Noise The Suppression electromagnetic flowmeter’s signal arises from sensing the voltage, which requires accurate quality. Noise can lead to mistakes in the electromagnetic flowmeter, and any mistakes will affect the

The electromagnetic flowmeter’s signal arises from sensing the voltage, which requires accurate repetition. quality. Noise can lead to mistakes in the electromagnetic flowmeter, and any mistakes will affect the repetition. 3.4. Level Flutter and Offset The high and low excitation waves of the flow signal and their zero-voltage level located in the 3.4. Level Flutter and Offset

signal are different. From the data, if positive and negative values are used to calculate the positive

The high andhalf low excitation waves of the results flow signal and their zero-voltage level located and negative cycles, it will cause unusual and detect mistakes. The zero-voltage level hasin the reactions for different Whenand we observe steadyare flow signals, the signals signaldifferent are different. From the data,flows. if positive negativethe values used to calculate the will positive follow thehalf zero-voltage and unusual down, which indicates that themistakes. flow signal canzero-voltage move up andlevel and negative cycles, itlevel willup cause results and detect The down. Based on thefor analysis above, in thisWhen paper,we a DSC algorithm has been designed to provide the will has different reactions different flows. observe the steady flow signals, the signals following functionalities: follow the zero-voltage level up and down, which indicates that the flow signal can move up and  Based An algorithm for calculation the flow arate based has on been the characteristics of the the down. on the analysis above, inof this paper, DSCsignal algorithm designed to provide electromagnetic flowmeter; following functionalities:  

Avoidance of noise suppression and the differential interference’s sector while calculating the amplitude; Signal interpretation, as well as dynamic and real-time computation;

Sensors 2017, 17, 821

5 of 15



An algorithm for calculation of the flow rate signal based on the characteristics of the electromagnetic flowmeter; • Avoidance of noise suppression and the differential interference’s sector while calculating the amplitude; Sensors 2017, 17, 821 5 of 15 • Signal interpretation, as well as dynamic and real-time computation; Greater accuracy and repeatability • repeatability for for the the current current solution; solution; and and • repetitive flow flow production. production. Consistency for productized and repetitive 4. Implementation 4.1. Hardware Architecture Architecture 4.1. Hardware The needs to to have The flow flow signal’s signal’s algorithm algorithm needs have the the flow flow signal signal features features mentioned mentioned in in the the previous previous section. Furthermore, the algorithm needs to be able to calculate the flow signal and address the section. Furthermore, the algorithm needs to be able to calculate the flow signal and address the noise, noise, signaland drift, and unsteady level. Moreover, the algorithm can be implemented in the signal drift, unsteady voltagevoltage level. Moreover, the algorithm can be implemented in the common common 32-bit MCU. We can calculate the flow signal effectively, but we also need to use the 32-bit MCU. We can calculate the flow signal effectively, but we also need to use the filter, whichfilter, can which can cause problems the signal’s movement, theThe level. The algorithm cause problems related torelated noise, to thenoise, signal’s movement, and theand level. algorithm needs needs to be to be implemented in the current. its efficiency has to to conform to the MCU’s consumptive implemented in the current. Thus, itsThus, efficiency has to conform the MCU’s consumptive resources. resources. The algorithm also requires additional work to function (e.g., communication, display, The algorithm also requires additional work to function (e.g., communication, display, and key and key functions) and to produce the real-time signal detection and calculation. functions) and to produce the real-time signal detection and calculation. Figure the DSC. DSC. The The MCU MCU master master is is responsible responsible Figure 22 illustrates illustrates the the hardware hardware block block of of the the MCUs MCUs in in the for The LCM LCM (Liquid Crystal Module) Module) signifies for controlling controlling the the UI UI (user (user interface). interface). The (Liquid Crystal signifies that that the the detection detection of The flow flow signal Because its its signal of the the key key adds adds the the analogy analogy output. output. The signal enters enters from from the the sensor. sensor. Because signal is is extremely small, the highest flow amplitude voltage depends on the mV. The instrumentation amplifier extremely small, the highest flow amplitude voltage depends on the mV. The instrumentation creates a larger which becomes largereven when passing thepassing OPA (Operational Amplifier). amplifier createssignal, a larger signal, whicheven becomes larger when the OPA (Operational The signal passes the ADC (analog to digital converter), and it is selected by the MCU slave Amplifier). The signal passes the ADC (analog to digital converter), and it is selected byafterwards. the MCU It produces the flow signal’s detection and the algorithm’s calculation. slave afterwards. It produces the flow signal’s detection and the algorithm’s calculation.

Figure 2. Hardware diagram. Figure 2. Hardware block block diagram.

4.2. Excitation Circuit 4.2. Excitation Circuit When designing the excitation, the suitable excitation will be selected and analyzed. This paper When designing the excitation, the suitable excitation will be selected and analyzed. This paper selects a low frequency rectangle excitation 0 and saddle-shaped excitation coils [17]. selects a low frequency rectangle excitation 0 and saddle-shaped excitation coils [17]. The H-Bridge circuit allows the DC electric motor to have forward, reverse and stop functions. The H-Bridge circuit allows the DC electric motor to have forward, reverse and stop functions. Figure 3a illustrates the H-Bridge circuit. Figure 3b indicates that when the POS_EN has a high Figure 3a illustrates the H-Bridge circuit. Figure 3b indicates that when the POS_EN has a high voltage voltage and the NEG_EN has a low voltage, due to the cross conduction of the transistor, the path of and the NEG_EN has a low voltage, due to the cross conduction of the transistor, the path of the the excitation current moves to the left. However, Figure 3c indicates that when the POS_EN has a excitation current moves to the left. However, Figure 3c indicates that when the POS_EN has a low low voltage and the NEG_EN has a high voltage, the path of the excitation current moves to the right. voltage and the NEG_EN has a high voltage, the path of the excitation current moves to the right.

Sensors 2017, 17, 821

6 of 15

Sensors 2017, 17, 821

6 of 15

Sensors 2017, 17, (a)821

(b)

(c)

6 of 15

Figure 3. (a) H-Bridge circuit; (b) High voltage POS_EN and low voltage NEG_EN; (c) Low voltage

Figure 3. (a) H-Bridge circuit; (b) High voltage POS_EN and low voltage NEG_EN; (c) Low voltage POS_EN and high voltage NEG_EN. POS_EN and high voltage NEG_EN.

4.3. DSC Algorithm

4.3. DSC Algorithm

When designing the excitation, the suitable excitation will be selected and analyzed. This paper selects a

low frequency rectangle of 0the andsuitable saddle-shaped excitation coils When designing the excitation excitation, excitation will be[17]. selected and analyzed. This paper (a) (b) (c) selects a low frequency rectangle excitation of 0 and saddle-shaped excitation coils [17].

4.3.1. CoilFigure Excitation Sync circuit; (b) High voltage POS_EN and low voltage NEG_EN; (c) Low voltage 3. (a) H-Bridge

POS_EN and high voltage NEG_EN. 4.3.1. CoilUsing Excitation Sync I/O POS, the NEG pin transmits the H-Bridge to produce the magnetic field’s the firmware

change and to lead to the differential interference’s signal. The differential interference’s signal is

DSC AlgorithmI/O POS, the NEG pin transmits the H-Bridge to produce the magnetic field’s Using4.3. the firmware used to ensure that the synchronous flow signal starts and calculates the flow signal accurately. When designing the excitation, the suitable excitation will be selected analyzed. This paper selects a signal is used change and to lead to the differential interference’s signal. Theand differential interference’s Obtaining the synchronous signal can consume the MCU resources and lead to burdens because low frequency rectangle excitation of 0 and saddle-shaped excitation coils [17]. to ensure that the synchronous flow signal startsTo and calculates the flow we signal Obtaining certain signals need to operate and calculate. avoid these problems, can accurately. use the H-Bridge the synchronous signal can consume the MCU resources and lead to burdens because certain signals circuit. 4.3.1. Coil Excitation Sync need to operate and calculate. To avoid these problems, we can use the H-Bridge circuit. Using the firmware I/O POS, the NEG pin transmits the H-Bridge to produce the magnetic field’s

4.3.2. change Start Sampling Data and to lead to the differential interference’s signal. The differential interference’s signal is

4.3.2. Startused Sampling Data that the sampling synchronous flow signal starts and rate calculates the be flow signal Basedtoonensure the Nyquist theorem, the sampling (fs) must twice asaccurately. large as that of Obtaining the synchronous signal can consume the MCU resources and lead to burdens because the highest frequency testsampling signal. Fortheorem, example, the algorithm takes a (f 1 skHz signal and brings the duty Based on the Nyquist the sampling rate ) must be twice as large as that certain signals need to operate and calculate. To avoid these problems, we can use the H-Bridge to 160 ms (6.25 Hz). The signal is converted and stored in the memory of the MCU when the of the highest circuit.frequency test signal. For example, the algorithm takes a 1 kHz signal and brings synchronization signals appear. The stored data are and the original flow signals.ofBased on thewhen the duty to 160 ms (6.25 Hz). The signal is converted stored in therate memory the MCU synchronization signals,Data the data in the MCU can be categorized into positive and negative cycles. 4.3.2. Start Sampling the synchronization signals appear. The stored data are the original flow rate signals. Based on the Therefore,Based they on canthebeNyquist processed in the next stage of the flow rate’s calculation algorithm. sampling the sampling rate (fs) must be twice as large as negative that of synchronization signals, the data in thetheorem, MCU can be categorized into positive and cycles. We need to consider the problem related to the data’s switch. When the signal isthe switching, it the highest frequency test signal. For example, the algorithm takes a 1 kHz signal and brings duty Therefore, they can be processed in the next stage of the flow rate’s calculation algorithm. requires the following steps: the signal is detected, obtained, and switched. It is easy to add the to 160 ms (6.25 Hz). The signal is converted and stored in the memory of the MCU when the We need to consider the appear. problem the data’s switch. When signal switching, system’s burden. The switching frequency 1tokHz, which corresponds to a the period ofon1 is ms. The synchronization signals The related storedisdata are the original flow rate signals. Based the it requires the following steps:the the signal isthe detected, obtained, and switched. It isbeeasy to add the synchronization signals, data in the MCU can be categorized into positive andcannot negative cycles. process of loading the ADC and switching effective figure through the MCU completed Therefore, theyswitching can use be processed in the next stage the flow rate’s calculation in 1 burden. ms. Therefore, we thefrequency queue to obtain andof switch the signals. system’s The is 1 kHz, which corresponds to aalgorithm. period of 1 ms. The process We need toinconsider thewhen problem related tothe the original data’s switch. Whensignal the signal is switching, it As illustrated Figure 4, conducting flow rate acquisition, the counter of loading the ADC and switching the effective figure through the MCU cannot be completed in 1 ms. requires the following steps: the signal is detected, obtained, and switched. It is easy to add the Data_In_Index will increase after obtaining a flow rate signal. This process is repeated until the entire Therefore,system’s we useburden. the queue to obtain and switch the signals. The switching frequency is 1 kHz, which corresponds to a period of 1 ms. The signal cycle is fetched (i.e.,4,160 slots). Whenthe theeffective Data_In_Index increases, thecannot Data_Transform_Index As illustrated in Figure when conducting the original flow rate signal acquisition, the counter process of loading the ADC and switching figure through the MCU be completed is used toms. check whether the the signal needs to beand converted. The advantage of this approach is that it in 1 Therefore, we use queue to obtain switch the signals. Data_In_Index will increase after obtaining a flow rate signal. This process is repeated until the entire allows theAssignal to beinacquired and converted parallelflow processing, thus, itthe saves time and illustrated Figure 4, when conductinginto the original rate signaland acquisition, counter signal cycle is fetched (i.e., 160 slots). When the Data_In_Index increases, the Data_Transform_Index improves the conversion efficiency. Additionally, it can avoid inability to detect Data_In_Index will increase after obtaining a flow rate signal. Thisthe process is repeated untilthe theflow entirerate in is used check whether the(i.e., signal needs to be advantage of this approach is that it signal cycle fetched 160 slots). When the converted. Data_In_IndexThe increases, the Data_Transform_Index realtotime due to is the delay of signal acquisition. used toto check whether theand signal needs to beinto converted. The processing, advantage of this approach that it time and allows theissignal be acquired converted parallel and thus, itis saves the signal toefficiency. be acquired and converted into processing, and thus,to it saves time improves allows the conversion Additionally, it parallel can avoid the inability detect theand flow rate in improves the conversion efficiency. Additionally, it can avoid the inability to detect the flow rate in real time due to the delay of signal acquisition. real time due to the delay of signal acquisition.

Figure 4. Using queue conversion data.

Figure 4. Using queue conversion data.

Figure 4. Using queue conversion data.

Sensors 2017, 17, 821

7 of 15

Sensors 2017, 17, 821

7 of 15

4.3.3. Obtain Available Available and 4.3.3. Obtain and Conversion Conversion Data Data After distribution of of time cancan be obtained. When eacheach signal has been After the the synchronous synchronoussignal, signal,the the distribution time be obtained. When signal has sampled, it can judge whether the signal is located in the effect zone. When the signal is in the effect been sampled, it can judge whether the signal is located in the effect zone. When the signal is in the zone, it will process the signal’s switch. This approach can avoid significantly unsteady zones or the effect zone, it will process the signal’s switch. This approach can avoid significantly unsteady zones non-effect zone. For example, the differential interference’s pulsespulses decrease several noise noise and error or the non-effect zone. For example, the differential interference’s decrease several and signals. They reduce the MCU burden when attempting to detect signals simultaneously. The positive error signals. They reduce the MCU burden when attempting to detect signals simultaneously. The half-cycle and the negative half-cyclehalf-cycle (see Figure 5)Figure can also positive half-cycle and the negative (see 5) be canrecognized. also be recognized.

Figure 5. Sampling flow signal. Figure 5. Sampling flow signal.

4.3.4. Average to Positive/Negative Region 4.3.4. Average to Positive/Negative Region The signals of the positive half-cycle and the negative half-cycle will be averaged, which can The signals of the positive half-cycle and the negative half-cycle will be averaged, which can advance and calculate the flow signal’s amplitude. Because the positive half-cycle and the negative advance and calculate the flow signal’s amplitude. Because the positive half-cycle and the negative half-cycle do not signify positive and negative, the flow amplitude has to use the absolute value of half-cycle do not signify positive and negative, the flow amplitude has to use the absolute value of the the data. The result of the calculation is raw data. data. The result of the calculation is raw data. Using Equation (5), we can calculate how many data are in the positive zone and in the negative Using Equation (5), we can calculate how many data are in the positive zone and in the negative zone. We attempt to calculate the data separately and equally. zone. We attempt to calculate the data separately and equally. p 1 n 1 . F  1. p  p−k1 0 P  k  p   1 n  n−k 1 0 N  k  n 

∆F = 1 p∑k=0 P[k + p] − 1 n∑k=0 N [k + n]

(5) (5)

where p is the number of total positive signal points, n is the number of total negative signal points, where p is the number of total positive signal points, n is the number of total negative signal points, P[ ] is the positive input signal, and N[ ] is the negative input signal. P[ ] is the positive input signal, and N[ ] is the negative input signal. 4.3.5. MAQ (Moving Average + Quick Sort) of Flow Results 4.3.5. MAQ (Moving Average + Quick Sort) of Flow Results When switching the original flow signal, the data are first saved in the array. When the new data When switching the original flow signal, the data are first saved in the array. When the new data enter, the old data are deleted as the new data are saved. The average is not calculated in this step enter, the old data are deleted as the new data are saved. The average is not calculated in this step because the signal will most likely add noise or error signals. If the average of the signals affects the because the signal will most likely add noise or error signals. If the average of the signals affects the S/N ratio directly, their accuracy will decrease. S/N ratio directly, their accuracy will decrease. After arranging the flow signal in the order of its values, it can eliminate the environment that After arranging the flow signal in the order of its values, it can eliminate the environment that causes potential noise. The signal’s data persist from 10% to 90%. The lower bound (10%) is the causes potential noise. The signal’s data persist from 10% to 90%. The lower bound (10%) is the differential interference time. After filtering, the remaining data are used to calculate the totals and differential interference time. After filtering, the remaining data are used to calculate the totals and averages, which can be observed in Figure 6. By adding steady signals and calculating the averages, averages, which can be observed in Figure 6. By adding steady signals and calculating the averages, we can obtain the flow signals. we can obtain the flow signals.

Sensors 2017, 17, 821 Sensors 2017, 17, 821 Sensors 2017, 17, 821

8 of 15 8 of 15 8 of 15

Figure 6. Algorithm of MAQ (Quicksort and Average). Algorithm of of MAQ MAQ (Quicksort and Average). Figure 6. Algorithm

5. Experiments and Results 5. Experiments and Results 5.1. Flow Testing Environment 5.1. Flow Testing Environment Environment Figure 7 depicts the flow testing apparatus in this study. The testing equipment uses the pump Figure 7 depicts equipment uses thethe pump to depicts the theflow flowtesting testingapparatus apparatusininthis thisstudy. study.The Thetesting testing equipment uses pump to generate the flow. When the pressure tanks accumulate pressure and water level, a valve regulates generate thethe flow. When thethe pressure tanks accumulate pressure andand water level, a valve regulates the to generate flow. When pressure tanks accumulate pressure water level, a valve regulates the flow of water and installs the electromagnetic flowmeter to generate the flow test condition, flow flowflow of water andand installs the electromagnetic flowmeter to generate the flow test condition, flowflow rate the of water installs the electromagnetic flowmeter to generate the flow test condition, rate monitor, and control. Thus, the tests must obey the national flow measurement rules. The monitor, and control. Thus, Thus, the tests theobey national flow measurement rules. Therules. upstream rate monitor, and control. themust testsobey must the national flow measurement The upstream pipe length is less than 5D (D is the nominal pipe diameter), and the downstream pipe pipe lengthpipe is less than 5D (D isthan the nominal diameter),pipe anddiameter), the downstream pipe length is greater upstream length is less 5D (D ispipe the nominal and the downstream pipe length is greater than 2D. than 2D. length is greater than 2D.

Figure 7. Flow testing apparatus. Figure 7. Flow testing apparatus. Figure 7. Flow testing apparatus.

Because of limitations caused by various factors and the interference test environment, the test Because of limitations caused by various factors and the interference test environment, the test standard uses a comparisoncaused method after obtaining the test results, which is a environment, comparison to a flow Because byafter various factorsthe and theresults, interference test standard usesofa limitations comparison method obtaining test which test is a comparison tothe a flow meter (referred to as the standard) at the national flow calibration laboratory with standard parts and standard uses a comparison method after obtaining the test results, which is a comparison to a flow meter (referred to as the standard) at the national flow calibration laboratory with standard parts and standard conditions. The pulse output isnational used as the cumulative amount of traffic statistics. meter (referred to as the at theis flowcumulative calibrationamount laboratory with standard standard conditions. Thestandard) pulse output used as the of traffic statistics.parts and The specifications of the flow test environment are listed below: standard conditions. The output is used as theare cumulative amount of traffic statistics. The specifications of pulse the flow test environment listed below: The specifications of the flow test environment are listed below:  the diameter of the testing flowmeter is DN80 (nominal diameter 80 mm);  the diameter of the testing flowmeter is DN80 (nominal diameter 80 mm);  the dynamic range of the flow rate is 0 to 10 m/s; • dynamic range of the flow rate is 0 to 10 m/s; the of the  the diameter testing liquid is testing water; flowmeter is DN80 (nominal diameter 80 mm); • the testing liquid is water; the of theuses flowa rate is 0 to 10 m/s;  the dynamic standard range flowmeter Yokogawa AXF (0.2%). • the testing standard flowmeter uses a Yokogawa AXF (0.2%). the liquid is water; These experiments indicate that the results of the proposed DSC algorithm, ΔF (raw data of flow • the standard flowmeter usesthat a Yokogawa (0.2%). These experiments indicate the resultsAXF of the proposed DSC algorithm, ΔF (raw data of flow rate), Gaussian (Gaussian filter algorithm—using mean filter of third order), and MA (moving rate), Gaussian (Gaussian filter algorithm—using mean filter of third order), and MA (moving average algorithm) can calculate the average of the flow, and then the process can be repeated [18]. average algorithm) can calculate the average of the flow, and then the process can be repeated [18].

Sensors 2017, 17, 821

9 of 15

These experiments indicate that the results of the proposed DSC algorithm, ∆F (raw data of flow rate), Gaussian (Gaussian filter algorithm—using mean filter of third order), and MA (moving average algorithm) can calculate the average of the flow, and then the process can be repeated [18]. The experimental results for ∆F+MA, ∆F+MA+Gaussian, and the proposed DSC are listed in Tables 1–3, respectively. Table 1. Experimental result of the ∆F + MA. Upstream Temp (◦ C)

Downstream Temp (◦ C)

Master Flow Rate (m3 /h)

Master Total Volume (L)

Test Total Volu58me (L)

Volume Error (% of Read)

Repeatability Error (%)

Average Volume Error (% of Read)

31.36 31.28 31.29

31.66 31.58 31.58

90.18 90.22 90.07

1491.40 1491.70 1484.10

1499.79 1499.68 1493.70

0.56 0.53 0.65

0.05

0.58

31.20 31.20 31.20

31.41 31.41 31.41

35.96 35.93 36.00

594.80 595.10 598.60

595.97 589.55 595.66

0.20 −0.93 −0.49

0.46

−0.41

31.12 31.12 31.12

31.33 31.33 31.33

16.76 16.80 16.74

278.20 278.00 278.40

274.21 278.99 275.28

−1.43 0.36 −1.12

0.78

−0.73

Table 2. Experimental results of the ∆F+MA+GAUSSIAN. Upstream Temp (◦ C)

Downstream Temp (◦ C)

Master Meter Flow Rate (m3 /h)

Master Meter Volume (L)

Test Meter Volume (L)

Volume Error (% of Read)

Repeatability Error (%)

Average Volume Error (% of Read)

38.96 38.97 38.89

39.41 39.41 39.33

17.69 17.81 17.77

591.90 591.40 589.70

590.40 590.00 587.90

−0.25 −0.24 −0.31

0.036

−0.27

38.80 38.72 38.64

39.17 39.16 39.08

35.80 35.84 35.75

1190.00 1191.50 1188.20

1189.50 1190.80 1186.90

−0.04 −0.06 −0.11

0.035

−0.07

38.56 38.55 38.48

39.00 38.99 38.91

88.42 88.55 88.55

2941.30 2942.50 2954.70

2947.50 2950.70 2958.40

0.21 0.28 0.13

0.077

0.20

Table 3. Experimental results of the DSC. Upstream Temp (◦ C)

Downstream Temp (◦ C)

Master Flow Rate (m3 /h)

Master Total Volume (L)

Test Total Volume (L)

Volume Error (% of Read)

Repeatability Error (%)

Average Volume Error (% of Read)

29.21 29.21 29.21

29.37 29.37 29.29

88.95 88.89 89.09

1469.15 1471.11 1463.51

1473.66 1475.04 1465.70

0.31 0.27 0.15

0.07

0.24

29.13 29.13 29.13

29.29 29.29 29.30

37.42 37.42 37.52

619.59 619.05 619.21

619.47 620.13 619.80

−0.02 0.17 0.10

0.08

0.08

29.05 29.05 29.04

29.29 29.30 29.21

19.00 19.01 19.00

314.45 314.33 314.40

314.93 313.93 314.91

0.15 −0.13 0.16

0.13

0.06

5.2. Algorithm Comparisons Figure 8 shows the average volume error of the flow rate from low (16.76 m3 /h) to high (90.18 m3 /h); the lower error rate indicates that the performance of the meter is better and more accurate. In the results, ∆F + MA is the most unstable output because, at different flow rates, it has a high deviation and non-linearity. The results indicate that with a Gaussian filter, the accuracy is significantly better than that of ∆F + MA (see ∆F + MA + Gaussian). Lastly, the results indicate that the DCS has greater accuracy than the above two calculation methods. As illustrated in Figure 9, the DSC method has the best effect. Its max error is 0.18%. The second-best method uses ∆F + MA + Gaussian, whose max error is 0.47%. Lastly, ∆F + MA has a max error of 1.31%.

Sensors 2017, 17, 821

10 of 15

Sensors 2017, 17, 821 Sensors 2017, 17, 821

10 of 15 10 of 15

Sensors 2017, 17, 821

10 of 15

Figure 8. Comparison with ΔF+MA, ΔF + MA + Gaussian, and DSC for average volume error.

Figure 8. Comparison withwith ∆F+MA, ∆F Gaussian, and DSC for average volume Figure 8. Comparison ΔF+MA, ΔF++MA MA ++Gaussian, and DSC for average volume error. error. Figure 8. Comparison with ΔF+MA, ΔF + MA + Gaussian, and DSC for average volume error.

Figure 9. Maximum Gaussian,and andDSC DSCfor foraverage average volume error. Figure 9. Maximumerror errorrate rateofofΔF ΔF++MA, MA, ΔF ΔF ++ MA MA ++ Gaussian, volume error.

Figure 9. Maximum error rate of ∆F + MA, ∆F + MA + Gaussian, and DSC for average volume error. The repetitive of the the flow flowmeter metermeasurement. measurement. lower error The repetitiveerror errorrate raterepresents represents the the stability stability of AA lower error Figure 9. Maximum error rate of ΔF + MA, ΔF + stable MA + Gaussian, and DSC formeasurement average volume error. rate indicates that the flow meter uses a more detection for each in the same indicateserror that the meter uses more stable detection for each measurement in the same Therate repetitive rateflow represents theastability of the flow meter measurement. A lower error rate testing environment. Based on Figures 10 11, the the maximum maximum error usingthethe ΔF + MA + testing environment. Based ona Figures 10 and anddetection error ofofusing ΔF + same MA + testing indicates that the flow meter uses more stable for each measurement in the The repetitive error rate represents the stability of the flow meter measurement. A lower error Gaussian is approximately 0.08%. Gaussian is approximately 0.08%. environment. Based Figures 10 and 11,more the maximum errorfor of using the ∆F + MA Gaussian is rate indicates thaton flow meter uses stable detection each measurement in + the same Using +the MA Gaussian hasaaa better result can Gaussian algorithm Using of of ΔFΔF + MA + +Gaussian has better can be beexpected expectedbecause becausethe the Gaussian algorithm approximately 0.08%. testing environment. Based on Figures 10 and 11, the maximum error of using the ΔF + MA + blurs images achievea asmooth smootheffect. effect.In In other other words, words, the number of of average blurs images toto achieve theGaussian Gaussianuses usesa alarge large number average Gaussian is approximately 0.08%. Using of ∆F + MA + Gaussian has a better result can be expected because the Gaussian algorithm operations to achieve better repeatability error results, however, it also means that even if the signal operations to achieve better repeatability error results, however, it also means that even if the signal Using of ΔF + MA + Gaussian has aIn better result can be expected because the Gaussian algorithm has interferences or noises, the Gaussian is still to smoothing the calculation, so that the real flow blurshas images to achieve a smooth effect. other words, the Gaussian uses a large number of average interferences or noises, the Gaussian is still to smoothing the calculation, so that the real flow blurs images to achieve aby smooth effect. In otherresults, words, the Gaussian uses a large number of average signal will be affected the smoothing calculation, thereby reducing the accuracy. This is why the operations to achieve better repeatability error however, it also means that even if the signal signal will be affected by the smoothing calculation, thereby reducing the accuracy. This is why the operations achieve repeatability error results, however, it that also the means that even the signal Gaussiantofilter is outbetter of consideration in this study. Figure 11 shows maximum errorif of using has interferences noises, the Gaussian is still toFigure smoothing thethat calculation, so that real flow Gaussian filteror is out of consideration in this study. 11 shows the maximum errorthe of using hasDSC interferences or noises, the Gaussian stilloftoΔFsmoothing the calculation, so thatthe the flow is 0.13%, which is extremely close toisthat + MA + Gaussian (0.08%). Lastly, ΔFreal + MA isbe 0.13%, which isthe extremely close calculation, to that of ΔF +thereby MA + Gaussian (0.08%). Lastly, the ΔF is + MA signalDSC will affected by smoothing reducing the accuracy. This why the has will a maximum errorby ofthe 0.78%. signal be affected smoothing calculation, thereby reducing the accuracy. This is why the has afilter maximum error of 0.78%. Gaussian is out of consideration in this study. Figure 11 shows that the maximum error of using Gaussian filter is out of consideration in this study. Figure 11 shows that the maximum error of using DSC DSC is 0.13%, which is extremely MA++Gaussian Gaussian (0.08%). Lastly, the+∆F is 0.13%, which is extremelyclose closetotothat that of of ∆F ΔF ++ MA (0.08%). Lastly, the ΔF MA+ MA has ahas maximum error of 0.78%. a maximum error of 0.78%.

Figure 10. Comparison with ΔF + MA, ΔF + MA + Gaussian, and DSC for repeatability error.

Figure 10. Comparison with ΔF + MA, ΔF + MA + Gaussian, and DSC for repeatability error.

Figure 10. Comparison with ΔF + MA, ΔF + MA + Gaussian, and DSC for repeatability error.

Figure 10. Comparison with ∆F + MA, ∆F + MA + Gaussian, and DSC for repeatability error.

Sensors 2017, 17, 821

11 of 15

Sensors 2017, 17, 821

11 of 15

Sensors 2017, 17, 821

11 of 15

Figure 11. Maximum error rate of ΔF + MA, ΔF + MA + Gaussian, and DSC for repeatability error.

Figure 11. Maximum error rate of ∆F + MA, ∆F + MA + Gaussian, and DSC for repeatability error.

The above test data and statistical results indicate that our proposed DSC algorithm has better Figuretest 11. Maximum error ratealgorithms of ΔFresults + MA,inΔF + MA + Gaussian, and DSCerror for repeatability error. has better The above data statistical indicate that ourvolume proposed DSC performance than the and other two both the average andalgorithm the repeatability error. Additionally, the two results indicate in that using the Gaussian filter benefits the repeatability repeatability. error. performance than the other algorithms both the average volume error and the The above test data and statistical results indicate that our proposed DSC algorithm has better However,the the results algorithm can stillthat be used it has interference noise. The trueHowever, flow Additionally, indicate usingeven the though Gaussian filter benefits and the repeatability. performance than the other two algorithms in both the average volume error and the repeatability signals and the accuracy will be affected; therefore, this research does not consider the Gaussian filter. the algorithm can still bethe used evenindicate though that it hasusing interference and noise. The truethe flow signals and the error. Additionally, results the Gaussian filter benefits repeatability. accuracy will be affected; therefore, this research does not consider the Gaussian filter. However, the algorithm can still be used even though it has interference and noise. The true flow

5.3. Compared with Krohne-IFC100 signals and the accuracy will be affected; therefore, this research does not consider the Gaussian filter. 5.3. Compared with Krohne-IFC100 The experimental results are compared with the Krohne IFC 100, a known measurement device from Germany. The device’s accuracy is listed at 0.5% in the specifications. The same transducer is 5.3. Compared with Krohne-IFC100 The experimental results are compared with the Krohne IFC 100, a known measurement device used for calculating the average volume error and repeatability. The experimental results are compared with the Krohne IFC 100, a known measurement device from Germany. The device’s accuracy is listed 0.5% in the specifications. TheKrohne same transducer is Figure 12 depicts the average volume erroratcomparison between the DSC and (IFC 100, from Germany. The device’s accuracy is listed at 0.5% in the specifications. The same transducer is used 0.5%). for calculating average volume and repeatability. The resultsthe indicate that, for theerror Krohne device (IFC 100, 0.5%), the error in the higher flow used for12 calculating the average volume error and repeatability. Figure depicts volume between DSCisand Krohne rates is higher; the the rate average is better in the lowerror flow.comparison However, the error in the DSC more stable (IFC and 100, Figure 12 depicts the average volume error comparison between the DSC and Krohne (IFC 100, on average. The that, average errordevice trend of the100, DSC0.5%), is poorthe in error the areas with high flow flow rates 0.5%).lower The results indicate for volume the Krohne (IFC in the higher 0.5%). The results indicate that, for the Krohne device (IFC 100, 0.5%), the error in the higher flow rates and the areas withlow lowflow. flow rates, whichthe is similar illustrated is higher; the better rate isinbetter in the However, error to inthe theKrohne DSC isdevice. more As stable and lower rates is higher; the rate is better in the low flow. However, the error in the DSC is more stable and in Figure 13, the max average volume error is 0.18 percent. The Krohne device’s (IFC 100, 0.5%) value and on average. The average volume error trend of the DSC is poor in the areas with high flow lower on average. The average volume error trend of the DSC is poor in the areas with high rates flow is 0.92%. betterrates in the areas with low flow rates, is similar Krohne illustrated in Figure 13, and better in the areas with lowwhich flow rates, whichtoisthe similar to thedevice. KrohneAs device. As illustrated Figure 14 depicts comparison result of repeatability error between DSC and Krohne (IFC-100, the max average volume error isvolume 0.18 percent. device’s (IFC 100, 0.5%) value is 0.92%. in Figure 13, the max average error is The 0.18 Krohne percent. The Krohne device’s (IFC 100, 0.5%) value 0.5%). It can be found that the repeatability error of Krohne (IFC-100, 0.5%) is higher in the middle Figure is 0.92%.14 depicts comparison result of repeatability error between DSC and Krohne (IFC-100, flow rate, while the regional high flow rate repeatability is better. However, the repeatability error of Figure 14 depicts comparison result of repeatability error(IFC-100, between DSC and Krohne in (IFC-100, 0.5%).DSC It can be study found repeatability Krohne 0.5%) islow higher the middle in this is that morethe stable to the highererror flow.of It can be found in the high and flow rate area, 0.5%). It can be found that the repeatability error of Krohne (IFC-100, 0.5%) is higher in the middle flow rate, while the regional high flow rate repeatability is better. However, the repeatability error the performance of Krohne (IFC-100, 0.5%) is more excellent, while the flow rate section is better for of rate, while regional highthe flowhigher rate repeatability better. However, the repeatability error of area, DSC flow in study isthe more stable flow. It canisdata, be found thebehigh and low flow rate thisthis study. Figure 15 shows theto maximum reproducibility whichincan found to be about 0.13% DSC in this study is more stable to the higher flow. It can be found in the high and low flow rate area, in this study and 0.11% for(IFC-100, Krohne (IFC-100, Krohne the performance of Krohne 0.5%) is0.5%). moreAlthough excellent, while(IFC-100, the flow0.5%) rate showed section slightly is better for the performance of Krohne (IFC-100, 0.5%) is more excellent, while the flow rate section is better for better reproducibility of only about 0.02%, repeatability is data, very close. this study. Figure 15 shows the maximum reproducibility which can be found to be about 0.13% this study. Figure 15 shows the maximum reproducibility data, which can be found to be about 0.13% in this andand 0.11% forfor Krohne AlthoughKrohne Krohne (IFC-100, 0.5%) showed slightly instudy this study 0.11% Krohne(IFC-100, (IFC-100,0.5%). 0.5%). Although (IFC-100, 0.5%) showed slightly betterbetter reproducibility of only about 0.02%, repeatability is very close. reproducibility of only about 0.02%, repeatability is very close.

Figure 12. Comparison with Krohne IFC 100 for average volume error.

Figure 12. Comparison with Krohne IFC 100 for average volume error.

Figure 12. Comparison with Krohne IFC 100 for average volume error.

Sensors 2017, 17, 821 Sensors 2017, 17, 821

12 of 15 12 of 15

Sensors 2017, 17, 821

12 of 15

Sensors 2017, 17, 821

12 of 15

Figure 13. Maximum error rate of DSC and Krohne IFC 100 for average volume error.

Figure 13. Maximum error rate of DSC and Krohne IFC 100 for average volume error. Figure 13. Maximum error rate of DSC and Krohne IFC 100 for average volume error.

Figure 13. Maximum error rate of DSC and Krohne IFC 100 for average volume error.

Figure 14. Comparison with Krohne IFC 100 for repeatability error.

Figure 14. Comparison with Krohne IFC 100 for repeatability error. Figure 14. Comparison with Krohne IFC 100 for repeatability error. Figure 14. Comparison with Krohne IFC 100 for repeatability error.

Figure 15. Maximum error rate of DSC and Krohne IFC 100 for repeatability error.

5.4. Comparison with Wavelet Transform The experimental results illustrate a comparison of the wavelet transform algorithm [19]. The Figure 15. Maximum error rate of DSC and Krohne IFC 100 for repeatability error. wavelet Figure transform uses the error H-Bridge excitation. The for processor usederror. is LPC2136 15. Maximum rate of and DSC the and Krohne error. IFC 100 repeatability (ARM7TDMI-S based high-performance 32-bit RISC Microcontroller, Philips, Tokyo, Japan). 5.4. Comparison with Wavelet Transform Although the testWavelet flow’s range is not completely the same, we obtain a condition to determine an 5.4. Comparison Comparison with Wavelet Transform 5.4. with Transform The flow experimental results a comparison the wavelet transform algorithm [19]. The average rate statistic thatillustrate is accurate. Using the of wavelet transform to perform the switching The experimental results illustrate a acomparison of of the wavelet transform algorithm [19]. [19]. The wavelet transform uses the H-Bridge and the After excitation. The processor used LPC2136 The experimental results illustrate comparison wavelet transform maneuver, the flow is approximately 0.45 to 2.9 m/s. thethe switch becomes linear, theisalgorithm flow speed wavelet usesuses the the H-Bridge and excitation. The used LPC2136 (ARM7TDMI-S based high-performance 32-bit RISC Microcontroller, Philips, Tokyo, Japan). has atransform 0.3%transform inaccuracy. The wavelet H-Bridge andthe the excitation. Theprocessor processor used is is LPC2136 Although the test flow’s range is not completely the same, we obtain a condition to determine an (ARM7TDMI-S based high-performance 32-bit RISC Microcontroller, Philips, Tokyo, Japan). (ARM7TDMI-S based high-performance 32-bit RISC Microcontroller, Philips, Tokyo, Japan). Although average flow rate statistic thatis isnot accurate. Using the the same, waveletwe transform tocondition perform the switching Although the test flow’s range completely obtain a to determine an the test flow’s range is not completely the same, we obtain a condition to determine an average flow maneuver, the flow is approximately 0.45 to 2.9 m/s. After the switch becomes linear, the flow speed average flowthat rate statistic that is the accurate. Using the wavelet transform to perform the switching rate statistic is accurate. Using wavelet transform to perform the switching maneuver, the flow has a 0.3% inaccuracy.

maneuver, the flow to 2.9 m/s. Afterlinear, the switch becomes the flow speed is approximately 0.45istoapproximately 2.9 m/s. After0.45 the switch becomes the flow speed linear, has a 0.3% inaccuracy. has a 0.3% inaccuracy.

Sensors 2017, 17, 821 Sensors 2017, 17, 821

13 of 15 13 of 15

Sensors 2017, 17, 821

13 of 15

As illustrated in Figure 16, we use the wavelet transform algorithm to develop a comparison of the average rate. In order objectivity and consistency ofdevelop the data, we try to compare As flow illustrated in Figure 16, we the wavelet transform algorithm to to develop aa comparison ofof the As illustrated in Figure 16, to weensure useuse thethe wavelet transform algorithm comparison the flow average flow rate. In to order to ensure the objectivity consistency thedata, data, we try try to compare the same flow rate much as possible. Using the and testand data of the wavelet transform algorithm, the average rate. Inas order ensure the objectivity consistency ofofthe we to compare the 3Using the same flow rate as much as possible. the test data of the wavelet transform algorithm, the test flow rate is limited between 19–20 m /h, and the maximum average flow error is 0.41% (0.26% same flow rate as much as possible. Using the test data of the wavelet transform algorithm, the test flow+ test flow rate is limited between 19–20 m3/h, and the maximum average flow error is 0.41% (0.26% + 0.16%). rate is limited between 19–20 m3 /h, and the maximum average flow error is 0.41% (0.26% + 0.16%). 0.16%). Comparedwith withthe theDSC, DSC,its itsmeasurement measurementrange rangeisisapproximately approximatelyaaflow flowspeed speedofof1 1m/s m/sto to55m/s. m/s. Compared Compared with the DSC, its measurement range is approximately a flow speed of 1 m/s to 5 m/s. This measurement range can cover the wavelet transform algorithm. Furthermore, its accuracy is This measurement range cancan cover algorithm.Furthermore, Furthermore, its accuracy is This measurement range coverthe thewavelet wavelet transform transform algorithm. its accuracy is betterbetter thanthan thatthat of other other algorithms. better than that of algorithms. of other algorithms.

Figure 16. Comparison with wavelet transform for average volume error.

Figure 16. Comparison with wavelet transform for average volume error. Figure 16. Comparison with wavelet transform for average volume error. 5.5. Processor Price Comparison

5.5. Price 5.5. Processor Processor Price Comparison Comparison As shown by the prices provided in Figure 17 of the processor cores for the MCU, the price of the shown DSC is nearly less than that ofin theFigure Krohne 100,processor 0.5%) and cores approximately 10% less As by prices provided 17 of for the price As shown by the the2.5 prices provided in Figure 17(IFC of the the processor cores for the the MCU, MCU, thethan price of of that is of nearly the wavelet transform algorithm; however, the average volume flow rate and the reproducible the DSC 2.5 less than that of the Krohne (IFC 100, 0.5%) and approximately 10% less the DSC is nearly 2.5 less than that of the Krohne (IFC 100, 0.5%) and approximately 10% less than than performance of the DSC are not inferior to thosethe of the Krohne (IFC 100, 0.5%) and the reproducible wavelet that the that of of the wavelet wavelet transform transform algorithm; algorithm; however, however, the average average volume volume flow flow rate rate and and the the reproducible transform algorithms. Table 4 summarizes the results of the proposed DSC algorithm in comparison performance of DSC not to those of Krohne (IFC 0.5%) and wavelet performance of the the DSC are are From not inferior inferior those of the thethat Krohne (IFC 100, 100, 0.5%) and the the wavelet with the other algorithms. Table 4, to it can be noted the proposed DSC algorithm has the transform algorithms. Table 4 summarizes the results of the proposed DSC algorithm in comparison transform algorithms. Tableerror 4 summarizes theThe results of the proposed DSC algorithm comparison smallest average volume and total cost. repeatability error of the proposed DSC in algorithm with the other From Table 4, it be noted that the proposed DSC with is the other algorithms. algorithms. From Table it can can notedthan thatthat theof proposed DSC algorithm algorithm has has the the comparable to that of the Krohne IFC4,100 but isbesmaller the other algorithms. smallest average volume error and total cost. The repeatability error of the proposed DSC algorithm is smallest average volume error and total cost. The repeatability error of the proposed DSC algorithm comparable to to that of of thethe Krohne IFCIFC 100100 butbut is smaller than that of the other algorithms. is comparable that Krohne is smaller than that of the other algorithms.

Figure 17. Cost comparison. Table 4. Summary of results between DSC algorithm in comparison with the other algorithms. ΔF + MA + Krohne Wavelet ΔF+MA Figure 17. Cost comparison. DSC FigureGaussian 17. Cost comparison. (IFC-100) Transformation [19] 0.18 Average Volume Error (%) 1.31 0.47 0.92 0.41 Table 4. Summary of results between DSC0.08 algorithm in comparison with the other algorithms.0.13 Repeatability Error (%) of 0.78between 0.11 n/a algorithms. Table 4. Summary results DSC algorithm in comparison with the other 126.9 Total Cost (NT dollar) n/a n/a 390.89 140

ΔF+MA ∆F+MA Average Volume Error (%) 1.31 Repeatability Error (%) Average Volume Error (%) 0.78 1.31 Error (%) TotalRepeatability Cost (NT dollar) n/a 0.78 Total Cost (NT dollar) n/a

ΔF + MA + ∆F + MA + Gaussian Gaussian 0.47 0.08 0.47 0.08 n/a n/a

Krohne Wavelet DSC Krohne Wavelet (IFC-100) Transformation [19] DSC (IFC-100) [19] 0.18 0.92 Transformation 0.41 0.920.11 0.41 n/a 0.18 0.13 0.11 n/a 140 0.13 126.9 390.89 390.89 140 126.9

Sensors 2017, 17, 821

14 of 15

6. Conclusions In this paper, a dynamic synchronous capture algorithm is proposed to calculate the flow rate for an electromagnetic flowmeter. From the experiment, the DSC algorithm fits the flow speed detection’s algorithm, and the DSC algorithm can be implemented in the mainstream 32-bit MCU. The results indicate that the data are less than those of the Krohne device (IFC 100, 0.5%). Its measurement range can cover the wavelet transform switch algorithm. Furthermore, its accuracy is greater than that of the wavelet transform switch algorithm, and the DSC algorithm can obtain better competition in the market. The algorithm does not need a DSP or MCU; thus, it is suitable for the application platform and occasion. The only condition of the DSC algorithm is its ability to be used with a simple H-Bridge circuit for control. In addition to reducing costs, the algorithm’s effectiveness to meet the specifications of the meter can be compared to the cost to provide ADC signal resolution, which will allow it to obtain higher accuracies and better competition in the market. In this paper, which used only water as a measurement standard, suggestions for future research are to continue studies using different liquids of various amounts in detection tests. Changes to the signal are likely to occur, especially with the additional use of different excitation frequencies, and other digital filters can also be assessed to calculate the flow rate signal. Author Contributions: Yong-Yi Fanjiang gave the basic idea of this research, designed the algorithm and experiments, and wrote the paper. Shih-Wei Lu performed the experiments and analyzed the data. Conflicts of Interest: The authors declare no conflict of interest.

References 1. 2.

3.

4. 5. 6.

7.

8. 9. 10. 11.

Schena, E.; Massaroni, C.; Saccomandi, P.; Cecchini, S. Flow measurement in mechanical ventilation: A review. Med. Eng. Phys. 2015, 37, 257–264. [CrossRef] [PubMed] Research and Markets. Intelligent Flow Meter Market by Type, Communication Protocol, Application, and Geography—Global Trend & Forecast to 2022, Research and Markets Report (ID: 3742638). May 2016. Available online: http://www.marketsandmarkets.com/PressReleases/intelligent-flow-meter.asp (accessed on 15 December 2016). Bo, Y.; Li, C.; Yupin, L. High-speed and precise measurement for ultrasonic liquid flow metering based on a single FPGA. In Proceedings of the IEEE Instrumentation and Measurement Technology Conference (I2MTC’09), Singapore, 5–7 May 2009; pp. 309–312. Bansode, M.P.; Kulkami, V.B. FPGA Based Fluid Flow Rate IR Sensor for Microstructures. Int. J. Adv. Found. Res. Comput. 2015, 2, 205–210. Sun, B.J.; Wang, K. Ultrasonic flowmeter based on FPGA. Appl. Mech. Mater. 2013, 291, 2566–2569. [CrossRef] Bansode, P.M.; Kulkarni, V.B. Comparative Design and Synthesis of IR and Optical Sensors for Fluid Flowrate Using FPGA. In Proceedings of the 2015 IEEE International Conference on Computing Communication Control and Automation (ICCUBEA), Pune, India, 26–27 February 2015; pp. 922–926. Garcia, D.L.; Wilcox, D.R. DSP Filter Calculation for a Digital Doppler Velocity Flow Meter. In Proceedings of the International Conference on Scientific Computing (CSC), The Steering Committee of The World Congress in Computer Science, Computer Engineering and Applied Computing (WorldComp), Las Vegas, NV, USA, 21–24 July 2014; p. 1. Li, F.; Wang, B.; Huang, Z. Discussion on the Interference in Electromagnetic Flowmeter. Chin. J. Sci. Instrum. 2005, 26, 727–729. Lin, S.Y.; Lee, J.Y. Trial-Production of the Electromagnetic Flowmeter Circuit; Department of Electrical Engineering, National Cheng Kung University: Tainan, Taiwan, 2006; pp. 1–22. Zhang, H.; Tang, S. Application of Electromagnetic Flowmeter in Wastewater Disposal Plant. Autom. Instrum. 2010, 1, 64–66. Xu, L.; Peng, Z.; Cao, Z.; Ling, Q.; Wang, G. Weighting Function-Based Coil Size Optimization for Electromagnetic Flowmeter. In Proceedings of the IEEE International Conference on Instrumentation and Measurement Technology (I2MTC), Hangzhou, China, 10–12 May 2011; pp. 1–6.

Sensors 2017, 17, 821

12.

13.

14.

15. 16.

17.

18. 19.

15 of 15

Cao, J.L.; Li, B. Study on Muti-Parameter Measurement Electromagnetic Flowmeter and Its Realization Techniques. Ph.D. Thesis, School of Mechatronics Engineering and Automation Shanghai University, Shanghai, China, 2007; pp. 5–19. Chen, X.; Zhang, H.J. The Investigation of Electromagnetic Flowmeter’s Three Value Variable-Frequency Trapezoidal Waveform Exciting Mode; School of Detect Engineering and Automation Zhejiang University: Hangzhou, China, 2005; pp. 8–14. Tang, S.; Dong, F. A New Double Frequency Exciting Mode for the Electromagnetic Flowmeter. In Proceedings of the IEEE International Conference on Electric Information and Control Engineering (ICEICE), Wuhan, China, 15–17 April 2011; pp. 4710–4713. Cratree, M.A. Industrial Flow Measurement; Science by Research; The University of Huddersfield: Huddersfield, UK, 2009; pp. 147–168. Zhang, R. Study and Implementation of Digital Signal Processing Software System for Electromagnetic Flowmeter. Master’s Thesis, School of Control of Complex Systems for Control Engineering and Theory, Hefei University of Technology, Hefei, China, 2012; pp. 6–12. Smith, S.W. The Scientist and Engineer’s Guide to Digital Signal Processing, 2nd ed.; California Technical Publishing: San Diego, CA, USA, 1999; pp. 277–279. Available online: www.DSPguide.com (accessed on 1 December 2016). Wang, G.J.; Liu, K.; Huang, Y. Fast Gaussian Filter Implemented in Real-Time Systems; Institute of Artificial Intelligence and Image Recognition, Wuhan Huazhong University of Science: Wuhan, China, 2010. Zhang, J.J. Research on High-Precision Electromagnetic Flowmeter. Master’s Thesis, China Jiliang University, Hangzhou, China, 2012; pp. 60–63. © 2017 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).