Sie sind auf Seite 1von 54

SOUTHERN POLYTECHNIC STATE UNIVERSITY Marietta, GA

Prepared for MTRE 4000-001 Advanced Control System

Prepared by Kader Conde

(MATLAB/Simulink)

Control System for DC Motor Drive System


April 2012

Acknowledgments
I am grateful to all those who have had a direct impact on this work. I would also like to thank and recognize all the undergraduate students in mechatronic engineering program at Southern Polytechnic State University, over the years with whom I had good fortune, and who contributed in some ways and feedback to the development of this material. In addition, I greatly owe my indebtedness to all the authors of the articles listed in the bibliography of the paper. Finally, I would very much like to acknowledge the encouragement, patience, and support provided by my family members as well as Dr. Chan Ham who pushed me to strive to excellence.

Kader Conde

Page |2 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Abstract
The project shall describe a MATLAB/SIMULINK realization of a DC Motor (Brushless) as well as implementing controls methods. The paper will presents with the design of a control system that shall control the speed/torque of the motor taking into account all factors. All major elements of classical control theories will be represented, coupled with ingenious and conventional tuning methods. Electric machines such as DC Motor, AC Motor, Induction Motors and Generators play important roles in industry as well as everyday life. The same general concept can be applied for each type whether it is for generating electrical power in power plants or provide mechanical energy in production industry. The aim of this project is to deeply investigate the behavior of an electrical machine; precisely a specific type of DC motor. The second focus of the paper to use computer simulation as a tool for conducting transient and control studies. The fact of the matter is that simulation and optimization represent the last steps in the design process. Aside from constructing the actual system; which happens to be time consuming, tedious, and costly, simulation is often chosen by engineers in their individual approach. MATLAB/SIMULINK represents the ideal companion in studying controls and conceptual designs. MATLAB and SIMULINK not only offer matrix computer algebra in handling control systems, but also an entire control system toolbox for advanced simulation.

Page |3 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

List of Symbols
Voltage across coil of armature Resistance of armature Current of armature Inductance of armature Voltage induced Angular Velocity of motor Electromagnetic torque Torque due to rotor acceleration Torque due to rotor velocity Torque of mechanical load Damping coefficient from mechanical rotation Inertia of the motor Torque constant Motor constant Rotation per minute Natural Frequency Damping Ratio Percent Overshoot Settling Time Rise Time Proportional Gain Integral Gain Derivative Gain

Page |4 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Table of Figures
Figure 1: Multiview Drawing of Permanent Magnet DC Motor ................................................................ 11 Figure 2: Electrical Representation of a DC Motor ................................................................................... 12 Figure 3: Complete Block Diagram of DC Motor Model ........................................................................... 14 Figure 4: Simplified Block Diagram of DC Motor Model .......................................................................... 14 Figure 5: Open-loop Block Diagram of DC Motor Model ......................................................................... 16 Figure 6: Typical Feedback Control System .............................................................................................. 16 Figure 7: DC Step Motor Response via Transfer Function State-Space Model ......................................... 20 Figure 8: Step Response of DC Motor Model Manually Obtained ............................................................ 21 Figure 9: Root Locus Plot of DC Motor Model .......................................................................................... 22 Figure 10: Impulse Response of DC Motor Model ..................................................................................... 23 Figure 11:Ramp Response of DC Motor Model ......................................................................................... 24 Figure 12: Bode Diagrams of DC Motor Model ........................................................................................ 25 Figure 13: Nyquist Diagram of DC Motor Model ...................................................................................... 26 Figure 14: Step Response with Proportion Control: 30<Kp<70 with Increment of 5 ............................... 28 Figure 15: Step Response with PD Controller Kp = 122; 0<Kd<10 ......................................................... 29 Figure 16: Step Response of DC Motor with PI Controller Kp = 30; 30<Ki<80...................................... 30 Figure 17: Step Response of DC Motor with PID Controller Kp = 30; Kd = 1.4; 30<Ki<80 .................. 31 Figure 18: Step Response of DC Motor with Tuned PID Controller.......................................................... 33 Figure 19:Schematic of a Full-State Feedback System .............................................................................. 35 Figure 20:Step Response with Full-State Feedback Controller ................................................................. 36 Figure 21:Final Step Response with Full-State Feedback Controller........................................................ 37 Figure 22: Step Response of DC Motor for Discrete Model Ts = 0.1 ........................................................ 38 Figure 23:Step Response of DC Motor for Discrete Domain with PID Controller ................................... 40 Figure 24: Simulation Block Diagram of DC Motor Model in Simulink .................................................... 41 Figure 25:Step Response of DC Motor Model in Simulink......................................................................... 41 Figure 26:Simulation Block Diagram of Dc Motor via State-Space Model ............................................... 42 Figure 27:Step Response of Dc Motor Simulink Model via State-Space Modeling.................................... 42 Figure 28: Step Response with Proportion Control: 25<Kp<45 ............................................................... 44 Figure 29: Final PID Controller Tuning .................................................................................................... 46 Figure 30: Step Response of Final PID Controller Tuning Kp = 30.1, Kd = 59.2, Ki = 1.4 ..................... 47

