← All articles

Multiloop PI Tuning in MATLAB and Simulink With systune

A technical illustration shows interconnected feedback loops beside a buck converter schematic and simulated response plots.

Short answer: To tune interacting loops in MATLAB and Simulink, mark the controllers as tunable blocks, add analysis points where you want to measure each loop, state a goal for each loop, and tune all the gains at once with the systune command or the Control System Tuner app. [2][3] The MathWorks buck converter example does this for a cascade of two discrete PI controllers on a 48 V to 12 V converter: an inner inductor current loop and an outer output voltage loop. It estimates the plant frequency response, fits a third-order model, asks for loop crossovers of 30,000 and 3,000 rad/s with 3 dB gain margin and 60 degree phase margin, and tunes both loops together. [1] The example's own output shows the goals were not all met, which it judges acceptable for stable operation, so always read the goal plots before trusting the gains. [1]

Why tune the loops together

In a cascade, the inner loop is part of the plant the outer controller sees, so changing one controller moves the other loop's response. MathWorks' tuning tools jointly tune all free parameters of a control system, whatever its architecture or number of loops. [4] Their goal library covers reference tracking, disturbance rejection, loop shapes, closed-loop damping and stability margins. [4]

The buck converter example makes the contrast explicit: it is based on an article that tunes the inner current loop and the outer voltage loop one at a time, while the example tunes both loops at the same time. [1]

systune or Control System Tuner

  • Control System Tuner is the interactive app. It tunes systems with any number of feedback loops and tunable parts of any structure, such as PID, gain or state-space blocks, and lets you set goals, view responses and validate the design graphically. [3]
  • systune can do all the same tuning tasks at the command line, which suits scripted, repeated tuning. It also supports tuning one controller for multiple plants and designing gain-scheduled controllers. [3]

Both work on a MATLAB generalized state-space (genss) model, or on a Simulink model through Simulink Control Design (the slTuner interface for systune). [3]

Worked example: buck converter cascade (R2026a)

The example uses Simulink, Simscape, Simscape Electrical, Simulink Control Design, Control System Toolbox and System Identification Toolbox. [1]

  1. Find a steady operating point. The Simscape Electrical model reaches steady state after about 0.007 s, so the example takes an operating point snapshot at 0.007 s. [1]
  2. Estimate the frequency response. A PRBS perturbation (order 11, one period, amplitude 0.05, sample time 1e-5 s) is injected at the duty cycle and measured at the current and voltage ADC blocks. The result is thinned to 50 frequency points between about 700 and 300,000 rad/s. [1]
  3. Fit a model. A third-order discrete state-space model with one input (duty cycle) and two outputs (inductor current and output voltage) is estimated with ssest. [1]
  4. Build the tunable loop. Two discrete PI blocks with trapezoidal integration are created with tunablePID, the outer one starting from Kp = 1 and Ki = 200 to speed convergence, and connected with the model into one multiloop system. [1]
  5. Set the goals and tune. systune is run with all four goals below enforced as hard goals. [1]
Goal Loop Setting
Loop shape Inner current loop, outer loop opened Crossover 30,000 rad/s [1]
Loop shape Outer voltage loop Crossover 3,000 rad/s [1]
Margins Inner current loop, outer loop opened 3 dB gain, 60 degree phase, 30,000 to 300,000 rad/s [1]
Margins Outer voltage loop 3 dB gain, 60 degree phase, 3,000 to 30,000 rad/s [1]

The run ends with a hard goal value of 1.6989 after 83 iterations. The example notes that the inner loop bandwidth came out slightly below target and its phase margin fell below target at some frequencies, and that the result is still sufficient for stable operation. [1]

Tuned gain Value
Current loop Kp 0.1392 [1]
Current loop Ki 1,870.3 [1]
Voltage loop Kp 0.0329 [1]
Voltage loop Ki 255.3382 [1]
  1. Verify in simulation. The gains are written to the Simulink PID blocks and both loops are closed. A load step at 0.008 s raises the load resistance from 6 to 12 ohms, and an input voltage step at 0.016 s drops the supply from 48 V to 40 V. MathWorks reports that the tuned controllers track the voltage reference and reject these disturbances well. [1] For a faster response it suggests raising the target bandwidth, and for better transients raising the target phase margin. [1]

