Frontiers in Computing and Intelligent Systems ISSN: 2832-6024 | Vol. 12, No. 2, 2025 46 Design of Straw Moisture Detector based on AC Impedance Method Zuxian Wu 1 and Zhesheng Hou 2 1 School of Information and Control Engineering, Jilin of Chemical Technology University, Jilin Jilin 132022, China 2 School of Mechanical and Electrical Engineering, Jilin of Chemical Technology University, Jilin Jilin 132022, China Abstract: In this paper, a corn straw moisture detector with single-chip microcomputer as the core was designed based on the AC impedance method. The hardware uses the stm32 microcontroller as the controller, and the DDS sine wave generator generates a 100kHZ sinusoidal signal, converts the output constant current as the excitation signal through the constant current circuit, and then collects the ADC signal and the temperature signal. The software used FFT for detection, and the test data were fitted by least squares method. It is verified that the absolute measurement error of moisture content of the moisture detector designed in this paper is -2.0%~1.5%, and the response time is less than 1.5 s. Keywords: Impedance; Single-chip Microcomputer; Detector. 1. Introduction China is a traditional agricultural country, and as of 2022, the national land change survey shows that the national cultivated land area is 1.914 billion mu. Among them, the corn planting area reached about 603 million mu, the output was about 259 million tons [1], the straw output was estimated according to the grass-to-grain ratio of 1.2, and the corn straw product was about 310 million tons. As a renewable biomass resource with huge yield, straw can be widely used in industry, animal husbandry, and agriculture. Although China's straw yield is high, the effective utilization rate is not high, and it is still in the initial stage, and most of it is extensive utilization [2]. In order to achieve refined utilization, straw moisture content is a key factor that must be considered. At present, corn straw moisture detection methods include rapid drying method, near-infrared spectroscopy, microwave attenuation method, capacitance method and resistance method [3]. The rapid drying method is suitable for laboratory measurements, which takes a long time, the equipment required for NIR spectroscopy and microwave attenuation detection is expensive, and the capacitance method requires crushing the corn stalks to fill the measuring trough. In this paper, the AC impedance method is used to design a corn straw moisture detector, which can measure the internal moisture of a single corn straw with fast detection speed, high accuracy and low cost. Compared with the DC resistance method, the AC impedance method can effectively resist polarization interference, have a stronger signal, and have a larger detection range of moisture content [4]. In this design, a single-chip microcomputer is used as the controller, and the corn straw moisture content detector with temperature compensation function is detected by the AC impedance method, and the detection accuracy is verified by the test. 2. Hardware Design 2.1. General Design The overall block diagram of the system is shown in Figure 1. The microcontroller uses a 32-bit controller STM32H743 with a clock speed of 480MHZ and up to 16-bit ADC resolution, in addition to its high-performance Cortex-M7 core and hardware acceleration support, enabling it to perform FFT (Fast Fourier Transform) analysis. The single- chip microcomputer sends instructions through the serial interface to control the DDS sine wave generator to output a stable 100kHZ sine wave signal, and then through the constant current source circuit, the voltage and current conversion is carried out, and the two electrodes connect the straw to the circuit, and the output signal is filtered and pressurized, and the voltage signal is collected by the ADC module, and the collected signal is calculated by the single- chip microcomputer for FFT operation. The temperature information is collected using a DS18B20 chip, and the analog signal is converted to a digital signal by the ADC. Fig 1. Block diagram of the overall system design Fig 2. Corn straw moisture content detection device 47 2.2. Detection Device Design The corn straw moisture content detection device is shown in Figure 2, which uses two stainless steel needles as electrodes, with a spacing of 8mm and a length of 25mm, which can be directly inserted into the corn straw. The device has a built-in temperature sensor, which can measure the temperature in the field in real time. 2.3. Circuit Design 2.3.1. Sine Wave Excitation Circuit Using the DDS-based Direct Digital Synthesis (AD9833) as the signal generator, the design circuit is shown in Figure 3, which requires an external 25M crystal oscillator as the clock source, and the AD9833 writes data through a 3-wire serial interface to adjust the output frequency, phase, and amplitude. Here a sinusoidal excitation signal with a frequency value of 100kHz and a peak-to-peak value of 0.6V will be set. Fig 3. Impedance detection circuit 2.3.2. Constant Current Source Circuit The core reason for using the constant current source as the excitation is to eliminate the influence of the change of contact resistance and sample density on the measurement results, and when the electrode is in contact with the straw, there is a non-negligible contact resistance on the contact surface, and its magnitude is affected by the pressure, surface oxide layer and other factors. If a constant voltage source is used for excitation, the impedance calculation will be too high. However, the constant current source forces the output current to be constant, and the measured voltage only reflects the measured impedance, and the contact resistance does not affect the calculation result. In addition, the output impedance of the constant current source is extremely high (ideally ∞), which suppresses noise introduced by load changes. In this paper, the circuit is composed of two operational amplifiers, LM358, and the output current of the circuit can be deduced according to the theory of imaginary short and false break: / (1) Where is the output of the constant current circuit, and is the output voltage amplitude of the sinusoidal excitation circuit. Therefore, as long as the input voltage and remain unchanged, no matter how the load after the circuit changes, it will not affect the constant current output of the circuit. 2.3.3. Detection Circuits It is composed of a detection probe and an amplifier, and the output voltage of the circuit is: | | (2) Where is the output voltage, |Z| is the amplitude of the straw impedance. 2.3.4. Low-pass Filter Circuitry A simple RC low-pass filtering circuit that filters out high- frequency noise, and its cut-off frequency is calculated by equation (3). (3) 2.3.5. Boost Circuit There is a negative voltage in the signal output by the detection circuit, and the ADC needs a positive voltage signal for sampling, so a DC bias circuit needs to be added to the circuit so that the signal can be collected normally. 2.3.6. Temperature Detection Circuits Temperature has a great influence on the moisture content measured by impedance method, and the detection accuracy of DS18B20 digital thermometer can reach ±0.4°C, and the detection speed is less than 1 second. The temperature detection circuit is shown in Figure 4. Fig 4. Temperature detection circuits 2.3.7. Power Circuits The microcontroller does not have a negative power supply, so a negative voltage generation circuit needs to be designed, and the TPS63700 is used as a voltage converter to provide a stable -5V voltage for the amplifier. The circuit is shown in Figure 5. 3. Software Design It mainly includes the main program, ADC data acquisition subroutine, data processing subroutine and display subroutine. The main program mainly completes the initialization of the 48 system and calls each subroutine. The ADC data acquisition subroutine collects the temperature signal and the impedance response signal, respectively. The data processing subroutine is mainly to sum and average the temperature data and perform FFT operation on the impedance response signal, solve the signal amplitude, calculate the impedance value, fit the data between the moisture content, temperature and impedance value, etc., and calculate the straw moisture content by Newton iterative method. The main data obtained is printed to the display by the display subroutine. Fig 5. Power circuits 4. Moisture Content Detection Model and Test 4.1. Test Material The test material was corn straw harvested in autumn in Jilin area, and non-rotting and pest-free corn straw was taken as sample. 4.2. Test Method 3 parts of 10~15 g of raw straw samples were dried in a hot air drying oven at 105°C until the mass was constant [5]. The average of the moisture content of the 3 samples was taken as the initial moisture content of the straw. The results showed that the initial moisture content of the straw used was 10.4%. A certain amount of straw samples were weighed and packed in plastic bags using a MP31001 electronic analytical balance, and straw samples with a moisture content of 10%~20% were prepared by adding a small amount of deionized water to the straw multiple times. Stir constantly during the addition of deionized water to evenly distribute the water. Subsequently, the sample was double-sealed and placed in a cold room at 2°C for 2~4 days to allow the moisture to be slowly absorbed by the straw sample. In order to ensure uniform water distribution, shake the sample 3~5 times a day. Before the test, the actual moisture content of the sample was measured by the drying method. The actual wet-based moisture content of the samples in the test was 10.6%, 15.1%, 17.8% and 20.5%. Seal the container with plastic wrap and place in a refrigerator at 2°C. When the temperature of the sample is cooled to about 2 °C, the sample is taken out, quickly placed in a constant temperature drying oven, and the developed moisture content detection device is inserted vertically and completely into the center of the straw sample to ensure that the electrode and temperature sensor are in complete contact with the sample. The temperature of the drying oven was set to 10°C, and when the sample temperature was constant at 10°C for about 3 min, the impedance value of the sample at this temperature was measured. Then, set the temperature of the drying oven to 15, 20, 25, 30, 35 and 40°C. When the temperature is lower than 15°C, it takes 7~9 min to heat up from one temperature to the next set temperature, and when the temperature is greater than 15°C, it takes 12~15 min. When the temperature of the sample rises to the set value, extend it for 3~5 min to ensure that the sample temperature is uniform and constant, and then the impedance value is recorded. Each moisture content and each temperature are repeated 3 times, and the average of the 3 measurements is taken as the measurement result. 4.3. Test Results and Analysis Table 1 shows the data obtained from the experiment, which records the impedance values of corn straw measured by the detector at different moisture content and different temperatures. Table 1. Straw impedance values under different moisture content and temperature Water Content W% Temperature T/℃ 10 15 20 25 30 35 40 10.6 56.2 54.3 52.8 51.2 48.0 42.7 34.5 15.1 41.3 40.8 38.8 36.6 31.4 21.2 10.5 17.8 32.5 31.6 30.1 25.4 15.1 11.8 7.9 20.5 18.5 17.8 12.7 9.0 6.0 3.9 2.8 The above data are fitted, and the fitting result is as follows in equation (4). |Z| 91.6943 0.1742 2.7935 0.0205 0.0371 0.0039 (4) Where, | Z| is the impedance amplitude, kΩ; T is the temperature, °C; W is the moisture content, %. The obtained fitting results were tested, firstly, 5 straw samples with moisture content of 10.0%~20.0% were prepared by adding deionized water, and the moisture content of each straw sample was detected at any 5~7 temperatures between 10~40 °C using this detector. This is repeated 3 times at each temperature, and the average of the 3 measurements is taken as the measurement result. The moisture content measured by the developed detector was compared with the actual moisture content obtained by the drying method. The results show that in the range of moisture content of 10.0%~20.0% and temperature of 10~40°C, the absolute 49 measurement error of moisture content of this detector is - 2.0%~1.5%, and the response time is less than 1.5 s. 5. Conclusion In this paper, a corn straw moisture content detection device was designed based on the AC impedance method, and the software and hardware were designed according to the detection principle, and then the impedance value of corn straw under moisture content and temperature was measured by a self-made detector, and the data were fitted and analyzed. The test results show that the corn straw detector system is reliable in operation, has high measurement accuracy, and has a wide range of application prospects. References [1] Ming Cui, Zhaoyuan Hui, Yanliang Wang, et al. Innovative structure and technical characteristics of a multi-functional general-purpose corn harvester product[J]. Agricultural Machinery, 2023, (07):56-57+60. [2] Haiyan Liu, Peng Liu, Xiufei Wang, et al. Research progress on separation and comprehensive utilization of corn straw husk[J]. Heilongjiang Animal Husbandry and Veterinary Medicine, 2015,(13):63-64+67. [3] Jun Yang. Design of wheat straw moisture content detector based on AC impedance method[D].Northwest A&F University, 2013. [4] Shengquan Zhang. Method for determination of moisture content of resistive grain. Grain and Oil Processing and Food Machinery, (2): 66-66, 69. [5] Wenchuan Guo, Jun Yang, Chi Liu, et al. Design of a Wheat Straw Moisture Content Detection Instrument Based on AC Impedance Method [J]. Transactions of the Chinese Society of Agricultural Engineering, 2013, 29(23): 46-52.