You are on page 1of 52

PID Control Buck Converter By

using Arduino UNO


by nattaponPosted on27/03/2020

This project is an experiment to control the output voltage to be constant. For a


switching buck converter circuit by using an Arduino UNO microcontroller and a
closed-loop control program in the form of PID Control by sending the output
voltage value with a voltage divider circuit at the pin. A0 of the Arduino board and
sends a control signal to the power MOSFET in the form of pulse modulation
(PWM Signal) from pin 3 (D3) for switching to constant voltage at the output.
Figur
e 1 Prepare various equipment for testing.

Figure 1 shows the characteristics of the device used to construct a switching buck
converter circuit. For this experiment, a general-purpose PCB will be used.

Figur
e 2. The output inductor wound up for the experiment.

In Figure 2, the inductor on the output side uses a terroy core. Diameter 3.5 cm.,
black color and use wire No. 20 AWG wound about 55 turns in the core, which
will have an inductance of about 200uH/5A.
Fig. 3
Characteristics of the assembled buck converter circuit.

When the circuit is completed, it is shown in Figure 3. In the figure, it is seen that
the circuit is connected on the copper side of a multi-purpose PCB for easy
experimentation, correction, measurement of various signals. and connecting the
control signal and feedback signal back to the Arduino UNO control board.

Pictu
re 4 connection with Arduino UNO controller board

then assembling various circuits together, shown in Figure 4, which has 3


components: the control part of all operations is the Arduino UNO board (blue
board), the switching buck converter board (It's a universal board) and the resistors
for testing the circuit are 2 resistors of 10 ohms, 20 watts.
Figu
re 5 The experiment for the circuit to supply current to the load

Figure 5 shows the experimental characteristics of the circuit supplying current to


the load at currents of 0.5A and 1A by using a clamp meter to measure the
resulting current.
/
Example PID Control for Buck Converter
Reading analog input A0 for Control PWM signal output D3
Fs = 35kHz, Vo = 10V, Vi = 15-20V
R&D By : www.electronicsDNA.com
Date : 22-3-2020, (V.0)
/
#include <PWM.h>
#include <PID_v1.h>

int32_t frequency = 35000; //frequency (in Hz)


//Define Variables we'll be connecting to
double Setpoint, Input, Output;
//Specify the links and initial tuning parameters
double Kp=3, Ki=1, Kd=0; // 2 5 1
PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, DIRECT);

void setup()
{
Serial. begin(9600);
InitTimersSafe();
bool success = SetPinFrequencySafe(3,frequency);
Setpoint = 500;
//turn the PID on
myPID.SetMode(AUTOMATIC);
}

void loop()
{
Input = analogRead(A0);
// Serial.println(Input);
myPID.Compute();

// analogWrite(PIN_OUTPUT, Output);
pwmWrite(3, Output);
// Serial.println(Output);
}

Library PID_v1.h : http://www.mediafire.com/file/1zc1xngmdgmuhlm/Arduino-


PID-Library.zip/file

Library PWM.h : http://www.mediafire.com/file/rny8gch6anqeuxk/PWM-


master.zip/file

Fi
gure 6. Oscilloscope in response to a 10 ohm load.

Figure 6 shows an oscilloscope screen in response to a 10 ohm load with a


switching frequency set at 35kHz. periodically according to the size of the
connected load
F
igure 7 shows the power supply for testing the circuit.

In Figure 7 is a 20V/2A power supply for the experimental circuit, which we can
observe. Behavior in terms of input power and the performance of this preliminary
circuit

Figure 8 Editing the PID_v1.h library file at the Location SampleTime

In Figure 8, the program will modify the PID_v1.h library file where the
SampleTime position from the original value is equal to 0.1S. Let us change it to
the value of 0.001S instead in order to increase the duration of checking the error
value (Error). and is suitable for the response speed of the output voltage change.

Figure 9. The buck converter circuit designed and used in the experiment.

In Figure 9 is the buck converter circuit used in this experiment. It is designed to


require minimal equipment and can work according to the concept that was
planned. As for the output filter circuit, an inductor is approximately combined
with a capacitor. to make circuit design easier and faster And it will take a little
testing and adjusting the frequency to make the circuit effective. And the energy
loss inside the inductor is minimal.
Basics PID Control Constant
Current Based on Arduino UNO
by nattaponPosted on24/04/2020

