Sunteți pe pagina 1din 314

Power and Control Engineering Experiment

 Textbooks :
From basic to advanced, Automatic control lab
experiments (Using inverted pendulum high-speed
design experimental device),
Control and instrumentation research center,
Realgain technical institute, Published by A-Jin
Available for Download from http://realgain.co.kr

Automatic Control Systems (8th ed.) by B. C. Kuo

CONTROL SYSTEMS ENGINEERING


fifth edition , Nise
Chapter 1

CemTool Experiment
1. Experiment Objective

 Learn CEMTool usage that is necessary to control


the inverted pendulum, or other plants.
2. CEMTool Running

 CEM>>
Commands that
is used in CEM
mode
 M>>
Commands that
is used in M
mode
3. Symbols Used in CEMTool

Symbols Description
‘ Represents transpose of vector or matrix.
EX) a’ or A’

“ “ , ‘ ‘ Represents string
EX) CEM>>title(“Here is a text”)

[ ] Represents vector, matrix, or polynomial


EX) den = [1 3 4 2], A = [1 2 ; 3 4]

( ) Represents elements of vector, matrix, polynomial, or represents variables of


CEMTool function.
EX) A(1,2), step(num, den, t)

// , % Used to quote the comments appear.

; Represents the end of the row. When used at the end of the formula, it
prevents the output on the screen.
EX) A = [1 2 3 ; 4 5 6];

: Creates vector.
EX) CEM>>t = [0:1:0.1]

. Used to calculate elements of row or vectors each other.


EX) c = a.*b, d = a./b
3. Symbols Used in CEMTool

Symbols Description Symbols Description

+ Addition .+ Addition between elements

- Subtraction .- Subtraction between


elements
* Multiplication .* Multiplication between
elements
/ Division ./ Division between elements

^ Power .^ Power between elements


4.1 Vector Representation

CEM>> a = [1:4:1]
a=
1 2 3 4

CEM>> a = [8:2:-2]’
a=
8
6
4
2
4.2 Matrix Representation

CEM>> A = [1.2 10 15; 3 5.5 2; 4 6.8 7]


A=
1.2000 10.000 15.000
3.0000 5.5000 2.0000
4.0000 6.8000 7.0000
4.3 Calculate Vector and Matrix

CEM>> a = [1 2 3]; b = [4 5 6];


CEM>> c = a .* b
c=
4 10 18

CEM>> a = [-1 3 5 7 2];


CEM>> b = [2 6 0 -2 4];
CEM>> c = a .^ 2 + b .^3
c=
9 225 25 41 68
4.4 Reference of Matrix Elements

B = A(i;j) or A(i;j) = B

CEM>> A = [1 2 3; 4 5 6; 7 8 9]
A=
1 2 3
4 5 6
7 8 9

CEM>> A(1;2) // Distinguish between the rows and columns in CEM mode ” ; “

M>> A(1,2) % Distinguish between the rows and columns in M mode ” , “

CEM>> A(2 ; 1 : 3) // Elements of column 1 to 3 of row 2


M>> A(2, 1 : 3) % Elements of column 1 to 3 of row 2
4.5 Substitution of Matrix Elements

CEM>> A = [1 2 3 4 5; 6 7 8 9 10; 9 9 9 9 9; 0 0 0 0 0; 1 1 1 1 1];


CEM>> A(1 ; 2) = 100
M>> A(1, 2) = 100
A=
1 100 3 4 5
6 7 8 9 10
9 9 9 9 9
0 0 0 0 0
1 1 1 1 1

CEM>> C(2;1:3) = [1 2 3]
M>> C(2,1:3) = [1 2 3]
C=
0 0 0
1 2 3
5.1 Check the Status of the Variable

CEM>> a = [1 2 3];
CEM>> A =[1 2 3; 4 5 6; 7 8 9];
CEM>> list
변수목록
a 실수 행렬 1*3
A 실수 행렬 3*3

CEM>> lists
변수 목록 과 내용
a=
1 2 3
A=
1 2 3
4 5 6
7 8 9
5.2 Delete Variable (del)

CEM>> del A
CEM>> list
변수목록
a 실수 행렬 1*3

CEM>> del *
CEM>> list
설정된 변수가 없습니다.
5.3 Save Variable (save)

CEM>> save filename variable1, variable2, …


Save variables to the filename.var in current directory

CEM>> save work a b


Save variable a, b to the work.var

CEM>> save work


Save all variables to the work.var

Use menu
5.4 Load Data Command (load)

CEM>> A = [2 4 -1; -5 3 7; 2 5 8];


CEM>> save filename A
CEM>> list
변수 목록
A 실수 행렬 3*3
CEM>> del A
CEM>> list
설정된 변수가 없습니다.
CEM>> load filename
CEM>> list
변수 목록
A 실수 행렬 3*3
5.5 Help Command (help)
5.6 CEMTool Basic Command

Command Description
del delete variables
logging save data that appear on the screen
msgprint show string or data on the screen
format change the type of the number
fprint print string or data
help show help menu
load load data
print print the graph that appear on the screen
quit finish CEMTool program
save save variables used
list show variables used
lists show properties of variables used
6.1 Create New CEM File
6.2 Load Existing CEM File

 Use menu : Choose ‘File – Open’


 Use toolbar : Click toolbar icon
6.3 Save CEM File

 Use menu : Choose ‘File – Save CEM file’


 Use toolbar : Click toolbar icon
 Use shortcuts : Ctrl + S
7.1 Create User-Defined Function

function
Output variables <> Input variables
:
Operation commands
:
return
7.2 Program Control Command (for)

for (initial value; Condition; increased value) {


statement 1;
statement 2;
:
}

CEM>> for (k=0; k<10; k++){


j = j+k
}
7.2 Program Control Command (for)

for variable name = initial value : increased value : final value


statement 1;
statement 2;
:
end

M>> for k=0:10


j = j+k
end
7.3 Program Control Command (while)

while (condition){
statement 1;
statement 2;
:
}

CEM>> k = 4;
CEM>> a = eye(3,3); //input is 3*3 identity matrix
CEM>> b = k*a;
CEM>> while(b){
b = b – a;
}
7.3 Program Control Command (while)

while condition
statement 1;
statement 2;
:
end

M>> k = 4;
M>> a = eye(3,3); %input is 3*3 identity matrix
M>> b = k*a;
M>> while b
b = b – a;
end
7.4 Program Control Command(if, else)

if (condition1){ // run statement 1,2 if


condition 1 is satisfied
statement 1;
statement 2;
:
}
else{ // run statement 3,4 if condition 1 is
not satisfied
statement 3;
statement 4;
:
}
7.4 Program Control Command(if, else)

CEM>> if ( a > 1) {
k = 1;
}
else { if ( a < -1) { k = 100; }
else { k = 1000; }
}
7.4 Program Control Command(if, else)

if condition1 % run statement 1,2 if condition 1 is satisfied


statement 1;
statement 2;

elseif condition2 % run statement3,4 if condition 2 is satisfied


statement 3;
statement 4;

else % run statement 5 if both condition 1 nor condition 2 are not satisfied
statement 5;

end
7.4 Program Control Command(if, else)

M>> if ( a > 1)
k = 1;
elseif ( a < -1)
k = 100;
else
k = 1000;
end
8.1 Draw a Graph

CEM >> t = [0:2*pi:0.1];


CEM >> y = sin(t);
CEM >> plot(t,y)
8.2 Draw Graphs in One Window

CEM >> t = [0:2*pi:0.1];


CEM >> y = sin(t);
CEM >> y1 = cos(t);
CEM >> plot(t,y,t,y1)
8.3 Color and Shape of Graph

shape of graph color of graph

CEM >> plot(x,y,”option”); “―” ‘-----’ solid line b blue

M >> plot(x,y,’option’); “--” ‘----’ dashed line g green

“:” ‘.........’ dotted line B black


CEM >> plot(t,y1,”r-”)
M >> plot(t,y2,’b*’) “-.” ‘-.-.-.’
dashed
r red
dotted line
“o” ‘oooo’ circled line m magenta
“x” ‘xxxx’ x line y yellow
“*” ‘****’ * line c cyan
“+” ‘++++’ + line
8.4 Graph Information Dialog Box
8.5 Write Characters in Window

 Graph widow menu ‘ insert characters – write’


8.6 Write Title in Window

CEM>> t = 0:10:0.005;
CEM>> m = 0.5;
CEM>> vo = 100;
CEM>> wo = 10;
CEM>> ws = 2;
CEM>>
v=vo*(1+m*sin(ws*t)).*sin(wo*t);
CEM>> plot(t,y);

CEM>> title(“AM signal”);


CEM>> xtitle(“Time”);
CEM>> ytitle(“Amplitude”);
8.7 Multiple Graphs in One Window

CEM>> t = 0:10:0.1;
CEM>> plot(t, sin(t));
CEM>> hold on;
CEM>> plot(t,cos(t));
CEM>> hold off;
8.8 Split of Graph

CEM>> a = 0:10:0.1;
CEM>> b = cos(a);
CEM>> c = sin(a);
CEM>> subplot(2,2,3)
CEM>> plot(a,b)
CEM>> title(“Cosine Wave”);
CEM>> subplot(2,2,2)
CEM>> plot(a,c)
CEM>> title(“Sine Wave”);
8.9 Coordinate Tracking in Graph

 ‘Option’ menu
‘coordinate tracking
in graph’

click left mouse botton


9. Discussion

1. Draw graph of y = t 3
− 4t 2
+ 6t − 19
using CEMTool
(t=0~30, time interval=10msec)

2. Save above variables to ‘y.var’, clear all


variables, and load ‘y.var’.

3. Insert title, x-axis, and y-axis to the graph


(ex. Title : ‘Experiment’, X-axis : ‘time(sec)’
Y-axis : ‘y_out’ )
Chapter 2

SIMTool Experiment
1. Experiment Objective

 Learn SIMTool usage that is necessary to control


the inverted pendulum, or other plants.
2. SIMTool Running

 CEMTool running – input ‘simtool’ in CEMTool


command window
 CEMTool menubar running – SIMTool running
 SIMTool run icon of toolbar
3.1 SIMTool Input Block

Block name Function


Chirp Signal Generate sine signal that changes linearly
Clock Generate time
Constant Generate constant
Cosine wave Generate cosine signal
Digital Clock Generate simulation step time according to sampling size
Discrete Pulse Generator Generate pulse according to Sampling
From File Generate data from file (Used with ‘to File’)
From workspace Generate data from workspace
Ground Generate “0”
Pulse Generator Generate pulse
Ramp Generate ramp signal
Random Number Generate gaussian random number
Repeating Sequence Generate repeating signal
Signal Generator Generate random, sawtooth, sine, rectangular wave
Sine wave Generate sine signal
Squre wave Generate square signal
Step Generate step signal
Uniform Random Number Generate random number with the range
White noise Generate white noise
3.2 SIMTool Output Block

