Documentation

Test an Existing Controller

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 an MPC Controller block to the model.

  3. If your controller includes measured disturbances, add the md inport to the MPC Controller block.

    Double-click the MPC Controller block.

    In the Block Parameters dialog box, on the General tab, select Measured disturbance (md).

    Click OK.

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

    • The plant inputs to the manipulated variable (mv) inport of the MPC Controller block.

    • The plant measured outputs to the measured output (mo) inport of the MPC Controller block.

    • The measured disturbances, if any, to the plant and to the measured disturbance (md) inport of the MPC Controller block.

    • Any unmeasured disturbances or unmeasured outputs to their corresponding plant inport and outport.

    • The reference signals to the reference (ref) inport of the MPC Controller block.

  5. Specify the controller.

    Double-click the MPC Controller block.

    In the Block Parameters dialog box, in the MPC Controller field, specify the name of an mpc controller from the MATLAB® workspace.

    Click OK.

  6. (Optional) Modify the controller.

    After specifying a controller in the MPC Controller block, you can modify the controller:

    • Using the MPC Designer app:

      • In the Block Parameters dialog box, click Design.

      • In the MPC Designer app, tune the controller parameters.

      • In the MPC Designer tab, in the Result section, click Update 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.

    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, see Generate Simulink Model from MPC Designer.

See Also

| |

Related Examples

Was this topic helpful?