0% found this document useful (0 votes)
25 views12 pages

Lab 8 & 9

This document describes constructing a DC motor speed control system for an insulin pump using PID control in Simulink. It provides the theory behind PID control and mathematical models of the DC motor and insulin pump system. The objective is to control motor speed and thus insulin flow rate via a PID controller. Procedures are given to simulate the system with proportional, PI and PID control and analyze the step responses.

Uploaded by

saadshahab622
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views12 pages

Lab 8 & 9

This document describes constructing a DC motor speed control system for an insulin pump using PID control in Simulink. It provides the theory behind PID control and mathematical models of the DC motor and insulin pump system. The objective is to control motor speed and thus insulin flow rate via a PID controller. Procedures are given to simulate the system with proportional, PI and PID control and analyze the step responses.

Uploaded by

saadshahab622
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Lab # 08

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

Which is normally rewritten as:


𝑡
𝑑𝑒(𝑡)
𝑢(𝑡) = 𝐾𝑝 𝑒(𝑡) + 𝐾𝑖 ∫ 𝑒(𝑡)𝑑𝑡 + 𝐾𝑑
𝑑𝑡
0
𝐾𝑝
𝐾𝑖 = , 𝐾𝑑 = 𝐾𝑝 𝑇𝑑
𝑇𝑖
With this, the transfer function of a PID is as follows
𝑈(𝑠) 𝐾𝑖 𝐾𝑑 𝑠 2 + 𝐾𝑝 𝑠 + 𝐾𝑖 (1)
𝐺𝑃𝐼𝐷 (𝑠) = = 𝐾𝑝 + + 𝐾𝑑 𝑠 =
𝐸(𝑠) 𝑠 𝑠

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.

Mathematical Model of the system:


For potentiometer error detector,
𝐸𝑎 (𝑠) = 𝐾𝑝 [𝑅(𝑠) − 𝐶(𝑠)]
The dynamic model of a separately excited DC motor is given as
𝑑𝑖𝑎
𝑒𝑎 = 𝑒𝑏 + 𝐿𝑎 + 𝑖𝑎 𝑅𝑎
𝑑𝑡
Where 𝑒𝑎 is armature voltage of motor, 𝑒𝑏 is the motor back E.M.F, 𝐿𝑎 is the armature
inductance, 𝑅𝑎 is the armature resistance, and 𝑖𝑎 is the armature current.
Moreover, 𝑒𝑏 is given as
𝑑𝑤
𝑒𝑏 = 𝐾𝑏
𝑑𝑡
Where 𝐾𝑏 is the motor back E.M.F constant, and 𝑤 is motor speed. Thus,
𝑑𝑤 𝑑𝑖𝑎
𝑒𝑎 = 𝐾𝑏 + 𝐿𝑎 + 𝑖𝑎 𝑅𝑎
𝑑𝑡 𝑑𝑡
For armature controlled DC motor, the field current 𝑖𝑓 is constant as flux Ф is constant,
therefore the torque 𝑇 is given as
𝑇 = 𝐾𝑡 𝑖𝑎
Where 𝐾𝑡 is the torque constant.
In terms of machine parameters, the torque is given as
𝑑2𝑤 𝑑𝑤
𝑇 = 𝐾𝑡 𝑖𝑎 = 𝐽 2 + 𝐵
𝑑𝑡 𝑑𝑡
Where 𝐽 is the motor inertia, and 𝐵 is the motor viscous friction conatant.
Taking Laplace of above Equations

54
𝐸𝑎 (𝑠) = 𝐸𝑏 (𝑠) + 𝐼𝑎 (𝑠)[𝑅𝑎 + 𝑠𝐿𝑎 ]
𝐸𝑏 (𝑠) = 𝐾𝑏 𝑠 𝑤(𝑠)
𝑇 = 𝐾𝑡 𝐼𝑎 (𝑠)
𝑇 = 𝐾𝑡 𝐼𝑎 (𝑠) = 𝐽𝑠 2 𝑤(𝑠) + 𝐵𝑠𝑤(𝑠)
Solving above equations yields
𝐸𝑎 (𝑠) = 𝐾𝑏 𝑠 𝑤(𝑠) + 𝐼𝑎 (𝑠)[𝑅𝑎 + 𝑠𝐿𝑎 ]
𝑇
= 𝐾𝑏 𝑠 𝑤(𝑠) + [𝑅 + 𝑠𝐿𝑎 ]
𝐾𝑡 𝑎
𝐽𝑠 2 𝑤(𝑠) + 𝐵𝑠𝑤(𝑠)
= 𝐾𝑏 𝑠 𝑤(𝑠) + [𝑅𝑎 + 𝑠𝐿𝑎 ]
𝐾𝑡
𝐽𝑠 2 + 𝐵𝑠
= 𝑤(𝑠) [𝐾𝑏 𝑠 + [𝑅𝑎 + 𝑠𝐿𝑎 ]]
𝐾𝑡