Page |5 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Table of Contents
ACKNOWLEDGMENTS ............................................................................................................................................ 2 ABSTRACT .............................................................................................................................................................. 3 LIST OF SYMBOLS ................................................................................................................................................... 4 TABLE OF FIGURES ................................................................................................................................................. 5 TABLE OF CONTENTS.............................................................................................................................................. 6 INTRODUCTION ..................................................................................................................................................... 8 PROJECT OBJECTIVES ......................................................................................................................................................8 MINIMUM SUCCESS CRITERIA ..........................................................................................................................................8 TECHNICAL APPROACH .......................................................................................................................................... 9 SUMMARY OF MAIN FOCUS .............................................................................................................................................9 SCOPE OF MATHEMATICAL ANALYSIS .................................................................................................................................9 DC MOTOR BACKGROUND ................................................................................................................................... 10 GENERAL MACHINE BACKGROUND ..................................................................................................................................10 AN AUTOINDUCTIVITY...................................................................................................................................................10 MODELING A DC MOTOR ..................................................................................................................................... 11 PERMANENT MAGNET DC MOTOR .................................................................................................................................11 IM-15 GEARMOTOR PERMANENT MAGNET 455A116-2 ................................................... ERROR! BOOKMARK NOT DEFINED. ELECTRICAL SYSTEM .....................................................................................................................................................12 MECHANICAL SYSTEM...................................................................................................................................................13 STATE SPACE REPRESENTATION ......................................................................................................................................13 TRANSFER FUNCTION BLOCK DIAGRAM ............................................................................................................................14 FEEDBACK CONTROL SYSTEM .........................................................................................................................................16 MATLAB/SIMULINK SIMULATION ........................................................................................................................ 17 INTRODUCTION TO MATLAB .......................................................................................................................................17 INTRODUCTION TO SIMULINK .........................................................................................................................................17 MATLAB APPROACH ............................................................................................................................................ 18 MATLAB MODELING...................................................................................................................................................18 LINEAR ANALYSIS .........................................................................................................................................................21 Root Locus Diagram of DC Motor Model ...........................................................................................................22 Impulse Response of DC Motor Model ...............................................................................................................23 Ramp Response of DC Motor Model ..................................................................................................................24 Bode Plots of DC Motor Model ...........................................................................................................................25 Nyquist Diagram of DC Motor Model.................................................................................................................26 CONTROLLER DESIGN....................................................................................................................................................27 PID Controller Approach .....................................................................................................................................27 Matlab Tuning Tool ............................................................................................................................................32 State-Variable Feedback Design Controller ........................................................................................................34 CONTINUOUS TO DISCRETE CONVERSION.............................................................................. ERROR! BOOKMARK NOT DEFINED.

Page |6 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

SIMULINK MODELING & SIMULATION ................................................................................................................. 41 CONCLUSION AND FUTURE WORK ....................................................................................................................... 49 BIBLIOGRAPHY ..................................................................................................................................................... 50 APPENDICES......................................................................................................................................................... 51 APPENDIX A: MATLAB SOURCE CODE ............................................................................................................................51 APPENDIX B: DC MOTOR DATASHEET .............................................................................................................................54

Page |7 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Introduction
Project Objectives
The aim of this paper is to further research on analysis, synthesis, and modeling; as well as the actual behavior of a DC motor with a controller. It will require a heavy usage of powerful computation and simulation software. MATLAB shall be the software package used for high performance numerical computation and visualization. The combinations of classical and modern control theories to its flexibility, reliability and powerful graphics make MATLAB/SIMULINK essential for this paper. They enable user to simulate linear, as well as nonlinear, systems easily and efficiently. A theory is a general statement of principle abstracted from observation; while a model is a representation of a theory that can be used for control and prediction. For a model to be useful, it must be realistic and yet simple enough to be understood and manipulated. These requirements are not easily fulfilled as realistic models arent simple and simple model are seldom realistic.

Minimum Success Criteria


For this particular project, the main objectives will be: To accurately derive a mathematical (kinematics) model of the behavior of a dc motor based on provided parameters To accurately implement different controllers: one PID controller using classical control theories; one using discrete domain theories To accurately provide a detailed simulation of models ensuring optimization on factor like stability, rise time, and steady-state response/error.

Page |8 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Technical Approach
Summary of Main Focus
The main focus is to accurately derive a Mathematical model for describing the behavior of a permanent magnet dc motor. It will have to be a kinematics model relating either the output angular velocity or torque to the inputted voltage or current. Thus using control theories to extend the model representation including different control systems in order to obtain desired responses. The use of MATLAB and SIMULINK in modeling, analysis and control design is demonstrated. It will be assumed throughout that the reader already possesses basic knowledge of MATLAB and SIMULINK; therefore, the main focus will be on the actual implementation of the Control System Toolbox Functions.

Scope of Mathematical Analysis


In the derivation of the Mathematical model for dc motor, various techniques shall be used to enhance accuracy. In fact, the first step will be to provide a state-variable modeling of the kinematic behavior of a permanent magnet dc motor keeping in mind the goal (desired input and desired output). The first thing will be to lay out all kinematics equation that can relate voltage, current, torque, angular velocity and other useful parameter. Thus, using state-space variable modeling, derive the appropriate matrix, and based on the control-canonical form, derive a block diagram representing the dc motor behavior. The final steps will be several minor analyses, as well as tuning to find appropriate parameters for each different control system algorithms.

Page |9 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

DC Motor Background
General Machine Background
We consider DC motor with permanent magnets. The force provided by the motors is known as torque. The stall torque usually provided by the data sheets represents the theoretical maximum torque produced by the motor in case of totally free unrestricted motion. The DC motor rotates as a result of current flowing through a coil inside a magnetic field repelled by permanent magnets mounted in the armature. When a motor is rotating, the applied voltage to the motor is diminished by the voltage E produced by the rotor. The faster it rotates, the larger the value of E is. In general, where is a constant, and is the angular velocity of the motor. The torque on the rotor (the useful torque for a machine) is proportional to the current in the coil: In SI units, . Since , where is the resistance.

An Autoinductivity
The voltage generated by the motor coil is produced because the coil is rotating through the magnetic flux lines of the permanent magnet. If the current in the coil is changing, then the magnetic field generated by the coil is also changing. The magnetic flux of the field generated by the own current is varying, and this is equivalent to a movement of the coil through a magnetic field. This means that variations in the current through the coil lead to a generated voltage given by:

where is the inductance of the coil. It is important to note that the induced voltage opposes the voltage applied to the motor.

P a g e | 10 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Modeling a DC Motor
The intent is to develop a linear model for a DC motor, how to analyze the model under MATLAB (poles and zeros, frequency response, time-domain response etc.), how to design a controller, and how to simulate the open-loop and closed-loop system under SIMULINK. In our design, an actual DC motor will be used. In fact, it will be a Permanent Magnet DC motors.

Permanent Magnet DC Motor


As any other electric motor, the permanent magnet DC motor converts electrical energy into mechanical energy. They tend to have performance advantages over direct-current excited synchronous types, and have become predominant in fractional horsepower application. They are commonly lighter, more efficient and more reliable than others. During the design, the goal is to relate the applied voltage to the armature, to the velocity of the motor. In such case, two main systems must be considered: the electrical and mechanical system. But first let us take a close look at the motor that shall be used and its specifications.

