The Inverted Pendulum on a Linear Cart€¦ · The Inverted Pendulum on a Linear Cart Lab 8 Pre...

12
The Inverted Pendulum on a Linear Cart Lab 8 Pre Lab

Transcript of The Inverted Pendulum on a Linear Cart€¦ · The Inverted Pendulum on a Linear Cart Lab 8 Pre...

Page 1: The Inverted Pendulum on a Linear Cart€¦ · The Inverted Pendulum on a Linear Cart Lab 8 Pre Lab. Goals •Model the dynamics of the cart and the pendulum ... solution φ. Stabilize

The Inverted Pendulum on a Linear Cart

Lab 8 Pre Lab

Page 2: The Inverted Pendulum on a Linear Cart€¦ · The Inverted Pendulum on a Linear Cart Lab 8 Pre Lab. Goals •Model the dynamics of the cart and the pendulum ... solution φ. Stabilize

Goals

• Model the dynamics of the cart and the pendulum

• Find a suitable PID controller for stabilizing the pendulum while ignoring the cart stability

• Use an ad hoc approach to stabilizing the pendulum and the cart

Page 3: The Inverted Pendulum on a Linear Cart€¦ · The Inverted Pendulum on a Linear Cart Lab 8 Pre Lab. Goals •Model the dynamics of the cart and the pendulum ... solution φ. Stabilize

Model the cart and the pendulum

x

θ

Newton or Energy Method nonlinear equation of motion:

2( ) 6 cos sin2 2

cos sin 02 2

c r r r c

c r r

l lm m x x m m F

l lI m x m g

2

2

is cart mass: 0.94 kg

m is rod mass: 0.23 kg

b is the cart damping coefficient

l is the rod length: 0.6413

1I is the rod moment about the cart

3

is the gravity 9.18 m/s

c

r

c r

m

m l

g

Page 4: The Inverted Pendulum on a Linear Cart€¦ · The Inverted Pendulum on a Linear Cart Lab 8 Pre Lab. Goals •Model the dynamics of the cart and the pendulum ... solution φ. Stabilize

Observations

sin 02

c c

c

m x bx F

lI mg

Uncoupled: Linearize:

ˆˆ( ) ( )

ˆ( ) ( )

x c

c

x s G s F

s G s F

We need damping coefficient b

Matlab to design the closed loop controllers:

ˆ ( )( )ˆ

( )ˆ( )

ˆ ˆ( ) ( )

x

c

G sG sF

G ss

X s H s F

Page 5: The Inverted Pendulum on a Linear Cart€¦ · The Inverted Pendulum on a Linear Cart Lab 8 Pre Lab. Goals •Model the dynamics of the cart and the pendulum ... solution φ. Stabilize

Find Damping Coefficient b1. Remove the pendulum

2. Use in feedback loop to get b c cm x bx F

𝐶𝑠 𝐺𝑥00

0

0

2

2

1

/

/ /

p x p

x

p x c p

p c

c p c

K G KH

K G m s bs K

K m

s b m s K m

2 2 2p

n c c p c

c

Kb m m K m

m

Critical damped condition, then ζ = 1

b = 2 𝐾𝑝𝑚𝑐

Page 6: The Inverted Pendulum on a Linear Cart€¦ · The Inverted Pendulum on a Linear Cart Lab 8 Pre Lab. Goals •Model the dynamics of the cart and the pendulum ... solution φ. Stabilize

Confirm the Full Nonlinear Model

Experimental (LabVIEW):

Initialcondition

Numerical Integration ofNonlinear equations (Matlab)

Cart Position

Pendulum Position

Match?

Page 7: The Inverted Pendulum on a Linear Cart€¦ · The Inverted Pendulum on a Linear Cart Lab 8 Pre Lab. Goals •Model the dynamics of the cart and the pendulum ... solution φ. Stabilize

Stabilize the Pendulum in the upright position

Disturbance

Apply force toKeep θ ≈ π

𝐶𝑠 𝐺𝑥0

r(s)

ˆ ( )df s

( )ˆˆ( ) ( )

1 ( ) ( )d

G ss f s

C s G s

Page 8: The Inverted Pendulum on a Linear Cart€¦ · The Inverted Pendulum on a Linear Cart Lab 8 Pre Lab. Goals •Model the dynamics of the cart and the pendulum ... solution φ. Stabilize

Closed loop root locus

X X XO

PI controller PID controller

( )( )

( )

I

p

p I

p

p

I

I

p

s zC s K

s

KK

s

K Ks

s K

K K

K Kz

Kz

K

1 2

2

1 2

1 2

( )( )( )

( )

/

( )

I

p D

p p I

D D

p

I

D

s z s zC s K

s

KK K s

s

K K Ks s

s K K

K z z K

K z z K

K K

Page 9: The Inverted Pendulum on a Linear Cart€¦ · The Inverted Pendulum on a Linear Cart Lab 8 Pre Lab. Goals •Model the dynamics of the cart and the pendulum ... solution φ. Stabilize

Stabilize Both the Pendulum and Cart

+

+

+

+

u(s)ˆ( )s

ˆ( )x s

-

-

Since φ is small, ϕ is small, and ϕ 0

( ) 2

02 2

c r r c

c r r

lm m x bx m F

l lI m x m g

(1)

(2)

From (1), take Laplace transform:2 2

2

2

ˆ ˆˆ[( ) ]2

ˆˆ2ˆ

( )

c r r c

c r

c r

lm m s bs x m s F

lF m s

xm m s bs

Small perturbationfrom unstable

solution

φ

Page 10: The Inverted Pendulum on a Linear Cart€¦ · The Inverted Pendulum on a Linear Cart Lab 8 Pre Lab. Goals •Model the dynamics of the cart and the pendulum ... solution φ. Stabilize

Stabilize Both the Pendulum and CartPlug into Laplace of (2):

2 2

2 4 4

2

2 2

3 2

ˆ ˆ[ ] 02 2

ˆ ˆ( )2 2ˆ[ ]

2 ( ) ( )

2ˆ ˆ( ) ( )( )

2 2

c r r

r r c

c r

c r c r

r

c

c r c r r

l lI s m g m s x

l lm s m s F

lI s m g

m m s bs m m s bs

m ls

Rs F sI b m gl m m m gl

s s s bR R R

This is the open loop transfer function

Page 11: The Inverted Pendulum on a Linear Cart€¦ · The Inverted Pendulum on a Linear Cart Lab 8 Pre Lab. Goals •Model the dynamics of the cart and the pendulum ... solution φ. Stabilize
Page 12: The Inverted Pendulum on a Linear Cart€¦ · The Inverted Pendulum on a Linear Cart Lab 8 Pre Lab. Goals •Model the dynamics of the cart and the pendulum ... solution φ. Stabilize

𝑃𝐼𝐷𝑥

𝑃𝐼𝐷θ

+

+

+

+

𝐺ϕ 𝑠

𝐺𝑥(𝑠)

u(s)ˆ( )s

ˆ( )x s

-

-