Exp - Report 20195784
Exp - Report 20195784
CHAPTER 1: OVERVIEW......................................................................................... 4
1.1. CONTROL SYSTEM DESIGN IN GENERAL ....................................................... 4
1.1.1. Introduction ........................................................................................................ 4
1.1.2. Objectives: .......................................................................................................... 4
1.1.3. Components: ....................................................................................................... 4
1.1.4. Types of Control Design Systems: ..................................................................... 5
1.1.5. Applications of Control Design Systems: .......................................................... 5
CHAPTER 2: ONE-AXIS PID ENCODER DC MOTOR CONTROL .................. 6
2.1. PID in General: .......................................................................................................... 6
2.2. One-Axis PID Encoder DC Motor Control: .............................................................. 6
2.3. Pin connection and block diagram ............................................................................ 8
2.4. Hardware ................................................................................................................... 9
CHAPTER 3: CONTROL DC MOTOR .................................................................. 10
3.1. Control DC Motor by using PWM mode (or analogWrite) .................................... 10
3.1.1. Result ................................................................................................................ 11
3.2. Control DC Motor using frequency. ........................................................................ 11
3.2.1. Result ................................................................................................................ 12
CHAPTER 4: CACULATE MOTOR VELOCITY USING ENCODER ............. 13
4.1. Reading encoder ...................................................................................................... 13
4.2. Calculate the velocity .............................................................................................. 15
CHAPTER 5: TRANSFER FUNCTION ................................................................. 16
5.1. Find the transfer function ........................................................................................ 16
CHAPTER 6: DESIGN THE PID CONTROLLER ............................................... 20
6.1. PID Controller ......................................................................................................... 20
6.1.1. Result: ............................................................................................................... 20
CHAPTER 7: USING PID TO CONTROL MOTOR ON ARDUINO ................. 22
2
TABLE OF FIGURES
Figure 1: Basic PID control procedure. ................................................................................ 6
Figure 2: The Electrical Components Pin Connection ......................................................... 8
Figure 3: Hardware ............................................................................................................... 9
Figure 4: PWM-based motor control Code ........................................................................ 10
Figure 5: Encoder ............................................................................................................... 13
Figure 6: Reading one signal only Code ............................................................................ 13
Figure 7: Reading two signals Code ................................................................................... 14
Figure 8: Reading four signals Code .................................................................................. 14
Figure 9: Calculating velocity code .................................................................................... 15
Figure 10: Arduino code to get the transfer function ......................................................... 16
Figure 11: Matlab code to get the data to find the tf .......................................................... 17
Figure 12: Transfer function calculated by System Identification ..................................... 19
Figure 13: Simulink model ................................................................................................. 20
Figure 14: Code in Adruino ................................................................................................ 24
Figure 15: Experience result ............................................................................................... 24
3
CHAPTER 1: OVERVIEW
1.1.3. Components:
Control design systems consist of three primary components:
4
The plant: refers to the system being controlled, which can be any physical or virtual
system with inputs and outputs.
The controller: responsible for adjusting the inputs of the plant to achieve a desired
output.
The feedback loop: used to monitor the output of the plant and adjust the controller's
inputs to achieve the desired output.
5
CHAPTER 2: ONE-AXIS PID ENCODER DC MOTOR CONTROL
This controller is widely used in closed-loop control systems with feedback signals.
The task of PID helps to calculate the error value which is the difference between the
measured value of the variable parameter and the value desired setting.
2.2. One-Axis PID Encoder DC Motor Control:
One-Axis PID Encoder DC Motor Control is a type of control system that regulates
the behavior of a DC motor using feedback from an encoder. The system consists of a DC
motor, an encoder to measure the motor's rotation, and a PID controller to adjust the motor's
behavior based on feedback from the encoder. The PID controller adjusts the motor's input
voltage based on the difference between the desired output and the actual output, as
measured by the encoder. The proportional, integral, and derivative components of the
controller are used to adjust the motor's behavior based on the past, present, and future error
values, respectively. The electrical components is represented in the Table below.
6
Table 2.1: Electrical components
7
- DC Current for each
input/output pin: 40 mA;
- DC Current used for 3.3V Pin:
50 mA;
- Flash Memory like 256 KB
where 8 KB of flash memory
is used with the help of
bootloader;
- Static random access memory
(SRAM): 8 KB;
- Electrically erasable
programmable read-only
memory (EEPROM): 4 KB;
- Clock (CLK) speed: 16 MHz;
- USB host chip: MAX3421E;
- Length of this board: 101.52
mm;
- Width of this board: 53.3 mm;
- Weight of this board: 36 g.
2.3. Pin connection and block diagram
The pin connection of electrical components is shown in the Figure below.
8
2.4. Hardware
Figure 3: Hardware
9
CHAPTER 3: CONTROL DC MOTOR
10
3.1.1. Result
11
3.2.1. Result
12
CHAPTER 4: CACULATE MOTOR VELOCITY USING ENCODER
Figure 5: Encoder
Depending on how we are reading each channel of encoder we can increase the
accuracy of velocity as well as the position of motor.
Here is the code for reading one signal only (x1) (on rising of A channel):
13
Here is the code for reading two signals (x2) (on Rising of both A and B Rising):
Here is the code for reading four signals (x4) (on both Rising and Falling of both A
and B):
14
4.2. Calculate the velocity
When we have the Encoder Count, we can calculate the motor velocity by take the
number of Encoder Count divide by the time passed between each time we take the value.
After that we can get the real RPM by dividing the output by gear ratio and number
of pulses per rotation of encoder.
15
CHAPTER 5: TRANSFER FUNCTION
16
Here is the Matlab code:
17
18
Figure 12: Transfer function calculated by System Identification
From the results obtained from the Matlab tool, we get the form of the transfer
function of the block motor– driver DS4573 W/EC 38P (24V) and BTS7960H as follows:
0.0143
𝐺 (𝑠 ) =
𝑠 2 + 0.6732𝑠 + 0.08368
19
CHAPTER 6: DESIGN THE PID CONTROLLER
We use the Autotunning method to identify the Kp, Ki, Kd value, matlab code:
6.1.1. Result:
20
We get Kp = 92.8, Ki = 11.8, Kd = 124 with that we have Tr = 0.7709s, OS = 1%,
Ts = 1.1917s
21
CHAPTER 7: USING PID TO CONTROL MOTOR ON ARDUINO
22
23
Figure 14: Code in Adruino
24