A simpler cascade example (R2026b)

The "Tuning Multiloop Control Systems" example tunes a PI inner loop and a PID outer loop together with systune. The outer loop must reach at least 0.2 rad/s bandwidth and the inner loop ten times that, so the goals are loop shapes of 0.2/s and 2/s, with the outer loop opened when the inner goal is evaluated. [2] With the starting gains of 0.1 the loop is unstable. After tuning, the final value is 0.86, below 1, which means both loop-shape goals were met. [2] The tuned gains are then written back to Simulink with writeBlockValue for more thorough validation. [2]

What to check before you reuse the method

  • Read the goal value. A final value below 1 means the goals were met; above 1 means at least one was not, as in the buck example. Look at the goal plots to see which one.
  • Open the outer loop for inner goals. Both examples open the outer loop when they evaluate the inner loop's goals.
  • Tune at a real operating point. The buck example estimates its model at a steady-state snapshot; a different load or input voltage may need a new estimate.
  • Test disturbances in the full model. Frequency-domain goals do not replace a time-domain check with load and supply steps.
  • Have a qualified engineer review the gains before they run on hardware.

For planning the order of cascade tuning, see planning cascade controller tuning. For power converter loops, see global eigenvalue sensitivity weighting for power electronic controller tuning. When gains must change with the operating point, see PID gain scheduling and multi-loop verification.

Limits

  • Both examples are simulations. The MathWorks pages report no hardware results.
  • The buck converter gains belong to that Simscape model and operating point; they are not general converter settings.
  • The buck example needs six MathWorks products, including Simscape Electrical and System Identification Toolbox. [1]

Key takeaways

  • Tune interacting loops together against goals for each loop, with systune or Control System Tuner. [2][3]
  • The buck converter example goes from frequency response estimation to a third-order model, four hard goals and jointly tuned current and voltage PI gains. [1]
  • Its goals were not all met, and the example says so; a final value below 1 is what confirms that every goal is satisfied. [1][2]
  • Verify the tuned gains with disturbance steps in the full simulation before going further. [1]

Frequently asked questions

How do I tune multiple loops at once in MATLAB?

Model the controllers as tunable blocks, mark analysis points for each loop, define tuning goals such as loop shapes and stability margins, and run systune or the Control System Tuner app, which tune all free parameters together. [2][3][4]

What is the difference between systune and Control System Tuner?

Control System Tuner is the interactive app; systune does the same tuning tasks at the command line, which suits scripts and repeated runs, and also supports multiple plants and gain-scheduled designs. [3]

What does the MathWorks buck converter example tune?

Two discrete PI controllers in cascade on a 48 V to 12 V Simscape Electrical buck converter: an inner inductor current loop and an outer output voltage loop, tuned together with systune against loop-shape and margin goals. [1]

What does a systune final value above 1 mean?

That at least one goal was not fully met. In the buck converter example the hard goal value was 1.6989, and the inner loop fell slightly short of its bandwidth and phase margin targets. [1][2]

Sources

  1. MathWorks. "Multiloop Control Design for Buck Converter." Simulink Control Design documentation, R2026a. https://www.mathworks.com/help/releases/R2026a/slcontrol/ug/multiloop-pi-control-design-buck-converter.html
  2. MathWorks. "Tuning Multiloop Control Systems." Control System Toolbox documentation, R2026b. https://www.mathworks.com/help/releases/R2026b/control/ug/tuning-multi-loop-control-systems.html
  3. MathWorks. "Choosing an Automated Tuning Approach." Control System Toolbox documentation, R2026b. https://www.mathworks.com/help/releases/R2026b/control/ug/choosing-an-automated-tuning-approach.html
  4. MathWorks. "Automated Tuning Overview." Control System Toolbox documentation, R2026b. https://www.mathworks.com/help/releases/R2026b/control/ug/automated-tuning-overview.html

If you have a model or IO data for one of your own loops, LabCD's guided workflow lets you tune and test a controller on your first model for free, with a qualified engineer approving every controller.

Want to try this on your own plant model?

Try LabCD free with your first model