Block name Function


Flow Graph type One Change time base of graph at regular intervals
Flow Graph type Two Cumulative time base of graph at regular intervals
Horizon Bar Horizontal bar graphic gauges(numeric and bar graph)
Horizon Meter Horizontal meter graphic gauges(represent as needle)
Only Bar Bar graphic gauges (numeric display in bar graph)
Out Make us to see calculation result in CEMTool
Round Meter 120 120 degree meter graphic gauges (needle graph)
Round Meter 180 180 degree meter graphic gauges (needle graph)
Round Meter 270 270 degree meter graphic gauges (needle graph)
Scope Calculation results are represented in graph
Stop Simulation Stop simulation if the input value is not 0
Terminator Discard unused signal
To_File Generate the calculation result to file(*.var)
Value Express the output as number
Vertical Bar Vertical bar graphic gauges(numeric and bar graph)
Vertical Meter Vertical meter graphic gauges(represent as needle)
Water Tank Water tank graphic gauges
XY_plot Two calculation results are represented in X-Y graph
3.3 SIMTool Operation Block

Block name Function


Absolute Absolute value of the input signal
CEMTool Function Operation using CEMTool function
Combinatorial Logic Truth table operation
Dot Product Dot product of vector input
Gain Constant multiply of input
Generate Function Operation using internal function
Logical Operator NOT, AND, OR, NAND, NOR, XOR operation
Math Function Perform the specified operation
Matrix Gain Generate matrix product of the input signal
Min Block Generate minimum value of input values
Max Block Generate maximum value of input values
Product Generate product of the input signal
Relational Operator Relation operation (!=, <, <=, ==, >, >=)
Rounding Function Specified round function operation
Sign Generate sign of signal as 1 or -1
Sum +,- operation of input signal
Trigonometric Function Trigonometric function operation
3.4 SIMTool Continuous Block

Block name Function


Derivative Derivative input
Hit Crossing Find cross
Integrator Integrate input
Generate block input from previous integral
Memory
step
Reset Integrator Integrator that can choose signal integrated
State Space Generate state space
Generate the delayed input according to the
Transport Delay
set time
Transfer
Generate transfer function
Function
Variable Generate the delayed input signal according
Transport Delay to the change of the delay time
Zero-Pole Generate zero-pole model
3.5 SIMTool Discrete Block

Block name Function


Discrete Filter Implement the IIR and FIR filter
Discrete Time
Discrete time integrate of the input signal
Integrator
Discrete Latch Perform the D Latch operation

Discrete State Space Implement the discrete time state space

Discrete Transfer Implement the discrete time transfer


Function function

Discrete Zero-Pole Generate discrete time zero-pole model

Perform first order hold during sampling


First Order Hold
time
Unit Delay Delay during one sampling time
Perform zero order hold during sampling
Zero Order Hold
time
3.6 SIMTool Nonlinear Block

Block name Function

BackLash BackLash area setting


Coulomb & Viscous
Apply Coulomb & Viscous Friction to input
Friction
Dead Zone Dead zone area setting

Limiter Set upper and lower limit


Generate linear projection value of one
Look-up Table
input
Generate linear projection value of two
Look-up Table (2-D)
input
Generate the input signal selectively
Multiport Switch
according to the first input
Relay Relay area setting

Rate Limiter Set upper and lower limit of rate


Quantize signal according to the set
Quantizer
interval
Generate signal selectively according to
Switch
the threshold value
3.7 SIMTool Connection Block

Block name Function

Demux Separate the vector signal to scalar signal

Enable Select super block operation

From Switch block

Goto Receive signal sent from Goto block

Initial Condition Set initial condition of input signal

Inport Input port for the connection of super block

Add up several scalar signals to one vector


Mux
signal

Outport Output port for the connection of super block

Selector Generate selected input from two input

Trigger Select super block operation

Width Generate the number of vector of input signal


3.8 SIMTool Communication Block

Block name Function


Analogue Input Receive Analogue signal from RG-DSPIO board
Analogue Output Send Analogue signal to RG-DSPIO board
Digital Input Receive Digital signal from RG-DSPIO board
Digital Output Send Digital signal to RG-DSPIO board
C code Input Use the user written dll file to input processing application
C code function Use the user written dll file to I / O processing application
C code Output Use the user written dll file to output processing application
Encoder Receive encoder signal from RG-DSPIO board
Ethernet Input Block for communication with PC through Ethernet (input)
Ethernet Output Block for communication with PC through Ethernet (output)
Hareware Function Insert user defined C-code applicable to AUTOTool
Hardware Input port Insert input C-code to AUTOTool
Hardware Output port Insert output C-code to AUTOTool
Serial Input Receive signal from serial port
Serial Output Send signal to serial port
Connect internal input and external output in one-part
Simulation Input
simulation
Connect internal input and external output in one-part
Simulation Output
simulation
PWM Generate PWM signal
4. Connecting Blocks

<Import block>
Drag and drop from block
list tab to make block.

<Delete block>
After select a block, use
edit-delete menu, delete
key, or eraser button of
toolbar.
<Connecting blocks>
If the mouse point goes near the >
mark that is next to each block, the
mouse cursor changes the cross-
shaped
The state is ready to draw the line.
If we go to the block which is want
to connect, holding down the left
mouse button, then the dotted lines
are come to the desired direction.
If we release left button, the line is
disappear. Else if we take the line to
near the > mark of the block or
inside of the block, spots are marked
to the four corners of the block
connected. Under these conditions,
block is connected if the button is
released.
<connecting block from line>

If we move the mouse on the


line, holding down the right
mouse button, then the dotted
line comes on.
After this, we connect line to
other blocks at the same way.
Points to note when we save the file

Write within 8 characters.


Must begin with the character.
Special characters(+,- …) should not be included.

15
5. Simulation

 start time / stop time

 sampling time

 simulation method

 error tolerance

 time variable

 real time availability


5.1 View Time Base Results
5.1 View Time Base Results
6.1 Model Configuration
6.2 Set the Block Parameter
6.3 Setting the Simulation
6.4 Running
7. AUTOTool

 AUTOTool is user-friendly C-Code generator


which convert user-defined block file made by
SIMTool to universal C-Code.
7.1 AUTOTool Usage

[step 1] Implement algorithm using SIMTool


[step 2] AUTOTool interface setting
7.1 AUTOTool Usage

[step 3] Running time setting


7.1 AUTOTool Usage

[step 4] C code creation and download


7.1 AUTOTool Usage

[step 5] Excution
8. Discussion

1. Draw the graphs of sine input and its


corresponding output for the transfer
1
function G ( s ) = 2 using SIMTool,
s + 3s + 6
and observe the emergent changes.
(t=0~20, time interval=0.001sec)

2. Draw both input and output on the same


graph using CEMTool and out block.
Chapter 3

Input and output lab experiment through hardware


1. Experiment Objective

 Learn usage of I/O board and DSP board


(RG-DSPIO01).
 Learn Usage of Analogue input, Analogue output
block, Digital input, Digital output block, Encoder
block of SIMTool.
 Learn the principles of change of size of the output
signals depending on the parameter settings of the
Analogue output block, and confirm throughout the
experiment.
2. Hardware Composition

Division RG-DSPIO01
Analogue Input 8 ch (16 bit)
Analogue Output 4 ch (16 bit)
Digital Input 8 ch
Digital Output 8 ch
Interface PCI BUS
Input-output voltage Adjustable within -10~10V
Encoder Pulse
4 ch
Counter
<RS-DSPIO 01>
PWM 2 ch
<RS-DSPIO 01> Connector Pin connection

RGDSP 2.0

Analogue I/O
Port (37P) Digital I/O
Port (40P)

DSP
CPU
Pin arrangement of Analogue I/O Port of RG-DSPIO01

number symbol description number symbol description


Analog Output 4
1 AOUT0 AO ch0 20 AOUT1 AO ch1
2 AOUT2 AO ch2 21 AOUT3 AO ch3

Analog 3Input 8 AGND Analog GND 22 AIN0 AI ch0


4 AIN1 AI ch1 23 AIN2 AI ch2
5 AIN3 AI ch3 24 AIN4 AI ch4
6 AIN5 AI ch5 25 AIN6 AI ch6
7 AIN7 AI ch7 26 ENC0XB- Ch0 B-
# of Encoder is 4
8 ENC0XB+ Ch0 B+ 27 ENC0XA- Ch0 A-
9 ENC0XA+ Ch0 A+ 28 ENC0YB- Ch1 B-
10 ENC0YB+ Ch1 B+ 29 ENC0YA- Ch1 A-
11 ENC0YA+ Ch1 A+ 30 ENC1XB- Ch2 B-
12 ENC1XB+ Ch2 B+ 31 ENC1XA- Ch2 A-
13 ENC1XA+ Ch2 A+ 32 ENC1YB- Ch3 B-
14 ENC1YB+ Ch3 B+ 33 ENC1YA- Ch3 A-
15 ENC1YA+ Ch3 A+ 34 DGND Digital GND
16 PWM1 PWM ch1 35 PWM2 PWM ch2
17 DGND Digital GND 36 VCC +5V
18 AGND Analog GND 37 -15V -15V
19 +15V +15V
3. DSP Faculty of RG-DSPIO 01

 Real time and high-speed computation


experiment is available using DSP faculty
 Use DSP and I/O faculty together

Division RG-DSPIO01
Main Processor TMSC320C32
Processor
Operating frequency 60 MHz
ROM 128 Kbyte
Memory Normal SRAM 128 Kbyte (or 512 Kbyte)
Fast SRAM 256 Kbyte
Serial Controller Z85C30
communication Number of ports 1
Interface PCI BUS
4. I/O(Communication) Block Setting

Incoming
voltage to
input

-20
+20

Analogue Input & Analogue Output block


In this case, if input is -5V, return -20V,
if input is +5V, return +20V
4. I/O(Communication) Block Setting

Analogue Input block Analogue Output block


channel_num Channel number of I/O board(0-7) Channel number of I/O board(0-7)

Minimum input voltage to receive Minimum output voltage to supply


low_voltage
I/O board(within range set in ⑥) I/O board(within range set in ⑥)

Maximum input voltage to receive Maximum output voltage to supply


high_voltage
I/O board(within range set in ⑥) I/O board(within range set in ⑥)

Minimum mapping voltage sent Minimum mapping voltage sent


low_input
from I/O board to PC from PC to I/O board

Maximum mapping voltage sent Maximum mapping voltage sent


high_input
from I/O board to PC from PC to I/O board

