What's New - MapleSim Control Design Toolbox - Maplesoft

MapleSim Control Design Toolbox

What's New in the MapleSim Control Design Toolbox 

The MapleSim Control Design Toolbox now offers a more complete set of algorithms for PID control, new commands for computing closed-loop transfer functions, and numerous improvements to existing commands. These enhancements allow engineers to design a greater variety of controllers and controller-observer systems while taking advantage of the greater flexibility and analysis options available through the use of symbolic parameters.
Improvements include:

  • New command for PID controller automatic tuning
  • Updates to existing PID tuning commands to choose the format of the returned controller parameters
  • Updates to existing control design commands to support the DynamicSystems parameters option, which is new in Maple 18
  • New commands for the automatic computation of design parameters, such as poles and weighting matrices, for state feedback control design
  • New commands for system manipulation (for example, determining the closed-loop equations of common feedback system configurations) and simplification (for example, eliminating the structurally non-minimal states of a system)

with(ControlDesign); -1; with(DynamicSystems); -1

PID automatic tuning

The PIDAutoommand performs automatic tuning of a PID controller based on a single tuning parameter, Tc, which has the same order of magnitude as the desired time constant of the closed-loop. The time constant is proportional to the settling time of the system (first order approximation) and, therefore, provides a simple way to specify the desired closed-loop system response. This command can obtain the PID controller parameters for a wide range of plants, including unstable systems. The best-suited tuning method is automatically selected according to both the order and stability of the input system.  For instance, for stable higher order systems (order greater than 2), Skogestad internal model control (SIMC) tuning rules are applied.

infolevel[ControlDesign] := 3; -1

Design a PID controller for a system of order 7 with desired time constant Tc = 0.77. 