Experiment with another project with constant current control. By using the
Arduino UNO board using a PID Control program and using a PWM signal to
adjust the current that needs to be controlled to be stable. and receive a feedback
signal to analog pin A0 to read the value that occurs in the work (Process Value:
PV) and compare with the value that determines the operation of the system (Set
Point: SP), which will be The error value (Error) allows the program to adjust the
compensation value. (Compensation) that is appropriate correctly.

Figure 1 shows the


power supply voltage in the experiment.
From Figure 1, the multimeter will measure the voltage of the power supply used
in the test equal to 6.58V, which will be supplied to the circuit in the project. (The
schematic diagram of this project is shown in the figure below of this project.)

Figure 2. Current
value measured by setting Setpoint = 0.5A.

Figure 2 is a measurement of the resulting current. In which we will set the current
to be controlled at (Set point) 0.5A and the result from the power supply at the
voltage value of 6.58V is equal to 0.49A.

Figure 3 shows the


pulse width modulation signal when the input voltage is approximately 6.58V.

In Figure 3, an oscilloscope shows the characteristics of the resulting pulse-width


modulation signal. By optimizing (letting the process value close to or equal to the
set point) to maintain the required current amount equal to 0.5A, it will be noticed
that the Ton value is quite wide, almost 100%.
Figure 4. Tried
adjusting the voltage of the power supply to a higher level.

The next picture 4 is an experiment to increase the voltage of the power supply to
10V and test the operation of the circuit. This is to observe the response of the
system when the input voltage is unstable.

Figure 5 shows the


current measured when the input voltage is raised to 10V.

Figure 5 shows the measured current value when the input voltage is increased at
10V, it is equal to 0.52A, which the result is slightly higher than the value we need
(Setpoint), about 0.02A, which is still acceptable.
Figure 6. Pulsed
modulation signal characteristics in response to 10V input voltage.

In Figure 6, it can be seen that the nature of the resulting signal As the input
voltage increases, the duty cycle decreases. Compared to the supply voltage of
6.58V, this is to adjust in response to changes in input voltage and maintain a
constant current value.

Figure 7 shows an
input voltage increase of 15V.

Fig. 7 Same characteristics as the previous experiment. When experimenting to


adjust the voltage of the power supply increased to 15.02V and observed the
response behavior of the work.
Figure 8. The
current measured when the input voltage was increased to 15V.

Figure 8 shows the amount of current generated. When adjusting the voltage of the
power supply to 15.02V, the value is equal to 0.55A.

Figure 9. Pulse-
width modulated signal in response to an input voltage of 15V.

Fig. 9 The signal characteristics will have a reduced duty cycle. Compared with the
pressure of the previous experiment. And in the experiment, increasing the power
supply voltage to 20.01V in the next figure below gives a similar result.
Figure 10 The
experimental power supply voltage was increased to approximately 20V.

Figure 11 The
amount of current generated at the 20.01V power supply is equal to 0.58A.

Figure 11 The amount of current that occurs when the power supply is
approximately 20.01V, equal to 0.58A, with an error of 0.08A.
Figure 12. The
resulting modulation pulse signal.

Figure 12 shows the characteristics of the pulse width modulation signal, the duty
cycle will decrease. and a small error value of 0.08A

Figure 13
Characteristics of the experimental project

In Figure 13, all the circuits used in the test are connected and connected
together. During the experiment, the 10 ohm resistor (load) was quite hot so had to
use a fan to blow the heat to reduce the heat.
/*************************************************** *******
* PID Basic Example
* Reading analog input 0 to control analog PWM output 3
* Application for Current Contance Control
************************************************** ******/

#include <PWM.h>
#include <PID_v1.h>

int32_t frequency = 35000; //frequency (in Hz)


double Setpoint, Input, Output;
double Kp=3, Ki=0.2, Kd=0;
PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, DIRECT);

void setup()
{
Serial. begin(9600);
InitTimersSafe();
bool success = SetPinFrequencySafe(3,frequency);

Setpoint = 115; // 120 is SET Current load = 0.5A


myPID.SetMode(AUTOMATIC); //turn the PID on
}