voltage range Select the input voltage range set Select the output voltage range
select in I/O board set in I/O board
5. Principle of SCALING

 I/O resolution is 16bit


 Low voltage and High
voltage are parameters
which can set minimum
voltage and maximum
voltage that we wish to
use within the voltage
range of I/O board.
 Low input means physical
quantities of Low voltage,
High input means physical
quantities of High voltage.
6. Encoder Block

 Block for receiving signal from encoder through RG-


DSPIO 01 board

channel Channel number of I/O board(0-3)


resolution Encoder resolution setting(choose from 1,2,4)
7. Experiment

Cable

Measuring
PC with RG-01D Terminal
instrument
Port
(Multimeter or
Oscilloscope)
<Line connection method>
RG-DSPIO01
Inverted Signal type of board RG-
Signal type of high-speed
pendulum inverted pendulum DSPIO01
design experiment device
pin number system pin number
1 motor encoder A encoder A (ch0) 9
2 motor encoder A encoder (ch0)A 27
3 motor encoder B encoder B (ch0) 8
4 motor encoder B encoder (ch0)B 26
5 pendulum encoder A encoder A (ch1) 11
6 Pendulum encoder A encoder (ch1)A 29
7 pendulum encoder B encoder B (ch1) 10
8 pendulum encoder B encoder (ch1)B 28
9 encoder power(+5V) +5V 36
10 GND GND 18
motor drive signal
11 Analogue output 0 signal 1
(+)
Motor drive signal Analogue output 0
12 Connection of Analogue I/O Port of CRG-DSPIO01 board 3
(GND) ground
(0~3) Already connected through 0 channel among 4 Analog Output
<Terminal>
Device that provide convenient way to measure signal from pins can
be seen from I/O board
7. Experiment

<Problem> After implementing below signal using


SIMTool block, output through channel 0
using Analogue Output block Rectangular
pulse that has period 10 second, maximum
value 4.5V, minimum value 0.5V

Voltage
4.5 V

0.5 V
3 6 9 12 15 time(sec)
<Step 1> SIMTool block composition
<Step 2> Analogue Output block setting
<Step 3> Hardware setting / Running time setting
<Step 4> C-code generation / Transplant to DSP board
<Step 5> Running and graph check

<Step 6> Voltage check


<Example>
initial.BLK

initial.BLK should be executed before all experiments


to locate the cart in the middle of the pendulum.

Notice : When turn on the pendulum, it should be


started in Manual Mode. initial.BLK should be
executed before change to CEMTool Mode.
<Example>
initial.BLK

Analog output parameter

21
<Example>
initial.BLK

Observe the movement of cart of pendulum, by


changing value of constant block of Block Diagram of
SIMTOOL diversely.

22
8. Discussion

1. Generate square wave to output board and


check the output with oscilloscope.

2. Generate sine wave to output board and


check the output with oscilloscope.

3. Generate square and sine wave to output


board and check the output with analogue
input block.
Chapter 4

The Inverted Pendulum System


1. Experiment Objective

 Understand the system components of the inverted


pendulum system, and the usage of the H/W and S/W
related with the input/output signals from the hardware.

 Understand the basic tools to operate and communicate


with the inverted pendulum system.
2. Inverted Pendulum System

 Mechanical Elements
Index Spec.
Length [mm]
1300×200×250
(x×y×z)
Length of the Pendulum 400 [mm]
Weight of the Pendulum 0.2 [Kg]
Weight of the Cart 1 [Kg]
Distance Range -300 ~ 300 [mm]
Ball-Screw Pitch 12.7 [mm]

 Electrical Elements <Inverted Pendulum Sys.>


Index Spec.
Motor Output 24 [V] , 60 [W]
Maximum Angular Velocity
3800 [rpm]
of the Motor
Encoder Pulse (x4 Mode) 4000 [pulse]
Motor Input Voltage Range 0 ~ 5 [V]
2. Inverted Pendulum System

 Mechanical Components
 The ball screw transforms the commanded motor angular motion to the
linear motion of the moving pendulum.
 Two encoders are equipped at motor side and pendulum side to measure
the position and angle of the pendulum, respectively.

Encoder for Pendulum


Angle Sensing

DC Motor

Encoder for Ball Screw


Cart Pos. Sensing
2. Inverted Pendulum System

 Electrical Components
 By manipulating the electrical switches, you can handle the moving
pendulum in a desired way.
Index Functions

Lighted when the system is ready to


READY
operate
Lighted when the cart have reached
LIMIT
either left or right limit points
LED
Lighted when the system is being
INITIALIZE
initialized.
Lighted when the cart is controlled by
CEMTool
cemtool commands.

LEFT Move left when MODE=MANUAL

MOVE INITIALIZE Move the cart to the zero position

RIGHT Move left when MODE=MANUAL

MANUAL/ Switch the operation MODE between


MODE
CEMTool manual mode and cemtool mode
25P Connector
CEMTool
(connected with RG-IO DSP board)

POWER Power switch


2. Inverted Pendulum System

 Connector Pin Composition


 Pendulum uses two motor encoders for position & angle sensing, and one
analog output channel (ch. 0) for motor command (0 ~ 5V).
Pin No. Signals in the Inverted Pendulum System
1 Motor Encoder A
2 Motor Encoder
3 Motor Encoder B
4 Motor Encoder
5 Pendulum Angle Encoder A
6 Pendulum Angle Encoder
7 Pendulum Angle Encoder B
8 Pendulum Angle Encoder
9 Encoder Power (+5V)
10 GND
11 Motor Input (+)
12 Motor Input (GND)
2. Inverted Pendulum System

 Connection to RG-DSPI001

Signals in the Inverted RG-DSPIO01


Pin No. Signals in the RG-DSPI001
Pendulum System Pin No.
1 Motor Encoder A Encoder A (ch0) 9
2 Motor Encoder Encoder (ch0) 27
3 Motor Encoder B Encoder B (ch0) 8
4 Motor Encoder Encoder (ch0) 26
5 Pendulum Angle Encoder A Encoder A (ch1) 11
6 Pendulum Angle Encoder Encoder (ch1) 29
7 Pendulum Angle Encoder B Encoder B (ch1) 10
8 Pendulum Angle Encoder Encoder (ch1) 28
9 Encoder Power (+5V) +5V 36
10 GND GND 18
11 Motor Input (+) Analog Output 0 1
12 Motor Input (GND) Analog Output 0 GND 3
An Experiment for Cart Pos. Sensing

 Step 1. Block Composition

Ball screw pitch = 1.27 cm


 The cart moves 1.27 cm per revolution.

 If you set Encoder1 to X4 MODE, the encoder


generates 4000 (1000x4) pulses per revolution.
An Experiment for Cart Pos. Sensing

 Step 2. Block Parameter Settings


Motor is connected to Encoder A (ch0)

X4 MODE : 4000 pulses per revolution


-30~30cm (max. distance range)
An Experiment for Cart Pos. Sensing

 Step 3.
 Hardware Setting
 C-code Generating
 Implantation to the DSP Board
An Experiment for Cart Pos. Sensing

 Step 4. Experimental Results


 Move the cart at manual mode by using left and right
button
An Experiment for Pendulum Angle Sensing

 Step 1. Block Composition

1 Rev. = 2PI [rad]


 When Encoder is X4 MODE, it generates 4000
(1000x4) pulses per revolution.
An Experiment for Pendulum Angle Sensing

 Step 2. Block Parameter Settings

The angle is sensed by Encoder B (ch1)


An Experiment for Pendulum Angle Sensing

 Step 3.
 Hardware Setting
 C-code Generating
 Implantation to the DSP Board
An Experiment for Pendulum Angle Sensing

 Step 4. Experimental Results


Chapter 5

DC Motor Modeling in the Inverted Pendulum and


Its Step Response.
1. Experiment Objective

 Understand the meaning of transient response and


steady state response.

 Understand the modeling procedure of the DC motor in


inverted pendulum system as well as its mathematical
expression.

 Verify the mathematical model of the pendulum-free


system, constructed by yourself, by comparing the
simulation results with the experimental ones.
2. System Response: Step Response

R( s) Input
G (s) Output
Y (s)
<Open-Loop Response>

R( s) G (s) Y (s)
Input Output
<Closed-Loop Response>

 Now, we consider the (closed-loop) step response of the


following 2nd order system:

wn2
Y ( s ) G=
( s ) R ( s ), G ( s )
s 2 + 2ζ wn s + wn2
2. System Response: Step Response

 Overshoot:
the amount that the waveform overshoots the final value
−ζπ / 1−ζ 2
 M p = 1+ e
(M a x i m u m O u t p u t ) - (F i n a l O u t p u t )
 %Overshoot = ×100%
(F i n a l O u t p u t )
−ξπ / 1−ξ 2
( P.O = 100e ) Overshoot

 Settling Time:
the time to reach and stay
within 2% of the final value
ξωn Settling Time
 Ts =
4
2. System Response: Step Response

 Rise Time:
 the time duration from 10% to 90% of the final output.

Peak Time
 Peak Time:
the time required to reach
the maximum peak

π
 t peak =
ωn 1 − ξ 2 Rising Time
2. System Response: Step Response

 Under-damped (0 < ζ < 1)


 This has a fast response, but occurs (large) overshoot.

 Critically-damped (ζ = 1)
Under-damped
 No overshoot
 Faster response than
over-damped case.
 Critically-damped (ζ > 1)
 No overshoot Over-damped
 Slow response
Critically-damped

 Etc…
 ζ = 0: Marginally stable
 ζ < 0: Unstable
2. System Response: Step Response

 Constant Peak Time Tp


 Tp2 < Tp1

 Constant Settling Time Ts


 Ts2 < Ts1

 Constant %-Overshoot
 %OS1 < %OS 2
2. System Response: Step Response

 Step response variations for 2nd order under-damped system

Fixed Real Components

Fixed Imaginary Components

Fixed Damping Ratio


2. System Response: Ramp & Impulse Response

Ramp Input Impulse Input


3. Modeling of the Inverted Pendulum System: Pendulum-Free Case

 Parameters of the Inverted Pendulum System


 The modeling is based on the electrical & mechanical equations.
 For the modeling of the DC motor without the pendulum, the following
parameters are sufficient.
 Substantial tuning of the following parameters may be necessary in order
to compensate the parameter errors of the real pendulum system.

Symbol Meaning Value


M mass of the cart 1 [Kg]
b friction coefficient of the cart 0.5 [Kg/s]
r ball screw pitch 1.27 [cm]
Km motor torque constant 4.9 [Ncm/A]
Kb motor back emf constant 0.0507 [V/rad/s]
R motor resistence 0.3 [Ω]
3. Modeling of the Inverted Pendulum System: Pendulum-Free Case

 Motor_tf.cem
