100% found this document useful (1 vote)
81 views

PID Arduino Control of Temperature by PWM

Uploaded by

Matheus Cardoso
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
81 views

PID Arduino Control of Temperature by PWM

Uploaded by

Matheus Cardoso
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

International Journal of Computer and Systems

Engineering

Manuscript 1004

Arduino-based PID Control of Temperature in Closed Space by


Pulse Width Modulation of AC Voltage
Seiichi Nakamori

Follow this and additional works at: https://digitalcommons.fairfield.edu/ijcase

This item has been accepted for inclusion in DigitalCommons@Fairfield by an authorized administrator of
DigitalCommons@Fairfield. It is brought to you by DigitalCommons@Fairfield with permission from the rights-
holder(s) and is protected by copyright and/or related rights. You are free to use this item in any way that is
permitted by the copyright and related rights legislation that applies to your use. For other uses, you need to obtain
permission from the rights-holder(s) directly, unless additional rights are indicated by a Creative Commons license
in the record and/or on the work itself. For more information, please contact [email protected].
Online at https://digitalcommons.fairfield.edu/ijcase/ Published by Fairfield University, DigitalCommons@Fairfield © 2021

Vol. 2, No. 1, 2021

Arduino-based PID Control of

Temperature in Closed Space by

Pulse Width Modulation of AC

Voltage

by Seiichi Nakamori

ABSTRACT This paper investigates the proportional-integral-differential (PID) constant


temperature control in a closed space of the expanded polystyrene box with Arduino. We use an
incandescent light bulb as a heat source. During constant temperature control, Arduino generates
pulse width modulation (PWM) signals. The PWM signal, applied to the NPN transistor and zero
cross-type SSR, adjusts the alternating current voltage. The IC thermal sensor converts the heat
into electrical voltage, which is proportional to the temperature. Because the electrical voltage
converted by the IC thermal sensor is low, the operational amplifier amplifies the electrical
voltage. The analog-to-digital converter by Arduino digitizes the amplified voltage in 10-bit
resolution. The proportional (P) controller, the proportional-differential (PD) controller, the
proportional-integral (PI) controller, the integral (I) controller, and the PID controller adjust the
constant temperature, respectively. The best PID parameters are 𝑘𝑝 = 100.0, 𝑘𝑖 = 5.0, and 𝑘𝑑 =
5.0 with the I controller working within the deviation ± 3 (℃).

INDEX TERMS Constant temperature control, PWM, AC voltage, Arduino, PID controller, A/D conversion

_____________________________________________________________________________________

1 International Journal of Computer and Systems Engineering Volume 2 Issue 1,


