36
1 © 2015 The MathWorks, Inc.

© 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

1© 2015 The MathWorks, Inc.

Page 2: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

2© 2015 The MathWorks, Inc.

Simulink를이용한다양한제어시스템설계방법

김종헌차장

Senior Application Engineer

MathWorks Korea

Page 3: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

3

Challenge:

Manual tuning of control systems is time-consuming and often

suboptimal.

Not easy to make a simulation model for control design.

Solution:

Various control design features provided in MATLAB® & Simulink®

enable fast, easy, and rigorous tuning

Page 4: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

4

Agenda

Control Design using Robot Arm example

– Data-Driven Modeling (System Identification)

– Automatic PID Tuning (PID Tuner)

– Response Optimization

– Control System Tuner

– Online Parameter Estimation

Extras using Inverted Pendulum

– LQG & LQR Controller Design

– Gain Scheduling Controller Design

Page 5: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

5

Robot Arm Example

Six joints

– DC motor at each joint

– PID controller for each motor

Page 6: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

6

Robot Arm Modeling

SolidWorks Model

SimMechanics Model

SimMechanics model of the robot arm can be

generated directly from a CAD tool…

Page 7: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

7

DC Motor Modeling

To make more accurate simulation model, the effect of

actuator dynamics should be considered.

Page 8: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

8

Modeling Approach for well-known ActuatorFirst Principle Approach

First Principles Equations

Physical Components Libraries

Advanced Components Libraries

Take advantage of the flexibility provided by Simscape and the advanced physical component libraries in Simulink to create models for all kinds of actuators and sensors

http://www.matlabexpo.com/kr/2014/proceedings/confirmation.html

Page 9: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

9

Modeling Approach for unknown ActuatorData-Driven Approach : System Identification

System

Voltage Angle or

Angular Velocity

Input Output

Page 10: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

10

Modeling Approach for unknown ActuatorData-Driven Approach : System Identification

Voltage Angle or

Angular Velocity

Input Outputu y

u, y: measured time or

frequency domain signals

Model

x(t+1) = Fx(t) + Gu(t)

y = Hx(t)

Page 11: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

11

The System and the Model

System

Model

+

-Minimize

errorMeasured input

Page 12: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

12

Adding a controller

reference+

-

controller

Modeling both, plant and controller in a single environment

allows us to better understand and optimize the

performance of the entire system

S1 S2

S3

Page 13: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

13

We can use very powerful linear control techniq

ues to design our controller…

reference+

-

controller

S1 S2

S3

Use Simulink Control Design and the Control System Toolbox to linearize the plant and design the controller against requirements in the time and frequency domain

Page 14: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

14

Or we can fine tune our controller gains by opti

mizing the system response…

reference+

-

controller

S1 S2

S3

Use Simulink Design Optimization to set graphical constraints on relevant signals and optimize the controller gains against the nonlinear system response

Page 15: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

15

Automatic PID TuningPID Tuner

Use Simulink Control Design and the Control System Toolbox to linearize the plant and design the controller against requirements in the time and frequency domain

reference+

-

controller

S1 S2

S3

Page 16: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

16

Let’s apply PID Tuner to Robot Arm….

Six joints

– DC motor at each joint

– PID controller for each motor

Page 17: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

17

Quick and simple workflow for tuning single PID:

Tuning Individual PID Loops

Page 18: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

18

Tuning Multiple Loops

Standard approach: Tune each loop individually, then

iterate until overall response is satisfactory.

Challenges:

Loop interactions complicate tuning

Robustness is harder to analyze

May not yield best overall design

Time consuming

Requires expertise

Page 19: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

19

Solution for Systems with Complex Architecture

Multi-Input Multi-OutputMultiple Loop

Control System Tuner

Control System Tuner

Page 20: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

20

Solution for Systems with Complex ArchitectureControl System Tuner

Multi-Input Multi-OutputMultiple Loop

Control System Tuner

Effective, flexible, and easy to use!

– Tuning for multiple plant models or operating conditions

– Soft vs. hard requirements

– Band-limited requirements

– Custom parameterization of tuned blocks

Page 21: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

21

Tune against rich collection of requirements