// The parameters regarding the DC motor in the pendulum system
 M= 1000*10^(-3); // Mass of cart
 m = 200*10^(-3); // Mass of pendulum  0.2
 l = 40; // 질량중심까지의 거리 (cm) 33.6046
 b = 0.2; // 마찰계수
 R = 0.5; // 모터 저항 (ohm)
 r = 1.27; // 1회전당 카트 이동 거리(cm)  1.25
 Km = 4.9; // 모터 토크 상수 (N*cm/A)
 Kb = 0.0507; // 모터 역기전력상수 (V/rad/s)
 g = 9.80665*10^2; // gravitation coefficient (cm/sec^2)
// Coefficients of the DC motor transfer function
 Fr = b + ((2*pi)/r)^2*Km*Kb/R;
 Fv = 2*pi*Km/(r*R);
// Coefficients of the DC motor transfer function
 num=Fv/M;
 den=[1 Fr/M 0];
3. Modeling of the Inverted Pendulum System: Pendulum-Free Case

 Motor Equations:
V= iR + K bθ Km
 =T (V − K bθ)
T = K mi R

 Mechanical Equations:


θ =

x θ = 2π x
 r  r
 
 2π T  2π  K m   2π K m 2π K b
 F =  =
F  (V − K bθ )= (V − x )
 r  r  R  rR r
 Mx= ∑ Fapplied= F − bx    2π 2 K m K b 
  Mx + b +  2π K m
   
x = V
   r  R  r R
Fr Fv

X (s) Fv
Mx + Fr x =
FvV =
V ( s ) Ms 2 + Fr s
4. A Simulation for Model Verification

 Step 1. Connect the step-input & output block

DC Motor
Transfer Function
A Simulation for Model Verification

 Step 2. Block Setting


4. A Simulation for Model Verification

 Step 3. Simulation Time Setting


4. A Simulation for Model Verification

 Step 4. Simulation and Results


CEM>>plot(t, sim_step)
4. A Simulation for Model Verification

 Step 5. Repeat the Simulation with Different Km & Kb


5. An Experiment for Model Verification

 Step 1. Turn off the Power & Detach the Pendulum

 Step 2. Experimental Block Connection


5. An Experiment for Model Verification

The voltage range of DSP is actually


 Step 3. Block Setting –10~10V, but the pendulum system
uses only 0 [V]~5 [V]. This is a matter
of implementation.

The DSP only uses


the voltage range
0 [V] ~ 5 [V].

A little
offset

-24~24V, See pend_io.cem in the next page.


5. An Experiment for Model Verification

 Pend_io.cem

// The parameters for setting the analog output block


// That block will be used when we execute sensing of the
// input/output signal from the inverted pendulum systems

 ch = 0; // channel number 0
 AO_LV = 0; // Low voltage
 AO_HV = 5; // High voltage
 AO_Lin = –24; // Low input
 AO_Hin = 24; // High input

// The parameters for zero-adjusting ,


//which will be used after non zero-adjusting pao.blk is executed.

 AOdout = 2.5; // Desired output voltage


 AOout = 2.5; // The voltage measured
 AOalpha = 0; // Initial zero-adjusting value
5. An Experiment for Model Verification

 Step 4. Hardware Configuration


5. An Experiment for Model Verification

 Step 5. Experimental Results & Comparison


6. Discussion

 Find your own DC motor model by correcting the


parameters Km and Kb according to the simulation and
experimental results. Draw the graphs before and after the
correction and compare them with experimental result.

 Discuss overshoot, rise time, peak time, settling time for


the above response graphs. Are they under-damped or
critically-damped? Write your opinion.
Chapter 6

Root Locus Techniques


1. Experiment objective

 Learn root locus theory.

 Draw root locus of the inverted


pendulum motor and obtain its
corresponding gain by using CEMTool.

 Apply the obtained gain to both


simulation and experiment and
compare these two results.
2. Root Locus Theory

 If the system has variable loop gain,


the closed-loop pole location varies
depending on the value of the loop
gain.

Therefore, it is important to designers


knowing how the closed-loop pole
varies in the s-plane depending on the
value of the loop gain.
Figure 6.1
a. CameraMan®
Presenter Camera System
automatically follows a subject
who wears infrared sensors on
their front and back (the front
sensor is also a microphone);
tracking commands and audio
are relayed to CameraMan via
a radio frequency link from a
unit worn by the subject.

b. block diagram.

c. closed-loop transfer function.


Table 6.1
Pole location as a function of gain for the system of Figure 6.1
Figure 6.2
a. Pole plot from Table 6.1
b. root locus
Root Locus – Basic Rule

1. Number of branches
The number of branches of root locus equals the
number of closed-loop poles

2. Symmetry
The root locus is symmetry about the real axis
Root Locus – Basic Rule

3. Real-axis segments
On the real axis, for K>0 the root locus exists to the left
of an odd number of real-axis, finite open-loop poles
and/or finite open-loops zeros.
Figure 6.3
Poles and zeros of a
general open-loop
system with test
points, P i , on the
real axis
Root Locus – Basic Rule

4. Starting and ending points


The root locus begins at the finite and infinite poles
of G(s)H(s) and ends at the finite and infinite zeros
of G(s)H(s)
Root Locus – Basic Rule

5. Behavior at infinity
The root locus approaches straight lines as asymptotes
as the locus approaches infinity. Further, the equations
of the asymptotes are given by the real-axis intercept a
nd angle in radians as follows:

σa = ∑ finite poles - ∑ finite zeros


# of finite poles - # of finite zeros
(2k + 1)π
θa =
# of finite poles - # of finite zeros
Ex 6.1

Sketch the root locus for the system shown in Figure 6.4

Figure 6.4
System for Example 6.1
Figure 6.5
Root locus and
asymptotes
for the system of
Figure 6.4
K ( s − 3)( s − 5)
KG ( s ) H ( s ) =
( s + 1)( s + 2)

Figure 6.6
Root locus example
showing real- axis
break-away (-σ1) and
break-in points (σ2)
3. Exercise

 CEM>>motor_tf; ☜ Load transfer function


 CEM>>rlocus(num, den); ☜ Root locus graph

Figure 6.7
Root locus of the
inverted pendulum
motor system.
3. Exercise

 Command used to obtain the value of gain K


of any point on the root locus graph
 CEM>>rlocval(num,den,s)

 s is the root of closed-loop on the drawn root


locus graph. In root locus graph, x represents
real value of root, y represents imaginary
value of root, and root is represented by
s=x+iy. x, y coordinate can be obtained as
follows: First, choose Trace function of
graph(In graph menu ‘Option-Graph
coordinate trace’). Second, click the left
mouse button and move in the graph.
3. Exercise

Figure 6.8 Trace function of graph

 The value of gain, when s=-2 can be obtained


by using the following CEMTool command.
 CEM>>s=-2
 CEM>>K=rlocval(num, den, s)
4. Area of Desired closed-loop pole

 If Overshoot(L) and Settling time(M) are given


Figure 6.9 Desired pole area

Desired pole position can be chosen within oblique line area, but
we usually determine rather inner area at the boundary to give a
little margin.
5. Simulation

Figure 6.10 Simulation block


5. Simulation

 When the root is -10.6739 + 4.3220i


 CEM>>motor_tf
 CEM>>s=-10.6739+4.3220i
 CEM>>K1=rlocval(num, den,s)

Figure 6.11
Step response of the
Inverted pendulum
motor system when
gain K1=2.2337
5. Simulation

 When the root is -10.6739 + 14.3220i


 CEM>>motor_tf
 CEM>>s=-10.6739+14.3220i
 CEM>>K1=rlocval(num, den,s)

Figure 6.12
Step response of the
Inverted pendulum
motor system when
gain K=5.3741
6. Effect of limiter

★ If a limiter is added, the step response of simulation


changes as real inverted pendulum system

Figure 6.13 Limited Simulation block


6. Effect of limiter

When the root is -10.6739 + 4.3220i (K1=2.2337)

<Unlimited Response> <Limited Response>


Figure 6.14 Step response of the inverted pendulum
motor system when gain K1=2.2337
6. Effect of limiter

When the root is -10.6739 + 14.3220i (K1=5.3741)

<Unlimited Response> <Limited Response>

Figure 6.15 Step response of the inverted pendulum


motor system when gain K1=5.3741
7. Experiment

Figure 6.16 Experiment block


7. Experiment-block setting

 Step block : let cart move 30cm after 1 second


like as simulation.

Figure 6.17
Block setting

 Encoder block : Channel 0,


Resolution Miltiplier x4

 Gain is 1.27/4000 Pulse to cm


 When the motor rotates 1 time, the cart moves 1.27cm
7. Experiment-result

When the root is -10.6739 + 4.3220i(K1=2.2337)

<Experiment> <Simulation, Experiment>

Figure 6.18 Step response of the Inverted pendulum


motor system when gain K1=2.2337
7. Experiment-result

When the root is -10.6739 + 4.3220i(K1=5.3741)

<Experiment> <Simulation, Experiment>

Figure 6.19 Step response of the Inverted pendulum


motor system when gain K1=5.3741
8. Discussion

1. Compare the response of the inverted


pendulum motor systems for the two
different roots (i.e two different gains).
Which one is faster?

2. Discuss about why these different result


appears.
(Hint. Consider the system response
corresponding to pole position)
Chapter 7

Lead Compensator Design


1. Experiment objective

 Learn lead compensator design


method based on root locus theory.

 Apply a designed lead compensator to


the inverted pendulum and observe
emergent changes.

 Control the position of inverted


pendulum motor by using lead
compensator.
2. System response

 Setting the gain of root locus is the first


step for obtain satisfactory
performance.

 Usually, the steady state response is


improved by increasing the gain, but as
a result, the stability may be worse.

 Compensator is a device which is added


to the system for the purpose of
satisfying specifications.

 Compensator compensates for


inadequate performance of the original
system.
3.1 Meaning of lead compensator

s+z
C (s) K , p > z
s+ p

Figure 7.1 Pole and zero of lead compensator


Function : Improve transient response
Characteristics :
1. Zero at –z and pole at –p are selected to put design point on root locus.
2. Pole at –p is more negative than zero at –z.
3. Active circuits are not required to implement.
3.2 Design of lead compensator

<Step 1> Through the given performance specifications,


display the desired pole position and area on
the s-plane.

<Step 2> Display the pole and zero of GH(s) on s-plane,


and draw root locus graph.
Here, check whether we can create a required
closed-loop poles by using only open-loop gain
control.
If it is impossible, follow the steps below.

<Step 3> Set the zero z of the lead compensator just below
the desired pole position.
3.2 Design of lead compensator