2021
I. INTRODUCTION
Ibrahim (2002) describes constant value control of the temperature using the microcontroller Peripheral Interface
Controller (PIC). In Ibrahim (2002), PIC generates a pulse width modulation (PWM) signal for temperature control.
Fig. 9.7 in Ibrahim (2002) depicts its circuit diagram. The PIC terminal generates the PWM control signal to the gate
of the N-type MOS-FET. The electrical current flows from direct current (DC) 12 [V] supply to the series circuit of a
heater and MOS-FET. The PWM signal adjusts the temperature from the heater. Besides the theory of process
control, it explains the proportional-integral-differential (PID) controller setting and its C program listing. Hebel and
Devenport, with the micro-controller Basic Stamp, explain the PID constant value control of temperature. Here, the
Basic Stamp adjusts the temperature inside the film case. A heat source is the resistance of 47 [Ω]. The series circuit
of the resistance and the NPN-type transistor use the DC 9 [V] supply. The PWM signal from the Basic Stamp controls
the electrical current to the Base terminal of the transistor. Ibrahim (2006) describes the proportional-integral (PI)
control of the liquid level using PIC. Ogata (2010) explains two Ziegler-Nichols rules for tuning the PID controller in
the continuous-time system based on the step response of the plant, and the critical gain with the oscillation period.
In the feedback control of the temperature with the PIC, we use the sampled temperature data in a discrete-time
system. Ogata (1995) describes the control problems in the discrete-time system. Syouwa Dengyou Inc. provides a
PID temperature control learning device with a personal computer in the constant value control of temperature.
Nakamori and Sonoda (2014), by referring to “Electronic work 31”, studies the constant illumination control of an
incandescent lamp, with PIC, based on the phase delay in the AC voltage. Nakamori et al. (2015), with PIC, shows the
constant value control, by the integral (I) controller, to adjust the temperature at the IC thermal sensor transmitted
through space from two kinds of heat sources. One is the incandescent lamp, and the other is the soldering iron.
Nakamori (2017) examined constant value control of the temperature in the closed space of the expanded
polystyrene (EPS) box. Here, the heat source is the incandescent lamp. For constant temperature control, Arduino
generates the PWM signal to a zero cross-type SSR through an NPN transistor to control the AC voltage. The IC
thermal sensor converts the heat into an electrical voltage, which is proportional to the temperature. Since the
electrical voltage converted by the IC thermal sensor is low, the operational amplifier amplifies the electrical voltage
so that the analog-to-digital converter (ADC) in Arduino can digitize it to 10 bits resolution. The I controller operates
in adjusting the temperature constant. This paper, using the same circuit as in Nakamori (2017)
with Arduino, extends the study on the I controller to the proportional (P), proportional-differential (PD),
proportional-integral (PI), and PID controllers for the desired temperature 40 [℃]. In the experiment, we used the
incandescent lamp as a source of heat. We get parameters experimentally along with the proportional (P),
proportional-differential (PD), proportional-integral (PI), I, and PID controllers from the points of transient response,
overshoot, and steady-state error, i.e. quality requirements of the control system. In the PI, I, and PID controllers,
the overshoots are relatively large. To reduce the overshoot of the PID controller, considering the feasible transient
response of the PD controller, we insert the I controller when the absolute deviation of controlled temperature from
the reference input is less than 3 [℃] similarly to the technique by Villasante-Muñoz. In Villasante-Muñoz Arduino
generates a PWM signal to the solid-state relay (SSR) to turn on or off the heater, connected to the AC 200 [V], for
the temperature adjustment by the PID controller. Here, the I controller has been added to the PD controller on the
condition that the absolute steady-state deviation is less than 3 [℃].
The goal of this article is to clarify the parameter setting method in the PID controller experimentally through
the parameter settings in the P, PD, I, and PI controllers. The best PID parameters are 𝑘𝑝 = 100.0, 𝑘𝑖 = 5.0, and
𝑘𝑑 = 5.0 with the I controller working within the deviation ± 3 (℃). The PWM control signal varies in a stochastic
manner from the experiments in Section 3.
Usually, the PID controller (Silva et al., 1973) does not need the space-state model information on the
controlled object. Assuming knowledge of a state-space model, Zheng et al. (2002), and He and Wang (2006), based
on the iterative linear matrix inequality (ILMI) technique, and Shimizu (2016, 2020) and Goyal et al. (2020), based on
the LMI, design the multivariate robust PID controllers. This approach requires first of all the state-space model of
the controlled object.

_____________________________________________________________________________________

2 International Journal of Computer and Systems Engineering Volume 2 Issue 1,


2021
Section 2 presents the block diagram of the temperature feedback control system. Section 3, according to a
circuit diagram for the constant value control of temperature, shows the procedure to select parameters in the PID
controller experimentally through the P, PD, PI, and I controllers, respectively.

II. BLOCK DIAGRAM OF FEEDBACK CONTROL FOR CONSTANT TEMPERATURE ADJUSTMENT


Fig. 1 illustrates the block diagram of the feedback control system for constant temperature adjustment.

Fig. 1 Block diagram of the feedback control system for constant temperature adjustment.

Desired steady-state and transient responses are as follows:

(1) The steady-state deviation converges to zero.

(2) The overshoot is small.

(3) Rise time is short.

(4) Settling time is short.

(5) Delay time is short.

The proportional, integral, and derivative coefficients for the PID controller are tuned based on the above
performance appropriately.

The overall control function [1] is given by

