image thumbnail

MPC Tutorial IV: DMC Simulink Block and Example

by

 

25 Sep 2009 (Updated )

A DMC Simulink block with a demonstration example based the MATLAB demo, heatex

Tutorial on Use of the DMC Simulink Block

Tutorial on Use of the DMC Simulink Block

This document explains how to use the DMC Simulink block.

Contents

Heat Exchanger

The example is based on the Matlab demo 'heatex'.

heatex

Step Test

To use the DMC block, the step response model of the plant to be controlled is required. For the heat exchanger example, this is done by replace the heatex_sim model with heatex_sim_steptest.

% Firstly, define the smapling time
Ts=1;

% Then copy the heatex_sim_steptest model to heatex_sim so that the heatex
% demo interface can communicate with the model.
bdclose('heatex_sim')
!copy heatex_sim_steptest.mdl heatex_sim.mdl
heatex

% Now set the system to be open-loop, then run the model
set_param('heatex_sim/Feedback Control C/FB on-off Switch','sw','0');
sim('heatex_sim')
bdclose('heatex_sim')

% change the sign of step response because the dmc model is configure as
% nagative feedback.
sr=-sr;     % negative feedback
        1 file(s) copied. 

Baseline PI Control

For comparison, let us run PI control model to set up the baseline for comparison.

!copy heatex_sim_pi.mdl heatex_sim.mdl
heatex
set_param('heatex_sim/Feedback Control C/FB on-off Switch','sw','1');
sim('heatex_sim')
bdclose('heatex_sim')
        1 file(s) copied. 

Dynamic Matricx Control

Now, let us try to simulate the DMC model

% Firstly, define the DMC parameters
p0=15/Ts;   % time delay
P=p0+10;
M=p0+4;
R=0.01;
alpha=0.3;  % setpoint smooth factor

% Then copy the DMC Simulink model to heatex_sim so that it can communicate
% with the heatex GUI.
!copy heatex_sim_dmc.mdl heatex_sim.mdl
heatex

% Switch on the controller, then do the simulation
set_param('heatex_sim/Feedback Control C/FB on-off Switch','sw','1');
sim('heatex_sim')
bdclose('heatex_sim')
        1 file(s) copied. 

Result Comparison

subplot(211)
t=0:Ts:200;
plot(t,y_dmc,'-',t,y_pi,'--','linewidth',2);
title(sprintf('IAE of DMC: %g, IAE of PI: %g',sum(abs(y_dmc))*Ts,sum(abs(y_pi))*Ts));
ylabel('Output')
legend('DMC','PI','Location','SouthEast')
subplot(212);
plot(t,u_dmc,'-',t,u_pi,'--','linewidth',2);
ylabel('Input')
xlabel('time')
legend('DMC','PI','Location','SouthEast')

Contact us