<Step 4> Obtain the pole p of the lead compensator,


by calculating the angle from desired pole
position.
(Sum of the angles of each poles and zero is -180)
That is, -180 = - angle of poles + angle of zero.

<Step 5> Obtain the gain K by calculating the distance


between desired pole and each poles and zeros.

<Step 6> Draw a root locus graph with the values designed
by using CEMTool and check the step response.
If the step response fails to satisfy the
performance standards, go back to step 3 and
re-design.
4. Before lead compensation

When the root is When the root is


-10.6739 + 4.3220i -10.6739 + 14.3220i
K1 = 2.2337 K2 = 5.3741

Figure 7.2 Step response of the uncompensated


inverted pendulum motor system
4. Before lead compensation

Figure 7.3 Step response of the Uncompensated


inverted pendulum motor system
★ Design a lead compensator for the inverted pendulum motor will
operate with 10% overshoot and a two fold reduction in settling time.
5. Design lead compensator of the inverted pendulum motor

<Step 1> Determine desired


dominant pole.

★ Dominant pole position of


uncompensated system
L=10 -> -10.6739±14.3220i

★ Dominant pole position of


Lead compensated system
Figure 7.4 2 * ( -10.6739±14.3220i )
Desired pole area = -21.3478±28.6440i
5. Design lead compensator of the inverted pendulum motor

<Step 2> Draw root locus of inverted pendulum motor

Root locus of the


uncompensated system
dose not passes through
the desired dominant pole
-21.3478±28.6440i

Figure 7.5 Root locus of the uncompensated


inverted pendulum motor system.
5. Design lead compensator of the inverted pendulum motor

<Step 3> Set the zero of lead compensator


(ex. z = -20)

<Step 4> Calculate the pole of lead compensator


(2k + 1)180 =−θ1 − θ 2 − θ p + θ z

<Step 5> Calculate the gain K of lead compensator


distance from poles l1 × l2 × l3
K =
distance from zeros l4
s+z
=C (s) K , p > z
s+ p
5. Design lead compensator of the inverted pendulum motor

<Step 6> Draw root locus of lead compensated system

Dominant pole
passes through
-21.3478±28.6440i

Figure 7.6 Root locus of the lead compensated


inverted pendulum motor system.
6. Simulation

Figure 7.7
Simulation block and step
response of the
lead compensated system
6. Simulation

<Uncompensated> <Lead compensated>

Figure 7.8
Step responses of the uncompensated
and lead compensated system.
6. Simulation

<Uncompensated, Lead compensated>


Figure 7.9
Comparison of the step response of two systems.
7. Effect of limiter

★ If a limiter is added, the step response of simulation


changes as real inverted pendulum system

Figure 7.10
Limited simulation block and its corresponding step
response of the lead compensated system.
7. Effect of limiter

<Unlimited Response> <Limited Response>


Figure 7.11
Step response of the lead compensated
inverted pendulum motor system.
8. Experiment

<Step 1> Turn off the inverted pendulum system and


separate the pendulum from the system

<Step 2> Construct a block

Figure 7.12
Experiment block
8. Experiment

<Step 3> Block setting

Figure 7.13
Block setting

<Step 4> Hardware setting and C-code generation

<Step 5> Turn on and initialize the inverted pendulum


8. Experiment

<Step 6> Experimental result

Figure 7.14 Step response of the lead compensated


inverted pendulum motor system (Real experiment).
8. Experiment

<Step 7> Compare with simulation result

Figure 7.15
Comparison of the results of
simulation and real experiment
9. Discussion

1. Design a lead compensator for the inverted


pendulum motor will operate with 10%
overshoot and a two fold reduction in
settling time. Describe the design
procedure.

2. Compare with the uncompensated inverted


pendulum motor system.

3. Compare the results of simulation and real


experiment.
Chapter 8

Lag Compensator Design


1. Experiment objective

 Learn lag compensator design method


based on root locus theory.

 Apply a designed lag compensator to


the inverted pendulum and observe
emergent changes.

 Control the position of inverted


pendulum motor by using lag
compensator.
2.1 Meaning of lag Compensator

s+z
C (s) K , p< z
s+ p

Figure 8.1 Pole and zero of lag compensator


Function : Improve steady-state error
Characteristics :
1. Error is improved but not driven to zero.
2. Pole at –p is small and negative.
3. Zero at –z is close to, and to the left of, the pole at –p.
4. Active circuits are not required to implement.
2.2 Design of lag Compensator

<Step 1> Calculate steady-state error of uncompensated


system
( ex1. e1 = 1/Kv1 )
( ex2. e1 = 1/(1+Kp) )

Kp : position constant
Kv : velocity constant
Ka : acceleration constant
2.2 Design of lag Compensator

<Step 2> Calculate the steady-state error of lag


compensated system and its corresponding error
constant.
( ex1. e2 = e1/2, Kv2 = 1/e2 )
( ex1. e2 = e1/2, Kp2 = 1/e2 – 1 )

<Step 3> Set the pole p of the lag compensator close to


the origin.
( ex. p = – 0.04 )

<Step 4> Calculate and set the pole p of the lag


compensator.
( ex1. z = Kv2/Kv1 * p )
( ex2. z = Kp2/Kp1 * p )
2.2 Design of lag Compensator

<Step 5> Draw a root locus graph with the values designed
by using CEMTool and determine desired pole
which satisfies the performance standards.

<Step 6> Obtain the gain K by calculating the distance


between desired pole and each poles and zeros.
distance from poles l1 × l2 × l3
=K =
distance from zeros l4

<Step 7> Finally, check the response.


If the response fails to satisfy the performance
standards, go back to step 1 and re-design.
3. Before lag compensation

<Step Response> <Ramp Response>

Figure 8.2 Step and ramp response of the


only lead compensated(before lag compensation)
inverted pendulum motor system.
3. Before Lag compensation

Figure 8.3 Ramp response of the


only lead compensated(before lag compensation)
inverted pendulum motor system.
★ Design a lag compensator which improves the steady-state
error of lead compensated inverted pendulum motor
by a factor of 2 for the ramp input
4. Design lag compensator of the inverted pendulum motor

<Step 1> Calculate steady-state error of uncompensated


system
( ex. Kv1 = 0.02304, e1 = 1/Kv1 = 43.4110 )

<Step 2> Calculate steady-state error of lag compensated


system and its corresponding error constant.
( ex. e2 = e1/2 = 21.7055, Kv2 = 1/e2 = 0.04608 )

<Step 3> Set the pole p of the lag compensator close to


the origin.
( ex. p = – 0.04 )

<Step 4> Calculate and set the zero z of the lag compensator.
( ex. z = Kv2/Kv1 * p
= 0.04608/0.02304 * – 0.04 = – 0.08 )
4. Design lag compensator of the inverted pendulum motor

<Step 5> Draw a root locus graph and determine desired pole

Dominant pole
passes through
-21.3478±28.6440i

Figure 8.4 Root locus of the lead compensated


inverted pendulum motor system.
4. Design lag compensator of the inverted pendulum motor

<Step 6> Calculate the gain K of lag compensator


distance from poles l1 × l2 × l3
K =
distance from zeros l4
<Step 7> Check the response

-> Satisfy the


performance standards

Figure 8.5 Ramp response of the lag-lead


compensated inverted pendulum motor system.
5. Simulation-ramp

Figure 8.6 Simulation block and its corresponding response


5. Simulation-ramp

<Only lead compensated> <Lag-lead compensated>


Figure 8.7
Ramp responses of the only lead compensated
and lag-lead compensated system.
-> Ramp response of the lag-lead compensated system is better than
that of the only lead compensated system.
5. Simulation-ramp

<Only lead compensated, Lag-lead compensated>


Figure 8.8
Comparison of the ramp response of two systems.

-> Ramp response of the lag-lead compensated system is better than


that of the only lead compensated system.
5. Simulation-step

Figure 8.9 Simulation block and its corresponding response


5. Simulation-step

<Only lead compensated> <Lag-lead compensated>


Figure 8.10
Step responses of the only lead compensated
and lag-lead compensated system.
-> Step response of the lag-lead compensated system is almost same
as that of the only lead compensated system.
5. Simulation-step

<Only lead compensated, Lag-lead compensated>


Figure 8.11
Comparison of the step response of two systems.
-> Step response of the lag-lead compensated system is almost same
as that of the only lead compensated system.
6. Effect of limiter-ramp

★ If a limiter is added, the step response of simulation


changes as real inverted pendulum system

Figure 8.12
Limited simulation block and its corresponding ramp
response of the lag-lead compensated system.
6. Effect of limiter-ramp

<Unlimited Response> <Limited Response>


Figure 8.13
Step response of the lag-lead compensated
inverted pendulum motor system.
6. Effect of limiter-step

★ If a limiter is added, the step response of simulation


changes as real inverted pendulum system

Figure 8.14
Limited simulation block and its corresponding step
response of the lag-lead compensated system.
6. Effect of limiter-step

<Unlimited Response> <Limited Response>


Figure 8.15
Step response of the lag-lead compensated
inverted pendulum motor system.
7. Experiment

<Step 1> Turn off the inverted pendulum system and


separate the pendulum from the system

<Step 2> Construct a block - ramp input

Figure 8.16
Experiment block – ramp input
7. Experiment

<Step 3> Construct a block – step input

Figure 8.17
Experiment block – step input
<Step 4> Block setting

<Step 5> Hardware setting and C-code generation

<Step 6> Turn on and initialize the inverted pendulum


7. Experiment

<Step 7> Experimental result

<Step Response> <Ramp Response>


Figure 8.18
Step and ramp response of the lag-lead compensated
inverted pendulum motor system (Real experiment).
7. Experiment

<Step 8> Compare with simulation result

<Step Response> <Ramp Response>


Figure 8.19
Comparison of the results of
simulation and real experiment
8. Discussion

1. Design a lag compensator which improves the


steady-state error of lead compensated
inverted pendulum motor by a factor of 2 for
ramp input. Describe the design procedure.

2. Compare with the only lead compensated


inverted pendulum motor system.

3. Compare the result of simulation and real


experiment.
Chapter 9

Frequency Response Analysis


1. Objectives

 Understand Bode plot to analyze the frequency


response.

 Understand the meaning of gain margin and phase


margin in frequency domain analysis.
2. Bode Plot?

 Bode plot means a graphical representation of the steady


state response of a system when the input is given as a sine
wave.

 In particular, when a sine wave is applied to an LTI system,


the output is also given as a sine wave with the same
frequency. In this case, the amplitude and phase of the
output are determined from those of the input sine wave,
as well as the system characteristics.

 Likewise, a Bode plot is a graph which represents in the