1 𝑡 𝑑𝑒(𝑡)
u(t) = 𝑘𝑝 (𝑒(𝑡) + ∫ 𝑒(𝑡)𝑑𝑡 + 𝑇𝑑 ).
𝑇𝑖 0 𝑑𝑡
𝑘𝑝 : proportional gain; 𝑇𝑖 : integral time constant; 𝑇𝑑 : derivative time constant;

u(t): control input to the process; e(t): deviation in Fig. 1.

Section 3 presents PID control experiments for constant temperature.

III. PID CONTROL EXPERIMENTS FOR CONSTANT TEMPERATIRE ADJUSTMENTS

• Fig. 2 shows the circuit scheme for constant temperature control on the thermal sensor IC LM35DZ with
incandescent light as a heat source. The outline of the operation is as follows.

_____________________________________________________________________________________

3 International Journal of Computer and Systems Engineering Volume 2 Issue 1,


2021
(1) The Base terminal of the transistor NPN 2SC1815 receives the PWM pulse from port 9 of Arduino. During the
PWM control signal is 5 [V], the electrical current flows to the Phototriac TLP561J, and the trigger pulse occurs from
the Phototriac.

Fig. 2 Circuit diagram for constant temperature control (Nakamori, 2017).

(2) The IC LM35DZ thermal sensor converts heat from the 100 [W] incandescent lamp to DC voltage.

(3) Both Phototriac and Triac work as a zero-cross solid state relay (SSR) (Nakamori, 2017; Suzuki, 2016). Following
the zero-cross switching of the SSR, the AC voltage, with the zero-cross waveform, is supplied to the filament lamp.

(4) Because the voltage of the IC thermal sensor is low, the operational amplifier LM358N boosts the voltage. The
temperature coefficient of the IC thermal sensor is 10.0 [mV/℃], and the temperature accuracy of LM35DZ is ± 1/4
[℃] at room temperature.

(5) The voltage, amplified in step (2), is A/D converted by Arduino with a resolution of 10 [bits]. The 10-bit analog-
to-digital converter (ADC) divides the voltage range (0 ~ 5 [V]) into 10-bit levels 0 ~ 1023.

(6) In the experiment of Section 3, the reference input level is 400 for temperature 40 [℃].

(7) Comparing the reference input level with the A/D converted value in Arduino, P, PD, PI, I, and PID controllers
operate so that the A/D converted value approaches the reference input level, respectively. If the PWM value
changes to negative, we set the value to zero. If the PWM value exceeds 255, we set the value to 255.

_____________________________________________________________________________________

4 International Journal of Computer and Systems Engineering Volume 2 Issue 1,


2021
Fig. 3 Layouts in the experiment of constant temperature control: Arduino, LCD circuit on the breadboard, solid-
state relay semiconductor kit, the NPN transistor on a small breadboard, EPS box, etc. (Nakamori, 2017).

Fig. 3 shows the experimental picture of constant temperature control. EPS box, Arduino, solid-state relay
semiconductor kit, which consists of phtotriac and triac, etc., liquid crystal display (LCD), etc. are located. As shown
in Fig.4, the IC thermal sensor and the incandescent lamp are placed in the EPS box. The depth, width, height and
thickness within the EPS box are 14.5 [cm], 35 [cm], 28 [cm] and 2.5 [cm]. EPS belongs to the thermal insulation
material. The material having a thermal conductivity not exceeding 0,05 [W/m・K] is referred to as the thermal
insulation material. Fig. 5 shows the PID control program, which controls the temperature of the IC thermal sensor.
In the program, the control input has the form:
𝑘
𝑒(𝑘) − 𝑒(𝑘 − 1)
u(k) = 𝑘𝑝 𝑒(𝑘) + 𝑘𝑖 ∑ 𝑒(𝑖)∆𝑡 + 𝑘𝑑 ,
∆𝑡
𝑖=1

∆t = 1.12 (second), Deviation: e(k) = R(k) − M(k) ( see the block diagram of Fig. 1)
R(k): the desired temperature at discrete time k∆. M(k): the measured temperature at discrete time k∆.