Figure 1: Multiview Drawing of Permanent Magnet DC Motor: IM-15 GEARMOTOR Permanent Magnet 455A1162

P a g e | 11 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Torque constant Motor constant Inductance of armature Resistance of armature Damping of the mechanical system Moment of Inertial of the rotor

Electrical System
The electrical system can be represented by a voltage source across the coil of the armature. The electrical equivalent of the armature coil can be described by an inductance in series with a resistance and an induced voltage which opposes the voltage source. It usually result from the rotation of the electrical coil through fixed flux of the permanent magnets and known as the back emf (Electromotive Force) as state above.

Figure 2: Electrical Representation of a DC Motor

Mainly, in the analysis of the above circuitry, Kirchhoffs Voltage and Current Laws will be applied. Therefore, we have:

With: voltage across armature [Volt] armature coil resistance, [ohms] armature coil inductance [Henry] induced Voltage [Volt] motor angular velocity [rad/s] motor constant [N.m/amps]

P a g e | 12 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Mechanical System
The conservation of energy theorem states that in an isolated system, the total amount of energy shall remain constant over time except in presence of combustion or nuclear reaction. As a result, the sum of the torques of the motor must be equal to zero. Therefore, we have:

With electromagnetic torque torque due to rotor acceleration torque due to rotor velocity torque constant damping coefficient

State Space Representation


State space modeling is typically a mathematical representation/model of a physical system as a set of input, output and state variables. The main advantage of such technics is the simple fact the all variables are related by first order differential equations. Therefore, from the final equation of the mechanical and electrical systems, it is possible to rewrite them as follow:

As a result, putting the differential equation into a space form gives:

P a g e | 13 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Transfer Function Block Diagram


A system block diagram can be developed from the differential Equation given the above equations. The equation can be expresses as follow:

Finally, using the Control Canonical Form, the Block Diagram we can derive the block diagram of the system. It becomes:

Figure 3: Complete Block Diagram of DC Motor Model

The block diagram can be simplified by making numerous assumptions. First, let us assume that the load torque is constant. Since the change in becomes zero (assuming that no load is acting against the torque from the motor), it does not need to appear in the block diagram. Secondly, if the only focus is places on the angular velocity , the armature current does not need to appear as well in the block diagram (can always be observe in simulation since it is an output). Therefore, the simplified diagram becomes:

Figure 4: Simplified Block Diagram of DC Motor Model

Finally, using different simplification theorem, or Masons rule, on can derive the overall Transfer Function of the DC Motor. It becomes:

P a g e | 14 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Another way to obtain the transfer function would be to use the transfer function formula from state space variables which is: Since , the feedforward matrix does not apply to our system, Therefore, we have: . Thus,

We note that using both methods, we obtain the same result. Thus this can be used as a confirmation method in order to ensure that the result is accurate. From the overall transfer function of the kinematic model of the permanent magnet dc motor, we obtain the simplified open loop block diagram of the system:

P a g e | 15 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Figure 5: Open-loop Block Diagram of DC Motor Model

Feedback Control System


A typical feedback system control particularly the one desired shall be constitute of a Plant/DC motor (to be controlled), and a Controller (to be designed). The controllers main application is to receive a signal and provide the appropriate excitation for the plant. Our design solely deals with Linear Control. Linear control systems as stated above can use feedback to produce a control signal mathematically based on other variables, with the intend to drive the plant within desired operating range or state error. The controller is the device which monitors and affects the operational conditions of the given system. A PID controller calculates an error value as the difference between a measured process variable and a desired set point. As its acronym states, it features a Proportional, an Integral, and a Derivative gain that dictates how the mathematical condition for the excitation signal are set.

Figure 6: Typical Feedback Control System

P a g e | 16 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Introduction to MATLAB/Simulink Simulation


The speed of a DC motor can be varied by controlling the field flux, the armature resistance or the terminal voltage applied to the armature circuit. This section of the project shall be divided into two parts. The first part will focus on MATLAB analysis, modeling the DC motor, and investigate stability and control methods. In the second part, we will look at Simulink models and feedback control methods for DC motor drives for dynamic analysis shall be presented.

Introduction to MATLAB
The name MATLAB stands for matrix laboratory. MATLAB is a high-performance language for technical computing. It integrates computation, visualization, and programming in an easy-touse environment where problems and solutions are expressed in familiar mathematical notation. Typically, MATLAB is used for Math and computation, algorithm development, modeling, simulation, and prototyping, data analysis and scientific and engineering graphics. MATLAB features a family of application-specific solutions called toolboxes. Very important to most users of MATLAB, toolboxes allow you to learn and apply specialized technology. Toolboxes are comprehensive collections of MATLAB functions (M-files) that extend the MATLAB environment to solve particular classes of problems. Areas in which toolboxes are available include signal processing, control systems, neural networks, fuzzy logic, wavelets, simulation, and many others.

Introduction to Simulink
Simulink has become over the past years the most widely software package use in colleges and universities for modeling and simulating dynamics systems. It has the capabilities of supporting linear and nonlinear system, modeled in continuous time, sampled time, or hybrid of the two. One of the main advantages of Simulink is the fact that it encourages user to try things out. User can easily build models from scratch, or take an existing model and modify it. Simulations are interactive, so users can change parameters on the spot and immediately see what happens. Finally, since MATLAB and Simulink are incorporated together, user can simulate, analyze, and revise the models in either environment at any point. Simulink turn the user computer into a lab for modeling and analyzing systems that simply wouldnt be possible or practical. It is so practical that thousands of engineers use it to solve real problems in their professional careers.

P a g e | 17 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

MATLAB Approach
MATLAB Modeling of DC Motor
To produce a good design, there needs to be some amount of modeling. The above transfer function can be entered into MATLAB by defining the numerator and denominator polynomials, using conventions of MATLABs Control Toolbox. We will start defining the different motor constants:
% Motor Constants % --------------------------------------------------------------------------kt = 0.0212; % Torque Constant kv = 1.64; % Motor Constant K = 0.212; % Constant since kt = kv La = 1; % Armature Inductance Ra = 2; % Armature Resistance J = 0.04; % Moment of inertial of rotor B = 0.15: % Damping Coefficient %----------------------------------------------------------------------------