Robustness

Performance

Time Response

Loop Shaping

Page 22: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

22

Tune against rich collection of requirements

Gain Constraints

Disturbance Rejection

Limiting gain to reduce loop interaction (𝑆 = 𝐼 − 𝑇)

Reduce

cross-coupling

Reduce

peak sensitivity

Push gain down at

low frequency

Disturbance rejection as a gain constraint

Page 23: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

23

Tune against rich collection of requirements

Stability Margins

Linear Quadratic Cost

𝐽 = lim𝑇→∞

𝐸1

𝑇 0

𝑇

(𝑥𝑇𝑄𝑥 + 𝑢𝑇𝑅𝑢) 𝑑𝑡

Page 24: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

24

And we need to consider how to detect fault

when motor is broken.

Use Online Parameter Estimation

– to identify changes in system dynamics as they happen

– to adapt to operating conditions unknown at design time

Other Applications: Adaptive Control

Page 25: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

25

Online Parameter Estimation Capabilities

Current Features in System Identification Toolbox

– For Linear System

ARX, ARMAX (2014a)

AR, ARMA, OE, BJ (R2014b)

– For Non-linear System

Models linear in estimated parameters,

can be nonlinear in regressors(R2014a)

Page 26: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

26

Easy Deployment: Code Generation

All blocks support C, C++ code, PLC structured text

generation

Demos

– DC motor fault detection algorithm running on Arduino

Page 27: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

27

Further investigation…..

How about

– LQG/LQR controller?

– Gain scheduling controller?

Demos

– Balancing a pendulum on a cart

while tracking the cart position

– Input

Force on the cart

– Outputs

Angular velocity of the pendulum ( 𝜃),

Velocity of the cart ( 𝑥)

Page 28: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

28

LQR Controller Design

Can get optimal K using the linearized plant model

and lqr function.

Page 29: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

29

LQR Controller Design

Can get optimal K using the linearized plant model

and lqr function.

1. Set operating point

2. Set parameters to

make quadratic cost

function

3. Calculate K to

minimize quadratic cost

Page 30: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

30

State Observer

Measurement Noise

For control system having incomplete state information,

easy-to use kalman function enable to design optimal

LQG controller.

LQG Controller Design

Page 31: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

31

For control system having incomplete state information,

easy-to use kalman function enable to design optimal

LQG controller.

LQG Controller Design 1. Set operating point

3. Set parameters to

make quadratic cost

function

4. Calculate K to

minimize quadratic cost

2. Caculate Kalman gain

to estimate

Page 32: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

32

Gain Scheduling Controller Design

Use Parallel Computing to speed up calculation to get K

matrices at multiple operating points.

Page 33: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

33

Gain Scheduling Controller Design

For control system having incomplete state information,

easy-to design Kalman function enable to design

optimal LQG controller.

1. Set operating point

2. Set parameters to make

quadratic cost function

3. Calculate K to minimize

quadratic cost

Page 34: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

34

Gain Scheduling Controller Tuning Using

Parallel Computing

Steps to compare simulation methods

1. Open pool of MATLAB sessions

2. Generate parameter sets

3. Run simulations serially

4. Run simulations in parallel

Parameter Set 1

Parameter Set 2

Parameter Set 8

>> matlabpool(2)

Angle_operating_points = linspace(0,7*pi/16,num_ctrls);

for i = 1:length(angle_range)

~~~~~~;

end

parfor i = 1:length(angle_range)

~~~~~~;

end

Multi

Core

Page 35: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

35

Summary

Quick and simple workflows for tuning control systems in

MATLAB & Simulink:

PID Tuner for PID loops

Control System Tuner for everything else

MATLAB functions from Control System Toolbox and

Robust Control Toolbox

Benefits:

Avoids time-consuming hand tuning

Takes guesswork out of tuning

Uses rigorous, state-of-the-art methodology

Provides solid initial designs for further nonlinear optimization

Page 36: © 2015 The MathWorks, Inc. · 35 Summary Quick and simple workflows for tuning control systems in MATLAB & Simulink: PID Tuner for PID loops Control System Tuner for everything else

36

Thank You…