Because the change of the temperature inside the EPS box is relatively slow, the value of ∆𝑡 is set to 1.12. The
discrete-time control input u (k) is not strictly a numerical expression for the control input u(t) in continuous-time
systems. In this paper, we examine to adjust the PID parameters 𝑘𝑝 , 𝑘𝑖 , and 𝑘𝑑 from the viewpoints of the transient
and steady-state performances such as the overshoot, rise time, settling time, delay time, and the steady-state
deviation. In the PID programs of Fig. 5 and Fig. 16, dt stands for ∆𝑡.

_____________________________________________________________________________________

5 International Journal of Computer and Systems Engineering Volume 2 Issue 1,


2021
Fig. 4 Inside the EPS box. The IC thermal sensor and incandescent lamp are placed (Nakamori, 2017).

// PID control program; desired temperature: 40 [degrees


Celsius]
const float moku=400;
// kp=1; kp=5; kp=100
const float kp=100;
// ki=.8; ki=1; ki=5
const float ki=5.0;
// kd=1; kd=5
const float kd=5.0;
float dt;
float d;
float pretime;
float P,I,D;
float PreP = 0;
int co;
int pre;
float PID_error = 0;
long PID_p = 0;
int i;

_____________________________________________________________________________________

6 International Journal of Computer and Systems Engineering Volume 2 Issue 1,


2021
void setup() {
Serial.begin(9600);
pinMode(9,OUTPUT);
co=10;
}

void loop() {
analogWrite(9,co);
for(int i=0; i<1000; i++){
d+=analogRead(A0);
}
d=d/1000;
dt=(micros()-pretime)/1000000;
//Serial.print("dt=");
//Serial.println(dt);

pretime=micros();
PID_error=moku-d;
I+=PID_error*dt;D=(PID_error-PreP)/dt;
PreP=PID_error;

// PID controller:
co = kp*PID_error+kd*D+ki*I;

// P controller:
//co = kp*PID_error;

// PD controller:
//co = kp*PID_error+kd*D;

// PI controller:
co = kp*PID_error+ki*I;
Serial.print("check=");
Serial.println(d);
delay(500);
if (co <0) {
co=0;
}
else if (co >255) {
co=255;
}
else {
// operation C
co=co;
}

_____________________________________________________________________________________

7 International Journal of Computer and Systems Engineering Volume 2 Issue 1,


2021
Serial.print("control=");
Serial.println(co);
analogWrite(9,co);
delay(500);
}
Fig. 5 PID control program.