𝐾𝑏 𝑠𝐾𝑡 + 𝐽𝑠 2 + 𝐵𝑠[𝑅𝑎 + 𝑠𝐿𝑎 ]


= 𝑤(𝑠) [ ]
𝐾𝑡
𝐸𝑎 (𝑠) 𝐾𝑏 𝑠𝐾𝑡 + 𝐽𝑠 2 + 𝐵𝑠[𝑅𝑎 + 𝑠𝐿𝑎 ]
=[ ]
𝑤(𝑠) 𝐾𝑡
Or
𝑤(𝑠) 𝐾𝑡
=[ 2
]
𝐸𝑎 (𝑠) 𝐾𝑏 𝑠𝐾𝑡 + 𝐽𝑠 + 𝐵𝑠[𝑅𝑎 + 𝑠𝐿𝑎 ]
Finally
𝑤(𝑠) 𝐾𝑡
=
𝐸𝑎 (𝑠) 𝑠[𝐽𝑠 + 𝐵[𝑅𝑎 + 𝑠𝐿𝑎 ] + 𝐾𝑏 𝐾𝑡 ]
Simulink Model of the System

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).

𝐿𝑎 𝑠𝐼𝑎 (𝑠) + 𝑅𝑎 𝐼𝑎 (𝑠) + 𝐸𝑚 (𝑠) = 𝐸𝑎 (𝑠) (1)


𝐸𝑚 (𝑠) = 𝐾𝑚 Ω(𝑠) (2)
𝑇(𝑠) = 𝐾𝑚 𝐼𝑎 (𝑠) (3)
𝑇(𝑠) = 𝐽𝑠Ω(𝑠) + 𝐵Ω(𝑠) (4)
𝐾𝑓 Ω(𝑠) = 𝐾𝑓 + 𝑠𝑄(𝑠) (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).

The closed-loop control, considering a proportional controller, is represented by the transfer


function:
5𝐾𝑝
𝐺𝑐𝑙 (𝑠) =
𝑠 3 + 9𝑠 2 + 20𝑠 + 10 + 5𝐾𝑝
Note that when 𝐾𝑝 = 1 the final value of the response is 5/15 = 0.333. As long as Kp becomes
higher, the error at the steady state decreases. In theory when 𝐾𝑝 → ∞, the error at the steady
state tends to 0. However, increasing the value of Kp produces oscillations in the output
response when the magnitude of the error is considerably high. At an extreme situation, the
system may become unstable given a certain value of Kp. Figure 2 shows the plant output for
different values of Kp where considering a value of 𝐾𝑝 = 25 yields a final value of 125/135 =
0.926, but at the expense of extremely high oscillations.

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

2. Proportional Integral (PI) control


Considering only the instant error to control the plant is not a good option to achieve a highly
accurate and smooth response in plant output. The proportional control has no records of past
experiences, i.e. of the evolution of the response along the time, and thus its exhibits the
aforementioned limitations. An improvement on the proportional control is the addition of the
integral control, obtaining the PI controller, as shown in Fig. 3. A control action proportional
to the integral of the error is added to eliminate the error at the steady state.

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

3. Proportional Integral Derivative (PID) control

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:

Repeat the previous example including a derivative action with parameters 𝐾𝑝 = 5, 𝐾𝑖 =


5, 𝐾𝑑 = 1. Try different values for Kd and observe the effects on the system output. In this case,
we do not consider the inclusion of the filter coefficient, studying the ideal PID. Figure 6
depicts the system output for the example considered in the previous section with 𝐾𝑝 = 5, 𝐾𝑖 =
5 (the situation illustrated by the red line of Fig. 5) adding a derivative action with 𝐾𝑑 = 1.

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.

Table 1: Contribution of each component of the PID to the system response


Note that the effects are sometimes conflictive since, for instance, trying to reduce the rise time
by increasing the value of Kp, will lead to an increment in the overshoot, which could be solved
by modifying the value of Kd, that in turn, could modify the rise time. That is, the selection of
the parameters of a PID controller is a trade-off between the response characteristics and it is
responsibility of the designer, based on his experience, to tune it accordingly.

64

You might also like