The transfer function can be entered in MATLAB in a number of different ways. A good approach is in fact utilizing MATLAB built in control system toolbox to derive the transfer function from the state-space variable. Therefore, we have:
% Transfer Function Model (angular velocity)/(armature voltage) % --------------------------------------------------------------------------AA = [-Ra/La -kv/La; kt/J -B/J]; % State Matrix BB = [1/La; 0]; % Input Matrix CC = [0 1]; % Output Matrix DD = 0; % Feedforward Matrix [numTF denTF] = ss2tf(AA,BB,CC,DD); disp('DC Motor Model Representation'); TF = tf(numTF,denTF) %----------------------------------------------------------------------------

DC Motor Model Representation Transfer function: -8.882e-016 s + 0.53 -------------------s^2 + 5.75 s + 8.369

At this point of the analysis, we can utilize the result through MATLAB analysis to the one obtained manually as a mean of verification. As a result, we will simply compare both final transfer functions. Therefore, we have:

P a g e | 18 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

% Verification using Transfer Function Model obtained manually % --------------------------------------------------------------------------num = [kt/J*La]; den=[1 (J*Ra+B*La)/(J*La) (B*Ra+kt*kv)/(J*La)]; disp('Verification Transfer Function model'); TF2 = tf(num,den) % ---------------------------------------------------------------------------

Verification Transfer Function model Transfer function: 0.53 -------------------s^2 + 5.75 s + 8.369

Observing both results, we notice that they pretty much equal. In fact; State-Space Model Transfer Function:

Transfer Function Model Obtained Manually:

Therefore, we can conclude that:

Now that we have the transfer function entered in MATLAB, the intent is to analyze the system through various plots and responses. First we want to ensure that both transfer functions entered in MATLAB produce the same response. Therefore, we will plot basic step response in both cases:
% Step Response of DC Motor via Transfer Function % --------------------------------------------------------------------------step(TF); xlabel('t (sec)'); ylabel ('\omega_m (rad/sec)');

P a g e | 19 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

title('DC Motor Step Response via Transfer Function via State-Space Modeling');

% Step Response of DC Motor via obtained model % --------------------------------------------------------------------------step(TF2); xlabel('t (sec)'); ylabel ('\omega_m (rad/sec)'); title('DC Motor Step Response via Transfer Function via Manual result'); % --------------------------------------------------------------------------DC Motor Step Response via Transfer Function via State-Space Modeling
0.07 System: TF Final Value: 0.0633 0.06 System: TF Rise Time (seconds): 1.15 0.05

System: TF Settling Time (seconds): 1.99

(rad/sec)

0.04

0.03

0.02

0.01

0.5

1.5

2.5

t (sec) (seconds)

Figure 7: DC Step Motor Response via Transfer Function State-Space Model

P a g e | 20 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

DC Motor Step Response via Transfer Function via Manual result


0.07 System: TF2 Final Value: 0.0633

0.06

System: TF2 Settling Time (seconds): 1.99 System: TF2 Rise Time (seconds): 1.15

0.05

m (rad/sec)

0.04

0.03

0.02

0.01

0.5

1.5

2.5

t (sec) (seconds)

Figure 8: Step Response of DC Motor Model Manually Obtained

Characteristic Constants
Rise Time Settling Time Steady State response Transfer Function from State-Space Model 1.15 sec 1.99 sec 0.0633 rad/sec Transfer Function Manually Obtained 1.15 sec 1.99 sec 0.0633 rad/sec

We shall note that using both models, we obtained the same Step Response which confirms the result obtained above. Now let us create different analysis plot to fully understand the behavior of our system. We shall plot the RootLocus, an Impulse and Ramp Responses, the Bode Plots, and the Nyquist Plot.

Linear Analysis
Let us look and analyze the different response and plot of the system. We will be looking at the following different plots: Root Locus, Impulse response Ramp response

P a g e | 21 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Bode Diagram Nyquist Diagram

Root Locus Diagram of DC Motor Model


Root Locus
2

1.5

Imaginary Axis (seconds -1)

0.5

-0.5

-1

-1.5

-2 -3.5

-3

-2.5

-2

-1.5

-1

-0.5

0.5

Real Axis (seconds-1)

Figure 9: Root Locus Plot of DC Motor Model

The importance of the root locus method for control system theory lies in the fact that the location of the system poles determines its overall stability as well as the transient response. It is a simple graphical approach different from the Routh-Hurwitz Stability Table. In our case, we observe that both poles are located on the negative side of the imaginary axis (i.e. on the left side). This implies that the system is Stable throughout.

P a g e | 22 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Impulse Response of DC Motor Model


Impulse Response
0.07 System: TF Peak amplitude: 0.0677 At time (seconds): 0.347

0.06

0.05

0.04

Amplitude

0.03

0.02

0.01 System: TF Settling Time (seconds): 2.34 0

-0.01

0.5

1.5

2.5

3.5

Time (seconds)

Figure 10: Impulse Response of DC Motor Model

In control theory the impulse response is the response of a system to a Dirac Delta input. A Dirac Delta input or function is generalized function on the real number line that is zero everywhere except at zero, with an integral of one over the entire real line. As a result, its Laplace transform is 1. It is usually utilized to ensure proper settling time.

P a g e | 23 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Ramp Response of DC Motor Model


Step Response
0.05

0.045

0.04

0.035

0.03

Amplitude

0.025

0.02

0.015

0.01

0.005

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

Time (seconds)

Figure 11: Ramp Response of DC Motor Model

P a g e | 24 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Bode Plots of DC Motor Model


Bode Diagram -20 -30 -40 -50 -60 -70 -80 -90 360 System: TF Gain Margin (dB): 316 At frequency (rad/s): 5.86e+007 Closed Loop Stable? Yes

Magnitude (dB) Phase (deg)

315

270

225

180 10
-1

10

10

10

Frequency (rad/s)

Figure 12: Bode Diagrams of DC Motor Model

P a g e | 25 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Nyquist Diagram of DC Motor Model


Nyquist Diagram
0.05

0.04

0.03

0.02

Imaginary Axis

0.01

System: TF Gain Margin (dB): 316 At frequency (rad/s): 5.86e+007 Closed Loop Stable? Yes

System: TF Peak gain (dB): -24 Frequency (rad/s): 5.79e-017

-0.01

-0.02

-0.03

-0.04

