Sie sind auf Seite 1von 28

Applied Digital Control: Optimization for System Identification and Controller Design

David G. Wilson Mechanical Engineering University of New Mexico 1. wilson@me.unm.edu 2. starr@unm.edu


2/27/2006

Lecture Outline

Introduction Optimization: MATLAB Toolbox System Identification Control Design Conclusions Problems

Introduction: Continuous Controller


Continuous controller r(t)
+

u(t) D(s)
-

y(t) Mechanical System (Plant)

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)

Introduction: Digital Controller


Digital controller r(t)
A/D

r(k) e(k)
+ -

G(z) u(k) Difference Equation


clock

u(t)
D/A and Hold

y(t) H(s) Plant

y(k)

A/D

Digital controller operates on discrete signals (or samples) rather than continuous signals Implementation: Normally as discrete functions either in transfer (REF: CMU) function or state-space forms (difference equations)

Introduction: Servo Control System Components


Motor, amplifier, and sensing:
+ -

Controller and Amplifier

vi

Motor and Load

Sensing Device (Encoder,Tachometer) Example: general closed-loop control system


(REF: Electro-Craft)

Introduction: DC Motor Model

From input voltage to motor angle: && + B & + T sgn( & ) = K i J m m m f m t L


di & =v L + Ri + K e m i dt

