Lab 8 & 9
Lab 8 & 9
Object: To Construct a DC motor speed control system for an Insulin Pump via PID control
using SIMULINK.
Theory:
The PID controller is one of the most widespread control techniques in engineering and has
being used since the 1930s. PID stands for Proportional, Integral and Derivative since this type
of controller acts proportionally to the error, to the integral of the error and to the derivative of
the error. The idea behind the PID control is that acting proportionally to the error will produce
a promptly response of the controlled output; acting proportionally to the integral of the error
will eliminate the error at the steady state, and finally, being proportional to the derivative of
the error will reduce oscillations. Mathematically, the PID control action can be defined in the
time domain as:
𝑡
1 𝑑𝑒(𝑡)
𝑢(𝑡) = 𝐾𝑝 (𝑒(𝑡) + ∫ 𝑒(𝑡)𝑑𝑡 + 𝑇𝑑 )
𝑇𝑖 𝑑𝑡
0
Fig. 6.14 The PID control. The PID control, shown in red, acts over the plant proportionally to the error, its
integral and its derivative
Note from Eq. (1) that the ideal PID controller adds two zeros and one pole to the plant, and
therefore it is not implementable, given it represents a non-causal system, i.e. it exhibits more
zeros than poles. The implementable version of the PID has an additional pole according to Eq.
(2)
53
𝑈(𝑠) 𝐾𝑖 𝑁∗𝑠 (2)
𝐺𝑃𝐼𝐷 (𝑠) = = 𝐾𝑝 + + 𝐾𝑑
𝐸(𝑠) 𝑠 𝑠+𝑁
That is, a first-order filter is added to the derivative term, resulting in a two-pole two-zero
system. The additional pole, determined by the filter coefficient, N, is normally placed to be
non-dominant, having thus an insignificant effect in the system response.
In this lab, a DC motor speed control system is used control the motor speed, by use of
potentiometer error detector. The error is tuned by a PID controller and must be given to the
armature controlled motor whose speed will get controlled as per the control signal. The motor
shaft is coupled to the load through gearing arrangement with ratio N1/N2. Speed control
systems have innumerable applications, not only in biomedical engineering but also other
engineering domains such as Insulin pump control, machine tool control, constant tension
control of sheet rolls in paper mills, control of sheet metal thickness in hot rolling mills, radar
tracking system, missile guidance systems, inertial guidance, In armature controlled DC
servomotor the excitation of the field winding is kept constant and torque is varied by varying
the applied voltage connected to the armature.
54
𝐸𝑎 (𝑠) = 𝐸𝑏 (𝑠) + 𝐼𝑎 (𝑠)[𝑅𝑎 + 𝑠𝐿𝑎 ]
𝐸𝑏 (𝑠) = 𝐾𝑏 𝑠 𝑤(𝑠)
𝑇 = 𝐾𝑡 𝐼𝑎 (𝑠)
𝑇 = 𝐾𝑡 𝐼𝑎 (𝑠) = 𝐽𝑠 2 𝑤(𝑠) + 𝐵𝑠𝑤(𝑠)
Solving above equations yields
𝐸𝑎 (𝑠) = 𝐾𝑏 𝑠 𝑤(𝑠) + 𝐼𝑎 (𝑠)[𝑅𝑎 + 𝑠𝐿𝑎 ]
𝑇
= 𝐾𝑏 𝑠 𝑤(𝑠) + [𝑅 + 𝑠𝐿𝑎 ]
𝐾𝑡 𝑎
𝐽𝑠 2 𝑤(𝑠) + 𝐵𝑠𝑤(𝑠)
= 𝐾𝑏 𝑠 𝑤(𝑠) + [𝑅𝑎 + 𝑠𝐿𝑎 ]
𝐾𝑡
𝐽𝑠 2 + 𝐵𝑠
= 𝑤(𝑠) [𝐾𝑏 𝑠 + [𝑅𝑎 + 𝑠𝐿𝑎 ]]
𝐾𝑡
Figure 1: Block Diagram of DC Motor Speed Control System via Proportional (P) Controller
55
Figure 2: Block Diagram of DC Motor Speed Control System via Proportional Integral (PI) Controller
Figure 3: Block Diagram of DC Motor Speed Control System via Proportional Integral Derivative (PID)
Controller
Procedure:
1. Develop the complete block diagram of the given schematic diagram of speed control system
using Simulink.
2. Kp, Ki, and Kd are the variables and set it to some suitable value to simulate over, under
damped conditions of the system.
3. From the response curve determine the time domain specifications.
Lab Practice:
Simulate the system in figure 1 with following parameters. 𝐾𝑝 = 24/pi, 𝐾𝑖 = 5, 𝐾𝑑 =1, 𝐾𝑡 = 6 ∗
10−5 Nm/amps, 𝐽 = 5.4 ∗ 10−5 kg-m², 𝐵 = 4 ∗ 10−4 Nm rad/sec, 𝑅𝑎 = 0.1 ohms, 𝐿𝑎 = 0.001 H.
56
Figure 4: Step Response of PID Speed Controller
57
Lab # 09
Object: To Construct a DC motor based Insulin Pump model to control the Flow Rate via
PID Controller in MATLAB SIMULINK
Theory:
1. Proportional control
The proportional control relies on acting proportionally to the measured error. That is, the
higher the magnitude of the error is, the stronger the control action is applied to the plant. This
is an elemental and intuitive control action that improves the plant output but also may lead to
undesirable effects.
The proportional controller is configured through the parameter, Kp, which indicates how
strong is the control action according to the current error.
Lab Practice:
Let’s consider the insulin pump such that the flowrate of insulin exhibits a first-order dynamic.
For the convenience, the set of equations is presented, the relation of the flowrate and the motor
speed is given in Eq. (5).
58
Figure 1: The proportional control. The control action is proportional to the error, (control = error*Kp),
enabling the system to quickly react against perturbations and/or changes in the reference, but at the expense of
producing oscillations, even instability, when the error and/or Kp are sufficiently high
From Eqs. (1–5), the transfer function of the system can be derived as
5
𝐺(𝑠) =
𝑠3 + 9𝑠 2 + 20𝑠 + 10
We will study the effect of adding a proportional controller using different Kp values.
The gain of the system is 5/10 = 1/2, and thus, the step response in open loop will achieve that
value, while we pretend to produce the insulin flowrate commanded through the input to the
controlled system, i.e. the reference, in this case, for simplicity, a unitary step (Fig. 1).
59
Figure 2: Influence of the Kp parameter in the proportional control. As long as Kp increases, the system reacts
more impulsively against the error, reducing the error at the steady state but causing more oscillations
Figure 3: The PI control. The control action considers now both the error and its integral. Taking into account
the integral of the error permits this controller to eliminate the error at the steady state
Lab Practice:
For the system proposed in part 1, consider also an integral action over the error and check its
effect for different values of Ki. The closed-loop transfer function is now:
𝐾𝑖 5
𝐺𝑐𝑙 (𝑠) = 𝑓𝑒𝑒𝑑𝑏𝑎𝑐𝑘 (𝑠𝑒𝑟𝑖𝑒𝑠 (𝐾𝑝 + , 3 2
) , 1)
𝑠 𝑠 + 9𝑠 + 20𝑠 + 10
5𝐾𝑝 𝑠 + 5𝐾𝑖
𝐺𝑐𝑙 (𝑠) = 4
𝑠 + 9𝑠 + 20𝑠 2 + 10𝑠 + 5𝐾𝑝 𝑠 + 5𝐾𝑖
3
5𝐾
That is, the system gain is 1, i.e. 5𝐾𝑖
𝑖
60
The integral component of the PI adds an integrator, and thus the type of the system increases,
eliminating the error at the steady state when the input reference is a step.
Let’s observe this effect considering the previous example with 𝐾𝑝 = 5 and 𝐾𝑖 = 1 (Fig. 4).
Note that the system response (blue line) has slightly increased the overshoot but, most
importantly, the error at the steady state has been completely eliminated.
Figure 4: The PI control. After the first peak the response tends to the reference. Note how the error (red line)
tends to zero, while at the steady state, the input to the plant is only produced by the integral component
The effect of varying the parameter Ki reduces the steady-state time and the settling time at the
expense of largely increasing the overshoot of the system as shown in Fig. 5. Note how the red
response reaches its settling time at time 𝑡 = ~10𝑠 (and the blue one around 20), but the former
exhibits a 40% of overshoot.
61
Figure 5: The PI control. Notice that increasing the integral parameter the output achieves the steady state faster
but at the expense of a high overshoot
Finally, the third component of the PID controller comes into scene to reduce response
oscillations. The two other components have demonstrated their ability to produce a fast and
precise response, but at the expense of causing oscillations and high overshoots. This is because
in both cases the controller has no information about the change of the error, but only its instant
value and it’s integral along the time. The derivative of the error provides information about
its changes along the time. The derivative control will firmly act against sharp changes of the
error values, in an attempt to moderate it.
Lab Practice:
62
Notice that including a derivative control, an additional control action opposes the impulsive
action of the proportional and integrative components. This occurs when the derivative of the
error is negative, which coincides with the overshoot.
Figure 6: The PID control. Adding a derivative control the response is smoothed, reducing the overshoot and
oscillations. (To produce this plot, the derivative action has been limited to be properly shown since when the
step is raised, the derivative of the error tends to −∞)
Varying the value of Kd will cause a slower and smoother response, where the response
oscillations are flatten. See Fig. 7 for 𝐾𝑑 = 2. However, note that higher values for this
parameter will have the opposed effect; it causes an increment in the overshoot. This is because
as long as the parameter increases, the control action is stronger and stronger, producing an
excessive reaction to the controlled variable, i.e. the derivative of the error.
63
Figure 7: The PID control. The derivative control strives for reducing the overshoot; however, high values of
the parameter Kd may cause the opposed effect, even make the system unstable
PID Summary:
As stated in the previous sections, each component of the PID control exhibits valuable
advantages but also undesirable disadvantages. The contribution of the different parameters of
a PID is summarized in Table 1.
64