Main Content

Test an Existing MPC Controller with Simulink

This topic shows how to test an existing model predictive controller by adding it to a Simulink®model.

  1. Open your Simulink model.

  2. Add anMPC Controllerblock to the model.

  3. If your controller includes measured disturbances, add themdinport to theMPC Controllerblock.

    Double-click theMPC Controllerblock.

    In the Block Parameters dialog box, on theGeneraltab, selectMeasured disturbance (md).

    ClickOK.

  4. Connect the plant and controller signals in the Simulink model. Connect:

    • The plant inputs to the manipulated variable (mv) inport of theMPC Controllerblock.

    • The plant measured outputs to the measured output (mo) inport of theMPC Controllerblock.

    • The measured disturbances, if any, to the plant and to the measured disturbance (md) inport of theMPC Controllerblock.

    • 无边无际的干扰或无节制的输出to their corresponding plant inport and outport.

    • The reference signals to the reference (ref) inport of theMPC Controllerblock.

    • Connect any signal that you would like to visualize (such for example the plant outputs) toScope(Simulink)blocks.

  5. Specify the controller.

    Double-click theMPC Controllerblock.

    In the Block Parameters dialog box, in theMPC Controllerfield, specify the name of anmpccontroller from the MATLAB®workspace.

    ClickOK.

  6. (Optional) Modify the controller.

    After specifying a controller in theMPC Controllerblock, you can modify the controller:

    • UsingMPC Designer:

      • In the Block Parameters dialog box, clickDesign.

      • InMPC Designer, tune the controller parameters.

      • In theMPC Designertab, in theResultsection, clickUpdate and Simulate>Update Block Only.

        The app exports the updated controller to the MATLAB workspace.

    • Using commands to modify the controller object in the MATLAB workspace.

  7. Run the Simulink model. Verify that the simulation terminates without errors and that the signals in the loop behave as expected.

Tip

If you do not have a Simulink model of your plant, you can generate one that uses your MPC controller to control its internal plant model. For more information, seeGenerate Simulink Model from MPC Designer.

See Also

||

Related Topics