The electrical time constant L/R considered negligible: & )/R i = ( vi K e m && + ( B + K K / R ) & + T sgn( & ) = K v / R J m m t e m f m t i L

Motor Datasheet: Resistance Inductance Torque constant Back EMF constant Simplifications: Direct drive (N=1) No Gear Backlash (hysteresis, deadzone)
(REF: Wen)

Introduction: Amplifier Interaction


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

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

Introduction: Simple PWM Amplifier Model

Modeling of the amplifier:

Current controlled voltage source internal portion of PWM amplifier voltage characteristics: Required Voltage

When PWM frequency is Applied much larger than the Voltage Reference system frequency of Voltage interest then applied Ka voltage can be reduced to average value established Linearized for one PWM cycle Applied voltage voltage supply saturation Result: PWM and power (constant gain) stage considered as perfect voltage source as long as Voltage supply smaller than maximum available DC voltage If required voltage realizable then will
be fully applied otherwise limited to maximum available (REF: Friedrich)

Introduction: Amp Current Feedback Loop

Previously without current feedback it was noted:

&& + ( B + K K / R ) & + T sgn( & ) = K v / R J m m t e m f m t i L

With current feedback the input effectively becomes i = K aVD / A then

&& + B & + T sgn( & ) = K K V J m m m f m t a D/ A L

Effectively: i = K aVD / A is subject to saturation due to max amp current, max supplied voltage, and back EMF
(REF: Wen)

Introduction: Sensor Model - Encoders


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

K enc

mrad deg = 1.57 = 0.09 count count

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

Introduction: Digital Quantization Effects

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

Introduction: PID Digital Controller


Continuous PID Controller: Derivative action:

C ( s) / E ( s) = K P + K I / s + K D s

e( kT ) e[( k 1)T ] CD ( z ) z 1 = T E ( z) Tz Integral action: to preserve 1 both regions of stability and C I ( s ) = sys = C I ( z ) = c 2d ( sys, T , ' tustin' ) instability when mapping from s s to z employ the bilinear C I ( z ) T ( z + 1) transformation: = 2 ( z 1) Resulting z-transform model of E ( z ) cD ( kT ) =
PID controller:

( z 1) C( z) T ( z + 1) = KP + KI + KD 2( z 1) E ( z) Tz
(REF: Background Matl)

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

Introduction: Position Servo with PID Control


r(t)
A/D +

More complete model for a position servo with PID control:


PID Kp

T f ( s ) + Td ( s )

r(k) e(k)
-

u(k)

VD / A

T ( z + 1) KI 2 ( z 1)
1 ( z 1) KD T z

D/A and Hold

Ka s a + 1
Current Amplifier

Kt J T s 2 + Bs
DC Motor plus load

clock

y(k)
Digital controller

K enc

y (t ) = m (t )

Introduction: Other Potential Problems


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

What if encoder generates spurious signal creating a large error term 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 avoided when 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.
(REF: Background Matl, Klafter)

Introduction: Case Study Project Steps


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

Optimization applies where? What level of detail is sufficient?

Mechanical system with embedded controller prototype (hardware) Model development (physics/mechatronics) Plant model system identification Digital control system design Experimental/predicted correlation and performance results

Introduction: Plant Model SYS-ID -1


The Matherworks camp: Excerpts from Embedded Real-Time Control via MATLAB, Simulink, and xPC Target, by P.J. Mosterman, et.al.:
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 Simulink Parameter 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.

Introduction: Plant Model SYS-ID -2


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

3.

4.

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. 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. 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.

Introduction: Plant Model SYS-ID -3


Several other SYS-ID resources and techniques:

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 statespace 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 NLS Optimization 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.

Optimization: MATLAB Toolbox fmincon Constrained NL Opt.


Min

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.

x c( x ) 0 ceq( x ) = 0

f ( x)

Subject to:

A x b Aeq x = beq lb x ub

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.
(REF: MATLAB Opt. Toolbox)

Optimization: MATLAB Toolbox fmincon Steps Used for SYS-ID


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(); Open-loop data sets Closed-loop data sets sysid_opt.mdl switch yout

Dynamic Plant Model (params)

MATLAB Environment (Optimization Toolbox, Simulink Model)

System Identification: Servo Control System Problem


Motor model and PD controller: Cost Index: Subject to:

&& + B & + T sgn( & ) = K K V = J T m m f m t a D/ A = K ( ) + K (& & )


P DES m D DES m
position

2 J = ( m e )iter dt to ~ ~ ~ ( J T ) min J T ( J T ) max ~ ~ ~ ( B ) min B ( B ) max ~ ~ ~ (T f ) min T f (T f ) max

tf

Simulink model
kp encoder From Workspace ENCODER DESIRED encoderdot From Workspace ENCODER RATE DESIRED KP proportional gain kd KD derivative gain ka AMP Gain AMP Saturation Kt Jt.s+B DC Motor plus load 1 s Integrator

Zero-Order Hold

-KTf coefficient Friction sign function

velocity

Ts=1 msec

motor_sysid_opt.mdl

System Identification: SYS-ID Optimized Servo Results

Hub rate (r/s)

6 4 2 0 -2

Hub rate (r/s)

Calibration runs used skeleton PD controller to generate experimental closed-loop data sets Model parameters are frozen for validation run Friction may be both velocity and position dependent due to offset in position response Friction model refinements

45 Degree Calibration Run


60

90 Degree Validation Run


140 120 opt exp des

Hub angle (deg)

50 40 30 20 10 0 -10

Hub angle (deg)

100 80 60 40 20 0 -20 0

opt exp des

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.2

0.4

0.6

0.8

1.2

1.4

Time (sec)

Time (sec)

45 Degree Calibration Run


10 8 opt exp des

90 Degree Validation Run


20 opt exp des 15

10

0.1

0.2

0.3

0.4

0.5

0.6

0.7

-5

0.2

0.4

0.6

0.8

1.2

1.4

Time (sec)

Time (sec)

Digital Controller Design: Optimize Controller Design Problem


PID control parameters set-up to be optimized based on a calibrated and validated SYS-ID model and preliminary controller design
encoder_exp From Workspace ENCODER EXP position kp KP encoder From Workspace ENCODER DESIRED
ZOH

amp_out

torque_out

Simulink model
1 s

ka
z+1 z-1
1/z

0.3728 den(s) DC Motor plus load

ki*ts/2 KI kd/ts KD

AMP Gain AMP Saturation

Integrator
yout To Workspace

Discrete Rate Transition Rate Transition2 Transfer Fcn

ZOH

z-1 z

1/z

friction Tf coefficient Friction sign function

encoderdot From Workspace ENCODER RATE DESIRED ncoderdot_ex From Workspace ENCODER RATE EXP

Rate Transition1 Discrete Rate Transition3 Transfer Fcn1

velocity

pid_sysid_opt.mdl

Conclusions: Overview/Keypoints of Discussion

Discussed servo modeling, assumptions, and limitations Introduced some SYS-ID methods Reviewed fmincon in MATLAB optimization toolbox Simulated servo system optimization for model matching and calibration Set-up controller gain optimization problem

Conclusions: Nonlinear Friction Results


Slewing single flexible link system optimization results
2nd Order Plant Design Response to Input Shaping 1200
1200 High Fidelity with Friction Compensation Input Shaping

1000

1000

800

800

Theta Theta_c (count)

Theta (counts)

600 -. Commanded Shaped Input

600 input shaped reference in 400 experimental response . simulation response 200

400

- Experimental Response 200 -- Simulation Response 0

0 0

0.5

1.5

2 Time (sec)

2.5

3.5

-200 0

0.5

1 Time (sec)

1.5

2.5

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

(REF: Wilson)

Problems: Optimization Emphasis

May include an extra credit portion during projects Potential extra credit problem set

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 xPC Target, on internet. R.D. Klafter, et. al., Robotic Engineering an Integrated Approach, PrenticeHall, 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, Users 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.

References: Background Material


MATLAB website: www.mathworks.com Several 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, 1984 C.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

Das könnte Ihnen auch gefallen