-0.05 -1

-0.8

-0.6

-0.4

-0.2

0.2

0.4

Real Axis

Figure 13: Nyquist Diagram of DC Motor Model

Any system can be unstable depending on certain characteristics that can be graphically analyzed. Thus oscillation with increasing amplitudes in the signal can occur. It is also important to realize that stability shall remain independent of the input signal. To summarize the result obtain from the above analytical graphs and diagram, we have: The root locus as stated above display both poles (root of the characteristic equation) of the system on the left side of the imaginary axis; which predict total stability. Later, it is confirm by the plot of the responses. Finally, the system is observed to be overdamped which turn out to be crucial in the sense that the motor rotation does not oscillate.

P a g e | 26 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Controller Design
As states above, the implementation of the PID type Controller is generically couple with a control loop feedback mechanism. The PID controller has historically been considered the best controller. By tuning the parameters, the controller can provide control action designed for specific process requirements. Because of its now feedback structure the system can become unstable; oscillations with increasing amplitudes in the response can occur. We shall focus on stability for our linear system that is independent of the input-output signals. In doing so, of the most commonly applied techniques is coupling the plant with a Proportional-Integral-Derivative Controller. The most important/crucial aspect of such application is appropriately tuning all three parameters in order to obtain the desired output. Therefore the approach chosen is to observe the response of the system as a result of step excitations and varying gain parameters.

PID Controller Approach


Proportional Control We shall begin by using a proportional controller. The goal of is first to observe the impact of the proportional gain based controller on a linear system. Therefore we shall implement a small MATLAB program that will display on the same graph the responses based on increasing proportional gain:
% Proportional Controller % --------------------------------------------------------------------------Kp = 30:5:70; for i=1:length(Kp); num_p = Kp(i)*num; den_p = den; [num_P,den_P] = cloop(num_p,den_p); step(num_P,den_P); hold on end xlabel ('t (sec)'); ylabel('\omega_m (rad/sec)'); title ('Step Response with Proportion Control: 30 < K < 70'); % ---------------------------------------------------------------------------

P a g e | 27 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Step Response w ith Proportion Control: 0 < K < 50

0.8

m (rad/sec)

0.6

0.4

0.2

0.5

1.5 t (sec) (seconds)

2.5

Figure 14: Step Response with Proportion Control: 30<Kp<70 with Increment of 5

Typically, the proportional term produces an output value that is proportional to the current error value. The proportional response is adjusted by multiplying the error by a constant Kp, known as proportional gain. As we observe the effect of the PD controller, but particularly Kp on the system, we note the following: - Regardless of the value of Kp, the system becomes underdamped with increasing overshoot - The proportional has an important impact on the steady state error, - The rise time as well as the settling time does change by a very slight amount sometime negligible, - The system remain stable, even its overall stability can be degraded. Proportional-Derivative Controller
% Proportional-Derivative Controller % --------------------------------------------------------------------------Kp = 122; Kd = 0:2:10; for j=1:length(Kd); num_pd = conv(num,[Kd(j) Kp]); [num_PD,den_PD] = cloop(num_pd,den); step(num_PD,den_PD); hold on; end xlabel ('t (sec)'); ylabel('\omega_m (rad/sec)');

P a g e | 28 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

title ('Step Response with PD-Controller'); % --------------------------------------------------------------------------Step Response w ith PD-Controller

1.2

0.8

(rad/sec)

0.6

0.4

0.2

0.5

1.5

2.5

t (sec) (seconds)

Figure 15: Step Response with PD Controller Kp = 122; 0<Kd<10

We observe the following: - First with constant proportional gain, the derivative gain does not influence the steady state error as well as overall stability - However, the rise time, settling time, and overshoot are influenced as they all decrease as the derivative gain increases.

Proportional-Integral Controller
% PI Controller % --------------------------------------------------------------------------Kp = 30; Ki = 30:10:80; Kd = 0; for k=1:length(Ki); num_pi = [Kd Kp Ki(k)]; den_pi = [1 0]; [num_PI,den_PI] = cloop(conv(num,num_pi),conv(den,den_pi));

P a g e | 29 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

step(num_PI,den_PI); hold on; end xlabel ('t (sec)'); ylabel('\omega_m (rad/sec)'); title('Step Response with PI Controller'); % --------------------------------------------------------------------------Step Response w ith PI Controller 1.4

1.2

(rad/sec)
m

0.8

0.6

0.4

0.2

t (sec) (seconds)

Figure 16: Step Response of DC Motor with PI Controller Kp = 30; 30<Ki<80

We observe the following: The integral gain affect minutely the rise time and settling time of the system However it does not change the overall stability of the system On the other hand, it appears that it does affect the overshoot or peak response

PID Controller
% PID Controller % --------------------------------------------------------------------------Kp = 30; Kd = 1.4; Ki = [30:10:80]; for k=1:length(Ki);

P a g e | 30 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

num_C = [Kd, Kp, Ki(k)]; den_C = [1 0]; num_pid = conv(num,num_C); den_pid = conv(den,den_C); [num_PID,den_PID] = cloop(num_pid,den_pid); step(num_PID,den_PID); hold on; end xlabel ('t (sec)'); ylabel('\omega_m (rad/sec)'); title ('Step Response with PID-Controller'); % --------------------------------------------------------------------------Step Response w ith PID-Controller

1.2

0.8

(rad/sec)

0.6

0.4

0.2

0.5

1.5

2.5

3.5

4.5

t (sec) (seconds)

Figure 17: Step Response of DC Motor with PID Controller Kp = 30; Kd = 1.4; 30<Ki<80

The final tuning of the controller was done using an arbitrary approach of trial and error. The fact of the matter is that it was only possible due to the fact that we are dealing with a fairly simple system. In the case of more complex system such as those above second degree systems, or nonlinear system including disturbance, this approach will more than likely fail. Nonetheless there are different established methods that exist: Manual Tuning Which is the one employed above; it does not involves any Mathematical method, but is more effective for users with personnel experiences Ziegler-Nichols

P a g e | 31 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

It is a proven mathematical method; however this process also includes some trial anderror with very aggressive tuning. Cohen-Coon It is a good process models that include some math. Nonetheless it is often limited to first order system. Software Tool Software such as MATLAB often have methodology to automatically derive the best tuning gains for a great range of system. Their high cost is usually their major flaws couple with required training.