In Fig.5 the computed value of dt is 1.12 (second). Fig. 6 illustrates the temperature vs. time (second) by the P
controller for 𝑘𝑝 = 1.0, 𝑘𝑝 = 5.0 and 𝑘𝑝 = 100. As 𝑘𝑝 increases, the delay time becomes shorter and the steady-
state deviation is reduced. From Fig. 5 we see that the P controller has this feature so the steady-state deviation
remains. Fig. 7 illustrates the PWM control signal vs. time (second) by the P controller for 𝑘𝑝 = 1.0, 𝑘𝑝 = 5.0 and
𝑘𝑝 = 100. Fig. 8 illustrates the temperature vs. time (second) by the PD controller for 𝑘𝑝 = 5.0, 𝑘𝑑 = 1.0 and 𝑘𝑝 =
5.0, 𝑘𝑑 = 5.0. From Fig. 7 and Fig. 8, for 𝑘𝑝 = 5.0, by adding the D controller to the P controller, i.e. for the PD
controller, the deviation of the stationary state is reduced. Fig. 9 illustrates the PWM control signal vs. time (second)
by the PD controller for 𝑘𝑝 = 5.0, 𝑘𝑑 = 1.0 and 𝑘𝑝 = 5.0, 𝑘𝑑 = 5.0. Fig. 10 illustrates the temperature vs. time
(second) by the PI controller for 𝑘𝑝 = 100.0 and 𝑘𝑖 = 0.8, 𝑘𝑝 = 100.0 and 𝑘𝑖 = 1.0, and 𝑘𝑝 = 100.0 and 𝑘𝑖 = 5.0.
In Fig. 10 the overshoot is significant for 𝑘𝑖 = 1.0 and 𝑘𝑖 = 5.0. By adding the I controller to the P controller, i.e., in
the PI controller, the steady-state deviation converges to zero as time progresses. Fig. 11 illustrates the PWM control
signal vs. time (second) with the PI controller for 𝑘𝑝 = 100.0 and 𝑘𝑖 = 0.8, 𝑘𝑝 = 100.0 and 𝑘𝑖 = 1.0, and 𝑘𝑝 =
100.0, 𝑘𝑖 = 5.0. Fig. 12 illustrates the temperature vs. time (second) by the I controller for 𝑘𝑖 = 0.5, 𝑘𝑖 = 1.0 and
𝑘𝑖 = 5.0. Fig. 13 illustrates the PWM control signal vs. time (second) by the I controller for 𝑘𝑖 = 0.5, 𝑘𝑖 = 1.0 and
𝑘𝑖 = 5.0. Fig. 12 shows that the overshoot by the I controller is significant and the settling time is long. However,
the steady-state deviation converges to zero. Fig. 14 illustrates the temperature vs. time (second) with the PID
controller for 𝑘𝑝 = 30.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0, 𝑘𝑝 = 70.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0, and 𝑘𝑝 = 100.0, 𝑘𝑖 = 5.0 and
𝑘𝑑 = 5.0. Fig. 15 illustrates the PWM control signal vs. time (second) with the PID controller for 𝑘𝑝 = 30.0, 𝑘𝑖 = 5.0
and 𝑘𝑑 = 5.0 , 𝑘𝑝 = 70.0 , 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0 , and 𝑘𝑝 = 100.0 , 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0 . Compared to the I
controller, the settling time by the PID controller is short. The steady-state deviation by the PID controller converges
to zero about 300 (second) later. The overshoot by the PID controller is as significant as that by the I controller.
Compared to the PI controller for 𝑘𝑝 = 100.0 and 𝑘𝑖 = 1.0, and 𝑘𝑝 = 100.0 and 𝑘𝑖 = 5.0, the overshoot by the PID
controller is relatively large.

_____________________________________________________________________________________

8 International Journal of Computer and Systems Engineering Volume 2 Issue 1,


2021
Fig. 6 Temperature vs. time (second) by P controller for 𝑘𝑝 = 1.0, 𝑘𝑝 = 5.0 and 𝑘𝑝 = 100.

Fig. 7 PWM control signal vs. time (second) by P controller for 𝑘𝑝 = 1.0, 𝑘𝑝 = 5.0 and 𝑘𝑝 = 100.

_____________________________________________________________________________________

9 International Journal of Computer and Systems Engineering Volume 2 Issue 1,


2021
Fig. 8 Temperature vs. time (second) by PD controller for 𝑘𝑝 = 5.0, 𝑘𝑑 = 1.0 and 𝑘𝑝 = 5.0, 𝑘𝑑 = 5.0.

Fig. 9 PWM control signal vs. time (second) by PD controller for 𝑘𝑝 = 5.0, 𝑘𝑑 = 1.0 and 𝑘𝑝 = 5.0, 𝑘𝑑 = 5.0.

_____________________________________________________________________________________

10 International Journal of Computer and Systems Engineering Volume 2 Issue 1,


2021
Fig. 10 Temperature vs. time (second) by PI controller for 𝑘𝑝 = 100.0 and 𝑘𝑖 = 0.8, 𝑘𝑝 = 100.0 and 𝑘𝑖 = 1.0, and
𝑘𝑝 = 100.0 and 𝑘𝑖 = 5.0.

Fig. 11 PWM control signal vs. time (second) by PI controller for 𝑘𝑝 = 100.0 and 𝑘𝑖 = 0.8, 𝑘𝑝 = 100.0 and 𝑘𝑖 = 1.0,
and 𝑘𝑝 = 100.0, 𝑘𝑖 = 5.0.

_____________________________________________________________________________________

11 International Journal of Computer and Systems Engineering Volume 2 Issue 1,