void loop()
{
Input = analogRead(A0);
// Serial.println(Input); // Debuger Input feedback
myPID.Compute();
// analogWrite(PIN_OUTPUT, Output);
pwmWrite(3,Output);
// Serial.println(Output); // Debuger PWM Signal Driver MOSFET

*** Arduino PWM Library —-> Arduino PWM Frequency Library

*** Arduino Library PID Contro l —-> Arduino-PID-Library

Figure 14 Characteristics of various circuit connections used in the experiment

From the figure above, Figure 14 is the nature of the circuit connection. used in
experiments by devices that will function as switching It is a power MOSFET
STP105N3LL which will control signal as pulse modulated from pin 3 and use a 1
ohm 1 watt resistor to detect the current that occurs. The voltage drop across this
resistor will pass through the low pass filter circuit again before feeding it to pin
A0, which this pin will be a feedback pin.

From past experiments, it is concluded that To control the constant current by


programming PID Control to the Arduino UNO board, the program will try to
control the constant current value as we want (Set Point), even though the voltage
of the power supply has changed. (6.58V-20.01V) The value obtained may have
some slight errors. It depends on us how appropriate it can be applied.
Speed control DC motor and rotary
encoder with PID Control
by nattaponPosted on05/08/2020

Another project for controlling the speed of DC Motor (DC Motor) and using PID
Control as an algorithm to control the speed. by detecting the signal of the rotary
encoder, which is attached to the motor This will reduce the time spent on selecting
and installing a rotary encoder. The motor used will be the model CHR-GM25-
370, using a voltage of 12Vdc only.
Figure 1.
Characteristics of the connection on the experimental board.

In Figure 1, it is the manner of assembling various devices. into an experimental


board for easy learning and experimentation Which consists of 3 parts, mainly the
part of the processing board uses Arduino UNO, part 2 is the part of the motor
driver board, the regulator circuit and sends the Encoder signal to the processing
board. and part of the DC motor

Picture 2: Circuit
connection between Arduino UNO board and DC motor driver board.

In Figure 2, the circuit is connected between the processor board and the motor
driver board. In the part of the motor driver board, it receives all power from the
power supply adapter. To make it easier to experiment and have enough current to
use in this whole circuit.
Figure 3. Power
connection between DC motor and motor driver board.

In this project, for switching the direction of rotation of the motor. Let us swap the
wires connected between the motor driver board to red and black wires to the
motor connector. red and white can be used We will be able to see the nature of the
encoder signal that occurs from this direction switch.

Figure 4. The circuit used in the experimental project.

*Code Program Arduino UNO


#include <PID_v1.h>
#define PIN_INPUT 0
#define PIN_OUTPUT 9

int time_H;
int time_L;
intFrequency;
int encoder0PinA = 2;
int encoder0PinB = 3;
int encoder0Pos = 0;
int encoder0PinALast = LOW;
int n = LOW;
float t_period;
int sampleRate = 10;
double Setpoint, Input, Output;
double Kp=1, Ki=5, Kd=0.001;
PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, DIRECT);

void setup()
{
Serial.begin(9600);
pinMode (encoder0PinA, INPUT);
pinMode (encoder0PinB, INPUT);
pinMode (PIN_OUTPUT, OUTPUT);
Setpoint = 1000;
myPID.SetSampleTime(sampleRate);
myPID.SetMode(AUTOMATIC);
Serial.print(" ");
Serial.print("Test SP = ");
Serial.print(Setpoint);
Serial.print(" Hz");
delay(1000);
analogWrite(PIN_OUTPUT,40); // Start up DC Motor
delay(100);
}

