You are on page 1of 16

Term Project-Part I:

Designing a PID controller for


A Segway Vehicle

ME5659 34234 Control and Mechatronics


Ashkan Ghanbarzadeh

Estimation of human body moment of inertia (MOI) a round its center of gravity
In order to estimate , the MOI of human body (HB), we use the data in [1] and an approximated shape including
one sphere (1), four circular cylinders (3, 4), and one elliptical cylinder (2):
Table 1. Body Segments properties estimation

Segment No.
1
2
3
4
Whole Body

Height (m)
0.212
0.545
0.866
0.938
1.7268

Mass (Kg) Estimated Dimension Y(m)


1.6208
4.550
= 0.106
29.608
= 0.27, = 0.19 1.3483
1.0818
3.770 ( 2)
= 0.035
0.1
0.484
11.135( 2)
63.968
-

According to the table above, we can compute moment of inertia of each segment
around its own center of mass, with a rough approximation:
)

2
=
5

= 0.4 4.55) 0.106) = 2.0449 10

1
12
1
=
12

")

"

+3

) = 1/12)29.608 0.545 + 3 0.19 )) = 1.0000

+3

) = 1/12)3.770 0.866 + 3 0.035 ))

= 236.76 10

1
12

" + 3

"

) = 1/12)11.135 0.938 + 3 0.1 ))

= 844.26 10

#$%&'%( )* +,--)./ =

1 #1 66.23055
=
= 1.040
1
63.698

Now we have to calculate MOI of each segment around the center of the wheel, before
we can enter the total MOI into the governing equation. We can assume that the bottom
of the feet and the center of the wheels are at the same level (Fig.1), thereby, we can
transfer MOI of all segments to the point (0, 0, 0):

)2

= 2.0449 10

)2

+ 4.550 1.6208) = 11.9549

= 1.0000 + 29.608) 1.3483) = 40.9205

)2

= 236.76 10

+ 3.770) 0.17 + 1.0818 ) = 4.7577

")2

")

" 3"

= 844.26 10

+ 11.135) 0.484 ) = 3.4527

Figure 1. Picture of SEGWAY i2


from
http://www.segway.com/;
depicting the level of feet bottom
and wheels centerline.

And eventually, based on the assumptions total MOI of postulated human body would be:
45)2

)2

)2

+2

)2

+2

")2

= 69.2962

As an example we solve the problem for Segway i2, form SEGWAY Company. The geometric and mass
specifications of Segway i2 are obtained from the reference manual [2] provided by the company:

Table 2. Segway 2i Specifications, capture from ref. manual

The battery mass is 10.3 Kgs; which renders the overall mass 47.3 Kgs. In order the compute the MOI of vehicle
around the wheel centerline, we assume
a mass of 5 Kg for turning pipe (p)
(connecting the body of vehicle to
819
handlebar) and handlebar, and suppose
8J9
8 J9
that the rest of system mass is
concentrated in wheels (w) (short
cylinders) and a box (b) (rectangular
=9
cross-section)
containing
vehicle
technical parts. Referring to Table.2, the
size of assumed box is 656 636
2. Picture of tire for size estimation: (a) tire width; http://store.segway.com/p/i2206
and the diameter of tires Figure
wheel-kit-1/replacement-parts, (b) tire inner radius;
is 48.3 6 . Based on [3] the density of http://simplehomesdesign.com/images/Segway%20i2.
shredded tires is between 390 7 /
for our tires. Proportional size can be extracted from Figure.2
and 535 7 / , so we pick a value of 450 7 /
circa:
Hence, we can assume =9 = 106
9

and 819 = 206 . Now we can simply calculate MOI of the vehicle:

= >?8:9 819 A=9 B = >) 0.483) 0.3622) ) 0.1) 450) = 14.4341

9)

9)2

E)

E)2

H)2

819 /8:9 0.75; =9 /8:9 0.4

1
3

=
=

HI

1
2

1
12

9 ?8:9
E

819 A = 0.5 14.4341)[ 0.483) 0.3622) ] = 0.7369

+6 )=F

1
G 47.3 14.4341 5)[ 0.63) + 0.65) ] = 1.9028
12

1
= F G 5) 0.97 ) = 1.5682
3

KLK)2

= 4.2079

