# Implement of Fuzzy Control for Greenhouse Irrigation

Wenttao Ren, Quanli Xiang, Yi Yang, Hongguang Cui, Lili Dai

► To cite this version:

Wenttao Ren, Quanli Xiang, Yi Yang, Hongguang Cui, Lili Dai. Implement of Fuzzy Control for Greenhouse Irrigation. 4th Conference on Computer and Computing Technologies in Agriculture (CCTA), Oct 2010, Nanchang, China. pp.267-274, 10.1007/978-3-642-18333-1_31 . hal-01559623

HAL Id: hal-01559623

https://inria.hal.science/hal-01559623

Submitted on 10 Jul 2017

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# Implement of fuzzy control for greenhouse irrigation

Wenttao Ren¹, Quanli Xiang¹, Yi Yang², Hongguang Cui¹, Lili Dai¹

¹College of Engineering, Shenyang Agricultural University, Shenyang, 11086, China;

²Shenyang Liaowuyi E-TEC Co., Shenyang, 110044, China
{renwentao1958@yahoo.cn, xiangquanli1020@163.com, tianya@163.com,
cuihongguang7763@163.com, dadailili@163.com}

**Abstract.** By adopting the fuzzy control theory, a greenhouse irrigation automatic control system has been designed with the characteristic of accurate of the nonlinear, time-variability, long time delay and the characteristic of accurate mathematic model being hard to establish. Through some basic experiments, the basic domain of input and output of the fuzzy controller were ascertained. Time variables that were used to control the each connect duration of electromagnetic relay. Fuzzy control can be realized by MSP430F133 MCU control system with usage of the time variable. By the action of fuzzy control, prototype field experimental results showed that first-order inertial character performed by the system with the constant —3540s, which was no overshoot. With simple structure, low price and high reliability, the accuracy of the system meets irrigation technical requirements of crops in greenhouse.

**Keywords:** fuzzy control, MSP430F133, time constant, subsurface drip irrigation

## 1 Introduction

In cold, arid and semiarid regions of northeast, greenhouses product mainly in winter, so saving energy and water sources become important. Because of that, subsurface drip irrigation technology is popular[1]. But using manual to control irrigation is difficult to make an accurate irrigation amount and time, and it also could consume labor time, which restraint the development of this technology sufficiently. Because of drip irrigation worked under ground surface with little effect on temperature and humidity in greenhouse, signal-factor control is possible. With factors of nonlinear and uncertain characteristics in greenhouse, it difficult to build an exact mathematic model to control with modern control theory accurately. As a way of computer control, fuzzy control based on human thinking, can describe complicated changing process with simple words, and without mathematic model of system[2]. In recent years, Mao Hanping, Ding Weimin and so on[3-6] have introduced fuzzy control technology in greenhouse environment control system gradually, however, these still on the experimental stages. In order to further save water source and labour cost, this paper builds fuzzy controller use MATLAB, and designs a water-saving control system with the MSP430 MCU as control core. The system can set different upper and lower limits for irrigation according to water requirement regulation of crops in greenhouse.
# 2 Materials and methods

## 2.1 Overall design of irrigation control system

Base on the environmental characteristics of greenhouse, this paper put forward the way of distributed control, consisting of upper computer and lower computers that were distributed around different position of greenhouses( As shown in Fig.1). Using RS-485 bus for multicomputer communication between upper computer and lower computers, using PC as upper computer and using Level Two Controller as lower computers. Level Two Controllers can transmit the acquired humidity data to the upper computer by serial communication of RS-485. At the same time, they also accept the set value by upper computer and execute the order. The lower computers also can control by themselves. The combination of lower computers control and PC control intently make easy operation. Others controllers won't be influented if single one was wrong.

<figure><img src="image_2.png" /><figcaption>Fig. 1. Overall design scheme of control system</figcaption></figure>

## 2.2 Design of fuzzy controllers

Principle of fuzzy control system as shown in Fig.2. Fuzzy control system is mainly composed of fuzzy controller, actuator, controlled objects, sensor and A/D converting. According to the intent of designing, solenoid valve controlled by relay as actuator, soil as controlled object, soil moisture sensor based on FDR principle as the sensor were chose. The soil moisture sensor can detect soil volumetric water content which is the most common indicator of irrigation. Duration of voltage level of delay could be chose as output of fuzzy controller. So, it didn't need D/A converting.
Therefore, a fuzzy controller for the fuzzy control system should be designed. This paper used fuzzy control toolbox of MATLAB to design fuzzy controller.