void loop()
{
n = digitalRead(encoder0PinA);
if ((encoder0PinALast == LOW) && (n == HIGH)) { // Test For Signal A and B Direction
if (digitalRead(encoder0PinB) == LOW) {
// encoder0Pos--; // Recommend not to use
Serial.print(" CW, "); // Mark Direction CW
} else {
// encoder0Pos++; // Recommend not to use
Serial.print(" CCW, "); // Mark Direction CCW
}

time_H = pulseIn(encoder0PinA,HIGH);
time_L = pulseIn(encoder0PinA,LOW);
t_period = time_H+time_L;
t_period = t_period/1000;
Frequency = 1000/t_period;
if(Frequency>3000){ // Set error Variable for t_period more
Frequency = 0;
}
Input = Frequency;
Serial.print("PV = "); // Recommend not to use
Serial.print(Input); // Recommend not to use
myPID.Compute();
analogWrite(PIN_OUTPUT, Output);
Serial.print("PWM = "); // Recommend not to use
Serial.println(Output); // Recommend not to use
}
encoder0PinALast = n;
}
Experiment board DC Motor Speed
Control with Arduino UNO
by nattaponPosted on31/08/2021

This project is to build a training kit for controlling DC motor speed (DC Motor
Speed Control) with a small internal brushless motor and using a voltage of
24V/0.1A. Arduino UNO size 5Vp-p to control the motor drive size 24V to suit
both the voltage and motor driving current. This motor can be purchased from
various disassembly parts stores. at a very affordable price
Figure 1. Characteristics of the DC motor used in the experiment (1).

Figure 2. Characteristics of the DC motor used in the experiment (2).


Figure 3. Characteristics of the DC motor used in the experiment (3).

In Fig. 1 to Fig. 3 shows the characteristics of the motor used in a small


experimental Toshiba DC Motor CFL-008-8A, DC 24V/0.1 A, RH7-1056. The
motor is spinning and the sound is very quiet. (No loud noise) Adjusting the speed
is used to adjust the voltage supplied to the motor in the range of 15V-25V and the
current used is about 0.1A according to the nameplate specification attached to the
motor.

Figure 4 measures the size of the motor body.


Figure 4. The motor is about 14 centimeters wide, 4 centimeters long, and about 5
centimeters high. It is a squirrel-cage fan. The rotor is on the side with a permanent
magnet rotating.

Figure 5 Prepare various equipment Used to assemble a DC motor speed control


training set.

Figure 5 Start preparing various equipment Such as Arduino UNO controller


board, motor driver board and transparent acrylic board. used for laying out the DC
motor speed control training set.
Figure 6. Location of mounting devices. neat and appropriate

Fig. 6 Characteristics of the positioning of the mounting devices. Because the holes
are drilled for fixing the board and the motor.

Figure 7 Start drilling holes in the clear acrylic sheet for fixing various devices.
Figure 8 Attach the motor and Arduino UNO controller board to the clear acrylic
sheet.

Figure 7 and Figure 8. After drilling the holes, fix the motor and the Arduino UNO
controller board to the clear acrylic sheet and attach the rubber buttons at the
bottom of the 4 corners to make it easy to place on the table and reduce vibrate
during the experiment

Figure 9. Design and assembly of the motor drive circuit.


Figure 9 is the preparation of a device for driving the motor. To the designed
circuit by receiving a pulse width modulated signal from the Arduino UNO
controller board and then adjusting the amount of power supply to the motor with
another part of the buck converter circuit

Figure 10 Mount the motor driver board on the clear acrylic sheet.

Figure 10 shows the characteristics of mounting the motor driver board on a clear
acrylic sheet. and will continue to connect various signal cables For motor control
such as power supply to the motor about 24V, pulse width modulation signal wire
and ground wire.
/*
Program Test Board DC Motor Speed Control with Arduino UNO
DC Motor : 24VDC / 0.1A
MCU : Arduino UNO
Dev by : www.electronicsDNA.com
Date : 21-8-64, (V.0)
*/

#include <PWM.h>
int led = 9;
int input = 2;
int time_H;
int time_L;
float t_period;
float Frequency;
//int Setpoint = 120; // Set point Rang 400-700
double Output_PWM = 0;
// int error = 0;
int32_t frequency = 25000; // frequency (in Hz)