2021
Fig. 12 Temperature vs. time (second) by I controller for 𝑘𝑖 = 0.5, 𝑘𝑖 = 1.0 and 𝑘𝑖 = 5.0.

Fig. 13 PWM control signal vs. time (second) by I controller for 𝑘𝑖 = 0.5, 𝑘𝑖 = 1.0 and 𝑘𝑖 = 5.0.

_____________________________________________________________________________________

12 International Journal of Computer and Systems Engineering Volume 2 Issue 1,


2021
Fig. 14 Temperature vs. time (second) by PID controller for 𝑘𝑝 = 30.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0, 𝑘𝑝 = 70.0, 𝑘𝑖 = 5.0
and 𝑘𝑑 = 5.0, and 𝑘𝑝 = 100.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0.

Fig. 15 PWM control signal vs. time (second) by PID controller for 𝑘𝑝 = 30.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0, 𝑘𝑝 = 70.0,
𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0, and 𝑘𝑝 = 100.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0.

To reduce the overshoot and the settling time in Fig. 14 by the PID controller, this paper presents the Arduino
program of Fig. 16, compared to the program in Fig. 5, the bold italic typeface lines of Fig.16 are newly inserted for
the I controller in the PID controller. That is, the I controller in the PID controller operates within the deviation ± 3
(℃). If the absolute value of the deviation exceeds 3 (℃), the PD controller works. Taking into consideration the
feasible transient features of Fig. 8 for the rise time, settling time, and delay time by the PD controller, this operation
is introduced. Villasante-Muñoz suggests this idea associated with the I controller. Fig. 17 illustrates the temperature

_____________________________________________________________________________________

13 International Journal of Computer and Systems Engineering Volume 2 Issue 1,


2021
vs. time (second) by the PID controller for 𝑘𝑝 = 30.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0, 𝑘𝑝 = 70.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0,
and 𝑘𝑝 = 100.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0 with the I controller working within the deviation ± 3 (℃). Fig. 18 illustrates
the PWM control signal vs. time (second) by the PID controller for 𝑘𝑝 = 30.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0, 𝑘𝑝 = 70.0,
𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0, and 𝑘𝑝 = 100.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0 with the I controller working within the deviation ±
3 (℃). This PID control experiment shows preferable transient characteristics of the overshoot and the settling time
in the order of 𝑘𝑝 = 100.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0, and 𝑘𝑝 = 70.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0. For PID settings 𝑘𝑝 =
100.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0, and 𝑘𝑝 = 70.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0, after about 200 (second), the steady-state
deviation converges to zero. The best PID settings are 𝑘𝑝 = 100.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0 with the I controller
working within deviation ± 3 (℃).

// PID control program; desired temperature: 40 [degrees Celsius]


const float moku=400;
// kp=1; kp=5; kp=30; kp=50; kp=100
const float kp=70.0;
// ki=0.8; ki=1; ki=5
const float ki=5.0;
// kd=1; kd=5
const float kd=5.0;
float dt;
float d;
float pretime;
float P,I,D;
float PreP = 0;
int co;
int pre;
float PID_error = 0;
long PID_p = 0;
int i;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(9,OUTPUT);
co=10;
}

void loop() {
analogWrite(9,co);
for(int i=0; i<1000; i++){
d+=analogRead(A0);
}
d=d/1000;
dt=(micros()-pretime)/1000000;
//Serial.print("dt=");
//Serial.println(dt);
pretime=micros();
_____________________________________________________________________________________

14 International Journal of Computer and Systems Engineering Volume 2 Issue 1,


2021
PID_error=moku-d;
if(-30 < PID_error <30) {
I+=PID_error*dt;
}
I+=PID_error*dt;
D=(PID_error-PreP)/dt;
PreP=PID_error;
// PID controller:
co = kp*PID_error+kd*D+ki*I;
// P controller:
//co = kp*PID_error;
// PD controller:
//co = kp*PID_error+kd*D;
// PI controller:
// co = kp*PID_error+ki*I;
// I controller
//co = ki*I;
//Serial.print("D=");
//Serial.println(D);
Serial.print("check=");
Serial.println(d);
delay(500);
if (co <0) {
// operation A
co=0;
}
else if (co >255) {
// operation B
co=255;
}
else {
// operation C
co=co;
}
Serial.print("control=");
Serial.println(co);
analogWrite(9,co);
delay(500);
}

