optimization for system identification and controller designstarr/teaching/me581/adc-sysid.pdf ·...

28
Applied Digital Control: Optimization for System Identification and Controller Design David G. Wilson Mechanical Engineering University of New Mexico 1. [email protected] 2. [email protected] 2/27/2006

Upload: docong

Post on 06-Feb-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Applied Digital Control:Optimization for SystemIdentification and Controller Design

David G. WilsonMechanical EngineeringUniversity of New Mexico1. [email protected]. [email protected]

2/27/2006

Page 2: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Lecture Outline

IntroductionOptimization: MATLAB ToolboxSystem IdentificationControl DesignConclusionsProblems

Page 3: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Introduction:Continuous Controller

-

+ y(t)D(s) Mechanical System

(Plant)

r(t) u(t)

Continuous controller

• Continuous controller can be built using analog electronics• A digital controller can take the place of continuous controller• The mechanical system or “plant” considered analog or continuous

(REF: CMU)

Page 4: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Introduction:Digital Controller

-+

y(t)G(z)DifferenceEquation

H(s)Plant

r(t) u(k)

Digital controller

• Digital controller operates on discrete signals (or samples) rather than continuous signals

• Implementation: Normally as discrete functions either in transfer function or state-space forms (difference equations)

D/A andHold

A/D

A/D

clock

r(k) e(k) u(t)

y(k)

(REF: CMU)

Page 5: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Introduction:Servo Control System Components

-

+ θControllerand

Amplifier

Motorand

Load

v

Motor, amplifier, and sensing:

• Example: general closed-loop control system

Sensing Device(Encoder,Tachometer)

i m

(REF: Electro-Craft)

Page 6: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Introduction:DC Motor Model

From input voltage to motor angle:

The electrical time constant L/R considered negligible:

Motor Datasheet:ResistanceInductanceTorque constantBack EMF constant

Simplifications:Direct drive (N=1)No Gear Backlash(hysteresis, deadzone)

ime

Ltmfmmm

vKRidtdiL

iKTBJ

=++

−=++

θ

τθθθ

&