Matlab Tuning Tool


MATLAB offers a very simple way to obtain the best PID gain for the controller. In fact, it ensure that the controller will not affect the stability of the system. It produce results that provide with a robust system, balancing the response time with the stability margin. Therefore we have:

% Verification using Transfer Function Model obtained manually % --------------------------------------------------------------------------num = kt/J*La; den=[1 (J*Ra+B*La)/(J*La) (B*Ra+kt*kv)/(J*La)]; disp('Verification Transfer Function model'); TF2 = tf(num,den) Pidtune(TF2,'pid') Kp = 30.1; Ki = 59.2; Kd = 1.4; num_pid = [Kd Kp Ki]; den_pid = [1 0]; [num_PID,den_PID] = cloop(conv(num,num_pid),conv(den,den_pid)); step(num_PID,den_PID); xlabel('t (sec)'); ylabel('\omega_m (rad/sec)'); title('Step Response of DC Motor with Tuned PID Controller'); % ---------------------------------------------------------------------------

Continuous-time PID controller in parallel form: 1 Kp + Ki * --- + Kd * s s With Kp = 30.1, Ki = 59.2, Kd = 1.4

P a g e | 32 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Step Response of DC Motor w ith Tuned PID Controller 1.4

1.2

System: sys Peak amplitude: 1.1 Overshoot (%): 9.72 At time (seconds): 0.949 System: sys Settling Time (seconds): 1.43

(rad/sec)

0.8

System: sys Rise Time (seconds): 0.467

0.6

0.4

0.2

0.5

1.5

2.5

t (sec) (seconds)

Figure 18: Step Response of DC Motor with Tuned PID Controller

Finally, we obtain the best PID gain as follow: Proportional Gain: Integral Gain: Derivative Gain:

The result shows that for the best fit under PID controller, the characteristic of the controlled system are the following: Rise Time: Settling Time: Percent Overshoot:

P a g e | 33 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

State-Variable Feedback Design Controller


Controllability Analysis State-space techniques tend to be limited when it comes to certain system such nonlinear ones. As a result another tool, can be used to, if properly utilized, control the desire plant for accurate result. This technique solely rest on the principle that in a feedback system; the output usually denote y, is fed to the system matrix. However, if instead of just the error being fed back, appropriate gains would generate better results. Nonetheless, in order to viably apply such technique, one need to ensure that the plant; or in this case the DC motor is indeed controllable. This is simply done through the controllability matrix. Controllability implies that from any initial value to any final value within some finite time window. The theory state that the system shall be controllable is the rank of the Controllability matrix is the same as the order of the system (number of row in system matrix). Therefore, we have:

% State-Space Variable Feedback Controller; % --------------------------------------------------------------------------AA = [-Ra/La -kv/La; kt/J -B/J]; % State Matrix BB = [1/La; 0]; % Input Matrix CC = [0 1]; % Output Matrix DD = 0; % Feedforward Matrix TFss = ss(AA,BB,CC,DD); CM = ctrb(TFss) % Controllability Matrix rank(CM) %----------------------------------------------------------------------------

CM = 1.0000 0 ans = 2

-2.0000 0.5300

As stated above, the point of the above analysis was to determine whether or not our DC motor is controllable. The rank of the controllability matrix turns out to be 2, which is equal to the order of the system. Thus we can apply state-space variable feedback theories since the system is controllable.

P a g e | 34 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Full-State Feedback Controller Now that we ensure that our system is controllable, we want to define the governing parameters for the dc motor. Arbitrarily, we decided that the most important characteristics a dc motor transient response shall be the percent overshoot, and the settling time. Thus we want to design the phase-variable feedback gains to yield 5% overshoot and a settling time of 0.8 second. Note that the methodology through MATLAB shall be not only different but a little different that the approach when solving the problem by hand. The schematic for a full-state feedback system is:

Figure 19:Schematic of a Full-State Feedback System

The characteristic equation for the closed loop system is the determinant of . The expectation is 2 poles for the system. Therefore, we can arbitrarily pick the poles to fit the design requirements. Therefore we have:

% Feedback Design Controller % --------------------------------------------------------------------------OS = 5; Ts = 0.8; caushy = (-log(OS/100))/sqrt(pi^2+(log(OS/100))^2); Wn = 4/(caushy*Ts); p1 = -caushy * Wn + sqrt(-Wn^2 + caushy^2 * Wn^2); p2 = -caushy * Wn - sqrt(-Wn^2 + caushy^2 * Wn^2) K = place(AA,BB,[p1 p2]); step(AA-BB*K,BB,CC,DD,1,3); xlabel ('t (sec)'); ylabel('\omega_m (rad/sec)'); title('Step Response with Full-State Feedback Controller'); % ---------------------------------------------------------------------------

P a g e | 35 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

System: sys 0.012 Peak amplitude: 0.0106 Overshoot (%): 5 At time (seconds): 0.598

Step Response w ith Full-State Feedback Controller

System: sys Settling Time (seconds): 0.827

0.01

0.008

(rad/sec)

0.006

0.004

0.002

0.5

1.5

2.5

t (sec) (seconds)

Figure 20: Step Response with Full-State Feedback Controller

We observe that the system is behaving as expected. In fact the response displayed an overshoot of 5% and a settling time of 0.827 second. However, we observe that there is a huge steady state error with can be handle by adding a constant gain such as a proportional gain. Therefore, we have:

% Eliminating Steady State Error % --------------------------------------------------------------------------Nbar = rscale(AA,BB,CC,DD,K); step(AA-BB*K,BB*Nbar,CC,DD,1,3); % ---------------------------------------------------------------------------

P a g e | 36 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Step Response 1.4

1.2

Amplitude

0.8

0.6

0.4

0.2

0.5

1.5

2.5

Time (seconds)

Figure 21:Final Step Response with Full-State Feedback Controller

Note that, in the program, we used a function called rscale, that is not included in MATLAB library. rscale, simply find the factor for a full-state feedback system to eliminated the steadystate error. Credit is given to Yanjie Sun of the University of Michigan under the supervision of Prof. D. Tilbury. In addition, the result turned out to be very accurate.

Discrete Time Analysis