frequency domain the steady state amplitude and phase
variations between input and output of the LTI system
when the input is given as a sine wave.
2. Bode Plot? An Example
2. Bode Plot? An Example: 2nd Order System

 Substitute jw into s in the 2nd order system G(s):

wn2
G ( s ) s = jw =
( jw ) + 2ζ wn ( jw ) + wn2
2

 Represent it as the following rectangular form with real and


imaginary parts separated:

G (=
jw) R ( w) + jX ( w)
2. Bode Plot? An Example: 2nd Order System

 Now, we have the following phase form:

= =
G ( jw) | G ( jw) | e jφ | G ( jw) | ∠φ
X ( w)
where | G ( jw) |=R 2 ( jw) + X 2 ( jw), φ=
tan −1 [rad/sec]
R( w)

 Bode plot consists of two log-scale graphs:


an amplitude plot and a phase plot

 An amplitude plot represents 20 log | G ( jw) | versus w in [dB]


(decibel).

 A phase plot draws the phase angle in linear scale.


3. Analysis of Bode Plot: 2nd Order System

wn2
⇒ G ( jw) =
( jw) 2 + 2ζ wn jw + wn2

 Analysis of
1) Resonant Peak (Mr)
2) Resonant Frequency (wr)
3) Bandwidth (wb)
3. Analysis of Bode Plot: 2nd Order System

 Resonant Peak Mr
 The maximum value of the amplitude |G(jw)| of the transfer
function G(s).

 This Mr represents the relative stability of the closed-loop


system.

 The larger Mr is, the larger overshoot appears.

 Relationship between Mr and damping ratio ζ :

 1 1
 if 0<ζ ≤
 2ζ 1 − ζ 2 2
Mr = 
= M 1 if
1

 r 2
3. Analysis of Bode Plot: 2nd Order System

 Resonant Peak Mr
 When Mr lies in the range 1 < Mr < 1.4 (0 dB < Mr < 3 dB)
corresponding to 0.4 < ζ < 0.7, it yields a satisfactory
transient response.

 If ζ is larger than 1.5, a lot of overshoots arise which


deteriorate the performance of the system.
3. Analysis of Bode Plot: 2nd Order System

 Resonant Frequency wr
 The frequency at which the resonant peak (the maximum
value of |G(jw)|) is attained.

 Relationship between wr and damping ratio ζ :

wr wn 1 − 2ζ 2
=

 The larger wr is, the faster transient response is obtained.


3. Analysis of Bode Plot: 2nd Order System

 Bandwidth (wb)
 The frequency range from 0 [Hz] to the cutoff frequency
wb for which the 3dB-attenuation is exactly occurred.

 Bandwidth is related to the rise time of the closed-loop


system:
Bandwidth High freq. comp. System resp.
High Easily passed Faster
Low Rarely passed Slower

 Therefore, in frequency domain, it is reasonable to make


Mr small and wb large to yield small overshoot and fast
system response.
4. Drawing the Bode Plot for the DC Motor Dynamics

 CEM>>bode(G_num,G_den,w) // Drawing Bode Plot


4. Stability & Gain/Phase Margin

 Gain Margin
 The difference between 0 dB and the gain [dB] at the
frequency wg for which the phase becomes –180 [degree].
Gain Margin (Gm ) = 0[dB] − 20 log | G ( jwg ) | > 0

 If Gm > 0, the closed-loop system is stable, if Gm < 0, it is


unstable.

 Phase Margin
 The difference between the phase at the frequency wp
satisfying 20log|G(jwp)| = 0 [dB] and –180 [degree].
Phase Margin ( Pm ) = ∠G ( jwp ) − (−180) > 0

 the closed-loop system is stable if Pm > 0.


 Approximate relationship between Pm and ζ : Pm =100ζ
5. Finding Gain & Phase Margins of the DC Motor Dynamics

 Directly find the margins


 CEM>>[Gm,Pm,wg,wp]=margin(G_num,G_den)

 Find margins from Bode plot


 CEM>>w=logspace(-1,5); // freq. range setting
 CEM>>[mag,phase]=bode(G_num,G_den,w);
// calculation of Bode plot data(mag & phase)
 CEM>>[Gm,Pm,wg,wp]=margin(mag,phase,w);
// calculation of gain & phase margins
6. Discussion

 Draw the Bode plot for the given open-loop


system by using CEMTOOL commands, and discuss
the gain/phase margin and stability.
s +1
 G (s) = 2
s + 2s + 3

 Repeat the same procedure for your own DC


motor model.
Chapter 10

PID Compensator Design


1. Experiment objective

 Learn PID compensator design method


based on root locus theory.

 Apply a designed PID compensator to


the inverted pendulum and observe
emergent changes.

 Control the position of inverted


pendulum motor using PID
compensator.
2.1 Meaning of PID compensation

Figure 10.1 Closed loop control system.


de
u= K P e + K I ∫ edt + K D
dt
1
U ( s ) =( K P + K I + K D s ) E ( s )
s
U (s) 1 KD s2 + KP s + KI
=K P + K I + K D s =
E (s) s s
2.1 Meaning of PID compensation

C=
( s ) K ( s + z ) -> PD compensator
Function : Improve transient response
Characteristics :
1. Zero at –z is selected to put design point on root locus.
2. Active circuits are required to implement.
3. Can cause noise and saturation; implement with rate feedback or with
a pole (lead).

s+z
C (s) = K -> PI compensator
s
Function : Improve steady-state error
Characteristics :
1. Increases system type.
2. Error becomes zero.
3. Zero at –z is small and negative.
4. Active circuits are required to implement.
3.1 Characteristic of PID gain

Table 10.1 Characteristic of PID gain.

Response Steady
Settling
Rise time overshoot state
Gain time
error
Slightly
KD Decline Incline Decline
change
KP Decline Incline Incline Removal
Slightly Slightly
KI Decline Decline
change change

Adjust parameter value in order of P -> D -> I control.


3.2 Design of PD compensator

<Step 1> Through the given performance specifications,


display the desired pole position and area on
the s-plane.

<Step 2> Display the pole and zero of GH(s) on s-plane,


and draw root locus graph.
Here, check whether we can create a required
closed-loop poles by using only open-loop gain
control.
If it is impossible, follow the steps below.

<Step 3> Obtain the zero z of the PD compensator,


by calculating the angle from desired pole position.
(Sum of the angles of each poles and zero is -180)
That is, -180 = - angle of poles + angle of zero.
3.2 Design of PD compensator

<Step 4> Obtain the gain K1 by calculating the distance


between desired pole and each poles and zeros.
distance from poles l1 × l2
K1 =
distance from zeros l3
C=
( s ) K1( s + z )

<Step 5> Draw a root locus graph using the values designed
by using CEMTool and check the step response.
If the step response fails to satisfy the performance
standards, go back to step 3 and re-design.
3.3 Design of PID compensator

<Step 6> Set the pole p of the PID compensator equal to 0


and the zero z of the PID compensator close to origin.
( e.g. p = 0, z = – 0.05 )

<Step 7> Draw a root locus graph using the values designed
by using CEMTool, Obtain the gain K2
distance from poles l1 × l2 × l4
K2 =
distance from zeros l3 × l5
s+z
C (s) = K 2
s

<Step 8> Finally, check the response.


If the response fails to satisfy the performance
standards, go back to step 6 and re-design.
4. Before PID compensation

<Step response> <Ramp response>


Figure 10.2 Step and ramp response of the uncompensated
inverted pendulum motor system
★ Design a PID compensator for the inverted pendulum motor will
operate with 10% overshoot and a two fold reduction in peak time and
improves the steady-state error for ramp input
5.1 Design PD compensator of the inverted pendulum motor

<Step 1> Determine desired


dominant pole.

★ Dominant pole position of


uncompensated system
L=10 -> -10.6739±14.3220i

★ Dominant pole position of


PD compensated system
Figure 10.3 2 * ( -10.6739±14.3220i )
Desired pole area = -21.3478±28.6440i
5.1 Design PD compensator of the inverted pendulum motor

<Step 2> Draw root locus of inverted pendulum motor

Root locus of the


uncompensated system
dose not passes through
the desired dominant pole
-21.3478±28.6440i

Figure 10.4 Root locus of the uncompensated


inverted pendulum motor system.
5.1 Design PD compensator of the inverted pendulum motor

<Step 3> Obtain the zero of PD compensator


(2k + 1)180 =−θ1 − θ 2 + θ z

<Step 4> Calculate the gain K1 of PD compensator


distance from poles l1 × l2
K1 =
distance from zeros l3
C=
( s ) K1( s + z )
5.1 Design PD compensator of the inverted pendulum motor

<Step 5> Draw root locus of PD compensated system

-> Dominant pole passes through -21.3478±28.6440i

Figure 10.5 Root locus of the PD compensated


inverted pendulum motor system.
5.2 Simulation-step

Figure 10.6
Simulation block and step
response of the
PD compensated system
5.2 Simulation-step

<Before compensation> < PD compensated >


Figure 10.7
Step responses of the uncompensated
and PD compensated system.
5.2 Simulation-step

<Uncompensated, PD compensated>
Figure 10.8
Comparison of the step response of two systems.
5.2 Simulation-ramp

Figure 10.9
Simulation block and ramp
response of the PD compensated
system
5.2 Simulation-ramp

<Before compensation> <PD compensated>


Figure 10.10
Ramp responses of the uncompensated
and PD compensated system.
5.2 Simulation-ramp

<Uncompensated, PD compensated>
Figure 10.11
Comparison of the ramp response of two systems.
5.3 Effect of limiter-step

★ If a limiter is added, the step response of simulation


changes as real inverted pendulum system

Figure 10.12
Limited simulation block and its corresponding step
response of the PD compensated system.
5.3 Effect of limiter-step

<Unlimited Response> <Limited Response>

Figure 10.13
Step response of the PD compensated
inverted pendulum motor system.
5.3 Effect of limiter-ramp

★ If a limiter is added, the ramp response of simulation


changes as real inverted pendulum system

Figure 10.14
Limited simulation block and its corresponding ramp
response of the PD compensated system.
5.3 Effect of limiter-ramp

<Unlimited Response> <Limited Response>


Figure 10.15
Ramp responses of the uncompensated
and PD compensated system.
6.1 Design PID compensator of the inverted pendulum motor

<Step 6> Set the pole p of the PID compensator equal to 0


and the zero z of the PID compensator close to
origin.
(e.g. p = 0, z = – 0.05)

<Step 7> Calculate the gain K2 of PID compensator


distance from poles l1 × l2 × l4
=K2 =
distance from zeros l3 × l5
s+z
C (s) = K 2
s
6.1 Design PID compensator of the inverted pendulum motor

<Step 8> Check the response