### (1) Structure design

Structure design means setting linguistic variables of input and output. The soil moisture deviation (e) and its changing rate (ec) had been chosen as input variables, and the each connect duration of relay (u) had been chosen as output variables.

<figure><img src="image_3.png" /><figcaption>Fig. 2. Principle of fuzzy control system</figcaption></figure>

### (2) Fuzziness of precise variables

In fuzzy control system, it defines the actual ranges of input and output variables as their base domains. The base domains of e, ec and u can be got, which are respectively [0, 15%], [0, 2%] and [0, 120s] after repeated tests. Data in these domains were positive because speed of evaporation less than that of irrigation in the process of irrigation.

Base domains should be discreted as fuzzy subsets domains. e, ec and u were discreted six stalls where fuzzy subsets domains and fuzzy subsets are respectively [0, 6] and {ZO,PS,PM,PB}. The output languages were respectively “no-irrigation”, “short time -irrigation”, “moderate -irrigation” and “long time-irrigation”.

The quantization factor and scale factor are introduced in order to discrete variables of base domains into fuzzy subsets domains. The quantization factor is defined as the ratio of discreted stall to maximum of input in base domains. The scale factor is defined as the ratio of output in base domains to discreted stall. So, the quantization factors of e and ec can be calculated, which are respectively 40 and 300, and the scale factor of u is 20.

### (3) Assigning value to linguistic variables

Fuzzy subsets of domains of linguistic variables can be described by their membership functions (μ(x)). The range of μ(x) is [0, 1]. Membership means the proportion of value of fuzzy domains to each element of fuzzy subsets. μ (x) should be established by practical experience. This paper adopted triangle for shape of μ(x). The membership functions' shape of linguistic variables of e (E), linguistic variables
of *ec* (*EC*) and linguistic variables of *u* (*U*) had been shown in Fig.3 and Fig.4, where *U* is anisomerous. Points where value of membership is 1 are respectively 0, 0.667, 2.667, 6. Therefore, fuzzy controller can deduce small linguistic values if the deviation between the detecting value and the setting value of soil moisture is small. So the control role of certainty of outputs is weaker, that is to say the each connect duration of relay is short; on the other hand, the each connect duration of relay is long if the deviation is big. This method can correct the deviation rapidly. Membership function assignment of *E*, *EC* and *U* as shown in Table.1 and Table.2.

<figure><img src="image_4.png" /><figcaption>Fig. 4. Membership function of E and EC</figcaption></figure>

<figure><img src="image_5.png" /><figcaption>Fig. 4. Membership function of U</figcaption></figure>

<table><caption>Table 1. Membership function assignment of E and EC</caption><thead><tr><th rowspan="2">μ(x)</th><th colspan="7">E, EC</th></tr><tr><th>0</th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th></tr></thead><tbody><tr><th>ZO</th><td>1</td><td>0.5</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><th>PS</th><td>0</td><td>0.5</td><td>1</td><td>0.5</td><td>0</td><td>0</td><td>0</td></tr><tr><th>PM</th><td>0</td><td>0</td><td>0</td><td>0.5</td><td>1</td><td>0.5</td><td>0</td></tr><tr><th>PB</th><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0.5</td><td>1</td></tr></tbody></table>

<table><caption>Table 2. Membership function assignment of U</caption><thead><tr><th rowspan="2">μ(x)</th><th colspan="7">U</th></tr><tr><th>0</th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th></tr></thead><tbody><tr><th>ZO</th><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><th>PS</th><td>0</td><td>0.7</td><td>0.2</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><th>PM</th><td>0</td><td>0.2</td><td>0.7</td><td>0.8</td><td>0.4</td><td>0.2</td><td>0</td></tr><tr><th>PB</th><td>0</td><td>0</td><td>0</td><td>0.1</td><td>0.5</td><td>0.7</td><td>1</td></tr></tbody></table>

(4) Compilation of fuzzy control rules