Step Response in Discrete Time Domain A discrete-time couples discrete signal to discrete controller and plant. The discrete-time signal can be defined as a sequence or a series of signal values defined in defined points of time. Commonly, an AD-converter (analog-digital) converts the signal for computer operations. The first step is to convert the continuous transfer function to a discrete transfer function. It will be coupled with a zero-order-hold and the sampling time will be appropriately chosen. For design purpose, we will plot the step response for the following sampling time Ts equal to 0.1 second. As a result, we have:

% Continous to Discrete Modeling

P a g e | 37 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

% --------------------------------------------------------------------------Ts = 0.12; [numz,denz] = c2dm(num,den,Ts,'zoh'); numz = [numz(2) numz(3)]; [numz_cl,denz_cl] = cloop(numz,denz); [x1] = dstep(numz_cl,denz_cl,101); t = 0:0.12:12; stairs(t,x1) xlabel ('t (sec)'); ylabel('\omega_m (rad/sec)'); title('Step Response of DC Motor for Discrete Model Ts = 0.1 sec') % --------------------------------------------------------------------------Step Response of DC Motor for Discrete Model Ts = 0.1 sec 0.06

0.05

0.04

m (rad/sec)

0.03

0.02

0.01

0.5

1.5 t (sec)

2.5

Figure 22: Step Response of DC Motor for Discrete Model Ts = 0.1

We observe that for sampling time equal to 0.1 sec the response behave like a desired discrete model. Therefore, it shall be the required sampling time. Now that we converted the DC motor system model to convenient discrete time model, we want to couple it to a convenient PID controller as operated for continuous time domain. The approach will not change in order to be more efficient.

P a g e | 38 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

PID Controller Discrete Time Domain In the step above, MATLAB helped convert the continuous time system to discrete time. Now in order to implement the PID controller, we shall apply the same process to convert the controller to discrete domain as well. The same gains will be applied except for the Integral gain; the reason being that we desire better control on the overshoot of the response. Therefore, we have:

% Discrete PID Controller % --------------------------------------------------------------------------Kp = 35; Ki = 59.2; Kd = 1.4; [dencz,numcz] = c2dm([1 0],[Kd Kp Ki],Ts,'zoh'); numaz = conv(numz,numcz); denaz = conv(denz,dencz); [numaz_cl,denaz_cl] = cloop(numaz,denaz); [x2] = dstep(numaz_cl,denaz_cl,31); stairs(t,x2) xlabel ('t (sec)'); ylabel('\omega_m (rad/sec)'); title('Step Response of DC Motor for Discrete Model with PID Controller') % ---------------------------------------------------------------------------

P a g e | 39 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Step Response of DC Motor for Discrete Model with PID Controller 1.4

1.2

m (rad/sec)

0.8

0.6

0.4

0.2

0.5

1.5 t (sec)

2.5

Figure 23:Step Response of DC Motor for Discrete Domain with PID Controller

An observation of the response shows that the system behaves as expected. It displays the exact same characteristics as the time domain response. The plot shows that the settling time is about 1.5 seconds which satisfies our design requirements.

P a g e | 40 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Simulink Modeling & Simulation


Simulink Modeling of DC Motor
The fact of the matter is Simulink is very often assimilate to MATLAB but not often, it is emphasize that it is in itself a complete analysis, simulation, and optimization tool. In fact, systems like ours can easily be modeled and simulated in real time through Simulink. Simulink provides an interface that is a graphical block diagramming tool and a customizable set of block libraries. As a result, our system will be implemented simply by reproducing the simulation block diagram obtained above. Therefore, we have:

Figure 24: Simulation Block Diagram of DC Motor Model in Simulink

Figure 25:Step Response of DC Motor Model in Simulink

P a g e | 41 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Simulink also offer the possibility to work on state-space domain. This implies that it is not require to convert the state-space variables to time domain form in order to obtain simulation. As a result, we have the possibility to model the DC Motor simply by using the state-space variable obtained above. Therefore, we have:

Figure 26:Simulation Block Diagram of Dc Motor via State-Space Model

Figure 27:Step Response of Dc Motor Simulink Model via State-Space Modeling

Controller Design
We want to observe as done above different step responses as a result of PID gain parameters. The approach is rather simple; first create a subsystem that will be the DC motor model (above system). A second system will be implemented. It will represent the PID Controller. Finally replicate the process for changing the value of the desired gain; then display all output on a single scope using an appropriate bus creator. Thus we have:

Proportional Controller

P a g e | 42 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

P a g e | 43 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Figure 28: Step Response with Proportion Control: 25<Kp<45

Proportional-Derivative Controller

P a g e | 44 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Proportional-Integral Controller

P a g e | 45 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

PID Controller
We observe the same the result as the one produced in the Matlab program. Thus, it confirms not only the viability of the model and the methodology. Now using this new and enhanced tool that is Simulink, we will produce the final response for the tuned PID Controller. Therefore, we have:

Figure 29: Final PID Controller Tuning

P a g e | 46 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Figure 30:Step Response of Final PID Controller Tuning Kp = 30.1, Kd = 59.2, Ki = 1.4

Discrete Time Analysis

P a g e | 47 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

P a g e | 48 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Conclusion and Future Work


Throughout the project, the goal was to electronically design a controller that shall accurately control the angular velocity of a permanent magnet dc motor given the input voltage as the overall input. In order to achieve such task, we had to accurately model the actual DC Motor based on constants obtain from the datasheet and kinematic relationships. An accurate model was derived, and the observation of the different responses and plot showed that not only the system was stable but responded as expected. The second task was then to design an adequate controller for the system. A PID controller was implemented showing show the respective gains (proportional, derivative, and integral) influenced the transient and steady-state responses. Finally the overall system was discretized. In fact, digital system tends to produce better result easily handled by electronic device and computers. There are number of topics for future work and development related with the simulation model designer in this thesis. These include: Inserting external disturbances and possibly noise created by the coil and magnetic field. This will make the above simulation as close to reality as possible. A second aspect could be implementing a controller that shall be the synergy between linear control theory, and fuzzy logic, to enhance robustness, and stability Finally, include in the design the PWM or Pulse Width Modulation

