PID-based temperature control device for electric kettle

A normal electric kettle usually is intended to boil water until boiling point and cannot be controlled. Most of the kettle does not provide the temperature display for user to track the current temperature reading. Thus, this project is inspired from the shortcoming of most kettles that are sold at the market. By using Arduino microcontroller, a device is developed to control water temperature inside electric kettle. To provide automated temperature control, PID controller is chosen since it can provides precise water temperature control with less fluctuation. The device is also equipped with the display of the current water temperature and desired temperature. The device is tested to an electric kettle and the performance of PID controller in controlling water temperature is compared to on-off controller. An analysis is performed based on the amount of fluctuation with respect to desired temperature to verify the efficacy of the designed circuit and controller. It is found that the developed device and PID controller are capable to control the water temperature inside kettle based on the desired temperature set by user with less amount of fluctuation.


INTRODUCTION
A common electric kettle consists of two electrical parts, that are heat element and on-off switch as depicted in Figure 1. When electric power supplied to the heat element, it will heats up the water inside kettle at full power to bring the water at 100 • C. The generated steam pressure subsequently will induce the on-off switch to stop the heating process. Based on this simple process, an electric kettle is only serve one purpose: to boil water. To enable the capability of electric kettle of controlling water temperature, it should be equipped with a device that can measure water temperature inside the kettle, thus providing data for the controller of the device to perform correct control action to the heat element. With a correct selection and proper design of the controller, a precise temperature control can be achieved with minimal fluctuation. One of the most prominent controller that can be used in this application is PID controller.
PID controller widely used in industry since it have simple structure and does not require mathematical derivation. It contain three terms: proportional, derivative and integration of the error reading which those will be summed together thus producing analog signal to the actuator to provide treatment for both transient and steady state response. It has been proven to work in controlling linear and nonlinear, fast and slow response systems. With proper tuning method to obtain the suitable PID gains, the precise and stable water temperature at desired setpoint can be prepared.
There are many applications can be adopted if an electric kettle is able to produce warm water at desired level temperature. For example, at 37 • C water temperature, a guardian can prepare warm formula milk for their babies or toddlers [1]. Powder milk is best prepared at 60 • C to obtain perfect solubility [2]. A coffee enthusiast always require heated water of 93 • C for brewing a delicious coffee drink [3]. Tea is best to be prepared at 82 • C for maximum flavour extraction from tea leaves [3].
By having an external device that can control temperature of electric kettle, user does not have to buy an expensive water warmer or similar device to obtain their preferred temperature of warm water. By using a cheap electric kettle and the proposed device that is developed in this project, user is able to obtain the warm water at the desired temperature. There are a few almost similar work has been done which can be used as a reference for this work. In [4], the project of controlling air temperature inside closed case is developed based on PIC16F877 microcotroller. LM35 temperature sensor is used for temperature measurement and proportional controller is used as control algorithm to drive DC-powered lamp and DC-powered fan to control air temperature inside the case. Temperature control inside drying chamner is done by [5]. Arduino Mega 2560 microcontroller is used as a main part and MLX90614 infrared sensor is used for temperature measurement. The microcontoller perform on-off algorithm to control magnetron to control air temperature inside chamber. The magnetron is AC-powered equipment which is driven by TRIAC-based circuit which is activated by PWM signal given by microcontroller. Temperature control of beer brewing process is done in [6] by utilizing Arduino UNO microcontroller and DS180B20 temperature sensor. On-off, proportional and PID controller are tested to compare the control performance in controlling beer temperature.