<Step response> <Ramp response>


Figure 10.16 Step and ramp response of the
PID compensated inverted pendulum motor system.
6.2 Simulation-step

Figure 10.17
Simulation block and step
response of the
PID compensated system
6.2 Simulation-step

< PD compensated > < PID compensated >


Figure 10.18
Step responses of the PD compensated
and PID compensated system.
6.2 Simulation-step

< PD compensated, PID compensated>


Figure 10.19
Comparison of the step response of two systems.
6.2 Simulation-ramp

Figure 10.20
Simulation block and ramp
response of the PID compensated
system
6.2 Simulation-ramp

<PD compensated> <PID compensated>

Figure 10.21
Ramp responses of the PD compensated
and PID compensated system.
6.2 Simulation-ramp

< PD compensated, PID compensated>


Figure 10.22
Comparison of the ramp response of two systems.
6.3 Effect of limiter-step

★ If a limiter is added, the step response of simulation


changes as real inverted pendulum system

Figure 10.23
Limited simulation block and its corresponding step
response of the PID compensated system.
6.3 Effect of limiter-step

<Unlimited Response> <Limited Response>

Figure 10.24
Step response of the PID compensated
inverted pendulum motor system.
6.3 Effect of limiter-ramp

★ If a limiter is added, the ramp response of simulation


changes as real inverted pendulum system

Figure 10.25
Limited simulation block and its corresponding ramp
response of the PID compensated system.
6.3 Effect of limiter-ramp

<Unlimited Response> <Limited Response>

Figure 10.26
Ramp response of the PID compensated
inverted pendulum motor system.
7.1 Experiment-PD

<Step 1> Turn off the inverted pendulum system and


separate the pendulum from the system

<Step 2> Construct a block – step input

Figure 10.27
Experiment block – step input
7.1 Experiment-PD

<Step 3> Construct a block – ramp input

Figure 10.28
Experiment block – ramp input

<Step 4> Block setting

<Step 5> Hardware setting and C-code generation

<Step 6> Turn on and initialize the inverted pendulum


7.1 Experiment-PD

<Step 6> Experimental result

<Step Response> <Ramp Response>


Figure 10.29
Step and ramp response of the PD compensated
inverted pendulum motor system (Real experiment).
38
7.1 Experiment-PD

<Step 7> Compare with simulation result

<Step Response> <Ramp Response>


Figure 10.30
Comparison of the results of
simulation and real experiment
39
7.2 Experiment-PID

<Step 1> Turn off the inverted pendulum system and


separate the pendulum from the system

<Step 2> Construct a block-step

Figure 10.31
Experiment block – step input
7.2 Experiment-PID

<Step 3> Construct a block-ramp

Figure 10.32
Experiment block – ramp input

<Step 4> Block setting

<Step 5> Hardware setting and C-code generation

<Step 6> Turn on and initialize the inverted pendulum


7.2 Experiment-PID

<Step 6> Experimental result

<Step Response> <Ramp Response>


Figure 10.33
Step and ramp response of the PID compensated
inverted pendulum motor system (Real experiment).
7.2 Experiment-PID

<Step 7> Compare with simulation result

<Step Response> <Ramp Response>


Figure 10.34
Comparison of the results of
simulation and real experiment
8. Discussion

1. Design a PID compensator for the inverted


pendulum motor will operate with 10%
overshoot and a two fold reduction in peak
time and improves the steady-state error for
ramp input. Describe the design procedure.

2. Compare with the uncompensated inverted


pendulum motor system.

3. Compare the result of simulation and real


experiment.
Chapter 11

Modeling of the Inverted Pendulum System


1. Objectives

 Understand the kinematic & dynamic motion equations


of the inverted pendulum system.

 Build a mathematical model for the inverted pendulum


system as a state-space form when the pendulum is at
upright position.

 Analyze the state-space model of the pendulum: system


type, stability, and transfer function.
2. Modeling of the Inverted Pendulum System

 Two Mechanical Principles for Modeling


 Newton’s 2nd Law for Linear Motion
 If the body is rigid, then, the product of total mass and the linear acceleration of
the center of the mass equals to the total sum of the forces applied to the body.

  Fk −1
F2 M a
   
Ma = F1 + F2 + ... + Fk Center of the mass

F1 
Fk
 Newton’s 2nd Law for Rotational Motion
 If the body is rigid and the rotational axis is fixed, then, the product of total
inertia and the angular acceleration of the body with respect to the rotational
axis equals to the total sum of the products of each contributed force applied to
the body and the distance from the rotational axis to the reaction point.

F1' '
  '  '  ' I

I α =r1 × F1 + r2 × F2 + ... + rk × Fk r1 α Fk

Rotational Axis  Fk
 r2
F1 
Fk
2. Modeling of the Inverted Pendulum System

 Parameters of the Inverted Pendulum System

Symbol Meaning Value


M mass of the cart 1 [kg]
m mass of the pendulum 0.2 [kg]
l length of the pendulum 40 [cm]
b friction coefficient of the cart 0.5 [kg/s]
r ball screw pitch 1.27 [cm]
Km motor torque constant 4.9 [Ncm/A]
Kb motor back emf constant 0.0507 [V/rad/s]
R motor resistence 0.3 [Ω]
2. Modeling of the Inverted Pendulum System

 Nonlinear model of the pendulum system


 The center of the mass of the pendulum: (xg, yg)
x + l sin θ , yG =
xG = l cos θ (1)

 Apply Newton’s 2nd Law to the pendulum system:

∑ F : Mx + bx + mx =


G
F (2)

∑ M : mx l cos θ − my l sin θ =


G G mgl sin θ (3)
2. Modeling of the Inverted Pendulum System

 Linear model of the upright-positioned pendulum system


 Linearize (1)~(3) by assuming θ ≈ 0 (sin θ ≈ θ, cos θ ≈ 1):
xG ≈ x + lθ , yG ≈ l ⇒  x + lθ, 
xG ≈  yG ≈ 0 (4)

∑ F : Mx + bx + mx =


FG
(5)

∑ M : mx l − my lθ =
G G mglθ (6)
 From Chapter 5, we know that
2π K m 2π K b
=F (V − x ) (7)
rR r
 Substituting (4) and (7) into (5)~(6) yields

( M + m) x + mlθ + Fr x =
FvV (8)
mx + mlθ = mgθ (9)
2π 2 K m K b 2π K m
 where Fr = b + ( ) and Fv = .
r R r R
2. Modeling of the Inverted Pendulum System

 Linear model of the upright-positioned pendulum system


 If we denote= , x2 θ =
x1 θ = , u V , then, we obtain
, x4 x=
, x3 x =
the following state-space representation:

x = Ax + Bu

y = Cx
where x := [ x1 x2 x4 ]
T
x3

 0 1 0 0   0 
 ( M + m) g F   0 1 0 0   F   0 
 0 0 r   29.4200  − v   −1.2121
A : =
Ml 
, B : = Ml 
 0 0 0.3090 
Ml
=  
0 0 0 1   0 0 0 1  0   0 
       
 − mg
0 0 −
Fr   −196.1330 0 0 −12.3615  Fv   48.4844 
 M M   M 

1 0 0 0 
C :=  
0 0 1 0 
3. Discussion

 The system is SIMO (Single-Input-Multi-Output). The input


is voltage V, and the outputs are the cart position x and the
pendulum angle θ. Find the corresponding transfer func-
tions with your own parameters Kb and Km (you may use any
CEMTOOL commands).

X (s)
1) H1 ( s ) =
V ( s)
2) H 2 ( s ) =
θ (s)
V (s)

 Is the pendulum system is stable or not? Check the stability


and show the procedure to do.
Chapter 12

Design of A PID Controller


For An Inverted Pendulum
1. Objectives

 Design a PID controller.


 Control the position of the cart to zero, and the angle of
the pendulum to perpendicular.

 Verify the designed PID controller by experiments.

 Tune the PID parameters for better performance.


2. Design of A PID Controller

 In order to attain the objectives, the position and angle


information must be measured.

 In other words, the inverted pendulum system is SIMO


(Single Input Multi Output). The input is the voltage
applied to the pendulum device, and the outputs are the
position and angle.
2. Design of A PID Controller

 PID Control Scheme


 We use the combination of the two PID controllers, one
for position control, and the other for angle stabilization.

 By suitably adjusting the gains of each PID controller,


one can change the desired performance as well as the
stability of the closed-loop system.

x
− PID Controller
xref +
For Pos. Control
+
+ Motor Command

PID Controller For


θ ref +
− Angle Stabilization

θ
2. Design of A PID Controller

 Step 1
 Connect the PID controller to the inverted pendulum model.
2. Design of A PID Controller

 Step 2: PID Gain tuning


 Set the PID1 and PID2 block suitably for converging
the pendulum angle and cart position within 5 seconds.
2. Design of A PID Controller

 Step 3: Simulation Results


3. Experiments

 Step 1
 Turn on the pendulum device and initialize it.

 Step 2
 Make a SIMTOOL blocks for experiments:
3. Experiments

 Step 3: SIMTOOL block settings


3. Experiments

 Step 3: SIMTOOL block settings

Internal structure of the block ‘pulse to rad’


3. Experiments

 Step 4: Hardware set-up & C-code generation


3. Experiments

 Step 5

1. Change the device mode from manual to CEMTool mode.

2. Rotate the pendulum of the device within 5 seconds


through 180 degrees counterclockwise for upright position.

3. Grab lightly the pendulum of the device at that position.

4. After 5 seconds are passed, the designed PID controller


operates the pendulum system to hold that position.
3. Experiments

 Step 6: Experimental Results


3. Discussion

 Find the PID values which improves the performance of the


pendulum. Show the graphs and compare them with others.

1) By computer simulation

2) By experiment
Chapter 13

Design of A Controller
For Inverted Pendulums
Using State-Feedback & Observer
1. Objectives

 Disign a state-feedback controller to remain the position of


the cart zero, and the angle of the pendulum perpendicular.

 Design an observer to estimate the unmeasured state


variables

 Apply the controller to the inverted pendulum cart, and


observe the system response.
2. Preliminaries

 State-Space Equation for Inverted Pendulum


(at upright position)
 State Equation: x =
Ax + Bu , x(0) =
x0
State-variables: x = θ θ x x 
T

 0 1 0 0   0 
 ( M + m) g F   F 
 0 0 r  − v 
A =
Ml Ml 
, B  Ml 
0 0 0 1   0 
   
 − mg F r   v 
F
 0 0 −  M 
M M 
 Output Equation: y = Cx
Output-variables: y = [θ x ]
T

1 0 0 0 
C= 
 0 0 1 0 
2. Preliminaries

 State-Space Equation for Inverted Pendulum