void setup() {
InitTimersSafe(); // initialize the digital pin as an output.
pinMode(led, OUTPUT);
pinMode(input, INPUT);
Serial.begin(9600);
bool success = SetPinFrequencySafe(led, frequency);
//if the pin frequency was set successfully, turn pin 13 on
if(success) {
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
}

void loop() {
Output_PWM = 20;
pwmWrite(led,Output_PWM);
delay(5000);

Output_PWM = 150;
pwmWrite(led,Output_PWM);
delay(5000);

Output_PWM = 250;
pwmWrite(led,Output_PWM);
delay(5000);
}

For the test program, this experimental excavator will be a preliminary


experiment. which will allow the motor to rotate with constant speed control by
adjusting the pulse width modulation at approximately 20%, 60% and 95%
respectively, in order to observe the rotational speed of the motor in relation to the
pulse width modulation signal. in a linear way (Linear range) how it is In the
section of the library (PWM.h) [download here]

Figure 11. Approximately 20% modulated pulse signal at pin D9.


Figure 12. Approximately 60% modulated pulse signal at pin D9.

Figure 13. Approximately 95% modulated pulse signal at pin D9.

In Figure 11 to Figure 13 is the nature of the resulting pulsed vid modulated


signal. By measuring the signal at pin D9, from the experiment, the motor speed is
linear at the pulse width modulation range about 30%-100%. In this experiment,
the switching frequency is 25kHz for the circuit. buck converter
Figure 14. Circuit for a DC motor speed control training set.

Figure 14 shows the circuit characteristics for a DC motor speed control training
set. Which will be in the part of the Arduino UNO control board (left side) and part
of the buck converter circuit (right side) to drive the motor and receive the pulse
video modulation control signal
Figure 15 Characteristics of the completed DC motor speed control training set.

For this project, it is a small project. Another type for use in speed control for a
small DC motor. We can control the general speed (Open-Loop Control) by
adjusting the pulse width modulation signal from the Arduino UNO controller
board as we want, which is a basic form. For the next part, we will continue to
develop a training set for DC motor speed control. by adding a circuit to detect the
rotational speed of the motor So that we can experiment in a closed control
(Closed-Loop Control) or a feedback control system (Feedback Control) in another
way.

Reference
Build the Simple Tachometer Sensor
for DC Motor Speed Control
by nattaponPosted on02/09/2021

This project is a continuation of the previous motor speed control training


project. By creating a speed detection circuit for the motor of the experimental
board additionally In order to want us to be able to control the speed of the motor
with a closed system (Closed-Loop Control) or call the feedback control system
(Feedback Control) by the circuit and the device that will be used to detect the
speed of this cycle can be bought online It's inexpensive and doesn't require a lot of
equipment.
Figure 1. Reflective Optical Sensor.

Figure 1 shows the Vishay Semiconductors TCRT5000 (Reflective Optical Sensor


with Transistor Output) optical sensor and reflected infrared light source. Which is
used to create a speed sensor circuit for a DC motor. And we can see more details
in Ref. 7 [Ref.7].

Fig. 2 Dimensions of the optical sensor body.

Fig. 2 shows the size of the small size optical sensor implemented. And can design
a circuit to be used with the motor speed control training set.
Figure 3 Preliminary experiments before use

Figure 3 is an initial circuit connection experiment. in order to study the correct


and proper implementation before use by this preliminary experiment allows us to
adjust the sensitivity (Sensitivity) of signal detection and selection of equipment to
be used in conjunction to be able to connect (Interface) to the control board
correctly.

Figure 4 Prepare a general-purpose PCB to assemble the circuit.


Figure 5. Cut a general-purpose PCB to assemble the circuit.

Figure 4 and Figure 5 show how to prepare a general-purpose PCB to assemble the
circuit to form a module and make it easy to install. In Figure 5, the PCB is cut to a
smaller size to fit the sensor.

Figure 6. Assembly characteristics of the sensor module.

Figure 6 is the assembly of various devices on the PCB and the nature of
assembling a sensor module for use.
Figure 7. Wiring to the sensor module.

Figure 7 shows the characteristics of connecting wires to the module to receive


power to the sensor (+5V and GND ) and send the speed detecting signal
(OUTPUT) back to the control board. 3 lines in total

Figure 8. Appearance of the assembled sensor module.

Figure 8 shows the characteristics of the assembled sensor module and can be
used.
Figure 9. Assemble some circuits on the motor driver board.

Figure 9 shows some parts of the circuit on the additional motor driver
board. Which in this part will adjust the signal level (Signal conditioner) between
the signal received from the sensor and the signal that will be sent to the control
board to be appropriate

Figure 10 Prepare to fix the module to the base with copper wire.
Figure 11. The appearance of the module fastening to the support base.

Figure 10 and Figure 11 show how the sensor module is attached to the holder. In
this case, No. 16 (AWG) copper wire is used to mount, because we can easily
adjust the distance between the detection position and the inclination of the sensor
bar. to get the correct tachometer signal

Figure 12 Overview of the assembly with the motor speed controller project.

Figure 12 shows an overview of the near-complete assembly of the motor speed


controller project.
Figure 13 Use black duct tape for signal capture.

Figure 13 shows the use of black electrical tape to attach to the winding rotor. in
order to generate a pulse signal while rotating However, when the sensor detects
the position of the black band, it will result in the signal on the output side being
logic 1 and vice versa, if the black band is not detected, the signal on the output
side will be logic 0.

Figure 14 Appearance of attaching black electrical tape to the motor


Figure 15 Signals that occur when the circuit operates and the motor rotates.

Figure 14 and Figure 15 are the characteristics of attaching the black band to the
rotor. In this experiment, it will be attached together in 4 points in the opposite
manner and the distance is as close as possible. And when experimenting with the
motor to rotate, we will get the signal generated in Figure 15, in which the figure
will measure the signal at the output of this speed detection circuit.

Figure 16 Characteristics of signal measurements and initial experiments.


Figure 16 shows the nature of the signal measurements and initial experiments. By
using the motor test program from the past motor speed control training project.

Figure 17 The circuit designed and used in the experiment.

Figure 17. The circuit designed and used in the experiment is part of the motor
speed control training set project. (outside the blue box) in which the blue box is
the part of the motor speed detection It is mainly powered by an optical sensor
(TCRT5000) and a transistor (2N4401).
Figure 18 Characteristics of the experimental project Tools and equipment used

For the project to create a speed detection circuit for the motor, this is a small
project. Another one that requires very little equipment to build. But it will take
some time to adjust the signal detection distance to get the correct signal. Including
finding ways to mount the modules that are flexible for later use. However, the use
of optical sensors this time may be useful to readers for various applications.
Simple PID Adaptive Tuning for
Mini Fan Speed Control with
Arduino UNO
by nattaponPosted on08/03/2022

This project is an introductory and easy experiment. For controlling DC motor


speed for a small fan by means of PID Adaptive Tuning by using the example
program from the PID_V1.h library to test the operation. (The program can be
downloaded for free). In order to study and understand the characteristics of PID
Adaptive Control, which is another form of closed loop control. In the experiment,
the Arduino UNO processing board is used to control the operation of this project.
Figur
e 1 Prepare various devices for assembling projects

Figur
e 2. Specification and characteristics of the experimental fan.
Figure
3. Characteristics of the circuit for experiment.

For the figure 1 to figure 3 is the preparation of various equipment. For


experimenting with the project, which the fan (Figure 2) can be purchased online at
home or online shop, and in Figure 3 is a circuit connection consisting of a buck
converter circuit, a signal sizing circuit ( signal condition) between the
microcontroller and the buck converter circuit. and voltage divider at the output
(Voltage Divider) for feedback signal
/*
Cradit code PID Adaptive Tuning Example Form Library PID_v1.h
MCU : Arduino UNO
DC Power supply : 12V/2A
Fan : DC12V/0.55A, Model : AD0812XB-A73GL
Dev by : www.electronicsDNA.com
*/

#include <PID_v1.h>
#define PIN_INPUT 0
#define PIN_OUTPUT 3

int sampleRate = 10;


//Define Variables we'll be connecting to
double Setpoint, Input, Output;

//Define the aggressive and conservative Tuning Parameters


double aggKp=4, aggKi=2, aggKd=0.001;
double consKp=2, consKi=5, consKd=0.001;

//Specify the links and initial tuning parameters


PID myPID(&Input, &Output, &Setpoint, consKp, consKi, consKd, DIRECT);

void setup()
{
//initialize the variables we're linked to
Input = analogRead(PIN_INPUT);
Setpoint = 500; // SP Test = 300, 500, 700

pinMode(13, OUTPUT);
digitalWrite(13, LOW);
delay(3000);

//turn the PID on


myPID.SetMode(AUTOMATIC);
}

void loop()
{
Input = analogRead(PIN_INPUT);

double gap = abs(Setpoint-Input); //distance away from setpoint


if (gap < 50)
{ //we're close to setpoint, use conservative tuning parameters
myPID.SetTunings(consKp, consKi, consKd);
digitalWrite(13, HIGH);
}
else
{
//we're far from setpoint, use aggressive tuning parameters
myPID.SetTunings(aggKp, aggKi, aggKd);
digitalWrite(13, LOW);
}

myPID.Compute();
analogWrite(PIN_OUTPUT,Output);
}

The experimental program shown above. This is an example in the PID_V1.h


library file, which is a PID Adaptive Tuning control. In this if (gap < 50) clause, it
defines the error range as an absolute value ( Absolute value) is one more range
compared to conventional PID Control, that is, in the case when the errormore than
50The system control constants (Kp,Ki and Kd) are used to be equal toaggKp=4,
aggKi=2, aggKd=0.001;This will help the system enter the set value
faster. During this time, the LED at pin D13 will be off. Then, when the error
valueless than 50It will make the style of control more stable with
configuration.consKp=2, consKi=5, consKd=0.001;And the LED will be on to
know the adjustment of the variable in the new control itself. However, the
suitability of the operation of that system The user must study and adjust according
to the process in the existing system.

Download Library (PID_v1.h)


Figu
re 4 Experiment 1 Voltage drop across the fan when SP = 300

Fig.
5 Experiment 1 The PWM signal drives the fan when SP = 300 is set.
Fig
ure 6 Experiment 1 The amount of current supplied to the circuit when SP = 300

For Figure 4 to Figure 6, it is experiment 1 by setting the setpoint: SP equal to 300


and allowing the circuit to work. Then test the output signal at pin D3 in Figure 5
at the measurement channel 1 (CH1) to observe. work In the measurement channel
2 (CH2) is a feedback signal, which is proportional to the speed of the fan and the
voltage supplied to the fan.

Fig
ure 7 Experiment 2 Voltage drop across the fan when SP = 500
Fig
ure 8 Experiment 2 The PWM signal drives the fan when SP = 500 is set.

Fig
ure 9 Experiment 2 The amount of current supplied to the circuit when SP = 500

In Fig. 7 to Fig. 9 are Experiment 2 with setpoint set to 500 and measure the output
signal at pin D3 in Figure 8 (CH1 has increased frequency) and at the measurement
channel 2 (CH2) it will be signal. feedback which will increase the voltage to
2.45V as well, the amount of current supplied to the fan will increase to about
300mA, shown in Figure 9.
Fig
ure 10 Experiment 3 Voltage drop across the fan when SP = 700

Fig
ure 11 Experiment 3 The PWM signal drives the fan when SP = 700 is set.
Fi
gure 12 Experiment 3 Amount of current supplied to the circuit when SP = 700

In the last experiment, Fig. 10 to Fig. 12, Experiment 3, set the setpoint value to
700 and measure the output signal at pin D3 in Fig. 11 (CH1 has increased
frequency) and the signal channel 2 (CH2) as a feedback signals. This will increase
the voltage to 3.45V and the amount of current supplied to the fan is about 400mA,
shown in Figure 12.

Figure 13 The circuit designed and used in the experimental project.

In Figure 13 is a circuit.designed and used in experimental projectsThe important


part is the Arduino UNO microcontroller board. The board receives the feedback
signal (Vmotor) to pin A0 through the voltage divider circuit (R5 and R6) and then
sends a signal to drive the fan in pulse mode. Modulation (PWM Signal) at pin D3
will be sent to transistor Q2 to adjust the signal level for power transistor Q4
appropriately (Driver). The signal from Q4 will be sent to the low-frequency filter
circuit through (Low pass filter) at positions L1 and C2 to supply power to the fan
itself.

Figure 14 Characteristics of the entire project experiment.

For experimenting in this project, we will observe not many PID Adaptive Tuning
control results because the fan will only adjust the speed to the setpoint without
much load and use the display of LED (D13) to reveal the change of the new
control parameters. But in case we want to apply this control method to systems
with more loads, it will help to see the difference clearly. In part, the admin has
brought various devices. enough to come to design and test the project In order to
give a preliminary idea to the readers first.

You might also like