Fuzzy control rules adopted the sentences of “if *E* is...and *EC* is...,then *U* is...”. Results as shown in Table.3.
<table><caption>**Table 3.** Fuzzy control rules</caption><thead><tr><th rowspan="2">U</th><th colspan="4">E</th></tr><tr><th>ZO</th><th>PS</th><th>PM</th><th>PB</th></tr></thead><tbody><tr><td rowspan="4">EC</td><td>ZO</td><td>ZO</td><td>PB</td><td>PB</td><td>PB</td></tr><tr><td>PS</td><td>ZO</td><td>PM</td><td>PB</td><td>PB</td></tr><tr><td>PM</td><td>ZO</td><td>PS</td><td>PM</td><td>PM</td></tr><tr><td>PB</td><td>ZO</td><td>PS</td><td>PS</td><td>PM</td></tr></tbody></table>

(5)Making lookup table of fuzzy control by MATLAB

In order to realize the action of fuzzy control and decrease amount of control value calculating, fuzzy control toolbox of MATLAB was adopted to make lookup table of fuzzy control, and fuzzy values were transmitted into accurate value using the method of weighted average. The data in this table can be used to control irrigation time. According to the above steps, we can get the lookup table of fuzzy control could be acquired as shown in Table.4.

<table><caption>**Table 4.** Lookup table of fuzzy control</caption><thead><tr><th rowspan="2">GR</th><th colspan="7">E</th></tr><tr><th>0</th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th></tr></thead><tbody><tr><td rowspan="7">EC</td><td>0</td><td>0</td><td>4</td><td>5</td><td>5</td><td>5</td><td>5</td></tr><tr><td>1</td><td>0</td><td>3</td><td>4</td><td>4</td><td>5</td><td>5</td></tr><tr><td>2</td><td>0</td><td>3</td><td>3</td><td>4</td><td>5</td><td>5</td></tr><tr><td>3</td><td>0</td><td>3</td><td>3</td><td>3</td><td>4</td><td>4</td></tr><tr><td>4</td><td>0</td><td>1</td><td>1</td><td>3</td><td>3</td><td>3</td></tr><tr><td>5</td><td>0</td><td>1</td><td>1</td><td>3</td><td>3</td><td>3</td></tr><tr><td>6</td><td>0</td><td>1</td><td>1</td><td>1</td><td>1</td><td>3</td><td>3</td></tr></tbody></table>

## 2.3 The realization of methods of fuzzy control by MCU

The lookup table could be saved in MCU as a two dimensional array for invoking by MCU in real time. In this paper, we write programs by data of lookup table in order to decrease the frequency of MCU.

The functions of MCU(MSP430F133) control system are setting upper and lower limits of irrigation and controlling relay on or off and communicating with upper computer. The current value of soil moisture could be obtained by soil moisture sensor and A/D converting. The *e* and *ec* were got by comparing the current value with setting value. Then these values were transmitted into fuzzy linguistic variables, and decisions were made according to table 3. As a result, the best result of the each connect duration of relay was appeared by different combinations of *e* and *ec*.

The function of fuzzy control subprogram is carrying out once irrigation time during the process of irrigation according to the signal detected by soil moisture
sensor. In Table 4, the value of GR means time of once irrigation. The relation between once “on-time” duration of relay(T) and GR in process of irrigation as shown by formula (1)

$$T = \text{sampling time} = \frac{GR}{6}. \quad (1)$$

Sampling time is 120s, so time frame of each connect duration of relay in process of irrigation have 0s, 20s, 40s, 60s, 80s and 100s. Flowchart of fuzzy control subprogram as shown in Fig 5.

<figure><img src="image_6.png" /><figcaption>Fig. 5. Flowchart of fuzzy control subprogram</figcaption></figure>

## 3 Results and discussion

In order to verify the effect of fuzzy control during irrigation, we test the soil humidity variation curve under different irrigation upper limit value and same incremental have been executed. The result as shown in Fig.6.

The results of four times experiments showed that the irrigation system shows up the characteristic of first-order inertial. Transfer function of this system is:

$$\phi(s) = \frac{1}{Ts + 1}. \quad (2)$$

According to response characteristics of first-order inertial system, the elapsed time that the output value is 63.2% of setting value is the time constant of the system’s transfer function (T). Using SPSS, the irrigation time were got corresponded by the four curves, which were T₁=52min, T₂=54min, T₃=60min, T₄=70min when the incremental is 1.896%.

We can calculate that the soil infiltration speed reduce gradually when soil water content is close to field capacity on the condition of neglecting influence of outside factor. Therefore, the corresponding time content increases gradually on the condition of same incremental. But the time content decreases gradually and is tending a constant when the soil water content far from the field capacity. This proves that the action of fuzzy control subdued changes in time content vary with changes of the capacity of absorbing water of soil in certain degree. So, average of T₁, T₂, T₃ and T₄ can be used as time content of this irrigation system.
<figure><img src="image_7.png" /><figcaption>Fig. 6. Soil humidity variation curve under different irrigation upper limits value and same incremental</figcaption></figure>

