TEMPERATURE CONTROL BASED ON FUZZY LOGIC USING ATMEGA 2560 MICROCONTROLLER

The country of Indonesia has a tropical climate. During the dry season there will be more hot conditions. For the middle class, the use of fans is needed as a neutralizer for hot temperatures. Currently the fan is still manually adjusted to the desired speed. Manually setting conditions, of course, cannot adjust to the current temperature conditions. Therefore we need a fan speed control device using a DS18B20 temperature sensor and a PING sensor. In this study, the algorithm system used is the fuzzy logic controller. The results showed that the change in the range of each increase in temperature and distance was linear. The results of the study show that with a temperature are 32 degrees of Celsius and a distance of 18 cm it produces an output of 60. Input temperatures are 35 degrees of Celsius and 16 cm produce an output of 125. Input temperatures are 35 degrees of Celsius and distance of 20 produce an output of 127. Input temperatures are 75 degrees of Celsius and a distance of 35 cm produces an output of 255 and when the temperature reaches 90 degrees of Celsius and a distance of 4 cm, the PWM returns to zerro because the temperature value exceeds the predetermined range.


Introduction
Indonesia, which has a tropical climate and is crossed by the equator, causes the air temperature to be warmer compared to other areas. This makes the tool's existence and function available cooling the room is very meaningful, especially during the dry season. Continuous exposure to the sun can cause a rise in temperature. If this happens in a room that has poor ventilation, it can cause the room to heat up quickly and feel stuffy. The vent functions as a place for air circulation. One tool that can cool the air is air conditioning. Almost all Indonesians in every home have air conditioners which aim to cool, cool the room in their house and move the air (air circulation) in the room. In a short period of time the development of technology developed very rapidly. This technological development is the result of hard work from human curiosity, but technological advances also have a negative impact, especially with the waste of energy, starting from people forgetting to turn off the air conditioner, a lot of energy is wasted due to human negligence [1]. The developing control system is using an intelligent system by utilizing computer vision [3] [4].
With the rapid pace of technological development, many sophisticated tools have emerged that can work automatically with intelligent systems and computer vision [5] [6]. Initially the temperature speed of the wind fan will be done manually by humans. but along with the development of technology in the field of electronics and mechatronics, this human task can be replaced by certain tools that can work automatically to adjust the fan speed automatically so that in this final project an Air Conditioner Controller Design is designed to be able to adjust the fan speed accordingly. with the distance and temperature in the room. The fan here uses a DC motor as a simulation.
DC motors (Direct Current) or direct current motors are included in the category of motor types that are most widely used both in industrial environments, household appliances to children's toys or as a supporting device for electronic instrument systems. The advantages of DC motors are high torque, not has a loss of reactive power and does not cause harmonics in the power system that supplies it [2]. The development of computer technology, both hardware and software, continues to develop as the development of electronic technology is increasingly advanced, as well as control technology which has experienced many advances from conventional control to automatic control to intelligent control [6] [7].
The use of Fuzzy Logic control techniques has been quite widespread in various applications ranging from industrial process control, household electronics, robot control and others [9] [10]. In this study, a simple application that uses fuzzy control is given, namely a temperature control system using a fan with a temperature sensor and a proximity sensor. This system can be applied to various motor speed control applications with various inputs from temperature sensors. The motor rotation control system is currently undergoing rapid development. Even though this control process is relatively easy and flexible to design, without involving complex mathematical models of the system to be controlled. The use of fuzzy logic controller tools in this prototype really helps the process of designing a fuzzy control system. Direct control response can be observed on the PC monitor screen.
Control systems have played an important role in modern science and engineering. There are several methods of control that are conventionally often used, namely using proportional control (P), integral control (I), derivative control (D) or a combination of these controls [3 ]. On the other hand, a control technology has also developed that no longer uses conventional methods to obtain a desired result through mathematical equations. But by implementing a system of human ability to control something, namely in the form of if-then rules, with a fuzzy logic control system [4]. Fuzzy logic control system is used as a control system application, because this control process is relatively easy and flexible to be designed without involving complex mathematical models of the system to be controlled.

