Idea Transcript
• INTRODUCTION (Kuo, 1995) ¾ What a control system is. ¾ Why control systems are important. ¾ What the basic components of a control system are. ¾ Some examples of control system applications. ¾ Why feedback is incorporated into most control
systems.
¾ Types of control systems.
What a control system is: (Kuo, 1995) To answer the question, we can cite that in our daily life there are numerous “objectives” that we need to be accomplished. For instance,
We need to regulate the temperature and humidity of homes and buildings for comfortable living.
We need to control the automobile and airplane to go from one point to another accurately and safely.
1
Manufacturing processes contain numerous objectives for products that will satisfy the precision and costeffectiveness requirements.
A human being is capable of performing a wide range of tasks, including decision making. Some of these tasks, such as picking up objects and walking from one point to another, are commonly carried out in a routine fashion.
Under certtain conditions, some of these tasks are to be performed in the best possible way. For instance, sprinter running a 100 m has the objective of running that distance in the shortest possible time.
A marathon runner, on the other hand, not only must run the distance as quickly as possible, but in doing so, he or she must control the consumption of energy and devise the best strategy for the race. The means of achieving these “objectives” usually involve the use of control systems that implement certain control strategies. RESERVOIR HILL ELECTRICITY
Sun
VALVE PUMP
MOTOR
IRRIGATION
Solar Collector GROUND LEVEL
WATER LEVEL
2
In recent years, control systems have assumed an increasingly impotant role in the development and advancement of modern civilization and technology. Practically every aspect of our day-to-day activities is affected by some type of control systems. Control systems are found in abundance in all sectors of industry, such as quality control of manufactured products, automatic assembly line, machine-tool control, space technolgy and weapon systems, computer control, transportation systems, power systems, robotics, and many others. Even the control of inventory and social and economic systems may be approached from the theory of automatic control.
Basic Components of a Control System: The basic ingredients of a control system can be described by: 1.Objective of control 2.Control system components 3.Results or outputs The basic relationship between these components is illustrated in Fig. 1. OBJECTIVES
CONTROLSYSTEM SYSTEM CONTROL
RESULTS
Figure 1. Basic components of a control system.
3
In more technical terms, the objectives can be identified with inputs, or actuating signals, u, and the results are also called outputs, or the controlled variables, y. In general, the objective of the control system is to control the outputs in some prescribed manner by the inputs through the elements of the control system.
Examples of Control System Applications: Industrial Sewing Machine: Sewing, as a basic joining operation in the garment making process, is in principle a rather complicated and laborious operation. For low cost and high productivity, the sewing industry has to rely on sophisticated sewing machines to increase the speed and accuracy of the sewing operations. Sewing machines can produce different type of stitches with a typical rate of over 100 stitches per second. One stitch corresponds to new revolution of the machine main shaft, which translates to top speeds as high as 8000 rpm. An ideal velocity profile of one start-stop cycle of the machine is shown in Fig. 2.
4
IDLE
RUN COMMAND
STOP COMMAND
VELOCITY
A
POSITION LOOP ON
B
ta
tb
C
tps
TIME (s) Figure 2. Ideal velocity profile of one start-stop cycle of an industrial sewing machine.
Typically, there should be no velocity overshoot at point A and no undershoot at point B. Acceleration time ta , deceleration time tb , and position search time tps , should be as short as possible. When the machine reaches the stopping point, C, there should be zero or negligible oscillations. To achive these performance objectives, the control system in the machine should be designed with stringent requirements.
5
Temperature Control System:
Thermo Couple
Thermometer
Mixer
Hot water
Hot water
Steam Controler
Manuel Control valve
Steam Automatic control valve
Cold water
Cold water Automatic Control
Manuel Control
Fluid Level Control Systems:
Pressured air
Plate
Adjustment Point Membrane Float
Float Fluid
Fluid
Valve Mechanical Control
Valve Pneumatic Control
6
Temperature Control of an Industrial Oven: Thermo-couple
Pragrammed Input
Industrial oven Temperature signal
Electronic Controller
Material
Valve
Fuel
Types of Control Systems: Open-Loop Control Systems (Nonfeedback Systems) The elements of an open-loop control system can usually be divided into two parts: the controller and the controlled process, as shown below. Reference input r
CONTROLLER
Actuating signal u
CONTROLLED PROCESS
Controlled variable y
An input signal or command r is applied to the controller, whose output acts as the actuating signal u ; the actuating signal then controls the controlled process so that the controlled variable y will perform according to prescribed standards. In simple cases, the controller can be an amplifier, mechanical linkage, filter, or other control element, depending on the nature of the system. Because of the simplicity and economy of open-loop control systems, we find this type of system in many noncritical applications.
7
Closed-Loop Control Systems (Feedback Control Systems) What is missing in the open-loop control system for more accurate and more adaptive control is a link or feedback from to the output to the input of the system. To obtain more accurate control, the controlled signal y should be fed back and compared with the reference input, and an actuating signal proportional to the difference of the input and the output must be sent through the system to correct the error. A system with one or more feedback paths such as that just described is called a closed-loop system.
Reference Error detector input r
+
+
e
CONTROLLER
-
DISTURBANCE, LOAD CONTROLLED PROCESS
+
TRANSDUCER
Controlled variable y
Feedback
Input, Output, Disturbance Manipulated inputs
Measured outputs Process Unmeasured outputs
Disturbance inputs Controller Manipulated input Process Disturbance input
8
Taking a Shower
Hot water
Cold water
Control objectives: Control objectives when taking a shower include the following: •to became clean •to be comfortable (correct temperature and water velocity a it contacts the body) •to “look good” (clean hair, etc.) •to became refreshed
9
To simplify our analysis, we discuss how we can satisfy the second objective (to maintain water temperature and flow rate at comfortable values). Similar analysis can be performed for the other objectives. Input variables: The manuplated input variables are hot-water and cold-water valve positions. Some showers can also vary the velocity by adjustment of the shower head. Another input is body position-we can move into and out of the shower stream. Disturbance inputs include a drop in water pressure (say, owing to toilet flushing) and changes in hot water temperature owing to “using up the hot water from the heater.”
Output variables: The “measured” output variables are the temperature and flow rate (or velocity) of the mixed stream as it contacts our body. Constraints (hard and soft): The are minumum and maximum valve positions (and therefore flow rates) on both streams. The maximum mixed temperature is equal to the hot water temperature and the minumum mixed temperature is equal to the cold water temperature. The previous constraints were hard constraints - they can not be physically violated. An example of a soft constraints is the mixed-stream water temperature – we do not want it to be above a certain value because we may get scalded. This is a soft constraint because it can physically happen, although yo do not want it to happen.
10
Operating characteristics: This process is continuous while we are taking a shower but is most likely viewed as a batch process, since it is a small part of our day. Safety, environmental and economic considerations: Too high of a temperature can scald us - this is certainly a safety consideration. Economically, if our showers are too long, more energy is consumed to heat the water, costing money. Environmental (and economically), more water consumption means that more water and wastewater must be treated. An economic objective might be to minimize the shower time. However, if the shower time is too short, or nor frequent enough, our clothes will become dirty and must be washed more often – increasing our clothes- cleaning bill.
Control structure: This is a multivariable control problem because adjusting either valve affects both temperature and flow rate. Control manipulations must be “coordinated”, that is, if the hotwater flow rate is increased to increase the temperature, the cold-water flow rate must be decreased to maintain the same total flow rate. The measurement signals are continuous, but the manipulated variable changes are likely to be discrete (unless our hands are continuously varying the valve positions).
11
Feedback control: As the body feels the temperature changing, adjustments to one or both valves is made. As the body senses a flow rate or velocity change, one or both valves are adjusted. F2 Height setpoint
Level transmitter
F1
LT
h
hm
F2
LC
hsp
hsp
Controller
Valve
F1
h
Process
hm Level controller
Level transmitter
Feed-forward control: If we hear the toilet flush, we move our body out of the stream to avoid the higher temperature that we anticipate. Notice that we are making a manipulated variable change (moving our body) before the effect of an output (temperature or flow rate) change is actually detected.
F1
Flow measurement
FM
F1
FFC
h
F2
Controller
Valve
F2
Process
h
12
1-DOF MASS&SPRING SYSTEM f(t) D’ALEMBERT principle
f
m x x(t) x(t)=xs+xd k
x , x& , &x&
c kx
For static case,
m &x&
m
mg
g
c x&
m &x&( t ) + c x& ( t ) + k x ( t ) = f ( t ) + mg (1) k x s = mg x& and &x& = 0 and f=0
Substituting x(t)=xs+xd into Eq.(1) yields
m &x& d + cx& d + kx s + kx d = f + mg
k x s = mg
m &x& d + cx& d + kx s + kx d = f + mg m &x& d + cx& d + kx d = f
In dynamic analysis, we consider the motion of the bodies around their static equilibrium positions, then the governing equation of motion is written as follows
m &x& + cx& + kx = f ENERGY method
f(t) m
x(t) g
x(t)=xs+xd k
c
1 E1 = m x& 2 2 1 2 E2 = k x − m g x 2 δW = f δx − c x& δx d ⎛ ∂E1 ⎞ ∂E 2 = Qx ⎟+ ⎜ dt ⎝ ∂x& ⎠ ∂x
d ⎛ ∂E1 ⎞ d ⎟ = (m x& ) = m &x& ⎜ dt ⎝ ∂x& ⎠ dt
∂E 2 = k x − mg ∂x
Q x = f − c x&
m &x& + cx& + kx = f + mg For static case,
x& and &x& = 0
and f=0
x(t)=xs+xd
m &x& d + c x& d + k x s + k x d = f + mg
m &x& + cx& + kx = f
k x s = mg
Degree of Freedom Energy Equations Virtual Work
MECHANICAL SYSTEMS
f(t)
Static Equilibrium Position
mg δstatic = k
m x(t) k (N/m)
c (Ns/m) F(t) Æ input X(t) Æoutput
1 DOF System (Mass&Spring)
f(t)
1 2 E1 = mx& 2
m
k (N/m)
x(t) c (Ns/m)
1 2 E 2 = kx 2
δW = f ( t )δx − cx& δx
Lagrange’s Equation:
d ⎛ ∂ (E1 − E 2 ) ⎞ ∂ (E1 − E 2 ) ⎜⎜ ⎟⎟ − = Qxi ∂x& i dt ⎝ ∂x i ⎠ Lagrange’s equation is written for linear systems as follow
d ⎛ ∂E1 ⎞ ∂E 2 ⎜⎜ ⎟⎟ + = Qxi dt ⎝ ∂x& i ⎠ ∂x i Where xi is the ith generalized co-ordinate and Qxi is the generalized force subjected to the ith generalized co-ordinate.
For Mass&spring system, application of the Lagrange’s equation gives the “Equation of Motion”.
d ⎛ ∂E1 ⎞ d ⎟ = (mx& ) = m&x& ⎜ dt ⎝ ∂x& ⎠ dt ∂E 2 = kx ∂x
Q x = f ( t ) − cx&
m&x& + kx = f ( t ) − cx& m&x& + cx& + kx = f (t )
θ m
c
M(t) R Viscous damping, B (Nms/rad)
k
1 I = mR 2 2
R R Sinθ
θ ≈R
1 &2 E1 = Iθ 2 1 E 2 = k (Rθ) 2 2 δW = M ( t )δθ − Bθ& δθ − cRθ& δ(Rθ)
For θa=[1 362.5 500]; >>roots(a)
ωn = 500 = 22.36 rad / s
s1=-1.3846
362.5 362.5 ξ= = = 8.1057 2 * ωn 2 * 22.36
s2=-361.1154
Over − damped system
K s1 Ks2 θ(s) = + s + 1.3846 s + 361.1154 1.0471s + 379.573 K s1 = lim (s + 1.3846) (s + 1.3846)(s + 361.1154) s → −1.3846
K s1 = 1.0511
1.0471s + 379.573 Ks2 = lim (s + 361.1154) (s + 1.3846)(s + 361.1154) s → −361.1154
K s 2 = −0.00402 1.0511 0.00402 θ(s) = − s + 1.3846 s + 361.1154
θ( t ) = 1.0511e
−1.3846 t
− 0.00402e
−361.1154 t
θ( t ) = 1.0511e
−1.3846 t
− 0.00402 e
−361.1154 t
1.2
dθ =0 dt
Initial condition, 1.0471 rad 1
Teta(t)
0.8
0.6
0.4
0.2
0
0
0.5
1
1.5
2
2.5 Time (s)
3
3.5
4
4.5
5
M(t)=100 Nm, All initial conditions are zero
100 M (s) = s 1 1 & & & 0.16θ + 58θ + 80θ = M(t ) 0.16 0.16 &θ& + 362.5θ& + 500θ = 6.25 M ( t )
[
]
2
[s + 362.5s + 500]θ(s) = 6.25 M (s)
6.25
100 625 θ(s) = = s 2 + 362.5s + 500 s s(s 2 + 362.5s + 500) 625 θ(s) = s(s + 1.3846)(s + 361.1154)
625 θ(s) = s(s + 1.3846)(s + 361.1154) K s = 0 K s = −1.3846 K s = −361.1154 θ(s) = + + s s + 1.3846 s + 361.1154 625 625 = = 1.25 K s = 0 = lim s s → 0 s(s + 1.3846)(s + 361.1154) 500
625 K s = −1.3846 = lim (s + 1.3846) s(s + 1.3846)(s + 361.1154) s → −1.3846 K s = −1.3846 = -1.2548 625 lim (s + 361.1154) K s = −361.1154 = s(s + 1.3846)(s + 361.1154) s → −361.1154 K s = −361.1154 = 0.00481
1.25 1.2548 0.00481 θ(s) = − + s s + 1.3846 s + 361.1154
θ( t ) = 1.25 − 1.2548 e
−1.3846 t
+ 0.00481 e
−361.1154 t
1.4
1.2
Steady-State value =1.25 Rad.
1
Teta(t)
0.8
0.6
0.4
0.2
0
0
1
2
3
4 Time (s)
5
6
7
Solution by MATLAB Simulink
1.4
1.2
1
Teta(t)
0.8
0.6
0.4
0.2
0
0
1
2
3
4 Time (s)
5
6
7
Example 1:
L
c=60 Ns/m
L/2 m
G
A
2m
F(t)
k=2000 N/m
B
m=25 kg
θ
c
k
Find θ(t) for F(t)=100 N (step function). 1
E1 =
1 &2 1 I A θ + 2mVB2 2 2
E1 =
1 1 2&2 1 mL θ + 2mL2θ& 2 23 2
E1 =
1 7 mL2 θ& 2 2 3
E1 =
( )
1 1 2&2 1 2 mL θ + 2m Lθ& 23 2
E1 =
1 1 2 mL + 2mL2 θ& 2 2 3
2
1 2 1 L 1 L2 2 θ E 2 = kx G = k θ = k 2 2 2 2 4
δ W = F δ x B − c x& B δ x B = F δ ( L θ ) − cL θ& δ (L θ )
(
)
δ W = FL δθ − cL 2 θ& δθ = FL − cL 2 θ& δθ 2
1
Apply Lagrange’s equation in order to get equation of motion
d ∂E1 ∂E 2 = Qθ + dt ∂θ& ∂θ L2 7 mL2&θ& + cL2θ& + k θ = FL 3 4
58.333 &θ& + 60 θ& + 500 θ = F
[58.333 s
θ(s) =
2
(Equation of motion)
]
+ 60 s + 500 θ(s) = F(s) 1
58.333 s 2 + 60 s + 500
1 1 58 . 333 θ(s) = F(s) s 2 + 1.0286 s + 8.5715
F(s)
3
θ(s) =
0.0171 2
s + 1.0286 s + 8.5715
F(s)
s 2 + 2ξωn s + ω2n
ω2n = 8.5715
ωn = 2.9277 rad / s
2ξωn = 1.0286
θ(s) =
0.0171
ξ=
1.0286 = 0.1752 2 * 2.9277
100 s + 1.0286 s + 8.5715 s 2
θ(s) =
(
F(s) =
100 s
1.71 2
s s + 1.0286 s + 8.5715
)
4
2
θ(s) =
(
1.71 2
s s + 1.0286 s + 8.5715
G (s) =
ω2n
s(s 2 + 2ξωn s + ω2n )
1
g( t ) = 1 −
θ(s) =
)
e − ξωn t sin(ωn 1 − ξ 2 t + θ)
1 − ξ2
(
8.5715 1.71 1.71
8.5715 2 s s + 1.0286 s + 8.5715 1.71
)
θ(s) = 0.1995
(
8.5715 2
s s + 1.0286 s + 8.5715
)
5
1 θ( t ) = 0.1995 1 − e − 0.1752*2.9277 t sin( 2.9277 1 − 0.1752 2 t + cos −1 (0.1752)) 2 1 − 0.1752
θ( t ) = 0.1995 −
0.1995 − 0.5129 t e sin(2.8824 t + 1.3947) 0.9845
θ( t ) = 0.1995 − 0.2026e −0.5129 t sin( 2.8824 t + 1.3947) 0.35
0.3
0.25
Teta(t)
0.2
θmax = 0.3135 rad
0.15
θss = 0.1995 rad
0.1
0.05
0
0
2
4
6 Time (s)
8
10
12
6
3
−
θmax − θss = e −
θmax − θss = e
πξ 1− ξ 2 3.1415*0.1752 1− 0.1752 2
= 0.5718
Maximum overshoot=%57.18 Max _ overshoot =
0.3135 − 0.1995 = 0.5718 0.1995
Î %57.18
7
Example 2: Find the transfer function of the system whose unit step response is given below. Max_overshoot=%26.28 Step Response 1.4
1.2
1
Amplitude
0.8
0.6
0.4
tmax=0.0764 s.
0.2
0
0
0.05
0.1
0.15
0.2 Time (sec)
0.25
0.3
0.35
8
4
−
0.2628 = e − 1.3364 =
πξ
− πξ 2 ln(0.2628) = ln e 1− ξ
1− ξ 2
πξ
1.786 =
1 − ξ2
π 2ξ 2
(1 − ξ 2 )
t max =
1.786 − 1.786ξ 2 = π 2ξ 2 2
11.6556ξ − 1.786 = 0
ξ = 0.3914
ωn =
π ωn 1 − ξ
3.1415 0.0764 1 − 0.3914 2
=
= 0.0764
2
3.1415 = 44.68 rad / s 0.703 9
G (s) =
ωn2
s 2 + 2ξωn s + ωn2
Input
=
1996.8 s 2 + 34.98 s + 1996.8
1996.8
Output
2
s + 34.98 s + 1996.8
10
5
CONTROL
f(t) m fd(t) k
x(t) C (Ns/m)
(N/m)
x(t) is the output variable and is measured by a displacement sensor. The output of a sensor is always an electrical output mainly voltage. In the Figure, f(t) is the actuating force that excites the system in order to produce the desired output x(t). On the other hand, fd(t) is the disturbance that works against actuating force and prevents the system to reach the desired output.
1
Actuators: Actuators are used to drive the engineering systems. DC motors, servo motors, hydraulic and pneumatic system elements are the basic type of actuating elements. The inputs of the actuators are also voltage. One can write a transfer function in order to model the behaviour of an actuator. (Voltage)
V1
Gact
G act =
(Force, Moment, etc.)
F(s) V1 (s) 2
1
Sensors: Sensors are the basic components of a control system that are used to measure the output/outputs of the system in order to obtain a feedback signal. The output of a sensor is mainly a voltage signal. One can write a transfer function in order to relate the input and output of the sensor. The input of a sensor is a physical event, temperature, pressure, displacement, velocity, acceleration, magnetic flux, rate of the fluid flow etc.)
(Voltage)
Displacement, pressure, temperature
V2
Gsens
V (s) G sens = 2 T(s)
3
OPENOPEN-LOOP CONTROL
-Fd V1
+
Gact
F(t)
+
G (s) =
1
G act = 100
Gsens
ms + cs + k
V2
0.1 Volt/m
100 N/Volt
[V1 G act − Fd ]
x(t)
2
1 2
ms + cs + k
G sens = V2
G sens = 0.1 4
2
[V1 100 − Fd ] V 2 (s) =
1 2
ms + cs + k
10 2
ms + cs + k
V1 (s) −
0.1 = V2 0 .1 2
ms + cs + k
Fd (s)
Let’s take Fd=0
V 2 (s) = V 2 (s) =
10 2
ms + cs + k 10 2
ms + cs + k
V1 (s) −
0.1 2
ms + cs + k
0
V1 (s) 5
Objective: The desired steady-state value of x(t) is 0.05 m. In this case, the sensor output voltage is calculated as
V2 = 0.1x 0.05 = 0.005 Volt The input voltage which is sufficient to obtain the output voltage, V2 is calculated as
V2ss =
10 ms 2 + cs + k
V1ss
m=200 kg c=300 Ns/m k=5000 N/m
The steady-state behaviour doesn’t include time variations and the system considered as static, then
V2ss =
10 V1 k ss
0.005 =
10 V1 5000 ss
V1ss = 2.5 Volt 6
3
V 2 (s) =
10 2
ms + cs + k 10
V1 (s)
2.5 200s 2 + 300s + 5000 s 1 10 2.5 200 V 2 (s) = 1 200s 2 + 300s + 5000 s 200 V 2 (s) =
V 2 (s) =
(
s s 2 + 1.5 s + 25
V 2 (s) =
V 2 (s) =
0.125
(
)
0.125
s s 2 + 1.5 s + 25
7
)
25 0.125 0.125
(
25 s s 2 + 1.5 s + 25 0.125
V 2 (s) = 0.005
(
)
25
s s 2 + 1.5 s + 25
)
ω2n = 25 ωn = 5 rad / s 2ξωn = 1.5 1 .5 ξ= = 0.15 2x5
8
4
G(s) =
ω2n
1
g( t ) = 1 −
2
s(s + 2ξωn s + ω2n )
1 − ξ2
e−ξωn t sin(ωn 1 − ξ2 t + θ)
θ = cos−1(ξ)
⎛ ⎞ 1 V2 ( t ) = 0.005 ⎜1 − e − 0.15*5 t sin ⎛⎜ 5 1 − 0.152 t + cos −1 (0.15) ⎞⎟ ⎟ ⎜ ⎝ ⎠ ⎟⎠ 1 − 0.152 ⎝
V2 ( t ) = 0.005 − 0.00506 e −0.75 t sin (4.943 t + 1.42) -3
9
x 10
8
The Figure shows that, desired x(t) value is achieved if the external disturbance Fd is zero.
V2(t)
7
V2(t) (Volt)
6
V (t ) x(t ) = 2 0 .1
5
4
3
V2ss=0.005 Volt
2
If Fd is not zero!
1
0
0
1
2
3
4
5 Time (Second)
6
7
8
9
10
9
Let’s take Fd=80 N.
V 2 (s) =
10 200s 2 + 300s + 5000
V 2 (s) =
V1 (s) −
0 .1 200s 2 + 300s + 5000
Fd (s)
10
2.5 0 .1 80 − 200s 2 + 300s + 5000 s 200s 2 + 300s + 5000 s 1
17 200s 2 + 300s + 5000 s 1 1 17 200 V 2 (s) = 1 200s 2 + 300s + 5000 s 200 V 2 (s) =
V 2 (s) =
(
0.085 2
s s + 1.5s + 25
)
=
25 0.085 0.085
(
25 s s 2 + 1.5s + 25 0.085
)
= 0.0034
(
25 2
s s + 1.5s + 25
) 10
5
V2 ( t ) = 0.0034 − 0.003439 e −0.75 t sin (4.943 t + 1.42) -3
9
x 10
8
Fd=0
7
6
5
V2(t)
4
3
2
Fd=80 N
1
0
0
1
2
3
4
5
6
7
8
9
10
11
Time (second)
Can we obtain desired x(t) even if Fd is not zero. This is the main concern of a control process. This can be achieved via the impementation of a closed-loop control.
-Fd (Error)
Vref
+ -
E
Gcont
+
V1
Gact
F(t)
G(s) =
+
1 2
ms + cs + k
x(t)
V2
Gsens 0.1 Volt/m
100 N/Volt Feedback
⎞ ⎟⎟ G sens = V2 ⎝ ms 2 + cs + k ⎠
[(Vref − V2 ) G cont G act − Fd ]⎛⎜⎜
1
12
6
⎞ ⎟⎟ G sens = V2 2 ⎝ ms + cs + k ⎠
[(Vref − V2 ) G cont G act − Fd ]⎛⎜⎜
1
⎞ ⎞ ⎛ ⎞ ⎛ ⎛ 1 1 1 Vref G cont G act G sens ⎜⎜ ⎟⎟ ⎟⎟ = V2 + V2 G cont G act G sens ⎜⎜ ⎟⎟ − Fd G sens ⎜⎜ ⎝ ms 2 + cs + k ⎠ ⎝ ms 2 + cs + k ⎠ ⎝ ms 2 + cs + k ⎠
⎡ ⎛ ⎞ ⎛ ⎞ ⎛ ⎞⎤ 1 1 1 Vref G cont G act G sens ⎜⎜ ⎟⎟ − Fd G sens ⎜⎜ 2 ⎟⎟ = V2 ⎢1 + G cont G act G sens ⎜⎜ 2 ⎟⎟⎥ 2 ⎝ ms + cs + k ⎠ ⎝ ms + cs + k ⎠ ⎝ ms + cs + k ⎠⎦ ⎣
⎛ ⎞ ⎛ ⎞ 1 1 G cont G act G sens ⎜ G sens ⎜ ⎟ ⎟ 2 2 + + + + ms cs k ms cs k ⎝ ⎠ ⎝ ⎠ V2 = Vref − Fd ⎡ ⎡ ⎛ ⎞⎤ ⎛ ⎞⎤ 1 1 + + 1 1 G G G G G G ⎜ ⎟ ⎜ ⎟ cont act sens cont act sens ⎢ ⎥ ⎢ ⎥ ⎝ ms 2 + cs + k ⎠⎦ ⎝ ms 2 + cs + k ⎠⎦ ⎣ ⎣ ⎛ ⎞ ⎛ ⎞ 1 1 0.1⎜ G cont 10 ⎜ ⎟ ⎟ 2 2 + + + + ms cs k ms cs k ⎝ ⎠ ⎝ ⎠ V2 = Vref − Fd ⎡ ⎡ ⎛ ⎞⎤ ⎛ ⎞⎤ 1 1 ⎟⎥ ⎟⎥ ⎢1 + G cont 10 ⎜ 2 ⎢1 + G cont 10 ⎜ 2 ⎝ ms + cs + k ⎠⎦ ⎝ ms + cs + k ⎠⎦ ⎣ ⎣
13
⎛ ⎞ ⎛ ⎞ 1 1 G cont 10 ⎜ 0.1⎜ ⎟ ⎟ 2 2 ⎝ ms + cs + k ⎠ V − ⎝ ms + cs + k ⎠ V2 = Fd ref ⎡ ⎡ ⎛ ⎞⎤ ⎛ ⎞⎤ 1 1 ⎟⎥ ⎟⎥ ⎢1 + G cont 10 ⎜ 2 ⎢1 + G cont 10 ⎜ 2 ⎝ ms + cs + k ⎠⎦ ⎝ ms + cs + k ⎠⎦ ⎣ ⎣
V2 =
10 G cont ms 2 + cs + k + 10 G cont
Vref −
0.1 ms 2 + cs + k + 10 G cont
Fd
The form of the transfer function of the controller is the most important parameter in a control application. Gcont can be Proportional, Derivative, Integral or a suitable combination of these three choices.
Kp K = ⎛ ⎞ i 1 Ti G cont = K p ⎜⎜1 + + Td s ⎟⎟ T s i ⎝ ⎠ K =K T d p d
14
7
Kp is the proportional constant, Ki is the integral constant and Kd is the derivative constant.
For proportional control, Gcont=Kp
V2 = V2 (s) =
10 G cont 2
ms + cs + k + 10 G cont 10 K p 2
ms + cs + k + 10 K p
Vref −
0.1 2
ms + cs + k + 10 G cont 0.1
Vref (s) −
2
ms + cs + k + 10 K p
Fd
Fd (s)
Vref=0.005 Volt, Fd=80 N Let’s take Kp=1000 V2 (s) =
10 *1000
0.005 0.1 80 − 2 200s + 300s + 5000 + 10 *1000 s 200s + 300s + 5000 + 10 *1000 s 2
15
V2 (s) =
10 *1000
0.005 0.1 80 − 2 s 200s + 300s + 5000 + 10 *1000 200s + 300s + 5000 + 10 *1000 s 2
V2 (s) =
50
1 8 1 − 2 s 200s + 300s + 15000 200s + 300s + 15000 s 2
1 8 1 1 200 − V2 (s) = 1 1 200s 2 + 300s + 15000 s 200s 2 + 300s + 15000 s 200 200
(
1 50 200
V2 (s) =
)
(
)
0.25
1 0.04 1 − 2 s + 1.5 s + 75 s s + 1.5 s + 75 s 2
75 0.25 0.25
75 0.04 1 1 0 .04 − V2 (s) = 75 2 75 2 s s + 1.5 s + 75 s + 1.5 s + 75 s 0.25 0.04
(
)
(
)
16
8
75 0.25 0.25
75 0.04 1 1 0.04 − V2 (s) = 75 2 75 2 s + 1.5 s + 75 s s + 1.5 s + 75 s 0.25 0.04
(
V2 (s) = 0.00333
)
)
1 75 1 − 0.000533 2 s s + 1.5 s + 75 s + 1.5 s + 75 s
(
75
(
)
2
V2 (s) = 0.0028
(
(
75 2
s s + 1.5 s + 75
ωn = 75 = 8.66 rad / s
ξ=
)
)
1.5 = 0.0866 2 * 8.66
θ = cos −1 (0.0866) = 1.484 rad
0.0028
V2 ( t ) = 0.0028 −
1 − 0.0866 2
17
e − 0.0866*8.66 t sin ⎛⎜ 8.66 1 − 0.0866 2 t + cos −1 (0.0866) ⎞⎟ ⎝ ⎠
V2 ( t ) = 0.0028 − 0.00281e −0.7499 t sin (8.627 t + 1.484) -3
6
x 10
Desired 5
Open-loop 4
V2(t) 3
2
Closed-loop, Kp=1000.
1
0
0
1
2
3
4
5
6
Time (second)
7
8
9
10
18
9
For Kp=10000 V2 (s) =
10 *10000
0.005 0.1 80 − 2 200s + 300s + 5000 + 10 *10000 s 200s + 300s + 5000 + 10 *10000 s 2
V2 (s) =
500
1 8 1 − 2 200s + 300s + 105000 s 200s + 300s + 105000 s 2
1 8 1 1 200 − V2 (s) = 1 1 200s 2 + 300s + 105000 s 200s 2 + 300s + 105000 s 200 200
(
1 500 200
V2 (s) =
)
(
)
2.5
1 0.04 1 − 2 s + 1.5 s + 525 s s + 1.5 s + 525 s 2
525 0.04 1 1 0.04 − V2 (s) = 525 2 525 s + 1.5 s + 525 s s 2 + 1.5 s + 525 s 2.5 0.04
(
V2 (s) = 0.004762
525 2.5 2.5
(
)
19
1 525 1 − 0.0000762 2 s + 1.5 s + 525 s s + 1.5 s + 525 s
(
525
)
2
V2 (s) = 0.0046858
)
(
(
525 2
s s + 1.5 s + 525
ωn = 525 = 22.91 rad / s
ξ=
)
)
1.5 = 0.032 2 * 22.91
θ = cos −1 (0.032) = 1.538 rad V2 ( t ) = 0.0046858 −
0.0046858 − 0.032*22.91 t ⎛ e sin ⎜ 22.91 1 − 0.0322 t + cos −1 (0.032) ⎞⎟ 2 ⎝ ⎠ 1 − 0.032
V2 ( t ) = 0.0046858 − 0.0046882 e −0.733 t sin (22.887 t + 1.538) 20
10
V2 ( t ) = 0.0046858 − 0.0046882 e −0.733 t sin (22.887 t + 1.538) -3
9
x 10
8
Closed-loop, Kp=10000
7
Desired 6
V2(t)
ess
5
Open-loop
4
3
2
Closed-loop, Kp=1000
1
0
Kp
ess
0
1
2
3
4
5
6
7
Time (second)
8
9
10
21
By MATLAB Simulink
22
11
For proportional-derivative (PD) control, Gcont=Kp+Kds Kp=10000, Kd=100
V2 = V2 =
10 G cont
Vref −
ms 2 + cs + k + 10 G cont
0.1 ms 2 + cs + k + 10 G cont
Fd
10 (10000 + 100s) 0.1 Vref − Fd 200s 2 + 300s + 5000 + 10 (10000 + 100s) 200s 2 + 300s + 5000 + 10 (10000 + 100s) V2 =
V2 =
100000 + 1000s 2
200s + 1300s + 105000 100000 + 1000s
200s 2 + 1300s + 105000
V2 =
Vref −
0.1 2
200s + 1300s + 105000
Fd
0.005 0.1 80 − s 200s 2 + 1300s + 105000 s
500 + 5s
1
200s 2 + 1300s + 105000 s
−
8
1
200s 2 + 1300s + 105000 s 23
V2 =
500 + 5s
1 8 1 − 2 s 200s + 1300s + 105000 200s + 1300s + 105000 s 2
1 (500 + 5s ) 200
1 8 1 1 200 − V2 = 1 1 s 2 2 200s + 1300s + 105000 200s + 1300s + 105000 s 200 200
(
V2 =
(
)
0.025 s + 2.5
s s 2 + 6.5s + 525
(
)
0.04
) s(s2 + 6.5s + 525) −
525 525 (0.025 s + 2.5) 0.04 0.04 − V2 = 0.025 525 2 525 s s 2 + 6.5s + 525 s s + 6.5s + 525 0.04 0.025
(
V2 = 0.00004762
)
525 s + 52500
(
s s 2 + 6.5s + 525
(
)
− 0.0000762
(
)
525
s s 2 + 6.5s + 525
) 24
12
PD Control by Simulink
Reference Voltage:0.005 Volt
Disturbance:-80 N
25
PD Control by Simulink -3
8
x 10
7
Desired 6
V2(t)
5
ess
4
3
2
1
0
0
0.5
1
1.5
Time (second)
2
2.5
3
26
13
PID Control by Simulink
Gc
Controller
27
Effect of the PID parameters on the output PID Control: Kp=1000, KI=1000, Kd=1000 Desired Output
PI Control: Kp=1000, KI=1000 PD Control: Kp=1000, Kd=1000
P Control: Kp=1000
28
14
Effect of the PID parameters on the output
29
15
STABILITY OF LINEAR CONTROL SYSTEMS
Among the many forms of performance specifications used in design, the most important requirement is that the system be stable. An unstable system is generally considered to be useless. The stability of a control system is directly related to the location of the roots of the charactersitic equation D(s).
s-plane
jω Stable region
si = −σi + j ωi
Unstable region
σ
0 Stable region
Unstable region
Example 1: Consider an open-loop control system V1(s)
1 100
V2(s)
s 2 + 9s + 15 V (s) 100 G (s) = 2 = 2 V1 (s) s + 9s + 15 V2 (s) =
100 2
s + 9s + 15
V1 (s)
D(s)
1
s-plane
D(s)=s2+9s+15
Imag
by MATLAB >>a=[1 9 15];
s1=-2.2087
>> roots (a)
s2= -6.7913
-6.7913
Reel
-2.2087
The two roots of D(s) are in the left hand side of the s-plane. It can be easily said that the open-loop system is stable. Step Response 7
6
5
Amplitude
V2(t)
Response of the system to a unit step input can be obtained by MATLAB as >>ns=[100];
4
V2ss=6.66
3
2
>>ds=[1 9 15],
1
>>step(ns, ds)
0
0
0.5
1
1.5
2
2.5
Time (sec)
Time (s)
Example 2: V1(s)
1 100
V2(s)
s 2 + 3s + 75 V (s) 100 G (s) = 2 = V1 (s) s 2 + 3s + 75 V2 (s) =
100 2
s + 3s + 75
V1 (s)
D(s) >>a=[1 3 75]; s1=-1.5+8.53i >> roots (a) s2=-1.5-8.53i
2
Response of the system to a unit step input can be obtained by MATLAB as >>ns=[100]; >>ds=[1 3 75],
Step Response 2.5
>>step(ns, ds) 2
Imag -1.5+8.53 i
Reel
Amplitude
1.5
s-plane
1
V2ss=1.33 0.5
-1.5-8.53 i 0
0
0.5
1
1.5
2
2.5
3
3.5
4
Time (sec)
Example 3: V1(s)
1 100
V2(s)
s 2 + 15 V (s) 100 G (s) = 2 = V1 (s) s 2 + 15 V2 (s) =
100 2
s + 15
V1 (s)
D(s) >>a=[1 0 15];
s1=+3.8730i
>> roots (a)
s2= -3.8730i
The real part of the roots are zero. No roots on the right-half s-plane and system is said to be marginally stable.
3
Response of the system to a unit step input can be obtained by MATLAB as >>ns=[100]; Step Response
>>ds=[1 0 15],
14
>>step(ns, ds)
12
10
8
Amplitude
V2(t)
s-plane Imag
6
3.873 i 4
Reel 2
-3.873 i
0
0
2
4
6
8
10
12
14
16
Time (sec)
Time (s)
Example 4: V1(s)
1 s 2 − 2s + 16
100
G (s) =
V2(s)
V2 (s) 100 = 2 V1 (s) s − 2s + 16
V2 (s) =
100 V1 (s) s − 2s + 16 2
D(s) >>a=[1 -2 16]; s1=1+3.8730i >> roots (a)
s2= 1-3.8730i
The real part of the roots are positive. Two roots are on the right-half s-plane and system is said to be unstable.
4
Response of the system to a unit step input can be obtained by MATLAB as >>ns=[100]; >>ds=[1 -2 16], Step Response 400
>>step(ns, ds) 200
0
-200
Amplitude
V2(t)
s-plane Imag
-400
1+3.873 i
Unstable
-600
Reel
1-3.873 i
-800
-1000
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5
Time (sec)
Time (s)
Example 5: Consider a closed-loop control system
R(s)+
System
s+3
K
V2(s)
s3 + 5s 2 + 9s + 5
Controller
V (s) Transfer function = 2 = H(s) R (s) Mason Formülü:
H(s) =
∑ Forward Paths 1 − ∑ Closed Loops
5
R(s)+
s+3
K
s3 + 5s 2 + 9s + 5
-
[R − V2 ]K RK
s+3 3
s + 5s 2 + 9s + 5
V2(s)
= V2
⎡ ⎤ s+3 = V2 ⎢1 + K ⎥ 3 2 s + 5s + 9s + 5 s + 5s + 9s + 5 ⎦ ⎣ s+3
3
2
K (s + 3) 3 2 V2 Ks + 3K = s + 5s + 9s + 5 = K (s + 3) R 1+ s3 + 5s 2 + (K + 9)s + (3K + 5) s3 + 5s 2 + 9s + 5
Forward Path
R(s)+
K -
s+3
V2(s)
s3 + 5s 2 + 9s + 5 Loop
By using Mason formula V2 = R
s+3 K 3 Ks + 3K s + 5s 2 + 9s + 5 = 3 2 ⎛ ⎞ s + 5s + (K + 9)s + (3K + 5) s+3 1− ⎜ − K 3 ⎟ 2 s + 5s + 9s + 5 ⎠ ⎝
D(s) Is the closed-loop control system stable? For what values of K, the system is said to be stable?
6
Routh-Hurwitz criterion: This criterion is an algebraic method that provides information about the stability of a linear time invariant system that has a characteristic equation with constant coefficients. The criterion tests whether any of the roots of characteristic equation lie in the right-half s-plane. The number of roots that lie on the jω axis and in the right half plane is also indicated. D(s) = s3 + 5s 2 + (K + 9)s + (3K + 5)
s3
1
K+9
s2
5
3K+5
s1
2K + 40 5
0
s0
3K+5
0
5 * (K + 9) − 1* (3K + 5) 5K + 45 − 3K − 5 2K + 40 = = 5 5 5
5 * (K + 9) − 1* (3K + 5) * (3K + 5) − 5 * 0 5 = 3K + 5 5 * ( K + 9) − 1* (3K + 5) 5
All terms must have the same sign. The number of positive roots is equal to the change in the sign.
K+9 >0 , K>-9 3K+5 > 0, K> -1.66 0.4K+8>0, 0.4K>-8, K>-8/0.4, K>-20
K>-1.66 System is stable for all positive K values. For K=10;
V2 =
10s + 30 s3 + 5s 2 + 19s + 35
Response of the system to a unit step input can be obtained by MATLAB as
R
s1= -1.1333 + 3.3941i s2= -1.1333 - 3.3941i s3= -2.7334 s-plane Imag -1.1333+3.3941i
>>ns=[10 30]; >>ds=[1 5 19 35],
-2.7334
Reel -1.1333-3.3941i
>>step(ns, ds)
7
Response to a unit step input, V2(t) Step Response 1.4
Stable
1.2
1
V2(t)
Amplitude
0.8
0.6
0.4
0.2
0
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5
Time (sec)
Time (s)
Example 1: R(s)+
K -
(s + 4 )(s + 20 ) s 3 (s + 100 )(s + 500 )
V2(s)
(s + 4)(s + 20) K 3 V2 (s) K (s + 4 )(s + 20 ) s (s + 100 )(s + 500) = = 3 R (s) 1 + K (s + 4 )(s + 20 ) s (s + 100 )(s + 500 ) + K (s + 4 )(s + 20 ) s3 (s + 100 )(s + 500) V2 (s) Ks 2 + 24 K s + 80K = R (s) s5 + 600s 4 + 50000s3 + Ks 2 + 24Ks + 80K
D(s)
8
D(s) = s5 + 600s 4 + 50000s3 + Ks 2 + 24Ks + 80K K>0, 24K>0, 80K>0 Î K>0 s5
1
50000
24K
s4
600
K
80K
s2 s1
600 * 24K − 1* 80K 600
3x107 − 1* K 600
s3
21408000K − K 16
− 7.2 x10
s0
0
2
11
+ 3.113256 x10 K − 14400K 600(21408000 − K )
3 *107 − K 14320K * K − 600 600 600 7 3 *10 − K 600
0
80K
3x107 − K
600 * 50000 − 1* K 600
2
3x107 − 1* K > 0 ⇒ K < 3x107 600
80K
21408000K − K 2 3x107 − K
2.34x105 < K < 2.1386 x107
> 0 ⇒ K < 2.1408x107
K 2 − 2.162 x107 K + 5x1011 < 0
2.34 x105 < K < 2.1386 x107
K>0
Step Response 25
20
Unstable
15
10
Amplitude
5
0
-5
ω = 10.6 rad / sec
-10
K=1x105
-15
-20
0
0.5
1
1.5
2
2.5
3
3.5
4
Time (sec)
Step Response
Step Response
1.8
2
1.6
1.5
Stable
1.4
1.2
Amplitude
Amplitude
1
1
0.8
0.5
0.6
K=5x105
0.4
0
K=2.34x105
0.2
-0.5 0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
0
2
0
0.2
0.4
0.6
0.8
Time (sec)
2.5
2.5
ω = 188.59 rad / sec
K=2.1386x107
2
1
1.2
1.4
1.6
1.8
2
Time (sec)
9
Step Response
Step Response
x 10
2
K=3x107
1.5
1
0.5
Amplitude
Amplitude
1.5
0
1
-0.5
0.5
-1.5
-1
Unstable
-2
0
0
0.02
0.04
0.06
0.08
0.1 Time (sec)
0.12
0.14
0.16
0.18
0.2
-2.5
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
Time (sec)
9
Example 2: R(s)+
V2(s)
1
K
s 3 + 30 s 2 + 200 s
-
1 K 3 V2 (s) K s + 30s 2 + 200s = = 3 2 1 R (s) 1 + K s + 30s + 200s + K s3 + 30s 2 + 200s
s3
1
200
s2
30
K
s1 s0
6000 − K 30
0
K
30 * 200 − 1* K 30
6000 − K * K − 30 * 0 30 6000 − K 30
K0
Kcritical=6000
By MATLAB, >>K=2000; >>ns=[K];
Step Response 1.4
>>ds=[1 30 200 K];
Stable
1.2
>>step(ns,ds) Amplitude
V2(t)
1
0.8
0.6
K=2000
0.4
0.2
0
0
0.5
1
1.5
2
2.5
Time (sec)
Time (sec)
10
By MATLAB, Marginally stable
>>K=6000;
K=6000
>>ns=[K];
Step Response 2
>>ds=[1 30 200 K];
1.8
1.6
>>step(ns,ds) 1.4
>>ds=[1 30 200 6000];
Amplitude
V2(t)
1.2
D(s)=s3+30s2+200s+6000
1
0.8
0.6
>>roots(ds)
0.4
p1=-30.0000 p2= 0.0000 +14.1421i p3=0.0000 -14.1421i
0.2
0
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5
Time (sec)
Time (sec) ω = 14.1421 rad / sec
By MATLAB, >>K=8000; >>ns=[K];
K=8000 Step Response
>>ds=[1 30 200 K];
12
10
>>step(ns,ds)
8
Unstable
Amplitude
V2(t)
6
4
2
0
-2
-4
-6
-8
0
0.5
1
1.5
2
2.5
3
Time (sec)
Time (sec)
11
ZIEGLER-NICHOLS DESIGN The coefficients of the controller can be chosen according to Kcritical and ωcritical which are calculated from Routh tabulation. Ziegler and Nichols recommended below relationships while determining the controller coefficients.
ωcritical * Tcritical = 2π
Tcritical =
2π ωcritical
⎛ ⎞ 1 G c (s) = K p ⎜⎜1 + + Td s ⎟⎟ ⎝ Tis ⎠
For P control Î K p = 0.5 * K critical For PI control Î K p = 0.45 * K critical Ti = 0.83 * Tcritical For PID control Î
K p = 0.6 * K critical
Ti = 0.5 * Tcritical Td = 0.125 * Tcritical
Example 2 (Cont.): R(s)+
Gc(s)
-
2π ωcritical
s 3 + 30 s 2 + 200 s
ωcritical = 14.1421 rad / sec
K critical = 6000 Tcritical =
V2(s)
1
=
2π = 0.444 sec . 14.1421
For G c (s) = K p , G c (s) = 0.5 * K critical = 3000 For G c (s) = K p +
Kp Tis
, G c (s) = 0.45 * K critical +
G c (s) = 2700 +
0.45 * K critical 0.83 * 0.444 s
7326.6 s
12
For G c (s) = K p +
Kp Tis
+ K p Td s
G c (s) = 0.6 * K critical +
G c (s) = 3600 +
0.6 * K critical + 0.6 * K critical * 0.125 * 0.444 s 0.5 * 0.444 s
16216.2 + 199.8 s s
13
APPLICATION OF THE MASON FORMULA H(s) =
∑ Forward Paths 1 − ∑ Closed Loops
R(s)
+
K
-
s +1
+ -
Y(s)
s 2 + 5s + 8 K1
s +1 K 2 Y(s) s + 5s + 8 H(s) = = R (s) ⎡ ⎤ s +1 s +1 − 2 1 − ⎢− K 2 K1 ⎥ s + 5s + 8 s + 5s + 8 ⎦ ⎣
s +1 K 2 Y(s) s + 5s + 8 H(s) = = R (s) ⎡ ⎤ s +1 s +1 − 2 1 − ⎢− K 2 K1 ⎥ s + 5s + 8 s + 5s + 8 ⎦ ⎣ s +1 K 2 Y(s) s + 5s + 8 H(s) = = R (s) 1 + K s + 1 + s + 1 K 1 s 2 + 5s + 8 s 2 + 5s + 8
H(s) =
Y(s) Ks + K = R (s) s 2 + 5s + 8 + Ks + K + K1s + K1
H(s) =
Y(s) Ks+ K = R (s) s 2 + (5 + K + K1 )s + (8 + K + + K1 )
1
Example: N(s) R(s)
+
+
K
+
s +1 s 2 + 5s + 8
-
-
Y(s)
K1 s
s +1 s +1 R (s) + 2 N(s) s 5 s 8 s 5 s 8 + + + + Y(s) = s +1 s +1 ⎡ ⎤ 1 − ⎢− K 2 s− 2 K1 ⎥ s + 5s + 8 s + 5s + 8 ⎦ ⎣ K
2
s +1 s +1 N(s) R (s) + 2 s 5 s 8 s 5 s 8 + + + + Y(s) = s +1 s +1 ⎡ ⎤ 1 − ⎢− K 2 s− 2 K1 ⎥ s + 5s + 8 s + 5s + 8 ⎦ ⎣ K
Y(s) = Y(s) =
2
(Ks + K )R (s) + (s + 1)N(s) 1 + Ks 2 + Ks + K1s + K1 Ks + K s +1 R ( s ) N(s) + 1 + Ks 2 + (K + K1 )s + K1 1 + Ks 2 + (K + K1 )s + K With respect to R(s)
With respect to N(s)
2
STEADY STATE ERRORS R(s) +
E(s)
G (s) Y(s)
G p (s)
K
-
[R (s) − E(s) G (s)] = E(s) R (s) = E(s)[1 + G (s)] E(s) =
1 R (s) 1 + G (s)
The steady-state error value can be found for different inputs, R(s).
Step Input: Input: R(t)
R(t)=Au(t)
R (s) =
A
E(s) =
A s
1 A 1 + G (s) s
t(s)
1 A s → 0 1 + G (s) s
ess = lim s E(s) = lim s s →0
A A = s →0 1 + G (s) 1 + lim G (s)
ess = lim
s →0
ess =
A 1 + Ks
K s = lim G (s) s →0
(Step input error coefficient)
The steady-state error for a step input with magnitude A.
3
Ramp Input: Input: R(t)
R (s) =
R(t)=At α
A s2
A=Tan(α) t(s)
A 1 1 A = lim s → 0 1 + G (s) s 2 s → 0 1 + G (s) s
ess = lim s E(s) = lim s s →0
A A A = = lim sG (s) s → 0 s + s G (s) 0 + lim sG (s)
ess = lim
s →0
K r = lim s G (s) s →0
s →0
ess =
Ramp input error coefficient
A Kr
Error coefficients and steady-state errors are valid for stable systems. Unity feedback systems are considered.
Example: Find the step input and ramp input error coefficients and steady-state errors for the closed loop system whose forward path is given as
G (s) =
s+5 s(3s 2 + 5s + 8)
K s = lim G (s) = s →0
ess =
0(3 * 0 2 + 5 * 0 + 8)
1 1 = =0 1 + Ks 1 + ∞
K r = lim sG (s) = lim s s →0
ess =
0+5
s →0
1 1 8 = = = 1.6 Kr 5 5 8
=
5 =∞ 0
There is no error for step input, A=1.
s+5
s(3s 2 + 5s + 8)
=
0+5 3 * 02 + 5 * 0 + 8
=
5 8
System has steady-state error for ramp input, A=1.
4
ROOTROOT-LOCUS Method Consider a control system,
R(s) +
E(s)
Y(s)
G p (s)
K
-
H(s) =
KG p (s) Y(s) = R (s) 1 + KG p (s) K
H(s) =
G p (s) =
N p (s) D p (s)
N p (s)
Y(s) = R (s)
D p (s) KN p (s) = N p (s) D p (s) + K N p (s) 1+ K D p (s)
H(s) =
KN p (s) Y(s) = R (s) D p (s) + K N p (s)
According to stability, the roots of the denominator of H(s) should lie on the left side of s-plane. Root Locus method gives the locations of the roots of the denominator with respect to varying controller gains, K.
RootRoot-Locus Plot: Plot: The root-locus plot of a closed loop system can be obtained easily by using the forward path transfer function of a closed loop control system. Example: Find the root locations of a closd loop cntrol system whose process transfer function is
G p (s) =
s +1
Zeros: Np(s)=0
s+1=0, s=-1
2
s(s + 5)(s + 4s + 8)
m = (number of zeros)=1
5
Poles, Dp(s)=0, n=Number of poles = 4. p1=0 p2=-5
n-m=4-1=3
p3=-2+2i p4=-2-2i
Plotting the root-locus : 1. Determine the zeros and poles of the Gp(s) 2. Determine the angles of asymptotes, 3. Determine the intersection of asypmtotes, 4. Determine the breakaway points. For the given system, zeros and poles are calculated as p1=0
z1=-1
p2=-5
n-m=4-1=3
p3=-2+2i p4=-2-2i
Angles of asymptotes:
θk =
(2k + 1) π , for k = 0 to (n − m − 1) (n − m ) Root Locus 10
8
6
Poles of Gp(s)
4
Imaginary Axis
2
Zeros of Gp(s)
0
-2
>>ns=[1 1]; >>ds=[1
-4
9
28
40
0]
-6
-8
>>rlocus(pay,payda)
-10 -8
-7
-6
-5
-4
-3
-2
-1
0
1
2
Real Axis
Root-locus by MATLAB
6
θ0 =
(2 * 0 + 1) π = π ⇒ 60o
Intersection of asymptotes:
4 −1 3 (2 *1 + 1) π = 3π ⇒ 180o θ1 = 4 −1 3 (2 * 2 + 1) π = 5π ⇒ 300o θ2 = 4 −1 3
∑ Poles − ∑ Zeros
σ=
σ=
(n − m )
0 + (−5) + (−2 + 2i) + (−2 − 2i) − ( −1) 3 8 − 9 +1 σ= = − = −2.66 3 3 Root Locus
10
KÆ∞
8
6
Rootcurve is Root-Locus symmetrical with respect to the real axis. axis.
180o
4
Imaginary Axis
2
KÆ∞
60o
K=0 K=0
K=0
Kc
0
-2
300o
K=0
-4
Critical K value can be found by Routh tabulation.
-6
-8
KÆ∞
-2.66 -10 -8
-7
-6
-5
-4
-3
-2
-1
0
1
2
Real Axis
Root-locus by MATLAB
Breakaway points: A Breakaway point is the intersection point of the root-locus curve on the real axis. These points can be found by,
dG p (s) ds
G p (s) =
=0
dN p (s) dG p (s) ds N p (s) = s + 1,
ds
=
D p (s) −
ds
=1
D p (s)
dD p (s)
D p (s) dN p (s)
N p (s)
ds 2
N p (s)
=0
D p (s) = s 4 + 9s3 + 28s 2 + 40s dD p (s) ds
= 3s3 + 27s 2 + 56s + 40
7
N p (s) = s + 1,
dN p (s) ds
D p (s) = s 4 + 9s3 + 28s 2 + 40s
=1
dD p (s) ds
dN p (s) dG p (s)
=
ds
(
ds
D p (s) −
= 3s3 + 27s 2 + 56s + 40
dD p (s) ds
N p (s)
D p (s) 2
)(
=0
)
1* s 4 + 9s3 + 28s 2 + 40s − 3s3 + 27s 2 + 56s + 40 (s + 1) = 0 − (2s 4 + 21s3 + 55s 2 + 56s + 40) = 0 There are no breakaway points because the root-locus curve doesn’t intersect the real axis.
s1=-7.1447 s2=-2.36 s3= -0.4955 + 0.9687i s4= -0.4955 - 0.9687i
Critical K value that makes the system marginally stable can be found by Routh tabulation.
H(s) =
Y (s) Ks + K = 4 3 R (s) s + 9s + 28s 2 + (40 + K )s + K
s4
1
28
K
s3
9
40+K
0
s2
212 − K 9
s1
− 0.1111K 2 + 10.1116K + 942.224 212 − K 9
s0
K
K
212-K>0 Î K 0
K < 148.2284 K>0
8
K = 148.2284
>> K=148.2284; için,
>> ds=[1 9 28 40+K K]; roots(ds)
D(s) = s 4 + 9s 3 + 28s 2 + (40 + K )s + K s1=-8.1282 s2= 0.0000+ 4.5732i s3= 0.00001 - 4.5732i s4= -0.8720
Root Locus 10
Imag KÆ∞
8
6
4
ωcritical=4.5732 rad/s
Imaginary Axis
2
Reel
0
-2
-4
-6
-8
-10 -8
KÆ∞ -7
-6
-5
-4
-3
-2
-1
Real Axis
0
1
0
2
Root-locus by MATLAB
Example: Plot the Root-Locus graph of the Closed-loop control system whose process transfer function is given as R(s) +
G p (s) =
s+3
K
Gp (s)
Y(s)
-
s(s + 5)(s + 6)(s 2 + 2s + 2)
9
Example: Plot the Root-Locus graph of the Closed-loop control system whose process transfer function is given as Process Transfer Function Controller
R(s) +
G p (s) =
-
s+3
Y(s)
Gp (s)
K
s(s + 5)(s + 6)(s 2 + 2s + 2)
Solution: Zeros and Poles of Gp(s) are found, s+3=0 Î z1=-3, Number of zeros m=1 s1=0, s2=-5, s3=-6, s4=-1+1i, s5=-1-1i, Number of poles=5 Angles of the Asymptotes
θk =
k0 =
(2k + 1) π n−m
k from 0 to (n − m − 1)
(2 * 0 + 1) π = π = 45o 5 −1
4
5 −1
4
k1
(2 *1 + 1) π = 3π = 135o =
k2
(2 * 2 + 1) π = 5π = 225o =
Angles of the Asymptotes
5 −1 4 (2 * 3 + 1) π = 7π = 315o k3 = 5 −1 4
Intersection point of the Asymptotes
σ=
∑ Poles − ∑ Zeros = 0 + (−5) + (−6) + (−1 + 1i) + (−1 − 1i) − (−3) = − 10 = −2.5 n−m
5 −1
4
The Breakaway point is calculated as,
dN p (s) dG p (s) ds
=
ds
D p (s) −
dD p (s)
D p (s) 2
ds
N p (s)
=0
1
Np(s)=s+3 Dp(s)=s5+13s4+ 54s3+ 82s2+ 60s
dN p (s) ds dD p (s) ds
=1 = 5s 4 + 52s3 + 162s 2 + 164s + 60
dN p (s) ds
dD p (s)
D p (s) −
ds
D p (s) 2
(
N p (s)
=0
)(
)
1* s5 + 13s 4 + 54s3 + 82s 2 + 60s − 5s 4 + 52s3 + 162s 2 + 164s + 60 (s + 3) D p (s)
2 s1 = -5.5257
=0
Breakaway point
s 2 = - 3.3311 + 1.2040i
- 4s5 - 54s 4 - 264s3 - 568s 2 - 492 s - 180 = 0
s3 = - 3.3311 - 1.2040i s 4 = - 0.6560 + 0.4677i s5 = - 0.6560 - 0.4677i
Root Locus by MATLAB, >>ns=[1 3]; >>ds=[1
13
54
82
60
0];
>>rlocus(ns,ds)
Asymptote Root Locus 10
Imaginary KÆ ∞
KÆ ∞
8
6
135O 4
Imaginary Axis
2
Breakaway Point
45O
-5.53
K=0 K=0
K=0
0
Real
K=0 K=0
-2
-4
KÆ ∞
-6
Intersection point KÆ ∞ -2.5
-8
-10 -15
-10
-5
0
5
10
Real Axis
2
BODE PLOTS The bode plot gives information about the frequency response of a system. Consider a system whose input is a harmonic function F(s)
s
f ( t ) = A cos(ω t ) F(s) =
ω2n
G (s) =
2
Y(s)
+ 2ξωn s + ω2n
A Sin(ωt) +A
As 2
s + ω2
A
A Cos(ωt)
ω
π 2
Y(s)=G(s) F(s)
π
-A The response y(t) can be written as,
+A
-A
y( t ) = A G (iω) cos(ωt + ϕ)
π 2
π
Example: Find the response of the system (G(s)) , to a harmonic excitation given as f(t)=3*Cos (5*t). Take ωn=1 rad/sec, ξ=0.3. Imaginary Solution: A = 3, s=5 i, |G(ω)|
G (iω) =
ω2n
(5i )2 + 2ξωn (5i ) + ω2n
ϕ
G (5i) = 0.0427
ϕ(5i ) = −3.0172 rad
Real(G(iω))
Imag(G(iω))
Real
y( t ) = 3 G (5i) Cos (5t + ϕ), y( t ) = 0.1281 Cos (5 t − 3.0172 ) The response of the system to a harmonic input, A*cos(ωt), can be found for different excitation frequencies, ω. For harmonic response replace s by iω. >> w=0:0.001:30; >> s=i*w; >>wn=1; >>ksi=0; >>gs=wn^2./(s.^2+2*ksi*wn+wn^2); >>plot(w,abs(gs))
3
Frequency Response of The System, System, ωn=1 rad/ rad/sec. sec. 6
Rezonance
ξ=0
5
ξ=0.1 4
|G(iω)| 3 Rezonance
ξ=0.3
2
ξ=0.5 1
ξ=0.707 ξ=1
0
0
0.5
Rezonance Frequency
1
ωn
1.5
2
2.5
3
ω (rad/sec)
ωr = ωn 1 − 2ξ 2
BODE PLOT by MATLAB
>>wn=1; >>ksi=0.3; >>ns=[wn^2]; >>ds=[1 2*ksi*wn wn^2]; >>bode(ns,ds)
Bode Diagram 20
Magnitude (dB)
0
-20
-40
-60
-80 0
Phase (deg)
-45
-90
-135
-180 -2
10
-1
10
0
10
1
10
2
10
Frequency (rad/sec)
4
BODE PLOT R(s) +
G (s) Y(s)
G p (s)
K -
H(s) =
G (s) 1 + G (s)
1+G(s)=0 Î G(s)=-1 Log10|G(iω)|
⎛ V dB = 20 * Log10 ⎜⎜ ⎝ Vref
G(s) plane
Gm
0
⎞ ⎟⎟ ⎠
Log10ω
Gain Margin Gm
ω=∞ -1 G(iω)
Phase Margin ϕm
Log10ω
ϕm
-180°
Example: Find the Gain and Phase margins of the system whose transfer function is given below,
>>ns=[100000000];
100000000 G (s) = s (s + 400) (s + 3000)
>>ds=[1 3400 1200000
0];
>>bode(ns,ds) Bode Diagram
50
Magnitude (dB)
0
Gm=32.2 dB -50
-100
-150 -90
ϕm=76.91°
Phase (deg)
-135
-180
-225
-270 1
10
2
10
3
10
4
10
5
10
Frequency (rad/sec)
5
EXAMPLES E1: Draw the approximate Root-Locus graph of a control system given below. R
+
G p (s ) =
K
-
Y
4s + 8 (s + 6)(s 2 + 5s + 15 .25)
Solution: Find Zeros ans Poles of the Gp(s)
4s + 8 = 0 ⇒ z1 = −2
m=1
s1 = −6, s 2 = −2.5 + 3i, s3 = −2.5 − 3i Angles of the Asymptotes: θk =
(2k + 1) π , for k = 0 to (n − m − 1) (n − m )
k0 =
n=3
(2 * 0 + 1) π = π = 90o
3 −1 2 (2 *1 + 1) π = 3π = 270o k1 = 3 −1 2
Intersection of the Asymptotes with real axis
σ=
∑ Poles − ∑ Zeros = (−6) + (−2.5 + 3i) + (−2.5 − 3i) − (−2) = − 9 = −4.5 3 −1
n−m
2
KÆ∞ Imaginary K=0 3i
The system remains stable for All positive K values.
K=0
-6
-4.5
-2.5
Real
270° -3i K=0 There is no breakaway point. KÆ∞
Real part of the roots goes to -4.5 as K goes to infinity.
6
E2. The forward path transfer function of a closed-loop control system is given as.
G (s) =
5s + 9 2
s (5s + 4s + 3K t )
Find the Kt value which makes the ramp input error coefficient Kr=2. Find the steady state errors for unit step and unit ramp input for this Kt value.
K r = 2 = lim s G (s) = s s →0
G (s ) =
5s + 9
(
s 5 *0 2 +4 * 0 + 3 * K t
K s = lim G (s) = s →0
s (5s 2 + 4s + 4.5)
ess for unit step input =
5*0 + 9
1 1 = = 0.5 Kr 2
9 3K t
5*0 + 9
0 5 * 0 2 + 4 * 0 + 4.5
1 1 = =0 1 + Ks 1 + ∞
ess for unit ramp input =
(
)
=
Kt=1.5
)= ∞
System has no steady-state error for unit step input. System has steady-state error for unit ramp input.
E3. The root-locus graph of a closed-loop control system whose denominator is D(s)=s3+2s2+(6+K)s+(3K+1) is given below. Find the coefficients (Kp, Kı, Kd) of a PID controller which will be employed in this control system by using the ZieglerNichols design. Root Locus
∞
10
8
ωcritical
K
6
4
s= 4.3211 Imaginary Axis
2
∞
0
i
K
-2
s= -4.3211 i -4
-6
K
-8
-10 -3
-3
∞ -2.5
-2
-1.5
-1
-0.5
Real Axis
0
0
0.5
0.5
Solution: First of all, find Kcritical by Routh tabulation.
7
D(s)=s3+2s2+(6+K)s+(3K+1) s3
1
6+K
s2
2
3K+1
s1
11 − K 2
s0
3K + 1
2 * (6 + K ) − 1* (3K + 1) − K + 11 = 2 2
11 − K * (3K + 1) − 2 * 0 2 = 3K + 1 11 − K 2
11 − K > 0 ⇒
K < 11
3K + 1 > 0 ⇒ K > −
Tcritical =
2π ωcritical
=
2π = 1.454 sec . 4.3211
G c (s) = 0.6 * K critical +
1 3
K 0 ⇒ K > −1.33
2
s + 2s + (K + 3)s + 3K + 4
K+3>0Î K>-3 s3
1
K+3
s2
2
3K+4
s1
−K+2 2
s0
3K+4
2 K + 6 − 3K − 4 − K + 2 = 2 2
-1.33 −1.33
A5. a)
Kcritical=108, Tcritical =
2π ωcritical
=
2π = 1.48 sec . 4.2426
For PI controller: Kp=0.45*Kcritical=0.45*108=48.6
G c (s) = K p +
Ti= 0.83*Tcritical=0.83*1.48=1.23 sec.
Kp Tis
= 48.6 +
b) For P controller: Kp=0.5*Kcritical=0.5*108=54, G c (s) = 54, G (s) = K s = Lim G (s) =
54 2
= ∞, e ss =
54 s (s + 6s + 18)
1 1 = =0 1+ Ks 1 + ∞
0 (0 + 6 * 0 + 18) 1 1 54 = 3, e ss = = = 0.333 K r = Lim s G (s) = s Kr 3 s→0 s (0 2 + 6 * 0 + 18) s→0
2
48.6 39.51 = 48.6 + s 1.23 s
TEXTILE ENGINEERING DEPARTMENT MAK326 CONTROL SYSTEMS (June 15, 2006) Final Exam Number:
Q1
Q2
Q3
Q4
Q5
Q6
∑
Name: (20) Q1. Consider the mechanical system shown in the Figure. Write the energy equations and virtual work expression. Obtain the equation of motion of the system. F is the input and θ is the output of the system. 2L L
3
L 6
O
A
F
3
m
θ
k
2k
(15)
B
IO =
mL2 9
c
Q2.
Find the transfer function of the closed-loop control system whose block diagram is given below. C (s ) H (s ) = =? R (s ) G3(s)
R(s) +
+
G1(s)
+
G2(s)
+ G4(s)
C(s)
-
-
G5(s) G6(s) (20)
Q3. Find the response of a mass&spring system to an impulse force with magnitude 20 N. All initial conditions are zero. f (t)=20 δ(t)
m=42 kg c=150 Ns/m k=1000 N/m
m x(t) k
c
m
d 2 x(t) dt
2
+c
dx + k x(t) = f (t) dt
Q4.
(20)
Using the Routh-Hurwitz criterion, determine the region for the controller gain K for which the control system works stable.
System
Controller
R(s) +
Y(s)
10 s + 1
K
s 2 (4 s + 1)(s + 1)
-
For the critical K value (Kcritical) the roots of the denominator of the closed loop transfer function are -0.1096, -1.1404, 0 ± 0.3536i. Determine the coefficients of a PI controller using the ZieglerNichols design. (15)
Vref + - Vo Consider the robot manipulator shown in the Manipulator Arm figure. The manipulator is driven by an electric motor. The input of the motor is the voltage V1 (output of the 10(1 + 0.2s) θ controller). The angular position θ of the manipulator V Vo (s) 1 arm is measured by an encoder. The input of the = 0.05 Encoder θ ( s ) encoder is θ and the output is the voltage Vo. Voltage Electric Motor Vo is used as feedback signal and compared with the θ(s) 1 reference voltage Vref which is the desired value of the = 2 closed loop control system. The error signal is sent to a V1 (s) 1.2s + 0.5s + 10 PD controller and controller produces the voltage V1. Draw the closed-loop control block diagram and find the transfer function of the closed-loop control V (s) . system, H(s) = o Vref (s)
Q5.
Step Response
1.4
(10) Q6. Consider the system and whose unit step response. What kind of controller should be used to obtain Overshoot < 10% and steady state error ess < 5%.
1.2
1
Amplitude
0.8
System Controller
R(s) +
2000
-
Desired value
0.6
Y(s)
1
0.4
2
42s + 150 s + 1000 0.2
0
0
0.5
1
1.5
2
2.5
3
3.5
Time (sec)
∑ Forward Paths Duration 100 Minutes. Good Luck. H(s) = 1 − ∑ Closed Loops 1 ωcritical * Tcritical = 2π G c (s) = K p 1 + + Td s Tis For P control Î K p = 0.5 * K critical For PI control ÎK p = 0.45 * K critical T = 0.83 * T i critical For PID control ÎK p = 0.6 * K critical T = 0.5 * T i
critical
Td = 0.125 * Tcritical Assist. Prof. Dr. Zeki KIRAL
G (s) =
2
ωn2
s + 2ξωn s + ω2n
g( t ) =
ωn 1 − ξ2
e − ξωn t sin(ωn 1 − ξ 2 t )
TEXTILE ENGINEERING DEPARTMENT MAK326 CONTROL SYSTEMS (June 15, 206) Solutions of Final Exam A1. E1 =
2
2
1 & 2 1 mL2 & 2 1 L 1 2L 12 2 2 kL θ θ = Ioθ = θ , E 2 = 2k θ + k 2 2 9 2 3 2 3 23
L 4L2 & L 2L & 2L θ δθ θ = − F δθ − c θ δ δW = − Fδ θ − c 6 9 6 3 3 Lagrange’s equation, d ∂E1 ∂E 2 = Q θ ,Equation of motion Î + dt ∂θ& ∂θ A2. H(s) =
mL2 && 4cL2 & 2kL2 L θ+ θ+ θ=− F 9 9 3 6
G1G 2 G 4 + G1G 3G 4 C(s) = R (s) 1 + G1G 3G 4 G 6 + G1G 2 G 4 G 6 + G 2 G 5
A3.
42 &x& + 150 x& + 1000 x = 200 δ( t ) Apply the Laplace transform for both sides
[
]
42 s 2 X(s) − s x (0) − x& (0) + 150 [sX(s) − x (0)]+ 1000 X(s) = 20 All initial conditions are zero.
[42 s
2
]
+ 150 s + 1000 X(s) = 20, X(s) =
X(s) =
(
1 20 42
1 42 s 2 + 150 s + 1000) 42
)
=
20 42 s 2 + 150 s + 1000
0.4762 2
s + 3.5714 s + 23.8095
=
23.8095 0.4762 0.4762
(
27.8095 2 s + 3.5714 s + 23.8095 0.4762
)
X(s) = 0.02 *
23.8095 s 2 + 3.5714 s + 23.8095
= 0.02 *
ω n2 s 2 + 2ξωn s + ω 2n
ω n = 23.8095 = 4.8795 rad / s , 2ξωn = 3.5714, ξ =
x ( t ) = 0.02 *
A4.
K
H(s) =
3.5714 = 0.366 2 * 4.8795
ωn
e − ξω n t Sin ω n 1 − ξ 2 t , x ( t ) = 0.1049 e −1.7857 t Sin (4.541 t ) 1 − ξ2
10 s + 1 2
10Ks + K 10Ks + K s (4s + 1)(s + 1) = = 2 4 10 s + 1 s (4s + 1)(s + 1) + 10Ks + K 4 s + 5 s 3 + s 2 + 10K s + K 1+ K s 2 (4s + 1)(s + 1)
s4
4
1
K
s3
5
10K
0
s2
5 − 40K 5
5-40K >0 Î K< 0.125 K
0 25K-400K2 >0 Î K< 0.0625
s1
s0
25K − 400K 2 5 − 40K
0
K
0
0 K >0 0
0 < K >cd dizinadı Buradaki >> sembolleri MATLAB’in komut satırını ifade etmektedir. 1.1 MATLAB’e ait yardımcı komutlar Yardımcı komutlar başlığı ile sözedilen komutlar MATLAB komut satırında kullanılabilen sistem komutları, ekran ve hafıza ile ilgili komutlardır. MATLAB programı büyük/küçük harf duyarlıdır (case sensitive). Bu nedenle komutlar küçük harfler ile kullanılmalı, değişken tanımlamalarında da küçük ve büyük harf değişkenlerin farklı rakamları isimlendirmek için kullanılabileceğine dikkat edilmelidir. dir : DOS işletim sisteminde kullanıldığı gibi aktif dizin içerisindeki dosyaların listesini görmek için kullanılan komuttur. >>dİr ↵ (Enter) pwd : Aktif dizini görüntülemek için kullanılan komuttur. >>pwd ↵ (Enter) clc : DOS işletim sistemindeki CLS (CLear Screen) komutu ile aynı işlevi gören komuttur. Ekranı temizlemek için kullanılır. >>clc ↵ (Enter)
whos: MATLAB programında o ana kadar tanımlanmış tüm değişkenleri görüntüler. >>whos ↵ (Enter) clear : MATLAB programında o ana kadar tanımlanmış tüm değişkenleri hafızadan silmek için kullanılan komuttur. >>clear ↵ (Enter) cd : MATLAB programı komut satırından aktif dizini değiştirmek için kullanılan komuttur. >>cd dizinadı ↵ (Enter) help : MATLAB programında bir komuta ait yardım istenildiğinde komut satırında yardım alınacak komut ile birlikte kullanılır. >>help komutadı ↵ (Enter) lookfor : MATLAB programı içerisinde genel bir arama yapmak için kullanılan komuttur. >>lookfor konuadı↵ (Enter)
2. MATLAB komutları MATLAB programı basit çözümlemelerin yanısıra ileri seviyedeki uygulamalara da cevap verebilecek nitelikte bir programdır. Kullanıcılar tarafından programlanabilir olması, MATLAB’in büyük avantajlarındandır. Aşağıda çok kullanılan temel MATLAB fonksiyonları tanıtılmıştır.
Roots: Bir polinomu sıfır yapan değerleri yani polinomun köklerini bulmak için kullanılan komuttur. Bu komutu aşağıdaki örnek ile açıklayalım. Örnek : 3
2
f(x) = 2x -3x -80x+100 2000
f(x)
1000 0 -20
-10
0
10
20
-1000 -2000
x Şekildeki eğri 3. dereceden bir polinoma aittir. Polinomun x eksenini kestiği noktaları (polinomun köklerini) bulmak için MATLAB programında komut satırında şu işlemlerin yapılması gerekmektedir. >>a=[2,-3,-80,100]; >>roots(a)
Açıklama:Polinomun katsayıları a isimli vektöre atanıyor polinomun kökleri bulunuyor.
Satır sonunda kullanılan ; karakteri işlem sonucunun ekrana yazılmamasını sağlar. İşlem sonucunun ekranda görülmesi isteniyor ise satır sonunda ; işareti kullanılmamalıdır. Roots komutu şu şekilde de kullanılabilir. >>roots([2,-3,-80,100]) Komut sonucu :
6.4813 -6.2213 1.2400
Poly: Kökleri verilen polinomun katsayılarını bulmak için kullanılan komuttur. Örnek : >>r=[-8,2,8]; >>poly(r) Komut sonucu : 1 -2 -64 128 3 Polinom : x − 2 x 2 − 64 x + 128
Polyval: Katsayıları ile tanımlanmış olan bir polinomun verilen değer için
sonucunu
hesaplamak için kullanılan fonksiyondur. Örnek : >>a=[3,-5,4,10]; >>polyval(a, 4.5) Komut sonucu : 200.1250
Max:
Verilen bir sayı dizisi içerisindeki en büyük değeri bulmak için kullanılan komuttur. Komutun kullanımına göre en büyük sayı değerinin dizi içerisindeki sırası da elde edilebilir. Örnek : >>x=[3,-5,4,10,5,20,4,15,12,-8]; >>max(x) Komut sonucu : 20 >>[y,k]=max(x) Komut sonucu : 20 (En büyük sayı) 6 (En büyük sayının dizideki yeri)
Min: Verilen bir sayı dizisi içerisindeki en küçük değeri bulmak için kullanılan komuttur. Komutun kullanımına göre en küçük sayı değerinin dizi içerisindeki sırası da elde edilebilir.
Örnek : >>x=[3,-5,4,10,5,20,4,15,12,-8]; >>min(x) Komut sonucu : -8 >>[y,k]=min(x) Komut sonucu : -8 10
Sum:
Verilen bir sayı dizisi içerisindeki elemanların toplamını bulmak için kullanılan komuttur. Örnek : >>x=[3,-5,4,10,5,20,4,15,12,-8]; >>sum(x) Komut sonucu : 60
Mean: Verilen bir sayı dizisi içerisindeki sayıların ortalamasını bulmak için kullanılan komuttur. Örnek :
1 N mean = ∑ x i N i =1
>>x=[3,-5,4,10,5,20,4,15,12,-8]; >>mean(x) Komut sonucu : 6
Sort: Verilen bir sayı dizisi içerisindeki sayıları küçükten büyüğe doğru sıralamak için kullanılan komuttur. Örnek : >>x=[3,-5,4,10,5,20,4,15,12,-8]; >>sort(x) Komut sonucu : -8 -5 3 4
4
5
10
12
15
20
Std:
Verilen bir sayı dizisi içerisindeki sayıların standart sapmasını bulmak için kullanılan komuttur Örnek : >>x=[3,5,4,10,5,20,4,15,12,8]; >>std(x) Komut sonucu : 5.6214
std =
1 N 2 ∑ ( x i − mean ) N − 1 i =1
Hist: Verilen bir sayı dizisi içerisindeki sayıların dağılımını ekranda görüntülemek için kullanılan komuttur. Örnek : >>x=[3,5,4,10,5,20,4,15,12,8,8,8,4,5,20,6,7,5,4,5,5,8,8]; >>hist(x) Komut sonucu : 7
6
5
4
3
2
1
0
2
4
6
8
10
12
14
16
18
20
Matris işlemleri Matris Tanımlama: MATLAB programında matris tanımlaması vektör tanımlama işlemine benzerdir, satırlar arasında ; karakteri kullanılır. Örnek : >>a=[3,5,4;10,5,20;4,15,12] Tanımlama sonucu:
Matrisleri Toplama:
3 5 4 10 5 20 4 15 12
>> a=[3,5,4;10,5,20;4,15,12]; >> b=[-3,6,-1;10,-6,2;5,7,-10]; >>c=a+b Komut Sonucu: 0
11 3 20 − 1 22 9 22 2
Matrisleri Çıkarma: >> a=[3,5,4;10,5,20;4,15,12]; >> b=[-3,6,-1;10,-6,2;5,7,-10]; >>c=a-b Komut Sonucu:
Matris Çarpımı :
6 −1 5 0 11 18 − 1 8 22
>> a=[3,5,4;10,5,20;4,15,12]; >> b=[-3,6,-1;10,-6,2;5,7,-10]; >>c=a*b Komut Sonucu:
6 −1 5 0 11 18 − 1 8 22
Matris Transpozu: >> a=[3,5,4;10,5,20;4,15,12]; >>c=a' Komut Sonucu:
3 10 4 5 5 15 4 20 12
Matris Tersi : >> a=[3,5,4;10,5,20;4,15,12]; >>c=inv(a) Komut Sonucu:
0 − 0 .2 0. 6 0 .1 − 0 . 05 0 . 05 − 0.325 0.0625 0.0875
Denklem Takımı Çözme : Denklem takımlarını çözerken MATLAB’in matris tersi alma işlemindeki üstünlüğünden yararlanılmaktadır.
3 x + 5 y − 9 z = −3 − 8 x − 6 y + 5 z = 10 10 x + 3 y − 6 z = −8 >>a=[3,5,-9;-8,-6,5;10,3,-6]; >>b=[-3;10;-8]; >>c=inv(a)*b yada
5 − 9 x − 3 3 − 8 − 6 5 y = 10 10 3 − 6 z − 8
>>c=a\b Komut Sonucu:
x = -0.7928 y = -1.0279 z = -0.5020
Matris Determinantı: Bir matrisin determinantını bulma. >>a=[3,5,-9;-8,-6,5;10,3,-6]; >>b=det(a) Komut Sonucu: -251 Verilen Noktalardan Eğri Geçirme (Curve Fitting) : Verilen x ve y en az hata ile sağlayan istenilen derecedeki polinoma ait katsayıları bulma. >>x=[1,3,5,6,9,12,15]; >>y=[4,8,15,9,12,20,24]; >>polyfit(x,y,3) (3. dereceden bir polinom) Komut Sonucu: 0.0138 -0.3082 3.0503 1.6163 3
2
Polinom : 0.0138 x -0.3082 x + 3.0503 x + 1.6163 25
20
15
10
5
0
0
Türev alma >>p1=’3*sin(x)’ >>diff(p1) Komut Sonucu: 3*cos(x)
5
10
15
Integral Alma >> p1=’3*sin(x)’ >>int(p1) Komut sonucu : -3*cos(x) Grafik Çizme : Örnek 1: >>p1=’x^3-2*x^2+3’; >>ezplot(p1,0,10) Komut Sonucu : x^3-2*x^2+3 800 700 600 500 400 300 200 100 0 0
1
2
3
4
5 x
6
7
8
9
10
4
5
6
7
8
9
10
Örnek 2: >>x=0:0.1:10; >>y=3*exp(-0.8*x).*cos(12*x-0.4); >>plot(x,y) 3
2
1
0
-1
-2
-3
0
1
2
3