$$T = \frac{T_1 + T_2 + T_3 + T_4}{4} \times 60 = 3540s. \qquad (3)$$

Substitutes the transfer function of system with T:

$$\phi(s) = \frac{1}{3540s + 1}. \qquad (4)$$

The following are calculation for indicators of dynamic performance of the system.

$$\text{Delay time: } t_d=0.69T=2443s; \qquad (5)$$

$$\text{Rising time: } t_r=2.207T=7813s; \qquad (6)$$

$$\text{Regulating time: } t_s=3T=10620s. \qquad (7)$$

## 4 Conclusions

Using the fuzzy control toolbox of MATLAB, the data that were used to control irrigation time were obtained, and achieved the precise irrigation. By means of the way of MCU control, it can keep the soil water content in upper limit and lower limit and achieved the automatic irrigation. So, this method can save water resource and
labour cost efficiently. Under the action of fuzzy control, the irrigation control system
performed the character of first-order inertial system with the time content was
3540s. The control precision met basic requirements of crop irrigation for greenhouse
in the range of allowable error without overshoot.

References

1. Yulong Zhang, Yi Hang, Hengming Zhang,: The Development and Application for Sectional Type Subirrigation Tip in Greenhouse, Chinese Journal of Soil Science. 35(1), 12--15 (2004)

2. Jianwu Dang, Shuxu Zhao, Yangping Wang,: Fuzzy Control Technology. Chinese railway, Beijing (2007)

3. Yingshan Zhong, Jiaqiang Yang, Jinlian Deng,: Multivariable Fuzzy Control of Temperature and Humidity in a Greenhouse, Transaction of the Chinese Society for Agricultural Machinery. 32(3), 75--78 (2001)

4. Chikun Gong, Cuiying Chen, Hanping Mao,: Multivariable Fuzzy Control and Simulation of a Greenhouse Environment, Transaction of the Chinese Society for Agricultural Machinery. 31(6), 52--54 (2000)

5. Weimin Ding, Xiaochan Wang, Yinian Li,: Review on Environmental Control and Simulation Models for Greenhouse, Transaction of the Chinese Society for Agricultural Machinery. 40(5), 162--168 (2009)

6. Yongchang Yu, Jiandong Hu, Pengjun Mao,: Fuzzy Control for Environment Parameters in Greenhouse, Transaction of the Chinese Society of Agricultural Engineering. 18(2), 72--75 (2002)

7. Dake Hu. FLASH Type and 16bits MCU with Ultralow Power Consumption of MSP430 Series. Beijing University of Aeronautics and Astronautics, Beijing (2001).

8. Dake Hu. C programs designing and development for MSP430 MCU. Beijing University of Aeronautics and Astronautics, Beijing (2002).

9. Xiaojun Qiao, Zuorui Shen, Qingyun Chen,: Design and Realization of General Computer Monitoring and Controlling System for Environment of Agricultural Facilities, Transactions of the CSAE. 16(3), 77--80 (2000)

10. R.G.Anderson, A.J.Meyer, M.A.Valenzhuela,: Web Machine Coordinated Motion Control Viaelectronic line-Shafting, IEEE.Trans Ind.Application, 37(1), 247--254 (2001)

11. Hongbin Xu, Xiangbin Du,: Control System Design for Stepper Motors, Journal of Chongqing Institute of Technology (Natural Science), 22(5), 32--34 (2008)

12. Xin Li, Mengke Qu, Yu Rong,: Design of Temperature and Humidity Fuzzy Controller Based on MSP430 MCU, CHINESE JOURNAL OF SENSORS AND ACTUATORS. 20(4), 805--808 (2007)

13. Songhe Xie, Yong Gan,: Fuzzy control system design and applying examples of MCU. Electronics industry, Beijing (1999)
14. Qihua Wu, Bangquan Xu,: Analysis of Synchronized Control System for Multi-Motor. Auto-control O.I.Automation, 22(1), 20--24 (2003)

15. Kevin Payette,: Synchronized Motion Control with the Virtual Shaft Control Algorithm and Acceleration Feedback. Proceedings of theAmerican Control Conference, 2102-2106 (1999)