Manufacturing Controls - PowerPoint PPT Presentation

1 / 50
About This Presentation
Title:

Manufacturing Controls

Description:

19. Nov. 22 THANKSGIVING HOLIDAY Ch. 9, Notes ... Model of the non-linear or linear system using ... mean and standard deviation of a vector. The variables ... – PowerPoint PPT presentation

Number of Views:63
Avg rating:3.0/5.0
Slides: 51
Provided by: Ern81
Category:

less

Transcript and Presenter's Notes

Title: Manufacturing Controls


1
Manufacturing Controls
  • FALL 2001
  • Lecture 18 

2
Syllabus
  • DATE TOPIC NOTES
  • 1. Sep. 20 Mechatronics Design Process Ch. 1
  • 2. Sep. 25 System Modeling and Simulation Ch. 2
  • 3. Sep. 27 Laplace Transforms and Transfer
    Functions Ch. 2
  • 4. Oct. 2 Electrical Examples Ch.2, Notes
  • 5. Oct. 4 Mechanical Examples Ch.2, Notes
  • 6. Oct. 9 More Examples, Thermal and Fluid
    Examples, QUIZ 1 (Take Home)
  • 7. Oct. 11 Sensors and Transducers Ch. 3
  • 8. Oct. 16 Digital control, Advanced MATLAB
  • 9. Oct. 18 Analog and Digital Sensing Ch. 3,
    Notes
  • 10. Oct. 23 Actuating Devices, time and frequency
    response Ch. 4
  • 11. Oct. 25 DC Motor Model, Ch. 4,
    Notes
  • 12. Oct. 30 Examples Ch. 5
  • 13. Nov. 1 Boolean Logic ,Programmable Logic
    Controllers Ch. 5, Notes
  • 14. Nov. 6 Stability and Compensators, P, PI and
    PD Ch. 6
  • 15. Nov. 8 PID Controllers - Review Ch. 7
  • 16. Nov. 13 QUIZ 2 (In Class - Open Book)
  • 17. Nov. 15 Practical and Optimal Compensator
    Design Ch. 8
  • 18. Nov. 20 Frequency Response Methods Ch. 9,
    Notes

3
Todays objective
  • To test the accomplishment of our objective of
    understanding systems theory by solving problems
    related to the concepts of optimal control
    systems for feedback control.

4
Comparison of input and actual response leads to
a natural criteria to optimize both the transient
and steady state responses.
5
Simulation and optimization
  • Model of the non-linear or linear system using
    Matlab's Simulink toolbox
  • Optimization using the Optimization toolbox
  • Matlab file that has the models transfer
    function
  • Matlab file converting the digital gains to
    analog signals
  • Simulink graphics model which takes the analog
    gains and simulates the step response

6
Optimization Toolbox
  • Is a collection of functions that extend the
    capability of Matlab. The toolbox includes
    routines for
  • Unconstrained optimization
  • Constrained nonlinear optimization, including
    goal attainment problems, minimax problems, and
    semi-infinite minimization problems
  • Quadratic and linear programming
  • Nonlinear least squares and curve fitting
  • Nonlinear systems of equations solving
  • Constrained linear least squares
  • Specialized algorithms for large scale problems
  • Reference Thomas Coleman, Mary Ann Branch and
    Andrew Grace, Optimization Toolbox, The Math
    Works,1999.

7
Optimization
  • Optimization concerns the minimization or
    maximization of functions. For example

8
To use the optimization toolbox
  • Most of these optimization routines require the
    definition of an M-file containing the function,
    f, to be minimized.
  • Maximization is achieved by supplying the
    routines with f.
  • Optimization options passed to the routines
    change optimization parameters.
  • Default optimization parameters can be changed
    through an options structure.

9
Medium-Scale Example
  • Unconstrained example
  • Consider the problem of finding a set of
    valuesx1,x2 that solves

10
Solution
  • Write an M-file that returns the function value
  • Call it objfun.m
  • Then invoke the unconstrained minimization
    routine
  • Use fminunc

11
Function
  • function f objfun(x)
  • fexp(x(1))(4x(1)22x(2)24x(1)x(2)2x(2)
    1)