&&&& )sgn(

Litmfmetmm

mei

RvKTRKKBJ

RKvi

τθθθ

θ

−=+++

−=

/)sgn()/(

/)(&&&&

&

(REF: Wen)

Page 7: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Introduction:Amplifier Interaction

Controller outputs +/- 10 Volts.Employ current amplifier to convert voltage to currentCurrent energizes motor to produce torque at shaftAmplifier Options:

Linear: output current proportional to input voltagePWM: output current switched between max/min voltages at high frequency (20-50Khz) with duty cycle proportional to input voltage (such as 50%)

(REF: Wen)

Page 8: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Introduction:Simple PWM Amplifier Model

Modeling of the amplifier:

When PWM frequency is much larger than the system frequency of interest then applied voltage can be reduced to average value established for one PWM cycleResult: PWM and power stage considered as perfect voltage source as long as smaller than maximum available DC voltage

RequiredVoltage

KReferenceVoltage

AppliedVoltage

Voltage supply

a

Linearizedvoltage supply(constant gain)

Applied voltage saturation

If required voltage realizable then will be fully applied otherwise limited to maximum available

Current controlled voltage source … internal portion of PWM amplifier voltage characteristics:

(REF: Friedrich)

Page 9: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Introduction:Amp Current Feedback Loop

Previously without current feedback it was noted:

With current feedback the input “effectively”becomes then

“Effectively:” is subject to saturation due to max amp current, max supplied voltage, and back EMF

Litmfmetmm RvKTRKKBJ τθθθ −=+++ /)sgn()/( &&&&

ADaVKi /=

LADatmfmmm VKKTBJ τθθθ −=++ /)sgn( &&&&

ADaVKi /=

(REF: Wen)

Page 10: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Introduction:Sensor Model - EncodersRotational encoder generates counts from the up/down edges of A/B channels.Quadrature decoding gives an effective multiplier of 4For a 1000 line encoder the resolution will give 2pi/(1000*4) or

Ideally, encoder can be modeled as a gain with a fixed integer resolution of 1 count = 1.57 mrad = 0.09 degOther types of sensors (tachometers, potentiometers) may have additional dynamics, such as low pass 1st or 2nd order filters used to minimize noise, etc.

countcountmradKenc

deg09.057.1 ==

(REF: Wen)

Page 11: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Introduction:Digital Quantization Effects

Quantization: analog signal with D/A and A/D conversions are defined in terms of finite word lengthFor 12-bit word that represents +/- 10 V the resolution becomes 20/212 =2.44 mv. Effects control output and measured input signalsEncoder quantization can effect velocity estimation through finite differencingTherefore a detailed simulation model would need to take into consideration

(REF: Wen)

Page 12: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Introduction:PID Digital Controller

Continuous PID Controller:Derivative action:

Integral action: to preserve both regions of stability and instability when mapping from s to z employ the “bilinear transformation”:Resulting z-transform model of PID controller:

sKsKKsEsC DIP ++= /)(/)(

)1()1(

2)()(

)'',,(2)(1)(

−+

=

=⇒==

zzT

zEzC

tustinTsysdczCs

syssC

I

II

⇒−−

=T

TkekTekTcD])1[()()(

If sampling is fast enough, even w/o bilinear, no problems should occur. However, when under-sampled the results are instability and inaccuracy.

TzzK

zzTKK

zEzC

DIP)1(

)1(2)1(

)()( −

+−+

+=

Tzz

zEzCD 1)()( −=

(REF: Background Mat’l)

Page 13: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Introduction:Position Servo with PID Control

-

+

r(t)

u(k)

More complete model for a position servo with PID control:

D/A andHold

A/D

clock

r(k)

e(k)

y(k)

Kp

enc

BssJK

T

t

+2

zz

TKD

)1(1 −

)1()1(

2 −+

zzTKI 1+a

a

sKτ

K

ADV /

)()( tty mθ=

PID

Current AmplifierDC Motorplus load

Digital controller

-

)()( sTsT df +

+

Page 14: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Introduction:Other Potential Problems

What if encoder generates spurious signal creating a large errorterm which in term generates a large correction term? What happens if the correction term is larger than the maximum D/A output? Saturation nonlinearity term coded before the D/A converter for prevention – needs further investigation.What about integrator anti-reset windup? Reset windup or integrator saturation can occur if output saturates and the controller continues to integrate the error. Problem automatically avoidedwhen velocity form of algorithm is used, then integration stops automatically when the output is limited. If using the position form then one way to stop updating the integrator when the output is limited is to use conditional integration, where the integral part of the controller is used only when the error is sufficiently small.Additional logic and coding implementation needs to be considered.

Control engineer needs to be aware during the design of such things as:

(REF: Background Mat’l, Klafter)

Page 15: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Introduction:Case Study Project Steps

Mechanical system with embedded controller prototype (hardware)Model development (physics/mechatronics)Plant model system identificationDigital control system designExperimental/predicted correlation and performance results

Optimization applies where? What level of detail is sufficient?

What if asked to design a digital controller for a mechanical system?

Page 16: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Introduction:Plant Model SYS-ID -1

1. Formal control design methods invariably rely on a plant model. The plant model can be derived from first principles but often contains unknown parameters. Experiments must be conducted to gather information on the behavior of the plant dynamics to help estimate these parameters. … Typically, values for physical parameters such as moments of inertia, masses, rod lengths, and gear ratios are well known and can be incorporated into the model. Parameters such as friction coefficients, viscosity, and stiction behavior, however, are not precisely known. Measured data from the rapid prototyping system can be used with the first-principle description to calibrate these parameters using SimulinkParameter Estimation (SPE)… SPE allows the selection of a set of parameters and states to be estimated. Min/max values of the parameters and initial states can be set, in addition to the expected values. SPE uses optimization algorithms from the Optimization Toolbox and, optionally, the Genetic Algorithm and Direct Search Toolbox.

The Matherworks camp: Excerpts from “Embedded Real-Time Control via MATLAB, Simulink, and xPC Target,” by P.J. Mosterman, et.al.:

Page 17: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Introduction:Plant Model SYS-ID -2

2. Linear system identification tools are useful if the dynamics of a system behave in a near-linear manner about a given operating condition, but cannot be modeled from first principles. The System Identification Toolbox computes linear discrete and continuous models using both time and frequency domain data.

3. Transfer function estimation is another process that takes experimental data and converts it using spectral estimation techniques to compute the frequency response of a system. The Signal Processing Toolbox has many functions to support the estimation of a transfer function.

4. If linear models do not describe the model accurately and the underlying equations of motion are not well known, a nonlinear black box neural network can be created using the Neural Network Toolbox.

The Matherworks camp: Excerpts from “Embedded Real-Time Control via MATLAB, Simulink, and xPC Target,” by P.J. Mosterman, et.al.:

Page 18: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Introduction:Plant Model SYS-ID -3

Applied SYS-ID (Jer-Nan Juang). The Observer/Kalman filter Identification (OKID) algorithm, is formulated entirely in the time-domain. The method computes the Markov parameters of a linear system, from which the state-space model and corresponding observer are determined simultaneously. The OKID method can effectively identify state-space models using time-domain (and frequency response data) I/O data.Flexible Robot Dynamics and Control, Chapter 4 SYS-ID (Robinett, et.al.). SYS-ID plays a key role in control system design. The first thing that a controls engineer learns in the real world is that the transfer function is not written on the outside of the H/W container. SYS-ID is used to obtain the transfer function and the critical parameters of plant models for controller design. Several SYS-ID techniques are reviewed with examples:

Linear Least Squares, Nonlinear Least Squares (NLS), Frequency Domain NLSOptimization Techniques:

VFO2AD Fortran optimization programs from Harwell Subroutine Library (freeware) for minimizing arbitrary performance index as a function of parameter constants and subject to both equality and inequality constraints (UPDATE: LANCELOT code?) http://hsl.rl.ac.uk/archive/hslarchive.html.MATLAB Optimization Toolbox: fmincon – constrained nonlinear optimization functions.

Several other SYS-ID resources and techniques:

Page 19: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Optimization: MATLAB Toolboxfmincon – Constrained NL Opt.

Multi-objective optimization is concerned with the minimization of a vector of objectives f(x) that can be the subject of a number of constraints or bounds.

ubxlbbeqxAeq

bxAxceq

xc

xfx

Min

≤≤=⋅

≤⋅=

≤0)(

0)(

)(

Where x, b, beq, lb, and ub are vectors, A and Aeq are matrices, c(x) and ceq(x) are functions that return vectors, and f(x) is a function that returns a scalar. f(x), c(x), and ceq(x) can be nonlinear functions.

Subject to:

(REF: MATLAB Opt. Toolbox)

Page 20: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Optimization: MATLAB Toolboxfmincon – Steps Used for SYS-ID

MATLAB Environment (Optimization Toolbox, Simulink Model)

SYS_ID_driver.m ... initialization … experimental data setup …params=fmincon(‘perfIndex’,params0,A,b,Aeq,beq,lb,up,’constraints’)

perfIndex.m … sim(‘sysid_opt’) … f= yout(…);

constraints.m … sim(‘sysid_opt’) … c= []; ceq=yout(…);

Dynamic Plant Model (params)

Open-loop data sets

Closed-loop data sets

sysid_opt.mdlswitch

yout

Page 21: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

System Identification:Servo Control System Problem

maxmin

maxmin

maxmin

2

)~(~)~(

)~(~)~(

)~(~)~(

)(

fff

TTT

itere

tf

to m

TTT

BBB

JJJ

dtJ

≤≤

≤≤

≤≤

−= ∫ θθ

velocity

position

Zero-OrderHold

-K-

Tf coefficient

kp

KPproportional

gain

kd

KDderivative

gain

1s

Integrator

encoderdotFrom

Workspace ENCODER RATE

DESIRED

encoderFrom

WorkspaceENCODER DESIRED

Friction sign function

KtJt.s+B

DC Motor plus loadAMP Saturation

ka

AMP Gain

motor_sysid_opt.mdl

)()(ˆ

ˆ)sgn( /

mDESDmDESP

ADatmfmmT

KK

VKKTBJ

θθθθτ

τθθθ&&

&&&&

−+−=

==++

Cost Index:

Subject to:Motor model and PD controller:

Simulink model

Ts=1 msec

Page 22: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

System Identification:SYS-ID Optimized Servo Results

0 0.2 0.4 0.6 0.8 1 1.2 1.4-20

0

20

40

60

80

100

120

140

Time (sec)

Hub

ang

le (d

eg)

90 Degree Validation Run

optexpdes

0 0.2 0.4 0.6 0.8 1 1.2 1.4-5

0

5

10

15

20

Hub

rate

(r/s

)

Time (sec)

90 Degree Validation Run

optexpdes

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7-10

0

10

20

30

40

50

60

Time (sec)

Hub

ang

le (d

eg)

45 Degree Calibration Run

optexpdes

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7-2

0

2

4

6

8

10

Time (sec)

Hub

rate

(r/s

)

45 Degree Calibration Run

optexpdes

Calibration runs used skeleton PD controller to generate experimental closed-loop data setsModel parameters are frozen for validation runFriction may be both velocity and position dependent due to offset in position responseFriction model refinements

Page 23: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Digital Controller Design:Optimize Controller Design Problem

velocity

torque_outposition amp_out

yout

To Workspace

friction

Tf coefficient

1/z

Rate Transition3

1/z

Rate Transition2

ZOH

Rate Transition1

ZOH

Rate Transition

kp

KP

ki*ts/2

KI

kd/ts

KD

1s

Integrator

ncoderdot_exFrom

Workspace ENCODER RATE

EXP

encoderdotFrom

Workspace ENCODER RATE

DESIRED

encoder_expFrom

WorkspaceENCODER EXP

encoderFrom

WorkspaceENCODER DESIRED

Friction sign function

z-1

zDiscrete

Transfer Fcn1

z+1

z-1

DiscreteTransfer Fcn

0.3728den(s)

DC Motor plus loadAMP Saturation

ka

AMP Gain

PID control parameters set-up to be optimized based on a calibrated and validated SYS-ID model and preliminary controller design

Simulink model

pid_sysid_opt.mdl

Page 24: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Conclusions:Overview/Keypoints of Discussion

Discussed servo modeling, assumptions, and limitationsIntroduced some SYS-ID methodsReviewed fmincon in MATLAB optimization toolboxSimulated servo system optimization for model matching and calibrationSet-up controller gain optimization problem

Page 25: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Conclusions:Nonlinear Friction Results

0 0.5 1 1.5 2 2.5-200

0

200

400

600

800

1000

1200

Time (sec)

The

ta T

heta

_c

(cou

nt)

High Fidelity with Friction Compensation Input Shaping

- Experimental Response

-- Simulation Response

-. Commanded Shaped Input

0 0.5 1 1.5 2 2.5 3 3.5 40

200

400

600

800

1000

1200

Time (sec)

The

ta (

coun

ts)

2nd Order Plant Design Response to Input Shaping

−− input shaped reference in

− experimental response

−. simulation response

Optimization based on high fidelity model help ID nonlinear friction and generate an input profile that compensated for this nonlinearity

Slewing single flexible link system optimization results

(REF: Wilson)

Page 26: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

Problems:Optimization Emphasis

May include an extra credit portion during projectsPotential extra credit problem set

Page 27: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

References/Resources:Lecture Composition Material

Carnegie Mellon University (CMU), Digital Control Tutorial, on internet.J. Wen, ECSE 4962 Control Systems Design, Lecture #4, Dept. ECSE, RPI, Feb. 2003, on internet.Robbins & Myers/Electro-Craft, DC Motors Speed Controls Servo Systems, Electro-Craft.P.G. Friedrich, Modelling of a Wound Rotor Salient Pole synchronous Machine and its Converter in the Constant Power Zone, on internet.P. Mosterman, et. al., Embedded Real-Time Control via MATLAB, Simulink, and xPCTarget, on internet.R.D. Klafter, et. al., Robotic Engineering an Integrated Approach, Prentice-Hall, 1989. Jer-Nan Juang, Applied System Identification, Prentice-Hall, 1994.R.D. Robinett, III, et. al., Flexible Robot Dynamics and Controls, Chapter 4, Kluwer Academic/Plenum Publishers, 2002. MATLAB, Optimization Toolbox, User’s Guide, The Mathworks, 2005.D.G. Wilson, D. Stokes, G.P. Starr, and R.D. Robinett, III, Optimized Input Shaping for a Single Flexible Robot Link, In SPACE 96: 5th International Conference and Exposition on ECOS, Albuquerque, NM, June 1996.

Page 28: Optimization for System Identification and Controller Designstarr/teaching/me581/ADC-SYSID.pdf · Optimization for System Identification and Controller Design ... Load v Motor, amplifier,

References:Background Material

MATLAB website: www.mathworks.comSeveral Digital Control Books:

R.G. Jacquot, Modern Digital Control Systems, Marcel Dekker, Inc., 1981.K.J. Astrom and B. Wittenmark, Computer Controlled Systems, Prentice-Hall, 1984C.L. Phillips and H.Troy Nagle, Digital Control System Analysis and Design, 2nd Ed., Prentice Hall, 1990.

Other pertinent references called out within the lecture