Fig. 16 PID control program with I controller working within deviation ± 3 (℃).

_____________________________________________________________________________________

15 International Journal of Computer and Systems Engineering Volume 2 Issue 1,


2021
Fig. 17 Temperature vs. time (second) by PID controller for 𝑘𝑝 = 30.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0, 𝑘𝑝 = 70.0, 𝑘𝑖 = 5.0
and 𝑘𝑑 = 5.0, and 𝑘𝑝 = 100.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0 with the I controller working within deviation ± 3 (℃).

Fig. 18 PWM control signal vs. time (second) by PID controller for 𝑘𝑝 = 30.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0, 𝑘𝑝 = 70.0,
𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0, and 𝑘𝑝 = 100.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0 with the I controller working within deviation ± 3
(℃).

_____________________________________________________________________________________

16 International Journal of Computer and Systems Engineering Volume 2 Issue 1,


2021
Fig. 19 Phase width modulated waveform (upper figure), for the PWM value 128, of the AC voltage waveform (lower
figure) (Nakamori, 2017).

Fig. 19 shows the pulse width modulated waveform of the AC voltage, by the zero-cross SSR for the PWM value
128. The voltages in Fig. 19 display the 1/10 values of the effective or root-mean-square (RMS) values and the peak-
to-peak values of the AC voltages measured through the probes of channels 1 and 2.

IV. CONCLUSION
This paper has proposed the constant control technique of the temperature using Arduino in a closed space of the
EPS box by adjustments of the temperature at the IC thermal sensor by the incandescent lamp. For the constant
temperature control with Arduino, the PWM technique is applied to the AC voltage by using the NPN transistor,
solid-state relay semiconductor kit as the zero cross-type SSR, etc. The P, PD, PI, I and PID controllers adjust the
constant temperature, respectively. For the desired temperatures 40 [ ℃], as time progresses, the controlled
temperature converges to the desired temperature for the PI, I, and PID controllers, including the I controller. For P
and PD controllers, the steady-state deviation remains. Fig. 17 illustrates the temperature vs. time (second) by the
PID controller for 𝑘𝑝 = 30.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0, 𝑘𝑝 = 70.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0, and 𝑘𝑝 = 100.0, 𝑘𝑖 = 5.0
and 𝑘𝑑 = 5.0 with the I controller working within the deviation ± 3 (℃). The overshoot and the settling time are
achievable in the order 𝑘𝑝 = 100.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0, and 𝑘𝑝 = 70.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0. For PID settings
𝑘𝑝 = 100.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0, and 𝑘𝑝 = 70.0, 𝑘𝑖 = 5.0 and 𝑘𝑑 = 5.0, after about 200 (second), the steady-
state deviation converges to zero. The best PID parameters are 𝑘𝑝 = 100.0, 𝑘𝑖 = 5.0, and 𝑘𝑑 = 5.0 with the I
controller working within the deviation ± 3 ( ℃ ). PWM control signal varies stochastically as seen from the
experiments in Section 3.
Learning about the constant value control of temperature in closed space could be helpful for the students of high
school or university to understand the PID control concept with the inexpensive experimental device in this paper.

REFERENCES
[1] Ibrahim, D., Microcontroller Based Temperature Monitoring and Control. Elsevier Science & Technology
Books, 2002.

[2] Hebel, M. and W. Devenport, “Industrial Control - Student Guide, Version 1.1.” Parallax Inc. [Online].
Available: http://mega-
avr.net/file/LITERATURA/PROGRAM/MK/Industrial%20Control%20(Students%20guide,%201999,%20%20v1.
1%20).pdf
_____________________________________________________________________________________

17 International Journal of Computer and Systems Engineering Volume 2 Issue 1,