12
help function FUNCTION Add new function.
New functions may be added to MATLAB's vocabulary
if they are expressed in terms of other
existing functions. The commands and
functions that comprise the new function must
be put in a file whose name defines the name of
the new function, with a filename extension
of '.m'. At the top of the file must be a
line that contains the syntax definition for
the new function. For example, the existence of a
file on disk called STAT.M with
function mean,stdev stat(x)
STAT Interesting statistics. n
length(x) mean sum(x) / n
stdev sqrt(sum((x - mean).2)/n)
defines a new function called STAT that
calculates the mean and standard deviation
of a vector. The variables within the body of
the function are all local variables.
13
A subfunction that is visible to the other
functions in the same file is created by
defining a new function with the FUNCTION
keyword after the body of the preceding function
or subfunction. For example, avg is a
subfunction within the file STAT.M
function mean,stdev stat(x) STAT
Interesting statistics. n
length(x) mean avg(x,n)
stdev sqrt(sum((x-avg(x,n)).2)/n)
------------------------- function
mean avg(x,n) MEAN subfunction
mean sum(x)/n Subfunctions are not
visible outside the file where they are defined.
Normally functions return when the end of the
function is reached. A RETURN statement can
be used to force an early return. See also
SCRIPT, RETURN, VARARGIN, VARARGOUT, NARGIN,
NARGOUT, INPUTNAME, MFILENAME.
14
Step 2 Invoke one of the optimization routines
  • x0 -1,1 Starting guess
  • options optimset(LargeScale,off)
  • x,fval,exitflag,outputfminunc(objfun,x0,optio
    ns)
  • Try this. After 40 iterations, it should produce
    the solution
  • X
  • 0.50000 -1.0000

15
And
  • The function at the solution x is returned in
    fval
  • fval
  • 1.3030e-10
  • The exitflag tells if the algorithm converged. An
    exitflag gt 0 means than a local minimum was
    found.
  • exitflag
  • 1

16
Output structure gives more details
  • For fminunc, it includes the number of
    iterations, the number of function elaluations,
    the final step size, a measure of first-order
    optimality, and the type algorithm used.
  • output
  • iterations 7
  • funcCount 40
  • stepsize 1
  • firstorderopt 9.280e-004
  • algorithm medium-scale Quasi-Newton line search

17
When more than one minimum
  • When there exists more than one local minimum,
    the initial guess for the vector x1,x2 affects
    both the number of function evaluations and the
    value of the solution point. In the example, x0
    is initialized to -1,1.
  • Try it again with another x0.

18
Variable options can be changed
  • The variable options can be passed to fminunc to
    change the characteristics of the optimization
    algorithm.
  • Xfminunc(objfun,x0,options)
  • Options is a structure that contains values for
    termination tolerances and algorithm choices.
  • An options structure can be created using the
    optimset function
  • optionsoptimset(LargeScale,off) Turning off
    the LargeScale option gives the medium-scale
    algorithm.

19
Other options
  • Other options include
  • controlling the amount of command line display
    during the optimization iteration,
  • the tolerances for the termination criteria,
  • if a user-supplied gradient or Jacobian is to be
    used,
  • and the maximum number of iterations or function
    evaluations.

20
Nonlinear Inequality Constrained Example
21
Preliminaries
  • Since neither of the constraints if linear, you
    cannot pass the constraints to fmincon at the
    command line
  • Instead, you can create a second M-file confun.m
    that returns the value at both constraints at the
    current x in a vector, c.
  • The constrained optimizer, fmincon, is then
    invoked.
  • Because fmincon expects the constraints to be
    written in the form c(x)lt0, the constraints must
    be rewritten in the form

22
Process
  • Step 1 Write an M-file confun.m for the
    constraints
  • Step 2 Invoke the constrained optimization
    routine
  • Look at the results

23
Step 1
  • function c,ceqconfun(x)
  • nonlinear inequality constraints
  • c1.5x(1)x(2)-x(1)-x(2)
  • -x(1)x(2)-10
  • nonlinear equality constraints - none
  • ceq

24
Step 2 Invoke constrained optimization routine
  • x0-1,1 Starting guess at the solution
  • optionsoptimset(LargeScale,off)
  • x,fvalfmincon(objfun,x0,,,,,,,con
    fun,options)
  • After 38 function calls, the solution x produced
    with function value fval is
  • x
  • -9.5474 1.0474
  • fval
  • 0.0236

25
Constraints
  • The values of the constraints at the solution can
    be evaluated
  • c,ceqconfunx
  • c
  • 1.0e-15
  • -0.8882
  • 0
  • ceq

26
Multiobjective Examples
  • The previous examples involved problems with a
    single objective function. Let us now consider
    solving problems with multiobjective functions
    using
  • lsqnonlin
  • fminmax
  • fgoalattain

27
Simulink Example
  • Suppose we want to optimize the control
    parameters in the Simulink model
  • optsim.mdl
  • This model may be found in the Optimization
    Toolbox directory.
  • Lets look for it. Try it. This will also check
    that Simulink is installed.

28
Simulink mdl file
  • The model is a nonlinear process plant
  • Limit amplifier
  • Rate amplifier
  • Under-damped third-order system
  • The actuator limits are a saturation limit and a
    slew rate limit.
  • The saturation limit cuts off input values
    greater than 2 units and less than -2 units
  • The slew rate limit is 0.8 units/sec.

29
Examine the response
  • At the Matlab command prompt, type
  • optsim
  • Open the Scope block by double clicking on it.
  • Run the simulation.
  • The output is oscillatory.
  • The problem is to design a feedback control law
    that tracks a unit step input function.

30
Closed loop plant
  • The closed-loop plant is entered in terms of the
    blocks where the plant and actuator have been
    placed in a hierarchical Subsystem block. A Scope
    block displays output trajectories during the
    design process.
  • A PID controller is used.

