0% found this document useful (0 votes)
76 views

Simulation of Inverted Pendulum With Step Response

This document summarizes the simulation of an inverted pendulum system. It defines the transfer function and state space representation of the system. It then calculates the poles and zeros. Finally, it simulates the impulse and step response of the open loop system.

Uploaded by

John Tyson
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views

Simulation of Inverted Pendulum With Step Response

This document summarizes the simulation of an inverted pendulum system. It defines the transfer function and state space representation of the system. It then calculates the poles and zeros. Finally, it simulates the impulse and step response of the open loop system.

Uploaded by

John Tyson
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

2018-EE-183

LAB 6: SIMULATION OF IMPULSE AND STEP


RESPONSE OF THE INVERTED PENDULUM
TABLE OF CONTENTS
Defining the Transfer Functioin
Defining the System in State Space
Poles and Zeros of the System
Impulse Response of the System
Step Response of the System
DEFINING THE TRANSFER FUNCTION

M = 0.5

M = 0.5000

m = 0.2

m = 0.2000

b = 0.1

b = 0.1000

i = 0.006

i = 0.0060

g = 9.8

g = 9.8000

l = 0.3

l = 0.3000

q = (M+m)*(i+m*l^2)-(m*l)^2

q = 0.0132

s = tf('s')

s =

s
Continuous-time transfer function.

P_disp = (((i+m*l^2)/q)*s^2- (m*g*l/q)/(s^4 + (b*(i+m*l^2))*s^3/q-


((M+m)*m*g*l)*s^2/q - b*m*g*l*s/q))

P_disp =

4.182e-06 s^6 + 7.603e-07 s^5 - 0.0001304 s^4 - 1.863e-05 s^3 - 0.0001025

-------------------------------------------------------------------------

2.3e-06 s^4 + 4.182e-07 s^3 - 7.172e-05 s^2 - 1.025e-05 s

Continuous-time transfer function.

P_pend = (m*l*s/q)/(s^3 + (b*(i + m*l^2))*s^2/q - ((M + m)*m*g*l)*s/q -


b*m*g*l/q)

P_pend =

1.045e-05 s

-----------------------------------------------------

2.3e-06 s^3 + 4.182e-07 s^2 - 7.172e-05 s - 1.025e-05

Continuous-time transfer function.

sys_tf = [P_disp ;P_pend]

sys_tf =

From input to output...

4.182e-06 s^6 + 7.603e-07 s^5 - 0.0001304 s^4 - 1.863e-05 s^3 - 0.0001025

1: -------------------------------------------------------------------------

2.3e-06 s^4 + 4.182e-07 s^3 - 7.172e-05 s^2 - 1.025e-05 s

1.045e-05 s

2: -----------------------------------------------------

2.3e-06 s^3 + 4.182e-07 s^2 - 7.172e-05 s - 1.025e-05


Continuous-time transfer function.

inputs = {'u'}

inputs = 1×1 cell array

{'u'}

outputs = {'x';'phi'}

outputs = 2×1 cell array

{'x' }

{'phi'}

set(sys_tf,'Inputname',inputs)
set(sys_tf,'Outputname',outputs)
sys_tf

sys_tf =

From input "u" to output...

4.182e-06 s^6 + 7.603e-07 s^5 - 0.0001304 s^4 - 1.863e-05 s^3 - 0.0001025

x: -------------------------------------------------------------------------

2.3e-06 s^4 + 4.182e-07 s^3 - 7.172e-05 s^2 - 1.025e-05 s

1.045e-05 s

phi: -----------------------------------------------------

2.3e-06 s^3 + 4.182e-07 s^2 - 7.172e-05 s - 1.025e-05

Continuous-time transfer function.

DEFINING THE SYSTEM IN STATE SPACE

p = i*(M+m)+M*m*l^2

p = 0.0132
A = [0 1 0 0;
0 -(i+m*l^2)*b/p (m^2*g*l^2)/p 0;
0 0 0 1;
0 -(m*l*b)/p m*g*l*(M+m)/p 0]

A = 4×4

0 1.0000 0 0

0 -0.1818 2.6727 0

0 0 0 1.0000

0 -0.4545 31.1818 0

B = [ 0;
(i+m*l^2)/p;
0;
(m*l)/p]

B = 4×1

1.8182

4.5455

C = [1 0 0 0;
0 0 1 0]

C = 2×4

1 0 0 0

0 0 1 0

D = [0;0]

D = 2×1

states = {'x' 'x_dot' 'phi' 'phi_dot'}

states = 1×4 cell array

{'x'} {'x_dot'} {'phi'} {'phi_dot'}

inputs = {'u'}
inputs = 1×1 cell array

{'u'}

outputs = {'x';'phi'}

outputs = 2×1 cell array

{'x' }

{'phi'}

sys_ss = ss(A,B,C,D, 'statename', states,


'inputname',inputs,'outputname',outputs)

sys_ss =

A =

x x_dot phi phi_dot

x 0 1 0 0

x_dot 0 -0.1818 2.673 0

phi 0 0 0 1

phi_dot 0 -0.4545 31.18 0

B =

x 0

x_dot 1.818

phi 0

phi_dot 4.545

C =

x x_dot phi phi_dot

x 1 0 0 0

phi 0 0 1 0
D =

x 0

phi 0

Continuous-time state-space model.

sys_tf = tf(sys_ss)

sys_tf =

From input "u" to output...

1.818 s^2 + 1.615e-15 s - 44.55

x: --------------------------------------

s^4 + 0.1818 s^3 - 31.18 s^2 - 4.455 s

4.545 s - 1.277e-16

phi: ----------------------------------

s^3 + 0.1818 s^2 - 31.18 s - 4.455

Continuous-time transfer function.

POLES AND ZEROS OF THE SYSTEM

[pole zero] = zpkdata(P_disp,'v')

pole = 6×1 complex

-5.6064 + 0.0000i

5.5673 + 0.0000i

-0.6980 + 0.6690i

-0.6980 - 0.6690i

0.6266 + 0.6687i

0.6266 - 0.6687i

zero = 4×1
0

5.5651

-5.6041

-0.1428

[pole zero] = zpkdata(P_pend,'v')

pole = 0

zero = 3×1

5.5651

-5.6041

-0.1428

IMPULSE RESPONSE OF THE SYSTEM

t = 0:0.01:1

t = 1×101

0 0.0100 0.0200 0.0300 0.0400 0.0500 0.0600 ⋯

impulse(sys_tf,t)
title ('Open Loop Impulse Response')

STEP RESPONSE OF THE SYSTE M


t = 0:0.05:10

t = 1×201

0 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 ⋯

u = ones(size(t))

u = 1×201

1 1 1 1 1 1 1 1 1 1 1 1 ⋯

[y,t] = lsim(sys_tf,u,t);
plot(t,y)
title('Open Loop Step Response')
axis([0 3 0 50])
legend('x' , 'phi')

THE END

You might also like