Guy on Simulink

Simulink & Model-Based Design

Control System Tuning without Guess or Stress

Posted by Guy Rouleau,

This week I am happy to welcome guest bloggers Pascal Gahinet, Suat Gumussoy, Erman Korkut, and Mathieu Cuenant to introduce systune and the new Control System Tuner app from Robust Control Toolbox.

Systune team

The Cure for Tuning Headaches

Simulink makes it easy to model and simulate feedback control systems. But how do you pick the gains of your controller to get adequate performance and robustness? Simple enough when tuning a single PI loop, harder for control systems with multiple loops, configurations, and operating conditions. You probably use a combination of know-how, experience, trial-and-error, and home-grown tools. Wouldn’t it be nice if you could just enter your specifications and let the computer figure out the gain values? Welcome to systune!

Tuning Workflow in Simulink

To see how this works, let’s tune a cascade controller for setting and regulating the speed of a DC motor. This controller consists of two feedback loops: an inner loop for controlling the current in the armature, and an outer loop for controlling the motor speed. Both loops use digital proportional-integral (PI) controllers, so there is a total of four gains to tune.

DC Motor Controller

The first step is to create a slTuner object for interacting with your Simulink model and to specify which blocks you want to tune:

ST0 = slTuner('DCMotor',{'SpeedController','CurrentController'});

Next, you list the signals and points of interest for tuning and validation. For example, the reference signal Ref and the output Speed will come handy for specifying how fast the control system should respond and for checking the actual response of the tuned system.

addPoint(ST0,{'Ref' , 'Speed' , 'SpeedMeas' , 'CurrentMeas'});

If these two steps look familiar, it’s because slTuner is just an extension of the slLinearizer interface we discussed in this earlier blog post.

Third and last step, you specify the tuning goals, that is, how the control system is supposed to perform. There is a lot to choose from, with goals ranging from tracking and disturbance rejection to loop shape, stability margins, and minimum closed-loop damping. For the DC motor application, I use the following goals:

  • Goal 1: The closed-loop system should respond to a step change in Speed setpoint with time constant of 0.05 seconds (rise time of about 0.1 seconds)
  • Goal 2: The inner (current) loop should have a bandwidth of about 200 Hz.

I use the StepResp and LoopShape objects from the TuningGoal library to express these goals:

Goal1 = TuningGoal.StepResp('Ref','Speed',0.05);
BandWidth = 2*pi*200;   % 200 Hz in rad/s
Goal2 = TuningGoal.LoopShape('CurrentMeas',BandWidth);
Goal2.Openings = 'SpeedMeas';

Note that the inner-loop bandwidth should be evaluated with the outer loop open, so I specify a loop opening at the location SpeedMeas in the Simulink model.

I can now launch the tuning algorithm:

ST1 = systune(ST0,[Goal1,Goal2]);
Final: Soft = 0.802, Hard = -Inf, Iterations = 60

Each tuning goal receives a normalized score and systune works on improving the overall score. A final score ≤ 1 means “pass” and a final score > 1 means “fail”. Here systune did well with a score of 0.8, and plotting the tuning goals confirms that the tuned responses are dead on spec:


Tuned System

The slTuner object ST1 represents the tuned control system and I can use it to access other system response for further validation. This is entirely similar to the slLinearizer workflow. For example, I can use getLoopTransfer to compute the stability margins of the current loop:

L = getLoopTransfer(ST1,'CurrentMeas',-1);
margin(L), grid on

Tuned System

When I am happy with the linear analysis results, I use writeBlockValue to push the tuned values of the PI gains to the Simulink model and perform additional validation in Simulink.


Tuned System

Control System Tuner App

With the new Control System Tuner app, you can do all the above without a single line of code! You launch this app from the “Analysis” menu in the Simulink model. Here is what it looks like:

Control System Tuner app

Now It’s Your Turn

There is a lot more you can do with systune and slTuner:

  • Tune any linear block in your model: Gain, PID Controller, Transfer Function, State Space, etc
  • Tune any control architecture, no matter the layout, number of feedback loops, and number or type of tuned blocks
  • Tune the controller against multiple models of the plant representing different operating conditions or parameter values
  • Tune gain-scheduled controllers. These are controllers whose gains vary with operating condition, for example, with engine speed in a diesel engine or air speed in an aircraft.

Check out the many examples and applications and try it on your control system. And as usual, we’d love to hear your thoughts!

Add A Comment

Your email address will not be published. Required fields are marked *

Preview: hide