31
Optimization approach
  • One way to solve the problem is to minimize the
    error between the output and input signals.
  • The variables are the parameters of the PID
    controller.
  • If you need to minimize the error at one time
    value, the problem would require a single
    objective function. However, let us set the goal
    to minimize the error for all time steps from 0
    to 100. This produces a multiobjective function
    with one function per time step.

32
Use the routine lsqnonlin
  • lsqnonlin is used to perform a least squares fit
    on tracking the output.
  • This is defined by a Matlab function in the file
  • tracklsq.m
  • It defines the error signal, yout. The output is
    computed by calling sim, minus the input signal 1
  • Error yout-1

33
tracklsq
  • tracklsq must run the simulation.
  • The simulation may be run either in the base
    workspace or the current workspace, i.e, the
    workspace of the function calling sim which in
    this case is the tracklsqs workspace.
  • In this example, the simset command is used to
    tell sim to run the simulation in the current
    workspace by setting SrcWorkspace to current.

34
Running the simulation
  • To run the simulation in optsim, the variables
  • Kp, Kd and Ki
  • And a1 and a2 that are variables in the plant
    block
  • Must all be defined.
  • You can initialize a1 and a2 before calling
    lsqnonlin and then pass these two variables as
    additional arguments.
  • lsqnonlin will then pass a1 and a2 to tracklsq
    each time it is called so you do not have to use
    global variables.

35
Choosing a solver
  • After choosing a solver using the simset
    function, the simulation is run using sim.
  • The simulation is performed using a fixed-step
    fifth-order method to 100 seconds.
  • When the simulation completes, the variables
    tout, xout and your are now in the current
    workspace (the workspace of tracklsq).
  • The Outport block is used in the block diagram
    model to put yout into the current workspace at
    the end of the simulation.

36
Procedure
  • Step 1- Write an M-file
  • tracklsq.m
  • Step 2 Invoke optimization routine

37
tracklsq.m
  • Function F tracklsq(pid,a1,a2)
  • Kp pid(1) Move variables into model
    parameters
  • Ki pid(2)
  • Kd pid(3)
  • choose solver and set model workspace to this
    function
  • opt simset('solver', 'ode5', 'SrcWorkspace',
    'Current')
  • tout, xout, yout sim('optsim', 0 100, opt)
  • F yout-1 compute error signal

38
optsim
  • Step 2 The second file invokes the model and the
    optimizing routine
  • optsim load the model
  •   pid0 0.63 0.0504 1.9688 setting initial
    values
  • a1 3 a2 43 initialize Plant variables in
    model
  • options optimset('LargeScale', 'off',
    'Display', 'iter', 'TolX', 0.001, 'TolFun',
    0.001)
  • pid lsqnonlin(tracklsq', pid0, , ,
    options, a1, a2)
  • put variables back into the base workspace
  • Kp pid(1) Ki pid(2) Kd pid(3)

39
Options
  • The variable options passed to lsqnonlin define
    the criteria and display characteristics. In this
    case you ask for output, use the medium-scale
    algorithm, and give termination tolerances for
    the step and objective function on the order of
    0.001.

40
Try it!
  • This should converge in 10 iterations and give
    final values of
  • pid 2.9108 0.1443 12.8161

41
Homework-Given the Simulink model of the motor
system- select the optimum values of the digital
PID controller (a,b,f,g).
42
Model explanation
  • Step input signal fed to a summation block
  • Constant values to be used are calculated using a
    separate M-file
  • Analog values in the Mat lab kernel
  • Zero order hold
  • DAC
  • Amplifier
  • Encoder feedback fed to the summation block for
    correction

43
Optimization of the parameters
  • Non-linear model
  • Enables the system to track a unit step input
    into the system
  • Two methods are used
  • lsqnonlin is the non-linear least squares
    method. It minimizes the error between the output
    and input
  • fminmax minimizes the maximum value of the
    output at anytime.
  • The first method is chosen
  • It is a multi-objective function because the
    error needs to be minimized for all time steps

44
lsqnonlin method
  • Least square fit on the tracking of output
  • E input-output
  • Objective is
  • Minimize

45
Mat lab optimizing files
  • Step 0 Creat the Simulink file
  • Step 1 the first file defines the function

46
Mat lab optimizing files contd.
  • Step 2 The second file invokes the model and the
    optimizing routine
  • Initial values of the parameters are defined

47
Optimization results
48
Results
  • Turn in a copy of your Simulink mdl file, the
    other Matlab m-files and your iteration results
    with the final values of a,b,f,g.

49
Lets try it again with the motor model we have
developed.
  • Due to difficulty of using a specific model a
    generic model was chosen. Future team members
    could try to work on the specific model
  • Thought the iterative steps were eliminated,
    still the initial value had to be chosen.
  • Only one method was dealt with. More methods can
    be used and compared for the best results

50
Any questions?
Write a Comment
User Comments (0)
About PowerShow.com