2021
[3] Ibrahim, D., Microcontroller Based Applied Digital Control. John Wiley & Sons, 2006.

[4] Ogata, K., Modern Control Engineering, 5th ed. Prentice Hall, 2010.

[5] Ogata, K., Discrete-Time Control Systems, 2nd ed. Prentice-Hall, 1995.

[6] “PID temperature control learning device, KENTAC 3522-S.” Syouwa Dengyou Inc. [Online]. Available:
https://www.k-sd.co.jp/kentac3522s/

[7] Nakamori, S. and T. Sonoda, “Constant illumination control of filament lamp by phase delay of AC voltage,”
Natural Science, Bulletin of the Faculty of Education, Kagoshima University, vol. 65, pp. 23–34, pp. 23–34,
2014.

[8] “Electronic work 31, Control of Triac by PIC, -PIC Controlled Dimmer, PICBasic Pro-.” [Online]. Available:
http://electroprojsk.fan.coocan.jp/eproj31.htm

[9] Nakamori, S., Akashi, M., Tsurudome, K. and T. Okugawa, in Microcontroller-based Integral Control of
Temperature by Phase Delay of AC Voltage. Horizons in Computer Science Research, vol. 12, NOVA Science
Publishers, 2015, pp. 65–80.

[10] Nakamori, S., “Arduino-Based Integral Control of Temperature in a Closed Space by Applying PWM
Technique to AC Voltage,” in Horizons in Computer Science Research., vol. 15, NOVA Science Publishers,
2017, pp. 209–222. [Online]. Available: https://novapublishers.com/shop/horizons-in-computer-science-
research-volume-15/

[11] Villasante-Muñoz, J. Jesus, ELECTRONOOBS -Temperature Controller-Code-. [Online]. Available:


http://electronoobs.com/eng_arduino_tut142_code1.php

[12] Silva, G. J., Datta A. and S. P. Bhattacharyya, PID Controllers for Time-Delay Systems. Birkhauser, 1973.

[13] Zheng, F., Wang, Q.-G. and T. H. Lee, “On the design of multivariable PID controllers via LMI approach,”
Automatica, vol. 38, pp. 517–526, 2002.

[14] He, Y. and Q. G. Wang, “An improved ILMI method for static output feedback control with application to
multivariable PID control,” IEEETransactionsonAutomaticControl, vol. 51, no. 10, pp. 1678–1683, 2006.

[15] Shimizu, K., “Dynamic output feedback control and dynamic PID control for linear MIMO systems via LMI,”
2016 IEEE Conference on Control Applications (CCA), 2016, doi: 10.1109/CCA.2016.7587940.

[16] Shimizu, K., Proportional-Integral-Differential Controller. Ohmsha, 2020.

[17] Goyal, J. K., Aggarwal, S., Sahoo, P. R., Ghosh, S. and S. Kamal, “Design of robust PID controller using static
output feedback framework,” IFAC PapersOnLine, vol. 53–1, pp. 13–18, 2020, doi:
10.1016/j.ifacol.2020.06.00.

[18] Suzuki, M., Arduino Radio Robot Crafts by XBee. Tokyo Denki University Press, 2016.
https://web.tdupress.jp/downloadservice/ISBN978-4-501-33160-3/
Seiichi Nakamori is a Specially Appointed Professor in the Faculty of Education, Kagoshima University, from April, 2017 to date. He
was appointed Professor Emeritus, Kagoshima University, in April 2016. He was a Professor, Department of Technology, Graduate
School of Education, Kagoshima University from April, 1994 to March 2016, Associate Professor, in the Department from April, 1987
to March, 1994 and a lecturer, Interdisciplinary Chair (Applied Mathematics), Faculty of Engineering, Oita University, from April, 1985
to March, 1987.

He received the B.E. degree in Electronic Engineering from Kagoshima University in 1974 and the Dr. Eng. Degree in Applied
Mathematics and Physics from Kyoto University in 1982. He is mainly interested in stochastic signal estimation and image restoration
problems

_____________________________________________________________________________________

18 International Journal of Computer and Systems Engineering Volume 2 Issue 1,


2021

You might also like