CIRCUIT DESIGN
The proposed device consists of six main parts: microcontroller, heater driver circuit, temperature sensor, temperature display, reference temperature input and control algorithm. Microcontroller acts as main brain for the device. It provides automated control of temperature reading, temperature display and heater control. Arduino microcontroller is chosen this project since it provides large library and wide hardware support [7].
To enable to capability of temperature control inside kettle, temperature sensor should be utilized. DS180B20 temperature sensor is used since it is water-proof and compatible to be interfaced to any microcontroller using a single digital pin, and even possible to connect multiple same sensors to the same pin. The sensor has a unique 64-bit ID burned-in at the factory to differentiate them which enable the multiple connection at the same pin of microcontroller. Power supply for the sensor is 3.0-5V and capable to measure temperature range from -55 • C to 125 • C.
For heater driver circuit, solid state relay SSR is used since it is easy to be interfaced between microcontroller and AC power supply. It is constructed based on TRIAC-based circuit. It should be noted that to drive SSR to control AC voltage, low frequency PWM (e.g: 0.1 times than the AC voltage frequency) should be used to obtain uniform cycle of AC voltage as illustrated in Figure 2. High frequency PWM (e.g. PWM frequency less frequency of AV voltage) of driving SSR will induce non-uniform phase angle of AC voltages thus making linear relationship between heater power and PWM duty cycle is not possible. Figure 2 and Figure  3 show the effect of AC voltage output when it is driven by low and high PWM frequency that supplied to SSR. In this work, low frequency PWM can be used for water temperature control since water temperature has slow step response. . High freqency PWM to drive an SSR will cause nonuniform phase angle trigger of AC voltage output A variable resistor is used to allow user to set their desired water temperature, and seven segment display is used to show the desired temperature and the current water temperature inside kettle. For control algorithm, PID controller is used in providing automated temperature control, where the PID is coded inside microcontroller. The details of the PID controller and its design is explained in the next section. Figure 4 shows the field diagram reflecting a microcontroller connected with input and output components.

PID CONTROLLER
PID is a proportional-integral-derivative controller, which control loop feedback mechanism. It is commonly used in industrial control system. The first PID controller was develop by Elmer Sperry in 1911 and it is used to automate a ship steering mechanism. On 1922, the first theoretical paper on PID control was develop by Nicolas Minorsky, which then was applied to automatic steering of ships [8]. Figure 5 is the block diagram of a system controlled by PID controller where y(t) is controlled output, r(t) is reference signal, e(t) is error signal and u(t) is control signal.
where e(t) = r(t)−y(t), K p is proportional constant, K i is integral constant and K d is derivative constant. The value of K p , K i and K d are the key in providing stable and desired transient response which can be obtained by using heuristic methods, analytical methods, frequency response method, optimization method and adoptive turning methods [9].
Nowadays, PID control algorithm is always implemented in microcontroller to enable compact design of a product. However, the integral and derivative operation in PID equation of (1) cannot be performed directly by microcontroller. Hence, the integral and derivative term of (1) need to be converted to discrete form. Starting with the derivative term, we can use the following difference equation as an approximation, such that; where e(k) is error signal in discrete domain, e(k−1) is previous error signal and T s is sampling time. Equation (2) is the approximate slope of the tangent line at e(t). The approximation of integral term can be written such that With these approximations, we can rewrite PID control algorithm in discrete form The details derivation and more precise approximation of PID controller in discrete form can be found in [9,10].
The kernel code of implementing discrete PID of (4) in Arduino IDE environment software is shown in Figure 6. Arduino IDE is a software designed for Arduino which allows user to write code in C language, compile, send/receive to/from microcontroller. K p , K i and K d of PID are the parameters that need to be tuned. In this project, the heuristic approach is be used to determine the appropriate values of PID gains. The procedure of determining the PID gains is explained as follows: (i) Set all gains to zero. (ii) Increase the K p gain until the response steadily oscillate. (iii) Increase the K d gain until the oscillations significantly reduced.  Figure 6. Code of PID control algorithm

