Real-Time Fuzzy Logic Position Controlled DC Motor Drives.
i
“I hereby declared that I have read through this report and found that it has comply
the partial fulfillment for awarding the degree of Bachelor of Electrical Engineering
(Control, Instrumentation and Automation)”.
Signature
: ………………………………………...
Supervisor’s Name
: MR. SYED NAJIB BIN SYED SALIM
Date
: …………………………………………
ii
REAL-TIME FUZZY LOGIC POSITION CONTROLLED DC MOTOR
DRIVES
GWYNNIE CHEMBAT AKIN
This Report Is Submitted In Partial Fulfillment of Requirements for the Degree
of Bachelor in Electrical Engineering (Control, Instrumentation and
Automation)
Fakulti Kejuruteraan Elektrik
Universiti Teknikal Malaysia Melaka
MAY 2009
iii
“I hereby declared that this report is a result of my own work except for the
excerpts that have been cited clearly in the references.”
Signature
: ………………………………...
Student Name : GWYNNIE CHEMBAT AKIN
Date
: MAY 2009
iv
ACKNOWLEDGEMENT
First of all, I always thankful to the Almighty for perseverance and
achievements to do this project report. I would like to express my appreciation to my
supervisor, Mr. Syed Najib Bin Syed Salim which he gives cooperation and great
encouragement to my project. I also wish to thank to my family and friends for their
support.
v
ABSTRACT
This project involves computer simulation and followed by hardware
implementation for the real application. In order to understand the characteristic of
the fuzzy logic controller, this project will be built to improve the teaching and
learning quality in control system subject. The aim of this project is to perform an
analysis to investigate the performances of DC motor with different load. The use of
fuzzy logic can help to avoid the need for precise mathematical modeling. Thus
anything that was built using conventional design techniques can be built with fuzzy
logic. The investigation and comparison of the output response from the simulation
and hardware can be done. Fuzzy logic controller will be design to improve its
performance.
vi
ABSTRAK
Projek ini dilaksanakan dengan menggunakan kaedah simulasi dan
perlaksanaan perkakasan. Pengawal logik samar digunakan
dalam perlaksanaan
projek ini. Dengan memahami ciri-ciri logik samar, maka projek ini dilaksanakan
bagi membuktikan kualiti pengajaran dan pembelajaran dalam subjek sistem
kawalan. Tujuan projek ini dilaksanakan adalah untuk membuat analisis dan
penyelidikkan keatas pergerakan DC motor dengan beban yang berbeza. Penggunaan
logik samar boleh membantu bagi mengelakkan ketepatan dalam bentuk matematik.
Oleh itu, sesuatu yang diperbuat dengan menggunakan teknik konvensional boleh
dibuat dengan menggunakan logik samar. Dengan membuat pembandingan dan
penyelidikkan keatas tindakbalas keluaran daripada simulasi dan perkakasan dengan
ini boleh dilaksanakan. Maka, pengawal logik samar dicipta bagi membuktikan
perlaksanaan projek ini.
vii
TABLE OF CONTENTS
CHAPTER
1
2
ITEM
PAGE
SUPERVISOR’S DECLARATION
i
TITLE
ii
DECLARATION
iii
ACKNOWLEDGEMENT
iv
ABSTRACT
v
ABSTRAK
vi
TABLE OF CONTENTS
vii
LIST OF TABLES
x
LIST OF FIGURES
xi
LIST OF ABBREVIATION
xv
LIST OF APPENDICES
xvi
INTRODUCTION
1
1.1 Background
1
1.2 Concept of Project
2
1.3 Objective
3
1.4 Scope of Project
3
1.5 Problem Statement
6
1.6 Outline of Report
6
LITERATURE REVIEW
7
2.1 Previous Project
7
2.1.1 PID Position Control System
10
2.1.2 Fuzzy Logic Position Controller
11
13
viii
2.1.3 Comparison of the Experimental
13
Results
2.1.4 Discussion
17
2.1.5 Conclusion
17
2.2 Control System Theory
2.2.1 Fuzzy Logic Controller
18
2.2.2 PID Controller
24
2.2.3 Conclusion
27
2.3 Microntroller
27
2.3.1 Comparison between Microcontrollers
28
2.3.2 Conclusion
30
2.4 Voltage Regulator
30
2.5 Serial Level Converter
31
2.6 Motor Driver
31
2.6.1 H-Bridge
32
2.6.2 Integrated Circuit
34
2.6.3 Conclusion
36
2.7 Electric Motor
37
2.7.1 DC Motor
39
2.7.2 Stepper Motor
39
2.7.3 Conclusion
41
2.8 Rotary Encoder
3
18
41
2.8.1 Absolute Rotary Encoder
42
2.8.2 Relative Rotary Encoder
43
2.8.3 Conclusion
45
METHODOLOGY
46
3.1 Overview
46
3.2 Modeling
48
3.2.1 Modeling of DC Motor
49
3.2.2 Step for Design Fuzzy Controller
52
3.3 Circuit Component
3.3.1 Microcontroller
52
52
ix
3.3.1.1 Step Programming the
55
Microcontroller
4
3.3.2 Serial Level Converter
56
3.3.3 H-Bridge
57
3.3.4 Position Encoder
58
3.4 Step for Design Circuit Using Proteus
58
3.5 Build Circuit with Strip board
60
3.6 List of Component
61
RESULT AND DISCUSSION
62
4.1 Modeling in Simulink
62
4.1.1 Matrix 3x3
4.1.1.1 Result 3x3
4.1.2 Matrix 5x5
4.1.2.1 Result 5x5
65
67
69
4.1.3 Discussion
71
4.1.4 Conclusion
73
4.2 Simulation in Proteus
4.2.1 Discussion
5
62
77
77
CONCLUSION AND RECOMMENDATION
78
5.1 Recommended
79
REFERENCES
80
APPENDIX
82
x
LIST OF TABLES
TABLE
ITEM
PAGE
2.1
Voltage-Speed Data
9
2.2
Fuzzy Rule Matrix for DC Motor Position
13
Control
12
2.3
Fuzzy Rule Table
22
2.4
Fuzzy Linguistic Terms
22
2.5
Proto-Type of Fuzzy Control Rules with Term
23
Sets (Negative, Zero, Positive)
2.6
Proto-Type of Fuzzy Control Rules with Term
23
Sets (NL, NM, NS, ZR, PS, PM, PL)
2.7
Summarizes the PID Terms and Effect on a
25
Control System
2.8
Comparison Types of Method Tuning the PID
25
Controller
2.9
Comparison between Microcontrollers
29
2.10
Logic Truth Table
36
2.11
Comparison between Stepper and DC Motor
41
2.12
Comparison Logic between Standard Binary and
43
Gray Encoding
2.13
Comparison between Absolute and Relative Error
44
3.1
List of Component
61
xi
LIST OF FIGURES
FIGURE
ITEM
PAGE
1.1
Concept of Project Block Diagram
2
1.2
Figure 1.2: K-Chart Block Diagram
4
1.3
Real-Time Fuzzy Logic Position Controlled DC
5
Motor Drives Block Diagram
2.1
Block Diagram of the PC-Based DC Motor
8
Positioning System
6
2.2
PID Position Controller
10
2.3
Fuzzy Logic Position Controller Block Diagram
11
2.4
Membership Functions
12
2.5
Simulation Result of Moving the Motor from 0˚
14
to 180˚
2.6
Measured Position Error and Control Output
15
Voltage PID Controller
2.7
Measured Position Error and Control Output
17
Voltage FLC Controller
2.8
Fuzzy Logic Control System Block Diagram
18
2.9
Signals Flowing In and Out of a Fuzzy Controller
19
Block Diagram
2.10
Example of a Membership Function
21
2.11
Three different Shapes of Membership Functions
21
2.12
Observation of System Response for deriving
22
2.13
PID Control System Block Diagram
24
2.14
PIC18F2431 Pin Diagram
28
2.15
PIC18F4331 Pin Diagram
28
2.16
PIC16F877A Pin Diagram
29
xii
2.17
PIC16F877A
29
2.18
Voltage Regulator
30
2.19
MAX232
31
2.20
MAX232 Pin Diagram
31
2.21
H-Bridge Schematic Diagram
32
2.22
Switching Control for Clockwise
33
2.23
Switching Control for Counter Clockwise
33
2.24
Functional Block Diagram of LMD18200
34
2.25
Connection Diagram and Ordering Information
35
2.26
LMD18200
35
2.27
The Common Motor Layout
36
2.28
DC Motor
38
2.29
Operation of DC Motor
38
2.30
Rotation of Stepper Motor
40
2.31
Comparison Design between Standard Binary and
42
Gray Encoding
2.32
Incremental Encoder
44
3.1
Flow Chart of Methodology
47
3.2
Flow Chart of Real-Time Fuzzy Logic Position
53
Controlled DC Motor Drive
54
3.3
Crystal Oscillator and Capacitor Circuit Diagram
54
3.4
PIC Circuit
54
3.5
Voltage Regulator Connection Diagram
55
3.6
Voltage Regulator Circuit
56
3.7
PIC Programmer
56
3.8
MAX232 Connection Diagram
57
3.9
MAX232 Circuit
57
3.10
The H-Bridge Circuit Diagram
58
3.11
H-Bridge Circuit
58
3.12
Feedback (Position)
59
3.13
Circle Ruler
60
3.14
Circuit on ISIS Layout
3.15
Complete Circuit
60
xiii
3.16
Real-Time FLC Position Controlled DC Motor
62
Drive
63
4.1
Membership Function for Input Thetaerror
63
4.2
Membership Function for Input Speed
64
4.3
Membership function for output voltage
64
4.4
Rules of FLC
65
4.5
Rules view of rules
65
4.6
Position Waveform
66
4.7
Speed Waveform
66
4.8
Current Waveform
67
4.9
Torque Waveform
67
4.10
Membership Function for Input Thetaerror
68
4.11
Membership Function for Input Speed
68
4.12
Membership Function for Output Voltage
69
4.13
Rules of FLC
69
4.14
Rules view of rules
70
4.15
Position Waveform
70
4.16
Speed Waveform
71
4.17
Current Waveform
71
4.18
Torque Waveform
72
4.19
Error at Speed Waveform for Matrix 3x3 Rule
72
4.20
Error at Speed Matrix 5x5 Rule
73
4.21
No Error at Position Waveform for 3x3 Rule
74
4.22
Error at Position Waveform Matrix 5x5 Rule
74
4.23
Circuit for Communication Test
75
4.24
Display Feedback for Communication Test
75
4.25
Circuit between RS232 and MAX232
76
4.26
Waveform between RS232 and MAX232
4.27
Circuit between MAX232 and PIC16F877A
4.28
Clock Waveform
xiv
LIST OF ABBREVIATION
COA
Center-of-Area
COG
Center-of-Gravity
CMOS
Complementary Metal-Oxide Semiconductor
DMOS
Double-Diffused Metal Oxide Semiconductor
DC
Direct Current
FLC
Fuzzy Logic Controller
GUI
Graphical User Interface
IEEE
International Electrical Electronic Engineering
I/O
MOSFET
Input/Output
Metal-Oxide Semiconductor Field-Effect
Transistor
PIC
Programmable Integrated Circuit
PID
Proportional, Integral, Derivative
PSM
Projek Sarjana Muda
PWM
Pulse Width Modulation
xv
LIST OF APPENDICES
INDEX
ITEM
PAGE
A
Hardware Layout
82
B
Program
85
C
Ghant Chart
87
D
Circuit Diagram
88
E
Modeling
89
F
IRF530N Datasheet
90
G
IRF9530N Datasheet
91
H
Motor Datasheet
92
I
Encoder Datasheet
93
J
PIC16F877A Datasheet
99
K
Voltage Regulator
107
1
CHAPTER 1
INTRODUCTION
The “Real-Time Fuzzy Logic Position Controlled DC Motor Drives” project
is needed interface software and hardware. This project is build to control the
performance of dc motor for positioning purpose and controlled by fuzzy logic
controller. Beside that, this project is build to comprehend the basic concepts of
fuzzy logic. In this chapter will discuss about general background, concept of project,
objective, scope, problem statement and report outline.
1.1 Background
Motion control deals with the use of high performance electric motor and is a
very important part industrial control systems. Motion control includes application
for position control in practically all branches of industry. An important advance in
this field has been made during the last years by the introduction of microprocessor
control systems. These systems are becoming a standard in motion control because of
fast advances in microelectronics technology and well-known benefits such as
greater accuracy, parameter sensitivity and higher interconnection capacity.
As a consequence of this progress, more and more applications that have used
simple electric drives for economic reasons are being replaced by motion control
systems. This is a natural evolution considering the benefits offered by motion
control systems in meeting the ever-increasing needs for improved quality and
greater productivity in all industries. To facilitate this move towards motion control
2
solutions, efforts are being made to continuously decrease the cost of these systems,
especially considering their power electronics and control parts.
1.2 Concept of Project
The concept of this project is shown in figure 1.1. Firstly, the controller
works by receiving a user position command then drive a dc motor to desire position
by using Serial Watcher. After receiving direction and position command from
computer, the controller will compare the actual and desire position to determine the
required pulse width modulation to drive a dc motor. The controller observes the
actual position of the position output shaft from the position encoder. The position
encoder attached at the output shaft motor.
Figure 1.1: Concept of Project Block Diagram
3
1.3 Objective
The objectives of the project are:
To perform a modeling of dc motor.
To make comparison between difference matrix.
To realize the operation of fuzzy logic for dc motor.
To investigate the result of output response according to a controller, load and
input.
1.4 Scope of Project
The K-Chart of the project is shown in figure 1.2. Firstly, with perform
modeling dc motor to get a parameter of dc motor by calculation. Then, design fuzzy
logic by using Matlab(simulink). After design a fuzzy logic block and 3x3 and 5x5
rules, there will be make a comparison between it with analyze a waveform. Then,
design a circuit by using Proteus (ISIS). After that, simulate the circuit with program
put inside the microcontroller and make an analysis on it. Then, implement the
circuit on the board. Finally, interface software with hardware then observe the result
and make an analysis.
For this project, the close loop system is needed. The close loop system is
used because it has a feedback function for monitoring the output position. The
project circuit parts are consist PIC controller, driver, dc motor and position encoder
as a feedback. The block diagram of this project is shown in figure 1.3. This project
is design and implements the hardware and the Serial Watcher as the software.
The dc motor is modeled and the dynamic parameters obtained will used to
analyze and design the controller. The modeling of dc motor is simulated in simulink
by using Matlab. The output response from simulink is analyzed and investigated and
record. The hardware will be interface with Serial Watcher software. From that
software, the user can give position command to drive the dc motor to desire
position.
4
5
Figure 1.2: K-Chart Block Diagram
Figure 1.3: Real-Time Fuzzy Logic Position Controlled DC Motor Drives Block
Diagram
6
1.5 Problem Statement
Most PID controller has been apply to the dc motor control position in
industry but still have a weakness that need to improve it by using fuzzy logic
controller.
The weaknesses of PID controller in application are the coefficients for the
PID controller are tuned in Kp, Ki and Kd are still give an effect to the minimum
settling time compare with the fuzzy logic controller which is the minimum settling
time can be achieved by tuning the control rules, membership functions and universe
of discourse of the output variable [1].
Beside that, by tuning and obtaining stable controller through trial-and-error
method is still the basic method in improving the expert knowledge toward
developing a tuned and stable fuzzy controller. But, it is an attempt to acquire proof
of principle experience in the fuzzy logic control and not necessarily a breakthrough
research in solving the proposed problem.
1.6 Outline of Report
As an outline, chapter one will discuss the background, concept, objectives,
scope and problem statement. Chapter two covers the previous research and theory of
control system such as fuzzy logic controller and PID controller, microcontroller,
voltage regulator, level converter, motor driver, electric motor and rotary encoder.
The approach and method apply in this project are present in chapter three. The result
and discussion from simulation and experiment present is discussed in chapter four.
The conclusion will cover in last chapter.
7
CHAPTER 2
LITERATURE REVIEW
This chapter will discuss about a review of control system that are usually
implemented in positioning system regarding on the previous researcher with
including an example of project. Besides that, some theory on several parts of the
project such as microcontroller, voltage regulator, level converter, motor driver,
electric motor and rotary encoder are also mentioned.
2.1 Previous Project
This part will be mention about discussion and result from previous project.
At last, there has a selection either choose fuzzy logic controller or PID controller are
better. The title project is Comparison on Fuzzy Logic and PID Controls for a DC
Motor Position Controller. This project was done by Paul I-Hai Lin, Santai Hwang
and John Chou.
The specification of the PC-Based Position Servo which they are considering
a PC-based DC motor position control (single input and single output) that will use
either a PID controller or a fuzzy logic controller of the PD type. In this system, the
motor angular position is to be controlled.
Both controllers are constructed based on the following basic hardware
elements which are a permanent magnet dc motor, a 486-PC with 55 MHz clock, an
interface card which consists of an 8-bit digital to analog converter (DAC), an 8255
programmable peripheral interface chip, an 8-bit analog to digital (ADC), a
8
potentiometer for position feedback, a two stage preamplifier and a power amplifier.
The block diagram of the system hardware is shown in figure 2.1. In addition, both
fuzzy and PID control algorithms are implemented in C programming language and
controllers are tuned with trial and error approach. The functions performed by both
controllers are accepts user commands and reports status, reads the position feedback
and calculates error, implements the transfer function and compensatory function
then output the motor command.
The objectives for comparison are the maximum position error of ˚,
0.5no
overshoot and a minimum settling time.
Figure 2.1: Block Diagram of the PC-Based DC Motor Positioning System
The dc motor used in the PC-based position servo is a permanent magnet dc
motor with the following parameters;
Ra = 1.5 ohms, armature resistance
La = 2.3 mH, armature inductance
Kt = 0.040832 Nm/Amp, torque constant
Ke = 0.04098726 volt/rad * sec-1, back emf constant
J = 4.942 x 10-5 kg-m2, rotor inertia
Since Coulomb, static and viscous friction are neglected, the transfer function
of the armature controlled dc motor from V to θ for position control is given as;
9
Kt
JLa
θ (s)
M=
(s) =
V (s)
K K
R
s s + e t s + a
JRa
La
Two poles are given by;
K e Kt
= 22.7 rad / sec
Ra J
Ra
= 652.2rad / sec
La
The motor was tested under no load condition to obtain some voltage speed
data. The dead zone of the dc motor is around ±1.3V. The data is shown below;
Table 2.1: Voltage-Speed Data
Motor Voltage (V)
Speed (RPM)
-5
4000
-4
2680
-3
1393
-2
812
+2.5
80
+3
450
+3.5
1307
+5
2000
An 8-bit digital to analog converter (D/A) and power amplifier provide the
proper voltage levels for the dc motor. Signal amplifier stage uses two operational
amplifiers to give a non-inverting voltage gain of 3.
The analog position sensor is a potentiometer with a single-turn and no
rotation stops. The sensor feeds absolute position data to an 8-bit ADC (±5V, 20µs
“I hereby declared that I have read through this report and found that it has comply
the partial fulfillment for awarding the degree of Bachelor of Electrical Engineering
(Control, Instrumentation and Automation)”.
Signature
: ………………………………………...
Supervisor’s Name
: MR. SYED NAJIB BIN SYED SALIM
Date
: …………………………………………
ii
REAL-TIME FUZZY LOGIC POSITION CONTROLLED DC MOTOR
DRIVES
GWYNNIE CHEMBAT AKIN
This Report Is Submitted In Partial Fulfillment of Requirements for the Degree
of Bachelor in Electrical Engineering (Control, Instrumentation and
Automation)
Fakulti Kejuruteraan Elektrik
Universiti Teknikal Malaysia Melaka
MAY 2009
iii
“I hereby declared that this report is a result of my own work except for the
excerpts that have been cited clearly in the references.”
Signature
: ………………………………...
Student Name : GWYNNIE CHEMBAT AKIN
Date
: MAY 2009
iv
ACKNOWLEDGEMENT
First of all, I always thankful to the Almighty for perseverance and
achievements to do this project report. I would like to express my appreciation to my
supervisor, Mr. Syed Najib Bin Syed Salim which he gives cooperation and great
encouragement to my project. I also wish to thank to my family and friends for their
support.
v
ABSTRACT
This project involves computer simulation and followed by hardware
implementation for the real application. In order to understand the characteristic of
the fuzzy logic controller, this project will be built to improve the teaching and
learning quality in control system subject. The aim of this project is to perform an
analysis to investigate the performances of DC motor with different load. The use of
fuzzy logic can help to avoid the need for precise mathematical modeling. Thus
anything that was built using conventional design techniques can be built with fuzzy
logic. The investigation and comparison of the output response from the simulation
and hardware can be done. Fuzzy logic controller will be design to improve its
performance.
vi
ABSTRAK
Projek ini dilaksanakan dengan menggunakan kaedah simulasi dan
perlaksanaan perkakasan. Pengawal logik samar digunakan
dalam perlaksanaan
projek ini. Dengan memahami ciri-ciri logik samar, maka projek ini dilaksanakan
bagi membuktikan kualiti pengajaran dan pembelajaran dalam subjek sistem
kawalan. Tujuan projek ini dilaksanakan adalah untuk membuat analisis dan
penyelidikkan keatas pergerakan DC motor dengan beban yang berbeza. Penggunaan
logik samar boleh membantu bagi mengelakkan ketepatan dalam bentuk matematik.
Oleh itu, sesuatu yang diperbuat dengan menggunakan teknik konvensional boleh
dibuat dengan menggunakan logik samar. Dengan membuat pembandingan dan
penyelidikkan keatas tindakbalas keluaran daripada simulasi dan perkakasan dengan
ini boleh dilaksanakan. Maka, pengawal logik samar dicipta bagi membuktikan
perlaksanaan projek ini.
vii
TABLE OF CONTENTS
CHAPTER
1
2
ITEM
PAGE
SUPERVISOR’S DECLARATION
i
TITLE
ii
DECLARATION
iii
ACKNOWLEDGEMENT
iv
ABSTRACT
v
ABSTRAK
vi
TABLE OF CONTENTS
vii
LIST OF TABLES
x
LIST OF FIGURES
xi
LIST OF ABBREVIATION
xv
LIST OF APPENDICES
xvi
INTRODUCTION
1
1.1 Background
1
1.2 Concept of Project
2
1.3 Objective
3
1.4 Scope of Project
3
1.5 Problem Statement
6
1.6 Outline of Report
6
LITERATURE REVIEW
7
2.1 Previous Project
7
2.1.1 PID Position Control System
10
2.1.2 Fuzzy Logic Position Controller
11
13
viii
2.1.3 Comparison of the Experimental
13
Results
2.1.4 Discussion
17
2.1.5 Conclusion
17
2.2 Control System Theory
2.2.1 Fuzzy Logic Controller
18
2.2.2 PID Controller
24
2.2.3 Conclusion
27
2.3 Microntroller
27
2.3.1 Comparison between Microcontrollers
28
2.3.2 Conclusion
30
2.4 Voltage Regulator
30
2.5 Serial Level Converter
31
2.6 Motor Driver
31
2.6.1 H-Bridge
32
2.6.2 Integrated Circuit
34
2.6.3 Conclusion
36
2.7 Electric Motor
37
2.7.1 DC Motor
39
2.7.2 Stepper Motor
39
2.7.3 Conclusion
41
2.8 Rotary Encoder
3
18
41
2.8.1 Absolute Rotary Encoder
42
2.8.2 Relative Rotary Encoder
43
2.8.3 Conclusion
45
METHODOLOGY
46
3.1 Overview
46
3.2 Modeling
48
3.2.1 Modeling of DC Motor
49
3.2.2 Step for Design Fuzzy Controller
52
3.3 Circuit Component
3.3.1 Microcontroller
52
52
ix
3.3.1.1 Step Programming the
55
Microcontroller
4
3.3.2 Serial Level Converter
56
3.3.3 H-Bridge
57
3.3.4 Position Encoder
58
3.4 Step for Design Circuit Using Proteus
58
3.5 Build Circuit with Strip board
60
3.6 List of Component
61
RESULT AND DISCUSSION
62
4.1 Modeling in Simulink
62
4.1.1 Matrix 3x3
4.1.1.1 Result 3x3
4.1.2 Matrix 5x5
4.1.2.1 Result 5x5
65
67
69
4.1.3 Discussion
71
4.1.4 Conclusion
73
4.2 Simulation in Proteus
4.2.1 Discussion
5
62
77
77
CONCLUSION AND RECOMMENDATION
78
5.1 Recommended
79
REFERENCES
80
APPENDIX
82
x
LIST OF TABLES
TABLE
ITEM
PAGE
2.1
Voltage-Speed Data
9
2.2
Fuzzy Rule Matrix for DC Motor Position
13
Control
12
2.3
Fuzzy Rule Table
22
2.4
Fuzzy Linguistic Terms
22
2.5
Proto-Type of Fuzzy Control Rules with Term
23
Sets (Negative, Zero, Positive)
2.6
Proto-Type of Fuzzy Control Rules with Term
23
Sets (NL, NM, NS, ZR, PS, PM, PL)
2.7
Summarizes the PID Terms and Effect on a
25
Control System
2.8
Comparison Types of Method Tuning the PID
25
Controller
2.9
Comparison between Microcontrollers
29
2.10
Logic Truth Table
36
2.11
Comparison between Stepper and DC Motor
41
2.12
Comparison Logic between Standard Binary and
43
Gray Encoding
2.13
Comparison between Absolute and Relative Error
44
3.1
List of Component
61
xi
LIST OF FIGURES
FIGURE
ITEM
PAGE
1.1
Concept of Project Block Diagram
2
1.2
Figure 1.2: K-Chart Block Diagram
4
1.3
Real-Time Fuzzy Logic Position Controlled DC
5
Motor Drives Block Diagram
2.1
Block Diagram of the PC-Based DC Motor
8
Positioning System
6
2.2
PID Position Controller
10
2.3
Fuzzy Logic Position Controller Block Diagram
11
2.4
Membership Functions
12
2.5
Simulation Result of Moving the Motor from 0˚
14
to 180˚
2.6
Measured Position Error and Control Output
15
Voltage PID Controller
2.7
Measured Position Error and Control Output
17
Voltage FLC Controller
2.8
Fuzzy Logic Control System Block Diagram
18
2.9
Signals Flowing In and Out of a Fuzzy Controller
19
Block Diagram
2.10
Example of a Membership Function
21
2.11
Three different Shapes of Membership Functions
21
2.12
Observation of System Response for deriving
22
2.13
PID Control System Block Diagram
24
2.14
PIC18F2431 Pin Diagram
28
2.15
PIC18F4331 Pin Diagram
28
2.16
PIC16F877A Pin Diagram
29
xii
2.17
PIC16F877A
29
2.18
Voltage Regulator
30
2.19
MAX232
31
2.20
MAX232 Pin Diagram
31
2.21
H-Bridge Schematic Diagram
32
2.22
Switching Control for Clockwise
33
2.23
Switching Control for Counter Clockwise
33
2.24
Functional Block Diagram of LMD18200
34
2.25
Connection Diagram and Ordering Information
35
2.26
LMD18200
35
2.27
The Common Motor Layout
36
2.28
DC Motor
38
2.29
Operation of DC Motor
38
2.30
Rotation of Stepper Motor
40
2.31
Comparison Design between Standard Binary and
42
Gray Encoding
2.32
Incremental Encoder
44
3.1
Flow Chart of Methodology
47
3.2
Flow Chart of Real-Time Fuzzy Logic Position
53
Controlled DC Motor Drive
54
3.3
Crystal Oscillator and Capacitor Circuit Diagram
54
3.4
PIC Circuit
54
3.5
Voltage Regulator Connection Diagram
55
3.6
Voltage Regulator Circuit
56
3.7
PIC Programmer
56
3.8
MAX232 Connection Diagram
57
3.9
MAX232 Circuit
57
3.10
The H-Bridge Circuit Diagram
58
3.11
H-Bridge Circuit
58
3.12
Feedback (Position)
59
3.13
Circle Ruler
60
3.14
Circuit on ISIS Layout
3.15
Complete Circuit
60
xiii
3.16
Real-Time FLC Position Controlled DC Motor
62
Drive
63
4.1
Membership Function for Input Thetaerror
63
4.2
Membership Function for Input Speed
64
4.3
Membership function for output voltage
64
4.4
Rules of FLC
65
4.5
Rules view of rules
65
4.6
Position Waveform
66
4.7
Speed Waveform
66
4.8
Current Waveform
67
4.9
Torque Waveform
67
4.10
Membership Function for Input Thetaerror
68
4.11
Membership Function for Input Speed
68
4.12
Membership Function for Output Voltage
69
4.13
Rules of FLC
69
4.14
Rules view of rules
70
4.15
Position Waveform
70
4.16
Speed Waveform
71
4.17
Current Waveform
71
4.18
Torque Waveform
72
4.19
Error at Speed Waveform for Matrix 3x3 Rule
72
4.20
Error at Speed Matrix 5x5 Rule
73
4.21
No Error at Position Waveform for 3x3 Rule
74
4.22
Error at Position Waveform Matrix 5x5 Rule
74
4.23
Circuit for Communication Test
75
4.24
Display Feedback for Communication Test
75
4.25
Circuit between RS232 and MAX232
76
4.26
Waveform between RS232 and MAX232
4.27
Circuit between MAX232 and PIC16F877A
4.28
Clock Waveform
xiv
LIST OF ABBREVIATION
COA
Center-of-Area
COG
Center-of-Gravity
CMOS
Complementary Metal-Oxide Semiconductor
DMOS
Double-Diffused Metal Oxide Semiconductor
DC
Direct Current
FLC
Fuzzy Logic Controller
GUI
Graphical User Interface
IEEE
International Electrical Electronic Engineering
I/O
MOSFET
Input/Output
Metal-Oxide Semiconductor Field-Effect
Transistor
PIC
Programmable Integrated Circuit
PID
Proportional, Integral, Derivative
PSM
Projek Sarjana Muda
PWM
Pulse Width Modulation
xv
LIST OF APPENDICES
INDEX
ITEM
PAGE
A
Hardware Layout
82
B
Program
85
C
Ghant Chart
87
D
Circuit Diagram
88
E
Modeling
89
F
IRF530N Datasheet
90
G
IRF9530N Datasheet
91
H
Motor Datasheet
92
I
Encoder Datasheet
93
J
PIC16F877A Datasheet
99
K
Voltage Regulator
107
1
CHAPTER 1
INTRODUCTION
The “Real-Time Fuzzy Logic Position Controlled DC Motor Drives” project
is needed interface software and hardware. This project is build to control the
performance of dc motor for positioning purpose and controlled by fuzzy logic
controller. Beside that, this project is build to comprehend the basic concepts of
fuzzy logic. In this chapter will discuss about general background, concept of project,
objective, scope, problem statement and report outline.
1.1 Background
Motion control deals with the use of high performance electric motor and is a
very important part industrial control systems. Motion control includes application
for position control in practically all branches of industry. An important advance in
this field has been made during the last years by the introduction of microprocessor
control systems. These systems are becoming a standard in motion control because of
fast advances in microelectronics technology and well-known benefits such as
greater accuracy, parameter sensitivity and higher interconnection capacity.
As a consequence of this progress, more and more applications that have used
simple electric drives for economic reasons are being replaced by motion control
systems. This is a natural evolution considering the benefits offered by motion
control systems in meeting the ever-increasing needs for improved quality and
greater productivity in all industries. To facilitate this move towards motion control
2
solutions, efforts are being made to continuously decrease the cost of these systems,
especially considering their power electronics and control parts.
1.2 Concept of Project
The concept of this project is shown in figure 1.1. Firstly, the controller
works by receiving a user position command then drive a dc motor to desire position
by using Serial Watcher. After receiving direction and position command from
computer, the controller will compare the actual and desire position to determine the
required pulse width modulation to drive a dc motor. The controller observes the
actual position of the position output shaft from the position encoder. The position
encoder attached at the output shaft motor.
Figure 1.1: Concept of Project Block Diagram
3
1.3 Objective
The objectives of the project are:
To perform a modeling of dc motor.
To make comparison between difference matrix.
To realize the operation of fuzzy logic for dc motor.
To investigate the result of output response according to a controller, load and
input.
1.4 Scope of Project
The K-Chart of the project is shown in figure 1.2. Firstly, with perform
modeling dc motor to get a parameter of dc motor by calculation. Then, design fuzzy
logic by using Matlab(simulink). After design a fuzzy logic block and 3x3 and 5x5
rules, there will be make a comparison between it with analyze a waveform. Then,
design a circuit by using Proteus (ISIS). After that, simulate the circuit with program
put inside the microcontroller and make an analysis on it. Then, implement the
circuit on the board. Finally, interface software with hardware then observe the result
and make an analysis.
For this project, the close loop system is needed. The close loop system is
used because it has a feedback function for monitoring the output position. The
project circuit parts are consist PIC controller, driver, dc motor and position encoder
as a feedback. The block diagram of this project is shown in figure 1.3. This project
is design and implements the hardware and the Serial Watcher as the software.
The dc motor is modeled and the dynamic parameters obtained will used to
analyze and design the controller. The modeling of dc motor is simulated in simulink
by using Matlab. The output response from simulink is analyzed and investigated and
record. The hardware will be interface with Serial Watcher software. From that
software, the user can give position command to drive the dc motor to desire
position.
4
5
Figure 1.2: K-Chart Block Diagram
Figure 1.3: Real-Time Fuzzy Logic Position Controlled DC Motor Drives Block
Diagram
6
1.5 Problem Statement
Most PID controller has been apply to the dc motor control position in
industry but still have a weakness that need to improve it by using fuzzy logic
controller.
The weaknesses of PID controller in application are the coefficients for the
PID controller are tuned in Kp, Ki and Kd are still give an effect to the minimum
settling time compare with the fuzzy logic controller which is the minimum settling
time can be achieved by tuning the control rules, membership functions and universe
of discourse of the output variable [1].
Beside that, by tuning and obtaining stable controller through trial-and-error
method is still the basic method in improving the expert knowledge toward
developing a tuned and stable fuzzy controller. But, it is an attempt to acquire proof
of principle experience in the fuzzy logic control and not necessarily a breakthrough
research in solving the proposed problem.
1.6 Outline of Report
As an outline, chapter one will discuss the background, concept, objectives,
scope and problem statement. Chapter two covers the previous research and theory of
control system such as fuzzy logic controller and PID controller, microcontroller,
voltage regulator, level converter, motor driver, electric motor and rotary encoder.
The approach and method apply in this project are present in chapter three. The result
and discussion from simulation and experiment present is discussed in chapter four.
The conclusion will cover in last chapter.
7
CHAPTER 2
LITERATURE REVIEW
This chapter will discuss about a review of control system that are usually
implemented in positioning system regarding on the previous researcher with
including an example of project. Besides that, some theory on several parts of the
project such as microcontroller, voltage regulator, level converter, motor driver,
electric motor and rotary encoder are also mentioned.
2.1 Previous Project
This part will be mention about discussion and result from previous project.
At last, there has a selection either choose fuzzy logic controller or PID controller are
better. The title project is Comparison on Fuzzy Logic and PID Controls for a DC
Motor Position Controller. This project was done by Paul I-Hai Lin, Santai Hwang
and John Chou.
The specification of the PC-Based Position Servo which they are considering
a PC-based DC motor position control (single input and single output) that will use
either a PID controller or a fuzzy logic controller of the PD type. In this system, the
motor angular position is to be controlled.
Both controllers are constructed based on the following basic hardware
elements which are a permanent magnet dc motor, a 486-PC with 55 MHz clock, an
interface card which consists of an 8-bit digital to analog converter (DAC), an 8255
programmable peripheral interface chip, an 8-bit analog to digital (ADC), a
8
potentiometer for position feedback, a two stage preamplifier and a power amplifier.
The block diagram of the system hardware is shown in figure 2.1. In addition, both
fuzzy and PID control algorithms are implemented in C programming language and
controllers are tuned with trial and error approach. The functions performed by both
controllers are accepts user commands and reports status, reads the position feedback
and calculates error, implements the transfer function and compensatory function
then output the motor command.
The objectives for comparison are the maximum position error of ˚,
0.5no
overshoot and a minimum settling time.
Figure 2.1: Block Diagram of the PC-Based DC Motor Positioning System
The dc motor used in the PC-based position servo is a permanent magnet dc
motor with the following parameters;
Ra = 1.5 ohms, armature resistance
La = 2.3 mH, armature inductance
Kt = 0.040832 Nm/Amp, torque constant
Ke = 0.04098726 volt/rad * sec-1, back emf constant
J = 4.942 x 10-5 kg-m2, rotor inertia
Since Coulomb, static and viscous friction are neglected, the transfer function
of the armature controlled dc motor from V to θ for position control is given as;
9
Kt
JLa
θ (s)
M=
(s) =
V (s)
K K
R
s s + e t s + a
JRa
La
Two poles are given by;
K e Kt
= 22.7 rad / sec
Ra J
Ra
= 652.2rad / sec
La
The motor was tested under no load condition to obtain some voltage speed
data. The dead zone of the dc motor is around ±1.3V. The data is shown below;
Table 2.1: Voltage-Speed Data
Motor Voltage (V)
Speed (RPM)
-5
4000
-4
2680
-3
1393
-2
812
+2.5
80
+3
450
+3.5
1307
+5
2000
An 8-bit digital to analog converter (D/A) and power amplifier provide the
proper voltage levels for the dc motor. Signal amplifier stage uses two operational
amplifiers to give a non-inverting voltage gain of 3.
The analog position sensor is a potentiometer with a single-turn and no
rotation stops. The sensor feeds absolute position data to an 8-bit ADC (±5V, 20µs