(at upright position)
 State Equation: x =
Ax + Bu , x(0) =
x0
State-variables: x = θ θ x x 
T

 0 1 0 0   0 
 ( M + m) g F   F 
 0 0 r  − v 
A =
Ml Ml 
, B  Ml 
0 0 0 1   0 
   
 − mg F r   v 
F
 0 0 −  M 
M M 
 Output Equation: y = Cx Design a State-Feedback Controller
 Output-variables: y = [θ x ]
T Based on only this model.

1 0 0 0 
C= 
 0 0 1 0 
2. Preliminaries

 State-Space Equation for Inverted Pendulum


(at upright position)
 State Equation: x =
Ax + Bu , x(0) =
x0
State-variables: x = θ θ x x 
T

 0 1 0 0   0 
 ( M + m) g F   F 
 0 0 r  − v 
A =
Ml Ml 
, B  Ml 
0 0 0 1   0 
   
 − mg F r   v 
F Design an observer
 0 0 −  M 
M M  based on this whole model

 Output Equation: y = Cx
Output-variables: y = [θ x ]
T

1 0 0 0 
C=  Output equation only concerned
 0 0 1 0  with observer, not with controller.
3. State-Feedback

 State-Feedback Techniques
 Open loop state equation: x =
Ax + Bu , x(0) =
x0
u + x x y
B ∫ C
+
A

u = − Kx

 Closed-loop state equation: x =


( A − BK ) x, x(0) =
x0

+ u + x x y
r=0
B ∫ C
+ +
A

−K
3. State-Feedback

 Laplace Transform of the Closed Loop System


=
 Closed-Loop (CL) System: x ( A − BK ) x, x(0) =
x0
 Take Laplace transform with x(0) ≠ 0

sX ( s ) − x(0) =( A − BX ) X ( s )

( sI − ( A − BK ) ) X ( s) =
x0

adj ( sI − ( A − BK ) )
→ X ( s ) = ( sI − ( A − BK ) )
−1
x0 = x0
det ( sI − ( A − BK ) )
3. State-Feedback

 Laplace Transform of the Closed Loop System


=
 Closed-Loop (CL) System: x ( A − BK ) x, x(0) =
x0

1. Zeros of the CL system


adj ( sI − ( A − BK ) ) (This only contains 1, s, s2, … .)
→ X (s) = x0 2. Hard to calculate
det ( sI − ( A − BK ) )

1. Poles of the closed-loop system:


det ( sI − ( A − BK ) ) =
0 Determine K so that
(eigenvalues of A–BK)
the CL poles are located
2. Relatively easy to determine
at the desired positions
3. If all poles have negative real parts,
it is stable and x(t) goes to 0.
3. State-Feedback

 An Example

 Phase Variable Form


 0 1 0  0 
c3 s + c2 s + c1
2
=T (s) = ⇔ x  0 0 1 = x + 0  u , y [c3 c2 c1 ] x
s + a2 s + a1 s + a0
3 2
 −a0 −a1 −a2  1 

 This yields the simplest evaluation of the feedback gains


 0 1 0  0   0 1 0 
A − BK  0
= 0 1  + 0  [=
k1 k2 k3 ] 
 0 0 1 

 −a0 −a1 −a2  1   −(a0 + k1 ) −(a1 + k2 ) −(a2 + k3 ) 

 det(sI – (A – BK)) = s3 + ( a2 + k3 ) s2 + ( a1 + k2 ) s + ( a0+ k1 )

 Desired C.E.: s3 + d2 s2 + d1 s + d0 = 0  ki = di-1 – ai-1


3. State-Feedback: Controllability

 Definition of Controllability
 The system is said to be controllable if an input to a system
can be found that takes every state variable from a desired
initial state to a desired final state.

 The Controllability Matrix


 nth order LTI system x =Ax + Bu , x(0) =x0 is controllable
if the matrix CM = [ B AB A2B … An–1 B ] is of rank n.

 If the system is not controllable, one cannot locate the CL poles


at the desired location.
4. Linear Observer

 The Needs for Observer


 An observer , sometimes called an estim ator , is used to
calculate state variables that are not accessible from the
plant.

 Definition
 A dynam ic system whose state variables are the estimates
of the state variables of another system is called an
observer of the latter system. (D. Luenberger in 1963)

 Objective
 Estimate the state variables of the LTI system
 State equation: x =
Ax + Bu , x(0) =
x0
 Output equation: y = Cx
4. Linear Observer

 Open-Loop Observer
 xˆˆˆ=
Ax + Bu , x(0) =
x0
 Same dynamic model 
 y = Cx

ex :=x − xˆˆ ex ==


Aex , ex (0) x0 − x0
 Error dynamics:  ⇒ 
ey :=
y − yˆˆ ey :==
Cey , ex (0) y0 − y0

 Problem:

One cannot change the poles of


the error dynamics, that is,
convergence speed of the error
is not accessible.
4. Linear Observer

 Closed-Loop Observer
 xˆˆˆ= Ax + Bu + L( y − yˆ ), x(0) = x0
 Same dynamic model 
 y = Cx
 The output error ey multiplied by L is fed back to the derivatives of the
observer`s state.
e :=
Error dynamics:  x
x − xˆˆ ex =
( A − LC )ex , ex (0) =
x0 − x0
 ⇒ 
ey :=
y − yˆ ey =
Cex
 By appropriately selecting L, closed-loop poles of the error
dynamics can be located at the desired positions.
4. Linear Observer

 An Example
 Observer Canonical Form
 −a2 1 0 b2 
b2 s 2 + b1 s + b0  −a
T (s) = ⇔ x =
 1 0 1  x +  b1  u , y =
[1 0 0] x
s 3 + a2 s 2 + a1 s + a0
 −a0 0 0  b0 

 This yields the simplest evaluation of the observer gains

 − a2 1 0   l1   −(a2 + l1 ) 1 0 
 A − LC = −a1 0 1  − l2  [1 0 0] = −(a1 + l2 ) 0 1 
 −a0 0 0   l3   −(a0 + l3 ) 0 0 
 det(sI – (A – LC)) = s3 + ( a2 + l1 ) s2 + ( a1 + l2 ) s + ( a0+ l3 )

 Desired C.E.: s3 + d2 s2 + d1 s + d0 = 0  li = d3-i – a3-i


4. Linear Observer: Observerbility

 Definition of Observability
 The system is said to be observable if the initial-state
vector, say x(t0), can be found from u(t) and y(t), measured
over a finite interval of time from t0.

 The Observability Matrix


 nth order LTI system x =
Ax + Bu , y =
Cx is observable
 C 
 CA 
if the matrix OM =   is of rank n.
  
 n −1 
CA 

 If the system is not observable, one cannot locate the CL poles


of the error dynamics at the desired location.
4. Observer-Based State-Feedback

 Separation Principle
 State-feedback and observer design can be carried out
separately: If both a controller and an observer are stable,
the combined control system is also stable.

 If one designs a controller u = – K x and obtains x̂ from


observer, then, u = − Kxˆ can be used instead of u = – K x.

u + x x y
r=0
+
− B ∫ C
+
A
PLANT
 x̂ +
B ++ x̂ ∫ C −

+ A

L OBSERVER
K x̂
5. Simulation

 State-Feedback Controller Design with Observer


 The Dynamic Model of the Inverted Pendulum

=x Ax + Bu

= y Cx + Du

 0 1 0 0   0 
 ( M + m) g Fr   F 
 0 0 − v 
1 0 0 0  0 
B = 
Ml 
A = 
Ml Ml 
C=  D= 
0 0 0 1  0  0 0 1 0 0 
   
 − mg F   Fv 
 0 0 − r  M 
M M
5. Simulation

 Step 1: Observability
 Execute the command lines below to check the
observability:
 CEM>>pend_ss //Load the matrices about inverted pendulum system
 CEM>>rank(obsv(A,C))

 If the output equals to ‘4’, then, the system is observable.

 Step 2: Controllability
 Execute the command lines below to check the
controllability:
 CEM>>pend_ss //Load the matrices about inverted pendulum system
 CEM>>rank(obsv(A,B))

 If the output equals to ‘4’, then, the system is controllable.


5. Simulation

 Step 3: Observer Design


 Select the desired observer poles
 To meet the requirements, calculate the observer gain
matrix L:
 CEM>> poles=[-67 -68 -69 -70]; // Poles of the observer
 CEM>> L = place(A',C',poles); // Calculate LT
 CEM>> L = L'; // Calculate L
 CEM>>Ao=(A-L*C); // Closed-loop System matrix
 CEM>>Bo= [B Ke]; // The observer is MIMO system
 CEM>>Co=eye(4); // Observer output = state estimates
 CEM>>Do=zeros(4,3); // Observer output = state estimates

 u 
= Ax + Bu + L( y − y ) = ( A − LC ) x + [ B L ]  
 xˆˆˆˆ
 =: Ao =: Bo  y 
 yˆˆ= Cx

5. Simulation

 Step 4: Design of a State-Feedback Controller


 Select two dominant poles which mostly affect to the
system performance.
 Select the other poles appropriately such a way that
i) they do not significantly affect to the performance;
ii) they are not repeated.

System poles: ( s 2 + 2ζ wn s + wn2 )( s + p1 )( s + p2 )

 CEM>>wn=4; // Natural freq.


 CEM>>zeta=0.7; // Damping ratio
 CEM>>cheq=[1 2*zeta*wn wn^2]; // 2nd-order characteristic eq.
 CEM>>chrt=roots(cheq); // Roots of the equation
 CEM>>P=[chrt(1) chrt(2) -5 -5.1]; // Determine the desired poles.
 CEM>>K=place(A,B,P); // Find K which locates the closed-loop poles
// to the above desired poles
5. Simulation

 Step 5: Make a Block Diagram for Simulation:

Controller K:
Matrix Gain Block

Observer Dynamics
5. Simulation

 Step 6: Block Settings

observer block setting pendulum block setting

Controller: set the gain matrix to K


5. Simulation

 Step 7: Simulation Results

As can be seen, the cart position and the pendulum angle


converge to the desired locations.
5. Experiment

 Step 1: Turn on and Initialize the Pendulum System.


 Step 2: Make a Block Diagram for a Real Experiment:
5. Experiment

 Step 3: Block Settings


5. Experiment

 Step 4: Hardware Setting and C-Code Generation:


5. Experiment

 Step 5: Experimental Results


6. Discussion

 Design the controller & observer to meet “settling


time < 2 [s]”. Repeat the procedure to yield much
less settling time. Compare & discuss the results.
(Hint: you can design such a controller by regulating the natural freq.
and damping ratio of the controller poles.)

1) For simulation

2) For experiment

S-ar putea să vă placă și