ARTIGO TÉCNICO LOW COST FUZZY SYSTEM APPLIED TO THE CONTROL AND SUPERVISION OF THERMAL ENVIRONMENT IN POULTRY FARMS

The aim of this study was to develop an automated fuzzy controller with microcontroller, consisting of hardware and software for the control and supervision of thermal environment in broiler farms. The study has been conducted in two steps: in the first one it was performed a computer analysis through simulation. In the second step it was performed the evaluation of the software and hardware developed by the equipment test in the registration of the thermal environment variables within the facility and activation of the climate control equipment. The experiment was conducted in a poultry house with broilers of Cobb 500 lineage, aged between 1 and 28 days in an experimental farm located in Bambuí MG. The presented prototype is able to operate in an automatic way, the equipment control for the ambience in poultry farms and supervision of meteorological variables. The developed fuzzy controller estimated satisfactorily the thermal comfort for the poultry during 28 days of experiment, keeping the thermal parameters within the specified by literature. The system can be used in the automation of ambience equipment for the four steps of the production chain for broiler chickens.


INTRODUCTION
Brazil is currently the third largest producer in the world of broiler chicken followed by the United States and China (ABPA, 2015).However, the poultry sector lacks technological innovations especially in the thermal environment control which meets the growing on domestic and foreign demand with maximum productivity of meat at the lowest cost.
Among the climatic elements the ones that most directly affect the poultry are the air temperature (DBT,°C) and relative humidity (RH), directly influencing the animals' thermal comfort (MOURA et al, 2010;CASSUCE et al, 2013).For an environment in feedlot condition to be considered comfortable it is necessary that the poultry does not lose energy to compensate cold or heat which is related to range on temperature and relative humidity which determine the zone of animal thermal comfort (NAZARENO et al., 2011).According to research conducted by OLIVEIRA et al. (2006), DAMASCENO et al. (2010) and ROCHA et al. (2010), the poultry thermal comfort can be assessed by the black globe temperature and humidity index (BGHI), which brings together the combined effects of DBT, RH, air velocity and solar radiation.
The choice of the controller based on fuzzy sets was due to non-linearity of involved climatic parameters.The intrinsic properties of weather systems prevent the dynamic response due to, for example, the input change, being independent from specific initial operating conditions (HAHN, 2011).The developed fuzzy controller was designed based on fuzzy sets, first proposed by Mamdani in 1974(LEE, 1990).
Poultry industry due to the needs to make available to internal and external markets, competitive products and services, i.e. quality products at low cost, automated systems for control and supervision on animal thermal comfort have assumed a prominent position.Given the importance of these factors this study aims to develop and build an automated fuzzy controller comprised of software and hardware embedded in PIC microcontroller (Peripheral Interface Controller) for the control and supervision of thermal parameters in facilities for broilers.