RESULTS AND DISCUSSION
The block diagram for overall system of this device that is connected to electric kettle is illustrated in Figure 7, where T (t) is water temperature inside kettle and T d is desired temperature. e(t) is error signal, as in .For real-time results, the hardware prototype of this project is connected to an 1500 Watt electric kettle and a PC (for data logging purpose) to verify the performance of the project as shown in Figure 8. For performance analysis of PID controller, the response of water temperature in the kettle is compared to on-off controller. The results are presented in several cases as tabulated in Table 1. The interface of the developed device is depicted in Figure 9 where the seven segment displays are to display current water temperature inside kettle, desired temperature from user and PID controller gains. DS180B20 sensor probe is immersed inside the kettle and the plugtop of electric kettle is connected to the device through switch socket outlet. The device also equipped with a knob to enable user to set their desired temperature. The toggle switch is to select the controller (either PID or on-off controller) for temperature control operation.   Figure 10. The definition of maximum fluctuation in this project.
As explained in previous section, PID controller has gain that need to be tuned which are K p , K i and K d . By using heuristic approach, the gain of PID controller can be determined. Based on the tuning procedure explained in Section III, after several tuning attempts for 45 • C, 65 • C and 80 • C temperature set point, the appropriate gains are successfully obtained and shown in Table 2. The PWM period of control signal u(t) is set to 1 s. Note that the tuning is done when water volume at 500 ml and intial water temperature is 29 • C. The approach to assign different values of PID gain for different set point is known as 'gain scheduling' method. It is also found the execution time for the microcontroller to implement the whole PID control algorithm is 1.13 s which including data logging to PC through USB communication. For performance analysis, the maximum fluctuation of water temperature along the desired temperature is recorded as depicted in Figure 10. Figure 11(a) to Figure 11(c) show the response of water temperature inside kettle when the device is using PID controller. For the CASE 1 experiment, the desired temperature is set at 45 • C and it is found the PID controller is able to generate appropriate PWM signal to the heater thus result in less amount fluctuation of water temperature. The highest fluctuation recorded at this case is 1.5 • C. Same performance of PID controller can be seen when the desired temperature is set at 65 • C and 80 • C where the water temperature is almost same with the desired temperature with a very small fluctuation. The maximum fluctuation recorded for CASE 2 and CASE 3 are 1.3 • C and 1.8 • C.
For comparison purpose, the device also performs on-off controller to control the water temperature. The control signal u(t) for on-off controller is expressed by: However, for case u(t) = −1 if e(t) < 0 has no meaning in this project, thus the term is omitted from the equation. Equation (5) reflect the on-off operation of heater: when T (t) < T d (t), the heater is activated, else T (t) ≥ T d (t)), the heater is deactivated. The time taken for the controller to perform the whole instruction including on-off control algorithm is 1.10 s. The results when the device perform the on-off controller are shown in Figure 12(a) to Figure 12(c). From the figure, a large amount of overshoot can be seen at water temperature response. On-off controller gives instant on and off signal to heater and this type of signal unable to regulate the water temperature with less fluctuation within desired temperature. The amount of fluctuation for CASE 7, CASE 8 and CASE 9 are 5.1 • C, 6.6 • C and 7.5 • C. The maximum fluctuation magnitude of all experiment cases is summarized in Table III. ISSN: 2088-8708 Figure 11. The response of water temperature inside electric kettle when using PID controller at 45 • C, 65 • C and 80 • C (Legend -Blue: desired temperature, red: water temperature inside kettle, yellow: control signal) (a) (b) (c) Figure 12. The response of water temperature inside electric kettle when using on-off controller at 45 • C, 65 • C and 80 • C (Legend -Blue: desired temperature, red: water temperature inside kettle, yellow: control signal) Based on the results, it can be concluded that PID controller is able to provide less amount of water temperature fluctuation as compare to on-off controller thus making it suitable for precise temperature control. However, in this work, the experiments are done by using 500 ml of water. For more water volume, the PID require different set of gains for precise temperature control at different desired temperature. Therefore, for future improvement, different structure of PID or advance controller shall be used which can cover various amount of water volume without performing tedious work to determine controller gain in various conditions. IJECE ISSN: 2088-8708 1691