Simulink Control Design 

This example shows how to use slTuner to tune a multiloop controller for a rotorcraft. Note that to define tuning goals and run systune and looptune commands, you need Robust Control Toolbox.
On this page… 

This example uses an 8state helicopter model at the hovering trim condition. The state vector x = [u,w,q,theta,v,p,phi,r] consists of
Longitudinal velocity u (m/s)
Lateral velocity v (m/s)
Normal velocity w (m/s)
Pitch angle theta (deg)
Roll angle phi (deg)
Roll rate p (deg/s)
Pitch rate q (deg/s)
Yaw rate r (deg/s).
The controller generates commands ds,dc,dT in degrees for the longitudinal cyclic, lateral cyclic, and tail rotor collective using measurements of theta, phi, p, q, and r.
The following Simulink model depicts the control architecture:
open_system('scdhelicopter')
The control system consists of two feedback loops. The inner loop (static output feedback) provides stability augmentation and decoupling. The outer loop (PI controllers) provides the desired setpoint tracking performance. The main control objectives are as follows:
Track setpoint changes in theta, phi, and r with zero steadystate error, rise times of about 2 seconds, minimal overshoot, and minimal crosscoupling
Limit the control bandwidth to guard against neglected highfrequency rotor dynamics and measurement noise
Provide strong multivariable gain and phase margins (robustness to simultaneous gain/phase variations at the plant inputs and outputs, see loopmargin for details).
We use lowpass filters with cutoff at 40 rad/s to partially enforce the second objective.
You can jointly tune the inner and outer loops with the systune command. This command only requires models of the plant and controller along with the desired bandwidth (which is function of the desired response time). You can use the slTuner interface to quickly set up the tuning task from the Simulink model. Create an instance of this interface with the list of blocks to be tuned.
ST0 = slTuner('scdhelicopter',{'PI1','PI2','PI3','SOF'});
Each tunable block is automatically parameterized according to its type and initialized with its value in the Simulink model ( for the PI controllers and zero for the static outputfeedback gain). Simulating the model shows that the control system is unstable for these initial values:
Mark the I/O signals of interest for setpoint tracking, and identify the plant inputs and outputs (control and measurement signals) where the stability margin are measured.
addPoint(ST0,{'thetaref','phiref','rref'}) % setpoint commands addPoint(ST0,{'theta','phi','r'}) % corresponding outputs addPoint(ST0,{'u','y'});
Finally, capture the design requirements using TuningGoal objects. We use the following requirements for this example:
Tracking requirement: The response of theta, phi, r to step commands theta_ref, phi_ref, r_ref must resemble a decoupled firstorder response with a onesecond time constant
Stability margins: The multivariable gain and phase margins at the plant inputs u and plant outputs y must be at least 5 dB and 40 degrees
Fast dynamics: The magnitude of the closedloop poles must not exceed 25 to prevent fast dynamics and jerky transients
% Less than 20% mismatch with reference model 1/(s+1) TrackReq = TuningGoal.StepResp({'thetaref','phiref','rref'},{'theta','phi','r'},1); TrackReq.RelGap = 0.2; % Gain and phase margins at plant inputs and outputs MarginReq1 = TuningGoal.Margins('u',5,40); MarginReq2 = TuningGoal.Margins('y',5,40); % Limit on fast dynamics PoleReq = TuningGoal.Poles(); PoleReq.MaxFrequency = 25;
You can now use systune to jointly tune all controller parameters. This returns the tuned version ST1 of the control system ST0.
AllReqs = [TrackReq,MarginReq1,MarginReq2,PoleReq]; [ST1,fSoft,~,Info] = systune(ST0,AllReqs);
Final: Soft = 1.13, Hard = Inf, Iterations = 68
The final value is close to 1 so the requirements are nearly met. Plot the tuned responses to step commands in theta, phi, r:
T1 = getIOTransfer(ST1,{'thetaref','phiref','rref'},{'theta','phi','r'}); step(T1,5)
The rise time is about two seconds with no overshoot and little crosscoupling. You can use viewSpec for a more thorough validation of each requirement, including a visual assessment of the multivariable stability margins (see loopmargin for details):
viewSpec(AllReqs,ST1,Info)
Inspect the tuned values of the PI controllers and static outputfeedback gain.
showTunable(ST1)
Block 1: scdhelicopter/PI1 = 1 Kp + Ki *  s with Kp = 0.733, Ki = 1.6 Name: PI1 Continuoustime PI controller in parallel form.  Block 2: scdhelicopter/PI2 = 1 Kp + Ki *  s with Kp = 0.0702, Ki = 1.54 Name: PI2 Continuoustime PI controller in parallel form.  Block 3: scdhelicopter/PI3 = 1 Kp + Ki *  s with Kp = 0.14, Ki = 2.59 Name: PI3 Continuoustime PI controller in parallel form.  Block 4: scdhelicopter/SOF = d = u1 u2 u3 u4 u5 y1 1.66 0.1231 0.0936 0.6095 0.0003637 y2 0.2908 1.429 0.0292 0.07929 0.1097 y3 0.003642 0.01314 2.262 0.012 0.03153 Name: SOF Static gain.
You may wonder whether the static output feedback is necessary and whether PID controllers aren't enough to control the helicopter. This question is easily answered by retuning the controller with the inner loop open. First break the inner loop by adding a loop opening after the SOF block:
addOpening(ST0,'SOF')
Then remove the SOF block from the tunable block list and reparameterize the PI blocks as fullblown PIDs with the correct loop signs (as inferred from the first design).
PID = pid(0,0.001,0.001,.01); % initial guess for PID controllers ST0.removeBlock('SOF'); setBlockParam(ST0,'PI1',ltiblock.pid('C1',PID)); setBlockParam(ST0,'PI2',ltiblock.pid('C2',PID)); setBlockParam(ST0,'PI3',ltiblock.pid('C3',PID));
Retune the three PID controllers and plot the closedloop step responses.
[ST2,fSoft,~,Info] = systune(ST0,AllReqs);
Final: Soft = 4.96, Hard = Inf, Iterations = 64
T2 = getIOTransfer(ST2,{'thetaref','phiref','rref'},{'theta','phi','r'}); clf, step(T2,5)
The final value is no longer close to 1 and the step responses confirm the poorer performance with regard to rise time, overshoot, and decoupling. This suggests that the inner loop has an important stabilizing effect that should be preserved.