Designing a new microcontroller-based moisture meter for loose materials using frequency separation

Article history: Received 2 June 2017 Received in revised form 7 September 2017 Accepted 10 September 2017 Variations in density, temperature, granule size, ionic conduction, etc. cause a measurement error for all indirect methods for measuring loose materials moisture content. Multiparameter method has the potential to decrease or even eliminate the influence of all disturbing parameters on the measurement variable (moisture content) for every measurement method (i.e., capacitive, microwave, etc.), this reduces the measurement error. Application of multi-parameter method of moisture measurement is a result of developing opportunities in instrumentation design using fast computer equipment. A new microcontroller-based moisture meter was developed for loose materials with binary frequency measurement control и temperature compensation. It was estimated that the expected measurement error is within permissible limits.


Introduction
*There are many moisture measurement methods for loose materials (Kupfer, 2005), where the electrical method is the most likable for practical use in a production environment, in particular, it concerns the high-frequency dielcometric (capacitive) method. Dielcometric moisture meters have many advantages such as follows:  they could be used to monitor moisture content in loose materials with different particle sizes;  such systems could be operated using relatively simple, inexpensive, easy-to-use and highly reliable electronic equipment;  accuracies satisfying the measurement requirements could be achieved;  moisture content could be continuously monitored;  use of such systems cause no adverse health effect on operating personnel and therefore do not require use of any means of biological protection when operating them;  unified output signals could be easily received when using such systems, and therefore such systems could be connected to teleautomatic control devices or to automatic control loops.
However such systems have such a disadvantage as inability to precisely control residual moisture content of less than 1÷0.5%. But it is not required, for example, for building materials.
The principle of the dielcometric method is based on dependence of dielectric permeability of a material on its moisture content (Kupfer, 2005). Most of capillary porous materials (granular media are considered to be such materials) are good dielectrics having dielectric permeability of ε=1÷6, while water permeability is ε=81 (Kupfer, 2005). Since water dielectric permeability is much higher than permeability of most materials capable of moisture absorbing, dielectric permeability gives reliable information on its moisture content. Presence of water even in small amounts greatly affects physical and chemical as well as electrical properties of a material. Such impact is primarily connected with high dielectric permeability of water. The dielcometric method mostly uses medium-wave and short-wave (f = 0.3 ÷ 30 MHz) frequency bands. In this case the method is also called capacitive. The dielcometric method is based on measuring the capacity of a meter filled with the measured material. The measured capacity is a function of dielectric permeability and, consequently, of moisture content of the controlled material. In an ideal scenario, moisture content of the loose material should be a prevailing factor determining a measurement result.
Beside moisture content, the measurement result is also affected by so-called uninformative parameters of the loose material. When developing moisture content measuring systems, there should be ways found to remove impact of such parameters on results of loose material moisture content measurements.
When measuring moisture content of loose materials using electric methods, it is desirable that used measuring devices respond only to changes in moisture content. Such a situation could be possible only in cases where there is a simple selective dependence between moisture content К1 (1) and value of the measured parameter (Ryszard, 1999).
In reality, the output parameter of the moisture metering transducer is a function of many variables, and in general it could be represented as a function of independent variables Кi: where is an inherently integral parameter depending on balance (concentration) of many components of the test material such as: moisture content 1 , temperature 2 , grain size composition 3 , chemical composition 4 , salt content 5 , packed density 6 and so on.
If such parameters change independently of each other, then a system of equations with unknown variables allowing determination of a value of any unknown variable could be received.
Using the metering transducer and a decisionmaking device, values of several variables affecting output parameters of the device could be determined. Such parameters include packed density, temperature, kind of a loose material, grain size composition.