Method
The research method used is the method of Research and Development (Research and Development / R & D). The initial stage of designing a tool requires an initial description of how the system works from the tool. The block diagram of this control system can be seen in Figure 1.  To design a controller in this study, fuzzy logic is applied to the DC motor controller using the Sugeno method. The control system is designed with two inputs in the form of a DS18B20 temperature sensor and a PING ultrasonic sensor. Both temperature and distance inputs will be processed by the fuzzy logic controller (FLC) to obtain the output value in the form of a PWM signal to control the rotational speed of the DC motor. Table 1, shows the variables and values of each variable in a fuzzy set. From the data that has been obtained as input to determine the output results, the data is made according to the range of fuzzy levels. Creating fuzzy sets using MATLAB software. Technological developments provide a wide variety of high performance applications such as manufacturing robots, electric trains, motor control. All of these can be designed using MATLAB software [5]. The following is a picture of making fuzzification using MATLAB software.
Fan speed control uses a Fuzzy Logic Controller which consists of input and output. The number of inputs in this system has two sensors, namely the DS18B20 temperature sensor and the PING sensor as well as the motor output using either a DC motor. The temperature input setting consists of three membership functions (MF), namely cold, standard, warm, hot, very hot. Meanwhile, the PING sensor input also consists of five MF, namely very close, near, standard, far, far away. The motor output settings consist of five MF, namely very slow, slow, standard, fast, and very fast. So in this study, there are three fuzzy variables, namely the DS18B20 temperature sensor, the PING sensor and the DC motor.
The temperature variable is divided into five fuzzy sets, namely: very cold, standard, warm, hot, very hot. Meanwhile, the PING sensor variable is divided into five fuzzy sets, namely very close, near, standard, far, far away. Meanwhile, motorized variables are divided into five fuzzy sets, namely: very slow, slow, standard, fast, and very fast.
Universal set of all values that are allowed to operate in variable blurring. The fuzzy domain set variables in the LDR can be seen at Table 2. The domains of the entire set are the values allowed in the Universal Set and can be operated in the fuzzy set. The fuzzy domain set variables on the DS18B20 sensor can be seen at Table 3.  Meanwhile, the fuzzy domain set variable on MOTOR can be seen at Table 5. The membership function (MF) function is a curve that shows the mapping of input data points to be involved in the interval value between 0 to 1. While the output from the control system on the fan uses a DC motor rotation. Figure 2 shows the membership function for the DS18B20 sensor input.

Result and Discussion
In this study, the implementation of the design carried out on a fuzzy control system for temperature control using a fan has been carried out. This temperature system uses a temperature sensor and a proximity sensor. The rule regulators in this system can be seen in Table 6 below. After the rule determination process, the next step is to create a definition formula in order to determine the output value (z). The following formula is used to determine of defuzy. In this experiment, the researchers used an ultrasonic sensor SR-504 and a DS18B20 heat sensor as the input component while the output of the researcher used a 12 v dc fan, the voltage source used +vcc and ground as power supply, the +vcc used was 12v and 5v, 5v voltage was taken from 5v voltage limiting circuit using IC-7805.
The measurement results from the sensor will be displayed on the 16*2 lcd and the pwm is used, the ultrasonic sensor is used as a distance sensor that measures 5 distances, namely very close, near, standard, far, far away. The DS18B20 heat sensor is used to determine the temperature of the room which consists of 5 very cold, standard, warm, hot, very hot categories.
Arduino Mega 2560 is used for the controller of this tool which processes input and output using a fuzzy framework and Arduino pin configuration. The pin installation settings on the microcontroller leg can be seen in Table 7. While the total circuit in the fuzzy control system for temperature regulation with a fan using a temperature sensor and a proximity sensor.
The DS18S20 temperature sensor requires a 4k7 resistor as a pull up resistor for input. This sensor uses a 5v power supply. In the simulation the pot is only used as a distance setting in the hardware, not using the hg pot. This sensor uses a 5v power supply. Potentio in the LCD circuit is used as a contrast control in Hardware of LCD required an additional power supply for the screen light or backlight of 5v with symbol A for the 5v middle and K for the ground.
This pwm amplifier uses an output pin with an active high configuration for input from the microcontroller while the output of this amplifier is inversely active low, resistor 10K is used as a pull down so that the output pin can be off. Table 8 shows the experimental results of the fuzzy control system on the wind fan. Based on the data above, the tool has run within the range, but in experiments it often does not read the sensor. So it is necessary to carry out repeated experiments in order to get the data that can be look for according to the range. But sometimes it doesn't match the range. It is still an evaluation for this tool.

Conclusion
In this study, the fan movement is regulated based on Fuzzy Logic Control with the Mamdani technique. This FLC has 2 inputs namely temperature sensor and PING sensor, and DC motor as the output. In this study, it is simulated through Matlab and Proteus application, then the actual prototype of the device is formed. There are only a few calculation errors in the prototype tool. The performance of the tool is 90% according to the rules that have been designed.