#$%&'%( )* +,--)-M- =

1 #1 0 + 0 + 5 0.97/2)
=
= 0.0513
1
47.3

Consequently, the total moment of system and human body is:


N:NOP

45)2

KLK)2

= 69.2962 + 4.2079 = 73.5041

Based on all the calculations, parameters in governing equation will be selected from Table.3:
Table 3. Governing equation parameters

Parameter
M
m
L
l
J
R

Value (SI)
47.3
63.968
1.0400
0.0513
73.5041
0.2415

Completing the required tasks

1) The given equations are:


QR S) =

T U+

WR S) =

Q S) +

Y
8 T+

WX S)
)

Z S)

Z S) +

3 [)

1)

QX S)

V/8 + 6
WX S)
T+

2)

Upon taking Laplace transform, we get:


[ [) =

T U+

[ ] [) =

[) +
Y
8 T+

[] [)
)

V [)

Z [) +

3 [)

[ [)

V/8 + 6
[] [)
T+

3)
4)

Writing X(s) in terms of V(s) form (4):


] [) =

Y 8 T + )
`
V [) =
V [)
V/8 + 6
[ +` [
[ +
[
T+

5)

Now we plug X(s) from (5) into (3):


[ [) =
Or:

T U+

[) +

[`
Y
V [) Z [) +
[ +` [

3 [)

[ [)

3)

[)[[ +
[) =

T U+

1 Y[ + V` Y` )[
)Z [) +
[ +` [

]=

Y[ + V` Y` )
T U+
6
[+` ) [ + [

)Z [) +
)

[ +

T U+

3 [)

3)

3 [)

6)

Equations (5) and (6) are the expression of [) and ] [) in terms of input (Z [)) and disturbance (3 [)),
respectively.
2) In order to analyze the stability of system, we consider the denominator of eq. (5) and (6):
] [) =
[) =

`
V [)
[ +` [

f
d [+` )
Z [) +
3 [)
[ + `" [ `e )
[ + ` ) [ + `" [ `e )

gh [) = [ + ` ) [ + `" [ `e ), i3 gj [) = [ + ` [.
Where d = Y ; f =

/ ;` =

klm nlo
; `"
n

= 6 / ; `e =

7 1&2)

pqrstqP
.
u

Closer look at equation 7-1 will show that there is a sign alteration in the coefficients of the 3rd degree polynomial
(`e would produce such term):

(7-1): [ + ` ) [ + `" [ `e ) = [ + ` + `" )[ + `" ` `e )[ `e `

Therefore, the system is unstable. Rouths array would delineate the same conclusion:
vw
vw
v
v}

x
` + `"
`" ` + `" ` `" `e )
`e ` `" ` + `" ` `" `e )

yz y{ y|
`e `
0
0

0
0

Looking at the third and fourth row of Rouths table, with all `1 > 0 , at least one sign change exist passing from
row 3 to 4 since they have a common term multiplied by a negative number; so the system has at least one root
with positive real part, and thus is not stable.

3) To design the PID controller for Q S) we assume a feedback-loop with gain [) = 1 and in turn the closed-loop
block diagram becomes as Fig.4.

Figure 3. Block diagram for designing PID controller

Considering equation (8) and a PID controller of form [) =


function from output angle to reference angle:

1 /[ we

can compute the transfer

[) = [)Z [) + [)3 [)
We aim to regulate the voltage in order to have a stable output angle, hence we use the following transfer function
to design the controller:
P:K =

[) [)
[)
=
1 + [) [) g [)

In which:
g [) = [ " + `" + ` + d )[ + ?`" ` `e + d H + d ` A[ + ?d 1 + +d H ` ` `e A[ +
g [) = 1[ " + g1[ + 2[ + g2[ + 3d. So the Rouths array would be of this form:
["
vw
v{
vx
v}

1
g1
1
1
1

2
g2
E2
F2
G2

C3
D3
E3
F3
G3

With chosen values from Table.3:


1 = 1;
2 = `" ` `e + d

+d

= 9.2120 0.0073

3 = 6.5502 10 )

g1 = `" + ` + d

6.5502 10 )

= 0.0415 0.0073

1`

d or

g2 = d

+ +d

H`

` `e = 0.0073

6.5502 10 )

0.3811

We employ the MATLAB code in appendix files to calculate the coefficients in Rouths table:
KP=input('KP= ');
KI=input('KI= ');
KD=input('KD= ');
R=0.483/2;
M=47.3;
m=63.968;
J=73.5041;
l=1.0400;
L=0.0513;
kT=0.75;
kbemf=0.5;
ra=1.4;
c1=0.01;
c2=0.01;
g=9.82;
a=kT/ra;
b=kT*kbemf/(R*ra);
A=-a/J;
B=m*g/J;
g1=a/(R*(m+M));
g2=(b/R+c2)/(M+m);
g3=(b*g1-a*g2)/(-a);
g4=c1/J;
g5=(M*g*L+m*g*l)/J;
num1=[A A*g3];
den1=[1 g2+g4 g4*g2-g5 g2*g5];
sys=tf(num1,den1);
s = tf('s');
C = KP + KI/s + KD*s;
Csys=feedback(sys,C);
rlocus(Csys)

C1=1;
C2=(g4*g2-g5+A*KP+A*KD*g3);
C3=KI*g3*A;
D1=g4+g2+A*KD;
D2=(A*KI+A*KP*g3-g2*g5);
D3=0;
E1=(D1*C2-D2*C1)/C1;
E2=(D1*C3-D3*C1)/C1;
E3=0;
F1=(E1*D2-E2*D1)/D1;
F2=(E1*D3-E3*D1)/D1;
G1=(F1*E2-E1*F2)/E1;
Routh_1column=[D1 E1 F1 G1];
disp('[D1 E1 F1 G1]= ')
disp(Routh_1column)

Where C1, D1, E1, F1, and G1 are the first column coefficients in Rouhts array.
Table 4. Iteration values to find a set of PID constants for a stable system

No. routhSegway(Kp, Ki, Kd))

1
2
3
4
5
6
7
8
9
10

(100, 200, 5)
(100, 200, -5)
(-100, -300, -5)
(-100, -300, -100)
(-1000, -3000, -1000)
(-2000, -3000, -1000)
(-2000, -2000, -1000)
(-1500, -750, -1000)
(-1500, -750, -500)
(-3000, -5000, -2500)

(D1, E1, F1,G1)


0.0051 1.7885 -649.8009 0.0002
0.0779 1.0640 -25.1000 0.0002
0.0779 -2.4667 -57.1379 0.0004
0.7703 -8.3402 -19.5478 0.0004
7.3297 -35.5802 -104.3042 0.0422
7.3297 17.8398 52.2776 0.0422
7.3297 25.1280 48.6599 0.0186
7.3297 7.5283 5.2202 0.0025
3.6856 1.2556 1.7309 0.0025
18.2621 195.0316 385.0683 0.1181

Settling time
<30
<25
>60
>100
<20

Row 6 through 9 meet Rouths criteria, and thus assure the stability of system; for instance a stable
simulated plot of theta with an impulse input as a disturbance (No. 7 from table above) is depicted on
Fig.4. Still, the performance of system needs to be observed for different values of ( H , , 1 ) (settling
time, overshoot percentage, etc.) and accordingly these three values can be optimized.

Figure 4. System response to impulse input for

H,

1,

= 2000, 2000, 1000)

4) With the same values used for above simulation, we get the following result for [] [) in time
domain:

Figure 5. Velocity response to an impulse disturbance using the same PID as part (c)

So, we have also a stable velocity plot, by using the PID controller, and having an impulse disturbance
to the block diagram.

5) We use rlocues command in MATLAB, and the result for the chosen set of PID constants is as follows:

Figure 6. System Root Locus for

H,

1,

= 2000, 2000, 1000)

Looking at the Root locus plot above, we see that the dominant poles are the complex couple in the vicinity of
imaginary axis. In order to make the system response faster (i.e. decrease settling time), we need to shift these
poles to left, farther from imaginary axis. Using a trial-error method, we inspect that by increasing H , , 1
proportionally to each other (with a factor of ), we can displace dominant poles further to left. Figure 5
represents root locus and its associated time-domain plot for various cases.

Figure 7. Root locus and impulse response for C=2 (top); C=10 *(middle); (c) C=50 (bottom).

We also note that by increasing C (which means increasing all PID constants by a factor of C): (I) the real pole
(which is not dominant) moves farther from imaginary axis, and (II) overshoot goes up which might not be
desirable considering design requirements.

The succeeding plots are obtained by other sets of PID constant values:

Figure 8. Value set

H,

1,

):

Top (-4000, -2000, -2000), Middle (-4000, -1000, -1000),


Bottom (-4000, -500, -500)

Above trend in changing PID constants tends to reduce settling time, but it increases negative overshoot, which
could be unexpected by vehicle user, and thus undesirable.

6) Until now, we only focused on designing a controller to regulate the voltage to have a stable output angle
and velocity; now we use below block diagram and apply distance disturbance from the user to our system.
The mentioned assumption for designing is valid, because the overall denominator of [) in (8) is equal to
the denominator of the first transfer function relating voltage and angle:
[) =

f
d [ + ` )Z [) + f3 [) [ + ` )
d [+` )
Z [) +
3 [) =
)
)
)
[ + `" [ `e
[ + ` [ + `" [ `e
[ + ` ) [ + `" [ `e )

Thereby the designed PID should be able to stabilize the whole system, encompassing the disturbance, as well.

Figure 9. Block diagram of system with disturbance

When we use above diagram, the result becomes eccentrically unstable:

Figure 10. The simulation result from Block diagram in Fig.7.

But if take advantage of the fact that both transfer functions have a common term in their denominator, and
change the diagram as Figure. 10:

Figure 11. Reshaping the block diagram by factoring the common denominator term

The responses to the unit impulse and unit step are depicted in Figure. 9, and 10 respectively. The gain block
has been employed to restrict the amplitude of velocity response under a specific amount. The reason behind
the strange result of Figure. 8 could be due to inability of ode45 to solve the numerical problem with that
configuration.

Figure 12. Theta output (top), and Velocity output (bottom) with implemented PID and disturbance and the same set used in part
(c): a derivative discontinuity in theta, and a considerable steady-state error in velocity output

Above graphs show that angle response (with same PID constant values used in task 3) has a derivative
discontinuity (abrupt change of momentary angular velocity) which is not desirable. What is more, velocity
has a different final value from zero. Figure 16 employs another set of values, yet the same two observations
can be noted in its plots.

Figure 13. Theta output (top), and Velocity output (bottom) with implemented PID and disturbance, with C=10 in part (e): a
derivative discontinuity in theta, and a considerable steady-state error in velocity output

The time-domain plots of a step input (when the driver leans forward and keeps a constant disturbance) are
displayed in Figure 13:

Figure 14. Step response: Theta (Top) and Velocity (Bottom) response to step input.

As can be observed, theta is still stable, but it has a large steady-state error, comparing its final value with 1.
Yet, the velocity increases linearly with time as the driver leans forward and stays in that position. If the
driver stops the disturbance after a while (e.g. 25 second), the velocity increases and then becomes stable
after the driver returns to normal situation:

Figure 15. Step response when the driver reverts to initial situation after 25 seconds.

7) Utilizing a saturation block results would destabilize the system response to impulse input, for both angel
position and velocity; as the following figure delineates:

Figure 16. Unstable Theta (left) and Velocity (right) with designed PID at step 3.

The step input results in a similar unstable output set. Moreover, increasing PID gains as a whole is not able
to control the system. System response to very small disturbance can be controlled, yet, such trivial
disturbances are not practical.

* Note on large and negative PID constant values:


As Fig. 17 shows, an odd number of sign inverting operational amplifier can be used to have a negative PID
constant set [4].

Figure 17. Inverting op-amp: : = 8 /8 1

Furthermore, to have large PID gains, values of resistances and capacitances can be selected in a way to have
produce big enough multiplications, and make designed values possible.

Figure 18. PID circuit

References
[1] Drillis, Rudolfs, Renato Contini, and Maurice Bluestein. "Body segment parameters." Artificial limbs 8.1
(1964): 44-66.
[2] www.segway.com/downloads/pdfs/ReferenceManual.pdf.
[3] http://www.fhwa.dot.gov/publications/research/infrastructure/structures/97148/st1.cfm.
[4] Katsuhiko Ogata, Modern Control Engineering, 5th edition.

You might also like