MATERIAL AND METHODS
In the first stage, simulations were performed of electronic circuit fuzzy controller using the Proteus ISI Professional v.8 software.Whereas for the control of dry bulb temperature parameters (dbt), black globe temperature (bgt) and relative humidity (RH) was used the computing environment MATLAB version 7.8, 2009a for the fuzzy rules.In the second stage it was performed an experiment in the municipality of Bambuí -MG in an experimental shed for broiler from the Poultry laboratory of the Instituto Federal de Minas Gerais -IFMG -Campus Bambuí.
The experimental poultry house had dimensions of 8.0 x 40.0 m, ceramic roof tiles, hollow bricks masonry bored in the gables and side walls of 0.45 m high, concrete floor, metal screen for side closure, side curtains in yellow and blue.The shed had internally 48 boxes (1.3 x 2.0m) for experimentation spread over the shed, being 24 boxes per side, one feeder and drinker per box and six fans typhoon model distributed along the shed, and three fans per side.Misting system distributed throughout the shed, 14 water emitters for each side, totaling 28 emitters.The heating system consisted of 48 infrared lamps, 250W / 220V distributed along the shed, 24 lamps per side, a lamp per box which were triggered according to the reading of the temperature sensors (dbt).
The poultry house was divided into two central regions by a blue raffia curtain, installed in order to permit the isolation of the two parts of the experimental shed in order that the equipment worked independently.The curtain was installed from floor to ceiling at a height of 2.8 m, forming two environments (A side and B side).On the B side of the shed equipments for air conditioning were triggered manually, according to the literature recommendations (Figure 1).On the A side of the shed (Figure 1), the fuzzy controller was installed that triggered automatically, from the measurement of thermal environmental parameters.The misting system operates independently, that is a pump on B side of 2 HP / 220V and another with the same electrical specifications and pressure on A side.Data collection began on August 8 th , 2012 at 08h00 min, being held under conditions of 24 hours a day, and was completed on September 5 th , 2012 at 08h00 min, totaling 28 days.The experiment was carried out with broilers Cobb 500 lineage, mixed with a density of 18 broilers per m -2 comprising the four stages of the poultry production system.198 chicks of a day of life were housed in six boxes, 33 broilers per box measuring 1.4 x 1.3 m.The installation was divided into two groups, and the B side comprises three boxes which the thermal parameters control (dbt, bgt RH) was performed in the conventional manner.On A side was used three boxes with automated control of thermal parameters by prototype developed on fuzzy controller.The data collect on the thermal environment A side was performed by the fuzzy controller and B side by data loggers HOBO ® brand with resolution of 0.1 °C and  0.7 °C precision.It was made the evaluation of the fuzzy controller prototype pilot developed through registration of the thermal environment parameters using dbt, bgt sensors, and RH installed on the outside of the experimental shed and inside the boxes at the level of the broilers.As for BGHI developed by BUFFINGTON et al. (1981), it was calculated by [eq.( 1)].The temperature of the dew point (tdp) can be obtained by [eq.( 2 BGHI was obtained by collecting the signs of bgt, dbt sensors, and RH, which incorporates the vapor pressure of water.Between 1 to 28 days of the broilers' life, the ventilation control system, misting and heating on A side was automated made, by the fuzzy controller according to the fuzzy rules on Tables 1 and 2. TABLE 1. Rule base of the fuzzy controller used in simulation and practical implementation to the input variables, dry bulb temperature (dbt) (°C) and Relative Humidity RH (%) and "thermal comfort" output, Very low ( VL) Low (L), Ideal (I), High (H) Very high (VH), Bad (B), Medium (M), Good (B).
Variable, relative humidity (RH) and dry bulb temperature (dbt) fuzzified for the 1 st , 2 nd , 3 rd and 4 th weeks of the poultry's life.In periods of low temperature when the air temperature reached values below 30 ° C (first week of poultry's life), the heating system was manually operated on the B side of the installation.
From the second week when the air temperature reached a value exceeding 33 °C, the misting system and fans were triggered.Similarly, it was done with the changes of BGHI and RH.Ventilators and nebulizers were triggered obeying the limits that provide thermal comfort for the broilers.The dbt, RH and BGHI bands considered comfortable for broilers were those proposed in scientific studies performed by OLIVEIRA et al. (2006) andCORDEIRO et al. (2010) for the 1 st , 2 nd , 3 rd and 4 th weeks of the poultry' life, that is, 29 to 33 °C, 24.6 to 28,2ºC, 20.7 to 22.5ºC, 21.2 to 21,4ºC and 51 to 57.5%, 60.1 to 68.7%, 66.7 to 70.2%, 67.2 to 71.2% and from 77 to 81.6, 73.3 to 76.6, 68.8 to 70.7, 68.3 to 69.1 respectively.These bands were adjusted by the system according to the age of the poultry.
The linguistic terms for the fuzzy controller configuration were associated according to the ranges shown on Tables 1, 2 and 3 for the 1 st , 2 nd , 3 rd and 4 th weeks.For dbt linguistic variable domains were assigned for the intervals (25. 5 34.5) (22.5 31.5) (19.5 28.5) and (16.5 25.5) representing the bands (27; 28; 30; 31 and 33), (24, 25, 27, 28 and 30), (21, 22, 24, 25 and 27) and (18, 19, 21, 22 and 24) by the terms: very low, low, ideal, high and very high corresponding to the 1 st , 2 nd , 3 rd and 4 th weeks, respectively.The pertinence functions equally assigned to every week are symmetrical triangular.For the linguistic variable RH, has been assigned the domain in the range (30 80) and the terms: very low, low, ideal, high and very high according to the intervals in Table 2 (40, 50, 60, 70 and 80) also with functions of symmetric triangular relevance.In accordance with studies by OLIVEIRA et al. (2006) were assigned the same domain bands referred to RH for the 1 st , 2 nd , 3 rd and 4 th weeks of the poultry's life.
Table 3 shows the relation between quality of animals thermal comfort levels and their necessary actions to ensure proper thermal environment to the poultry.The base rules for the fuzzy controller can be implemented based on the process of specialist knowledge, which are treated in linguistic form on the structure "if then".However, for this study, a detailed knowledge was dispensed as well as accurate knowledge and even the representative mathematical model of the control plant.Thus, the composite rule bases were based on studies by OLIVEIRA et al. (2006) and CORDEIRO et al. (2010) and by the referenced modeling and simulation that are shown on Table 2.For example, the rules of the fuzzy controller implemented as follows: The evaluation of the proposed equipment was based on the automated fuzzy controller ability to maintain the thermal variables, dbt, bgt, and RH in the boxes on the A side within the considered comfortable limits for the poultry provided in the literature.

Architecture of the fuzzy controller
The microcontroller used was PIC 18F4520 (MICROCHIP (2015).It is a general purpose microcontroller used in automation and control system, low cost, in order to minimize the overall cost of the system, which makes it a viable technical and economically option, as shown by ERDEM (2010).
For the record data of dbt and bgt variables it was used the temperature sensor LM35 model.To collect the bgt variable data it was introduced into a plastic globe with a diameter of 0.15 m, painted in black, calibrated against the standard globe, made of copper with 0.0015m diameter and 0.00005 m thick, equipped with temperature sensor model LM35.The collection of signs referring to the variable RH was made using the relative humidity sensor air HIH-4000 model, which works in a range of 2% to 100% by issuing a corresponding signal from 0 to 4Vcc, feeding of + 5V , which allows its direct connection to the converter pin A/D of the PIC.
The software developed for the control and supervision of dbt and bgt parameters was done in C language.On Figure 2 we can observe the algorithm simplified flowchart containing the software instructions that was boarded in the PIC18F4520.

Defuzzification Process
The defuzzification process transforms the fuzzy set that is on the consequent side of the rule, which in this study is the "thermal comfort" in an equivalent numerical value, which is most suitable to this process.Thus, with respect to the limits of thermal comfort for the broilers, it was assigned to this variable the linguistic terms: very good; good; medium and bad, in an area (0, 1) and functions of symmetrical trapezoidal relevance, so that the value next to zero ("0") indicates a worse feeling of thermal comfort and close to 1, the full state of thermal comfort.

RESULTS AND DISCUSSION
The prototype validation of the fuzzy controller built was made by comparing the variations of dbt, bgt and RH measured with sensors inside the A side boxes and BGHI obtained in function of dbt, bgt and RH in relation to the values measured and collected by data loggers Hobo installed inside (B side) and outside the shed and performance analyzes of the poultries.
It is observed from Figures 3 and 4 that an estimated average for dbt (A) measured by the fuzzy controller inside the A side box in relation to dbt (ext) measured at the outside of the shed by data loggers Hobo showed a very close statistically correlation, that R = 0.687 for the 1 st week and R = 0.602 for the 2 nd week, and the standard deviation between the two variables 2.07 and 6.81; 1.33 and 5.57 for the1 st and 2 nd week, respectively.However, it is observed on Figure 3 that the dbt (A) automatically controlled, provided an environment with temperatures lower than the desired one by the poultry, influenced by low temperatures occurred on the third to fifth day of poultry's life between 5h00min and 6h30min, which was an average of 6 °C.According to OLIVEIRA et al. (2006) and CORDEIRO et al. (2010), the optimal values for dbt (A) for the first week of the poultry's life should be between 30 and 33 °C.This fact may be due to inefficiency of the heating system by means of infrared lamps 250 W / 220V, which did not cover uniformly the entire area of the box.A possible solution for this case would be to use heating system by means of gas hoods.On Figures 3 and 4 can be seen that the average values of the dbt detected by the fuzzy controller sensors (A side) dbt (A) in relation to average values measured of the dbt inside the box (B side) by data loggers Hobo dbt (B) were 29.56 and 23.84 (ºC), 28.23 and 26.41 (ºC) for the 1 st and 2 nd weeks, respectively.This difference between the measured values was expected because the control of dbt (A) was automated by the fuzzy system and the control of dbt (B) was done in a conventional manner.It is also observed on Figure 3 that excluding the time of 04h00min to 07h00min between the 3 rd and 5 th day of poultry's life, the fuzzy controller kept dbt (A) within the limits considered comfortable by the poultries, as recommended by the authors.
It was conclude that the variations of dbt (A) corresponding to 2 nd week were within the limits considered comfortable throughout the observed time (Figure 4), i.e. between 27 and 30 °C as conducted studies (OLIVEIRA et al., 2006;CORDEIRO et al., 2010).3 and 4) was observed statistically that the values that caused discomfort to the poultry were on average smaller than 17.4% in the 1 st week and on the 2 nd week only 0.1% of the values were outside the recommended limits.The mean values and standard deviations of the BGHI observed throughout the experiment were 80.14 and 1.94 on the 1 st week, respectively, and 77.82 and 1.53 on 2 nd week, respectively.These show promising values given that the prototype of the fuzzy controller compound of the hardware and software developed was able to maintain the values of BGHI 82.6% within the limits accepted comfortable for the poultry on the 1 st week and 99.99% on the 2 nd week which are recommended values on the studies by OLIVEIRA et al. (2006).

BGHI (Figures
The misting system and fans were activated every time the dbt (A) exceeded the upper bands corresponding to the 3 rd and 4 th weeks; 27 °C and 24 °C.It is noted by Figures 5 and 6 that this occurred between 12h00min and 17h30min during the week.The misting system was only triggered when the RH (A) was below 50% or for short intervals when dbt (A) exceeded 27 °C and 24 °C (3 rd and 4 th weeks) depending on the upper limit of the RH.For cases in which the dbt (A) was below the lower bands corresponding to the 3 rd and 4 th weeks, i.e., 24 and 21ºC, the heater was activated.It is also observed from Figures 5 and 6 that such activation always occurred in the period from 21h00min to 6h00min throughout the week.
It is noted on Figures 5and 6 that the estimated mean values of dbt collected by the fuzzy controller sensors (A side) dbt (A) from the estimated average values of dbt measured inside the box (B side) by data loggers Hobo dbt ( B) were 24.72 and 24.34 (° C), 23.37 and 24.05 (° C) in the 3 rd and 4 th weeks, respectively.Related variables did not differentiate.These results were expected considering that the estimated average values for dbt (A) and dbt (Ex) on the 3 rd and 4 th weeks were 24.72 and 18.02 (ºC), 23.37 and 19.33 (° C) respectively, the period between the 15 th to 28 th day of the poultry's life.Although the misting system be activated every time the dbt (A) reached the upper limit of 27 (°C) at the 3 rd week and 24 (ºC) at the 4 th week the average values for dbt (ext) were 18.02 and 19.33 (ºC), respectively.It is also verified on Figures 5 and 6 that the estimated mean values and standard deviations of the BGHI observed throughout the experiment were 73.74 and 2.43 at the 3 rd week and 71.64 and 2.52 at the 4 th week, respectively.These results were expected, considering that the prototype of the fuzzy controller as a function of dbt, bgt and RH was able to maintain the values of BGHI 98.6% within the limits considered comfortable for poultry on the 3 rd week and 91.6% on the 4 th week, that is in accordance with the recommended limits in studies by OLIVEIRA et al. (2006).
Regarding RH, according to Figures 7 and 8 concerning the 3 rd and 4 th weeks of age of the poultries there was a significant statistically difference between the values measured by the fuzzy controller sensor inside the shed (box) RH (A) in relation the value measured by the data loggers Hobo on the outside of the shed RH (ext) during the observation period.The estimated mean values and standard deviations of RH (A) and RH (ext) observed during the experiment were 67.77%, 57.96% and 9.58, 24.24 in the 3 rd week and 65.20%, 53.34% and 8.44, 24.19 on the 4 th week Paulo D. de Alecrim, Alessandro T. Campos, Tadayuki Yanagi Junior, et al. Eng. Agríc., Jaboticabal, v.37, n.1, p.194-205, jan./fev. 2017 202 respectively.The correlation index between RH (A) and RH (ext) were R = 0.731 and R = 0.687 in the 3 rd and 4 th weeks, respectively.These results are in accordance with the RH bands considered optimum, associated with the poultry comfort temperatures according to OLIVEIRA et al. (2006) and CORDEIRO et al. (2010).
According to studies by OLIVEIRA et al. (2006), the RH values considered comfortable for broilers on the 3 rd and 4 th weeks of poultry's life are in the range from 60 to 71% on average.However, the percentage values for RH (A) obtained in this study, only 41.5% and 43% were within this range on the 3 rd and 4 th weeks, respectively.According to studies by CORDEIRO et al. (2010) andCASSUCE et al. (2013), the ideal range associated with dbt comfort of the poultry is 50 to 70% on average.Based on this recommendation, analyzing Figures 7 and 8, only 3.3% of RH values (A) were below 50% on the 3 rd week and 2.5% on the 4 th week where dbt (A) averages for these periods stood at 24.72 ° C and 23,37ºC respectively.The percentage values of RH (A) that exceeded 70% in the period were 24.20 and 12.50% for the 3 rd and 4 th weeks, respectively.Analyzing Figures 7and 8 this fact can be explained by high average values of RH (ext) in the time between 23h00min and 7h30min were 83.50% and 79.13% for the 3 rd and 4 th weeks respectively.Figures 7 and 8   The fans were triggered every time the sensors RH (A) of the fuzzy controller detected values above the limit range considered comfortable for poultry according to the routine of the fuzzy controller software Figure 2.For values below to this range was activated the misting system, also according to the routine of Figure 2.

Performance evaluation of poultry
Table 4 shows the average values for the performance rates observed on the 1 st , 2 nd , 3 rd and 4 th weeks of the poultry's life, such as feed intake, body weight, feed conversion, mortality rate, corresponding to treatment with (fuzzy controller) boxes of the A side of the shed and B side treatment with conventional control.Evaluating the fuzzy control in relation to the manual control to the FI variable on the 1 st week (Table 4) there was significant difference between the analyzed methods (p <0.05) where the poultry subjected to fuzzy control showed better WG and better FC, however, there were no significant differences (p> 0.05) for these variables.Experimental treatments with fuzzy controller influenced the WG and FI (p <0.05) on the 2 nd week of poultry life, however, FC variable was not influenced (p> 0.05) for used manual processing.This effect of the system on WG and FI was probably due to the efficiency on the control of environmental thermal parameters dbt, bgt and RH at the touch of equipment by the fuzzy controller.The mean dbt and BGHI occurred in these weeks were 29.56 ° C and 80.15 respectively on the 1 st week and 28.23 °C and 77.82, respectively on the 2 nd week (Figures 3 and 4).These values are in accordance with the values found in searches made by OLIVEIRA et al. (2006), CORDEIRO et al. (2010) and COBB (2011).
On the third week of poultry's life kept in treatment fuzzy control compared to manual treatment showed significant difference (p <0.05) for WG and FI.But for FC there was no significant difference (p> 0.05).Mean values for dbt, RH and BGHI for this week were 24.72ºC, 67.77% and 73.74 respectively.The average values for these parameters recommended in studies by OLIVEIRA et al. (2006) for the same period are 26.4ºC,68.45% and 69.75, respectively.Looking at Figure 5 it appears that in the period between 5h00min and 6h30min the average value for dbt (ext) was 9.76ºC, while for the dbt parameter controlled by the fuzzy system was 24.72ºC.
In the fourth week of poultry's life productive variables with fuzzy controller had better WG, FI and FC in relation to manual handling evidenced by the significant difference between the two treatments (p <0.05) for these variables.These results are justified by the automated control of dbt parameters, RH and bgt made by the fuzzy system whose values were 23.37 °C, 65.20% and 71.64, respectively.These values are consistent with studies by OLIVEIRA et al. (2006), CORDEIRO et al. (2010) and COBB (2011) who claims dbt ranging on average from 20 to 24 °C during this period of poultry's life the mean values of RH and BGHI that provide comfort for poultry should be between 60 to 70% and 68 to 72, respectively.
Considering the four-week experiment with poultry aged between 1 and 28 days it is concluded that the average values for dbt, dbt (ext) BGHI and collected these weeks by the fuzzy controller was 29.56 °C, 16.78ºC and 80.15 respectively on the 1 st week, 28.23 ° C, 18.08 °C and 77.82, respectively on the 2 nd week, 24.72 °C, 18.02 °C and 73.74, respectively on the 3 rd week and 23.37 ° C, 19.33 ° C and 71.64, respectively on the 4 th week.Thus, it can be said that the fuzzy controller was able to keep the climatic parameters considered in the experiment within the ranges considered comfortable for poultry from 1to 28 days of life according to studies by OLIVEIRA et al. (2006) andCORDEIRO et al. (2010).

CONCLUSIONS
The automated fuzzy controller with PIC microcontroller, consisting of software and hardware designed for supervision of climate parameters and equipment control to maintain the ambience inside commercial broiler farms, presented technically feasible as well as being of low cost.
The developed fuzzy controller was capable to maintain the climate parameters within the ranges considered comfortable by the referenced literature most of the time.

FIGURE 1 .
FIGURE 1. Scheme of the distribution division of sensors, fans and boxes.Unit: m

FIGURE 2 .
FIGURE 2. Simplified flowchart for the control of the dry bulb temperature (dbt), black globe temperature (bgt) and air relative humidity (RH).

FIGURE 3 .
FIGURE 3. Observed and estimated average values of the dry bulb temperature (dbt) (A) (°C), external dry bulb temperature (dbt) (ext) (°C), dry bulb temperature (dbt) (B) (°C), on the basis of the observed and estimated times of BGHI (Black Globe Humidity Index).

FIGURE 4 .
FIGURE 4. Observed and estimated average values of the dry bulb temperature (dbt) (A) (°C), external dry bulb temperature (dbt) (ext) (°C), dry bulb temperature (dbt) (B) (°C), on the basis of the observed and estimated times of BGHI.

FIGURE 5 .
FIGURE 5. Observed and estimated average values of the dry bulb temperature (dbt) (A) (°C), external dry bulb temperature (dbt) (ext) (°C), dry bulb temperature (dbt) (B) (°C), on the basis of the observed and estimated times of BGHI.
can be seen the estimated mean values of RH collected by the fuzzy controller sensors (A side) RH (A) regarding the estimated average values RH collected inside the box (B side) by data loggers Hobo RH ( B) were 67.71 and 38.36 (%), 65.20 and 40.20 (%) on the 3 rd and 4 th weeks, respectively.

TABLE 3 .
Relation between animal thermal comfort and the necessary actions.

TABLE 4 .
Observed average and estimated values of weight gain (WG), feed intake (FI), feed conversion (FC), p values and manual mortality rate values (MR) and fuzzy (TF) observed 24 hours a day for 28 days of the poultries' life in the fuzzy (FC) and manual controls (CM).Values in Kg.