Using the multi-parameter method of moisture content measurement
When implementing the multi-parameter method, the main objective is to find parameters to separate informative and uninformative signals. When moisture content is measured using electrical methods, the frequency separation of parameters could be applied, where measurements are made at two or more different frequencies (Pustynnikov and Dzhemella, 1966;Bartley et al., 1997;Lawrence et al., 1998;Ryszard, 1999). In this case the frequencies should be selected in such a way as to extract informative signal in one case and uninformative -in another.
In the case where there is need in compensation of perturbation from one or several parameters, which could be reduced by a total measurement of the major part of perturbation effects, two-frequency separation of parameters could be applied.
Firstly, optimum operating frequencies should be determined. Further, given that the value of the output signal of the moisture meter is composed of a signal caused by moisture gain ∆ and disturbing signal ∆ , signals at 1 and 2 frequency rate equal to 1 = 1 ∆ + 1 ∆ ; 2 = 2 ∆ + 2 ∆ . (2) The following Eqs. are conditions for perturbation compensation: 1 ∆ + 2 ∆ = 0 or = − 1 2 ; 1 + 2 = 0. ( The signal at the output of the signal combining unit is found using the following Eqs.: (4) The resulting sensitivity could be found by differentiation (4) with respect to W.
In addition, it is required to ensure that the condition (3) remains constant at the full range of moisture content measurements and over all possible variation zones of perturbations.
Analysis of research works devoted to frequency characteristics of loose materials revealed that dielectric permeability of wet loose materials decreases with increased frequency, while permeability of water and dry materials remains almost unchanged in the range up to 100 MHz. Furthermore, dielectric loss tangent of water has its minimum in the range of 10÷100 MHz. It is obvious that in the abovementioned range there will be minimal effect of the dielectric loss tangent depending on moisture. In this frequency range loss tangent will be mostly associated with losses of loose material and various electric components.
If measurements are made at a range, where moisture content variations cause increase in dielectric permeability of the material and dielectric loss tangent, then a signal dependent on sum of such components will be received. When measuring complete conductivity of the loose material in the range of frequencies, where dielectric loss tangent of water is minimal, we will receive a signal with no component depending on loss tangent of water. Adequately processing signals, we will get a signal showing mainly changes of the moisture content.
Researches of frequency characteristics of various loose materials in the wide frequency range prove capability of compensation of instability of physical and chemical properties of loose materials (Aouaichia et al., 2017;Arinova et al., 2017).
Moisture meters containing from two to eight independent constant frequency sources have been described in scientific papers (Pustynnikov and Dzhemella, 1966;Bartley et al., 1997;Lawrence et al., 1998;Ryszard, 1999). The required frequencies were pre-determined for a particular loose material, and moisture meters were pre-calibrated. The measurement results were then processed in accordance with the multi-parameter method.
It's possible to perform measurements on a large number of different frequencies generated by a single source in modern measurement systems based on microcontrollers and single-board computers. This makes it possible to automatically select the required measurement frequency at each time point. In this article, we offer one way to develop a moisture meter using a widely used microcontroller. The advantage of the proposed moisture meter is a binary control of the frequency choice for measurement and a wide choice of frequencies. And the priority now is to develop new effective algorithms for procession of informative signals.

Device designing development of the device structure
The structural schematic is shown in Fig. 1. The measuring system includes the following components: 1 -capacitive measuring transducer; 2 -timer; 3 -adjustable resistance; 4 -self-oscillator of rectangular impulses; 5 -microcontroller; 6 -heat sensor; 7 -heat sensor amplifier; 8 -transducer into the 4…20 mA unified current signal; 9 -RS-232 receiver-transmitter; 10 -display device. The oscillator has frequency controlling RCcircuit, where a capacitive measurement cell is included as a capacitor and active resistance is adjustable resistance operated by binary code generated by the microcontroller.
The structural schematic of the device includes a data transfer channel, a temperature correction channel and a channel for control of adjustable digital resistance. The data transfer channel is formed by a measurement cell 1, which is connected as a connector in the frequency controlling RCcircuit, adjustable resistance 3 and timer 2. The temperature correction channel consists of the heat sensor and heat sensor amplifier 7. The channel for control of adjustable digital potentiometer is represented by the microcontroller 5 and adjustable resistance 3. For purposes of online control of the measuring system there is the display device 10 included in the channel. There are two data outputs provided for remote information transmission: the transducer 8 into the 4…20 mA unified current signal and the RS-232 receiver-transmitter 9. The capacitive measuring cell 1 with plane-parallel field has one-side contact with the material being measured and is a capacitor included in the frequency controlling RC-circuit of the oscillator 4.
Active resistance of the RC-circuit is the adjustable resistance 3. The oscillator 4 is made at the high-frequency timer 2 and has output frequency signal, time parameters of which depend on the time constant of the RC-circuit discharge. The oscillator 4 output is connected with the digital input of the microcontroller 5. The microcontroller 5 counts frequency of generated impulses. At the same time measurement results are converted into a signal of moisture content of the measured material taking into account the temperature correction, and a digital signal for control of parameters of the adjustable resistance 3 is generated. The temperature signal of the measured loose material received from the heat sensor 6 is amplified and transmitted to the analog input of the microcontroller 5 to remove imperfection of measurement results due to dependence of dielectric permeability of the measured material on temperature.

Device operation description
The device operates as described below. At any specific time the capacitive measuring transducer 1 contacts with the measured material in the information measuring channel. Change in moisture content of the loose material in the operating area of the measuring transducer 1 causes change of its capacity, what in turn changes the time constant of the frequency controlling RC-circuit. When measuring moisture content, however, the adjustable resistance 3 remains constant and corresponds to the digital code generated by the microcontroller 6. Change of the time constant of the RC-circuit caused by change in moisture content of the measured material results in change of the oscillation frequency at the output of the oscillator 4.
At the same time, in the temperature correction channel a signal of voltage of the measured material from the heat sensor 6 is transmitted through the heat sensor amplifier 7 to the microcontroller 5 analog input to make temperature corrections of the measurement results. The microcontroller 5 converts the frequency signal with account of temperature corrections into an informative signal of moisture content of the loose material and registers it. After that the microcontroller generates a digital code and transmits it through the control channel to inputs of the adjustable resistance 3 with an aim to measure resistance. Thus, the time constant and consequently the oscillation frequency of the RC-circuit are forcedly changed. After that the measurement process is cyclically repeated in accordance with the abovementioned operation description. Moisture content of the loose material is measured at several operating frequencies. It is possible to adjust and optimize operating frequencies during the measurement process. Results of measurements at two and more frequencies are processed in the microcontroller 5 using a method of linear system solving. The microcontroller also generates a signal of moisture content for the display device 10 and transmits information to 4…20 mA and RS-232 outputs.

The sensory element of the device
The moisture meter is used together with the capacitive measuring cell and circular-type electrodes located in one plane. In the volume of the measured loose material such a cell establishes a plane-parallel field at a distance of approximately 3 -5 cm above the sensor surface (Arinova et al., 2017). Capacitor cells with plane-parallel electrodes have capacitances of approximately 20 pF (Arinova et al., 2017).
The cell could be used for digital laboratory measurements and in the flow of the loose material for continuous moisture measurements if appropriate structural modifications are made.

Estimation of an error of the measuring channel
The main measuring circuit of the system includes the capacitive sensor and the adjustable resistance with the following items: self-oscillator of rectangular impulses, unit of comparison and processing of the frequency signal at the PIC16F877A microcontroller, converter to the unified current signal and RS-232 interface module.
The following features are considered as initial data for estimation of the overall error of the measuring channel of the moisture metering system:  metrological characteristics of functional units of the measuring channel;  methodical error in signal frequency measurement, which depends on moisture content of the loose material;  external factors affecting the moisture metering error;  uninformative measuring signal components, such as grain size composition, packed density, temperature of the wet loose material and others.
Metrological characteristics of functional units of the channel are described as instrumental percentage errors in the ICs operational documentation, which is a part of the element base of the device. Since such errors of functional units are uncorrelated, the overall error of the measuring channel is estimated by the Eq. 7: where -error of the i-th unit of the measuring channel; N -number of error components of all components of the measuring channel; Кcorrection factor equaling to 1.2 for the most important parameters.
According to the structure of the moisture measuring channel, its overall error could be found using the Eq. 8: where -error of the capacitive cell; instrumental error of the self-oscillator; -error of the software of the processing unit; methodical error of the processing unit; instrumental error of the processing unit; instrumental error of the transducer to the unified current signal.
The capacitive cell generates the physical quantity, which is the capacity, and there is no need to estimate its error. Errors of the AD8400 potentiometer and ICM7555 timer are metrological characteristics; they are instrumental and defined in instrument ratings. The unit for frequency signal processing at the PIC16F877A microcontroller has three error components. These three components are: error of the method of pulse counting during a time period; error of the software used for informative signal processing; and instrumental error of the microprocessor.
The error of the method of pulse counting n during the time period could be calculated by the Eq. 9: The Eq. 9 makes it clear that the method error depends on number of impulses counted by the impulse counter. A diagram of dependence of the method error on the measurement cycle time at the crystal frequency of fr = 4 МHz is represented in Fig.  2.
The diagram shows that the counting cycle time should be increased to lower the error. However, the counting cycle time is limited by technical characteristics of the microcontroller, which is its memory capacity. Another way to reduce methodical error of the processing unit is to increase timing frequency fr of the quartz resonator in the structure of the PIC-controller. К coefficient shows for how many times the resonator frequency is increased in relation to 4 MHz, because one machine phase of the PIC16F877A microcontroller equals to four phases of the timing resonator in the microcontroller structure. When 4 MHz quartz is used, the timing length is 1 us. Then the К coefficient could be found using the Eq. 10: Then is equal to Eq. 11: A diagram of dependence of the methodical error of the processing unit on timing frequency of the quartz resonator at 1 ms cycle time is shown in Fig.  2.
Analysis of dependence shows that with an aim to reduce the error the frequency of the quartz resonator should be increased, since the counting cycle time increases by the K coefficient.
Frequency incoming on the input of the processing unit is in the range of 800 Hz and 800 KHz. For the worst value of the measurement method, i.e. for the minimum amount of frequency impulses of the measuring signal, the counting cycle time should be 500 ms at the quartz resonator frequency of 4 MHz. In this case the methodical error could be calculated using the Eq. 12: Main sources of software errors are the following:  program source code writing error and errors in translation of the program to the object code;  errors in the solving algorithm of the measuring task;  errors in tables for linear approximation of nonlinear characteristics of conversion;  use of unstable or slowly convergent algorithms when solving ill-conditioned problems;  errors of data format conversion;  rounding errors and others.
In the programming language numbers are represented in the form from -3,402823е+38 to + 3,402823е+38 and rounded up or down to the six decimal places, which will cause relative measurement error of 0.0001% for one mathematical operation (if there are no approximate calculation methods used in the algorithm). The designed error allows performing about 1 000 mathematical operations on digital value of the signal. Thus, in the worst possible case we will receive the software error of 0.01%.
The instrumental error of the frequency signal processing unit at the PIC16F877A microcontroller is defined by the least significant digit value; for the ten-digit ADC it equals to 0.04%.
The transducer to the unified current signal at the Op-amp LM258 has an instrumental error connected with offset null due to a temperature drift. For this type of the operation amplifier the temperature drift is 0.5 mV/К. Error of the signal notation at such temperature drift is 0.03%.
5V unipolar output signal of the microcontroller is transferred by the MAX232AEPE transmitterreceiver into the standard signal of the RS-232 interface. Since there are no operations performed with the binary code, the transducer does not introduce errors into the measuring channel.
In accordance with the Eq. 8, the overall error of measuring channels with the unified output current signal of 20 mА and RS-232 equals to 1%. The error is calculated for the worst value of the frequency measurement method. In order to reduce the error, the cycle time of counting of measuring signal impulses should be increased by 2 ms or timing frequency of the riming resonator in the microcontroller structure should be increased.

Conclusion
The high-frequency moisture meter was developed to measure moisture content of loose materials, primarily construction bulk mixes such as sand, cement, silicate mixture and others.
The multi-parameter high-frequency moisture meter developed in accordance with the structural schematic in Fig. 1 have the following advantages:  small overall dimensions and low power consumption;  wide frequency range of the measuring signal;  possibility of express adjustment to a required measuring frequency;  possibility to use the multi-parameter measurement method with frequency separation of parameters and correction for temperature of the material being measured;  simplicity and high-speed response of the control algorithm and informative signal processing algorithm;  availability of outputs for remote transmission of 4-20 mA unified signal and RS-485 standard, which provides use of such devices in automated systems;  acceptable measurement error;  real-time display of measurement results.