P a g e | 49 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Bibliography
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] M. Ong, Dynamic Simulation of Electric Machinery using MATLAB/Simulink, Prentice Hall, Upper Saddle River, NJ, 1998 M. S Sarma, Electric Machines: Steady State Theory and Dynamic Performance, 2nd ed, West, St. Paul MN, 1994 P. C, Sen. Principles of Electric Machines and Power. John Wiley & Sons, 1997 S. J. Chapman, Electric Machines Fundamentals, 3rd ed, WCB/McGrawHill, New York, 1998 M. H. Rashid, Power Electronics: Circuit, Devices, and Applications, Prentice Hall, New Jersey, 1988 J. J. Cathey, Electric Machine: Analysis and Design Applying Matlab, McGraw Hill Company, New York, 2011 Matlab/Simulink Software, Version 7.120 R2011a, The Math Works, Inc., 2002. H. R. Bishop, C. Richard, Modern Control Systems 9th ed Upper Saddle River, New Jersey, Prentice-Hall Inc. G. J. Bollinger, A. Neil, Computer Control of Machines and Processes, New York, Addisson-Wesley Publishing Company, 1998 R. S. Burns, Advanced Control Engineering, Boston, Butterworth Heineman, 2001. N. S.Nise, Control Systems Engineering 6th ed, John Wiley & Sons, Inc., 2006.

P a g e | 50 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Appendices
Appendix A: MATLAB Source Code
clear; clear all; clc; % Motor Parameters Constants % ---------------------------------------------------kt = 0.0212; % Torque Constant kv = 1.64; % Motor Constant K = 0.0212; % Constant La = 1; % Armature Inductance Ra = 2; % Armature Resistance J = 0.04; % Moment of inertial of rotor B = 0.15; % Damping Coefficient % ----------------------------------------------------

% Transfer Function Model (angular velocity)/(armature voltage) % --------------------------------------------------------------AA = [-Ra/La -kv/La; kt/J -B/J]; % State Matrix BB = [1/La; 0]; % Input Matrix CC = [0 1]; % Output Matrix DD = 0; % Feedforward Matrix [numTF denTF] = ss2tf(AA,BB,CC,DD); disp('DC Motor Model Representation'); TF = tf(numTF,denTF) %----------------------------------------------------------------

% Verification using Transfer Function Model obtained manually % ------------------------------------------------------------num = [kt/J*La]; den=[1 (J*Ra+B*La)/(J*La) (B*Ra+kt*kv)/(J*La)]; disp('Verification Transfer Function model'); TF2 = tf(num,den) % -------------------------------------------------------------

% Step Response of DC Motor via Transfer Function % ------------------------------------------------------figure(6); step(TF) xlabel('t (sec)'); ylabel ('\omega_m (rad/sec)'); title('DC Motor Step Response via Transfer Function via State-Space Modeling');

% Step Response of DC Motor via obtained model % --------------------------------------------------------------figure(7); step(TF2) xlabel('t (sec)'); ylabel ('\omega_m (rad/sec)'); title('DC Motor Step Response via Transfer Function via Manual result');

P a g e | 51 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

% ---------------------------------------------------------------

% Creating the Plot for Analysis % ------------------------------------------------------figure(1); rlocus(TF); figure(2); impulse(TF); figure(3); step(TF,1); figure(4); bode(TF); figure(5); nyquist(TF); figure(8); nichols(TF); % -------------------------------------------------------

% Proportional Controller % ------------------------------------------------------Kp = [30:5:70]; for i=1:length(Kp); num_p = Kp(i)*num; den_p = den; [num_P,den_P] = cloop(num_p,den_p); step(num_P,den_P); hold on end xlabel ('t (sec)'); ylabel('\omega_m (rad/sec)'); title ('Step Response with Proportion Control: 30 < K < 70'); % --------------------------------------------------------

% Proportional-Derivative Controller % -------------------------------------------------------Kp = 122; Kd = [0:2:10]; for j=1:length(Kd); num_pd = conv(num,[Kd(j) Kp]); [num_PD,den_PD] = cloop(num_pd,den); step(num_PD,den_PD); hold on; end xlabel ('t (sec)'); ylabel('\omega_m (rad/sec)'); title ('Step Response with PD-Controller'); % --------------------------------------------------------

% PI Controller % -------------------------------------------------------Kp = 30; Ki = [30:10:80]; Kd = 0; for k=1:length(Ki); num_pi = [Kd Kp Ki(k)]; den_pi = [1 0]; [num_PI,den_PI] = cloop(conv(num,num_pi),conv(den,den_pi)); step(num_PI,den_PI); hold on;

P a g e | 52 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

end xlabel ('t (sec)'); ylabel('\omega_m (rad/sec)'); title('Step Response with PI Controller'); % --------------------------------------------------------

% PID Controller % -------------------------------------------------------Kp = 30; Kd = 1.4; Ki = [30:10:80 ]; for z=1:length(Ki); num_C = [Kd, Kp, Ki(z)]; den_C = [1 0]; num_pid = conv(num,num_C); den_pid = conv(den,den_C); [num_PID,den_PID] = cloop(num_pid,den_pid); step(num_PID,den_PID); hold on; end xlabel ('t (sec)'); ylabel('\omega_m (rad/sec)'); title ('Step Response with PID-Controller'); % --------------------------------------------------------

% Continous to Discrete Modeling % -------------------------------------------------------Ts = 0.1; TF_D = c2d(TF,Ts,'zoh'); TF_CL = feedback(TF_D,1); dstep(TF_CL,1); xlabel('t (sec)'); ylabel('\omega_m (rad/sec)'); title('Stairstep Response:Original'); % --------------------------------------------------------

% Tuned PID Controller Response % ------------------------------------------------------------pidtune(TF2,'pid') Kp = 30.1; Ki = 59.2; Kd = 1.4; num_pid = [Kd Kp Ki]; den_pid = [1 0]; [num_PID den_PID] = cloop(conv(num,num_pid),conv(den,den_pid)); step(num_PID,den_PID); xlabel('t (sec)'); ylabel ('\omega_m (rad/sec)'); title('Step Response of DC Motor with Tuned PID Controller'); % -------------------------------------------------------------

P a g e | 53 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Appendix B: DC Motor Datasheet

P a g e | 54 CONTROL SYSTEM FOR DC MOTOR: Advanced Control Method using MATLAB/SIMULINK

Das könnte Ihnen auch gefallen