sys1 := TransferFunction(`/`(`*`(`+`(1, `-`(`*`(.3, `*`(s)))), `*`(`+`(1, `*`(0.8e-1, `*`(s))))), `*`(`+`(s, 1), `*`(`+`(`*`(2, `*`(s)), 1), `*`(`+`(`*`(.4, `*`(s)), 1), `*`(`+`(`*`(.2, `*`(s)), 1), `...
pid1 := PIDAuto(sys1, .77)

PIDAuto: Using Skogestad IMC tuning rules

`Record[Packed]`(Kp = 2.077922078, Ki = .6493506494, Kd = 1558441558., Tf = )

Return a DynamicSystems system object directly.

pidsys1 := PIDAuto(sys1, .77, 'returntype' = system); -1; PrintSystem(pidsys1); 1

PIDAuto: Using Skogestad IMC tuning rules

Design a PID controller for an integrating process with desired time constant Tc = 1.0.

sys2 := TransferFunction(`/`(1, `*`(s))); -1 pid2 := PIDAuto(sys2, 1.0)

PIDAuto: Using PIDUnstable

`Record[Packed]`(Kp = 2., Ki = 1., Kd = , Tf = (Ki = 1.))

Return a DynamicSystems system object directly.

pidsys2 := PIDAuto(sys2, 1.0, 'returntype' = system); -1; PrintSystem(pidsys2); 1

PIDAuto: Using PIDUnstable

PID tuning commands returned format

Existing PID tuning commands accept new options such as factored and returntypewhich are useful for specifying the way in which the controller parameters are returned. Use the option factored to return either the controller gains (proportional, integral, and derivative gain Kp, Ki, and Kd) or their factored version (proportional gain, integral time, and derivative time K, Ti, Td). Use the option returntype to return a record, a list or a system containing the controller parameters in either form or a DynamicSystems system object. The updated commands are CohenCoon, DominantPole, GainPhaseMargin, ZNFreq, and ZNTimeModified.

sys3 := NewSystem(`/`(`*`(`+`(s, 1)), `*`(`+`(`*`(`^`(s, 2)), s, 1)))); -1
fotd3 := evalf(ParameterIdentify:-TimeDomain(sys3))
[1., 1.414213562, 1.]

By default, the CohenCoon command returns a list containing the PID controller gains Kp, Ki, and Kd.

pid_list := CohenCoon(op(fotd3), 'controller' = PID)
[2.152188309, 1.079532192, .7019962725]

Using the new options factored and returntype, the CohenCoon command can return a record containing the factored version of the PID controller gains.

pid_rcrd := CohenCoon(op(fotd3), 'controller' = PID, 'factored' = true, 'returntype' = record)
`Record[Packed]`(K = 2.152188309, Ti = 1993630504., Td = .3261779044)

By default, the DominantPole command returns a sequence of lists containing the controller gains (Kp and Ki in this case) and the closed-loop poles.

pi_list := DominantPole(sys3, [`+`(`-`(3), `*`(2, I)), `+`(`-`(3), `-`(`*`(2, I)))], 'controller' = PI)
[`/`(47, 8), `/`(91, 8)], [-`/`(7, 8), `+`(`-`(3), `-`(`*`(2, `*`(I)))), `+`(`-`(3), `*`(2, `*`(I)))]

Using the option returntype, the DominantPole command can return a DynamicSystems system object directly.

pi_sys := DominantPole(sys3, [`+`(`-`(3), `*`(2, I)), `+`(`-`(3), `-`(`*`(2, I)))], 'controller' = PI, 'returntype' = system); -1; PrintSystem(pi_sys)

Support of parameters option

Existing ControlDesign< commands that accept DynamicSystems system objects as input now accept the parameters< option. You can use this option to define numeric values for symbolic parameters existing in the system object. This option is the same as the DynamicSystems parameters option. For examples of its use see the sections below.

State Feedback design parameters

Two new commands ComputePoles and ComputeQR help with the calculation of the pole locations for Ackermann's formula and the Q and R weighting matrices for LQR design.

The Ackermann command calculates the state feedback gain required in order to place the closed-loop poles in the desired locations. The ComputePoles automatically computes these pole locations such that the closed-loop system response has a desired time constant, Tc.

sys4 := StateSpace(Matrix([[1, f, 3], [g, 4, -1], [2, 5, 7]]), Matrix([[3], [9], [5]]), Matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]]), Matrix(3, 1)); -1
sys4 := StateSpace(Matrix([[1, f, 3], [g, 4, -1], [2, 5, 7]]), Matrix([[3], [9], [5]]), Matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]]), Matrix(3, 1)); -1

params := [f = 2, g = 0]; -1
tau := .1; -1
p := ComputePoles(sys4, tau, 'parameters' = params)
[`+`(`-`(1.124260354), `*`(3.158898890, `*`(I))), `+`(`-`(1.124260354), `-`(`*`(3.158898890, `*`(I)))), -0.1e2]
Kc := StateFeedback:-Ackermann(sys4, p, 'parameters' = params)
Kc := Matrix(%id = 18446744078209948118)

The LQR command calculates the linear quadratic state feedback regulator (LQR) gain given the weighting matrices Q and R. The ComputeQR command automatically computes these weighting matrices Q and R to obtain a closed-loop system with desired time constant, Tc.

QRmat := ComputeQR(sys4, tau, 'parameters' = params)
QRmat := Record(Q = Matrix(%id = 18446744078209948718), R = Matrix(%id = 18446744078209948838))
Kc := LQR(sys4, QRmat:-Q, QRmat:-R, 'parameters' = params)
Kc := Matrix(%id = 18446744078209942102)

System manipulation and simplification

The new commands for system manipulation and simplification are ControllerObserver, PIDClosedLoop, StateFeedbackClosedLoop, and ReduceSystem.

The ControllerObserver command calculates the equations of the subsystem comprised of a state feedback controller and an observer. This command is useful, for example, to construct an LQG controller comprised of an LQR state feedback controller and a Kalman observer. Use the closedloop option to obtain the closed-loop equations of the system with state feedback and observer.

sys5 := StateSpace(Matrix([[0, 1], [0, 0]]), Matrix([[alpha], [1]]), Matrix([[1, 0]]), Matrix(1, 1)); -1

Define the numeric value for parameter alpha

param := [alpha = 2]; -1

Design the LQR controller

W := ComputeQR(sys5, .5, 'parameters' = param)
W := Record(Q = Matrix(%id = 18446744078209945222), R = Matrix(%id = 18446744078209945342))
Kc5, Kr5 := LQR(sys5, W:-Q, W:-R, 'parameters' = param, 'return_Kr' = true)
Kc5, Kr5 := Matrix(%id = 18446744078209938246), Matrix(%id = 18446744078209938366)

Design the Kalman observer

G1 := LinearAlgebra:-IdentityMatrix(sys5:-statecount); -1
Q1 := `+`(`*`(`/`(2, 3), `*`(LinearAlgebra:-IdentityMatrix(sys5:-statecount)))); -1
H1 := Matrix([[1, 0]]); -1
R1 := Matrix([[2]]); -1
Kobs := Kalman(sys5, G1, H1, Q1, R1, 'parameters' = param)[1]
Kobs := Matrix(%id = 18446744078209935590)

Obtain the LQG controller.

LQG := ControllerObserver(sys5, Kc5, Kobs, 'Kr' = Kr5, 'parameters' = param); -1

Obtain the LQG control system closed-loop equations.

clLQG := ControllerObserver(sys5, Kc5, Kobs, 'Kr' = Kr5, 'parameters' = param, 'closedloop' = true); -1

The PIDClosedLoop command calculates the closed-loop system equations of a feedback system with the controller Gc located in the forward path before the plant Gp and inside the feedback loop. The feedback system has unity negative feedback. This is a basic feedback structure commonly used for P/PI/PID control, hence the name of the command.

Gp := TransferFunction(`/`(`*`(`^`(omega, 2), `*`(A)), `*`(`+`(`*`(2, `*`(omega, `*`(s, `*`(theta)))), `*`(`^`(omega, 2)), `*`(`^`(s, 2)))))); -1
Gc := TransferFunction(`+`(kp, `/`(`*`(ki), `*`(s)))); -1
cl := PIDClosedLoop(Gp, Gc); -1

clnum := PIDClosedLoop(Gp, TransferFunction(`+`(.5, `/`(`*`(.1), `*`(s)))), 'parameters' = [A = 1, omega = 1.2, theta = 2]); -1

Use the PIDClosedLoop command to access the controller output node through the augment_output option.

claug := PIDClosedLoop(Gp, Gc, 'augment_output' = true); -1

The StateFeedbackClosedLoop command calculates the closed-loop system equations of a plant with state feedback. This command requires the state feedback gain matrix Kc, but can also accept the feed-forward matrix Kr to support a state feedback structure with control law  

Kc, Kr := StateFeedback:-Ackermann(sys4, p, 'parameters' = params, 'return_Kr' = true)
Kc, Kr := Matrix(%id = 18446744078209912950), Matrix(%id = 18446744078209913070)
clsf := StateFeedbackClosedLoop(sys4, Kc, ':-Kr' = Kr, ':-parameters' = params); -1

The ReduceSystem command simplifies a state-space system by detecting and removing its structural unobservable and uncontrollable states. These struturally non-minimal states may occur, for example, as a result of extracting a subsystem from a subset of its inputs and/or outputs. The reduced state-space system is structurally minimal, that is, contains a subset of the original system states but preserves its state structure and variable names. The input/output response of the reduced system is equivalent to the transfer function of the original system.

sys6 := StateSpace(Matrix([[delta, 0, `+`(`-`(phi)), sigma], [3, 0, 0, 3], [1, 0, -1, 1], [0, 0, 0, 0]]), Matrix([[5, z, -1], [1, 3, `+`(`-`(x))], [0, 2, y], [0, 0, z]]), Matrix([[1, 0, 3, 5], [-3, 0,...
sys6 := StateSpace(Matrix([[delta, 0, `+`(`-`(phi)), sigma], [3, 0, 0, 3], [1, 0, -1, 1], [0, 0, 0, 0]]), Matrix([[5, z, -1], [1, 3, `+`(`-`(x))], [0, 2, y], [0, 0, z]]), Matrix([[1, 0, 3, 5], [-3, 0,...

Get a subsystem with inputs u1(t) and u2(t). This subsystem is uncontrollable and unobservable.

subsys6 := Subsystem(sys6, {1, 2}); -1; Controllable(subsys6), Observable(subsys6)
false, false

Get a structurally minimal system removing the non-minimal (structural uncontrollable and unobservable) states.

redsys := ReduceSystem(subsys6); -1; Controllable(redsys), Observable(redsys)
true, true

Verify the input/output response is not affected by the removed states.

verify(TransferFunction(subsys6):-tf, TransferFunction(redsys):-tf, 'Matrix')

Ready for the next step?

Talk with our product specialists today for a free, 30-day evaluation of Maple.

*Evaluations are not available for students or personal edition users.