Temperature Control for an Electrical Water Heater by ...Jang LK (2018) Temperature Control for an...

11
Central Chemical Engineering & Process Techniques Cite this article: Jang LK (2018) Temperature Control for an Electrical Water Heater by LabVIEW’s Model Predictive Control (MPC) Tool Kit. Chem Eng Process Tech 4(1): 1053. *Corresponding author Larry K. Jang, Department of Chemical Engineering, California State University, Long Beach, CA, USA, Tel: 908-405-103, Email: Submitted: 23 April 2018 Accepted: 18 May 2018 Published: 22 May 2018 ISSN: 2333-6633 Copyright © 2018 Jang OPEN ACCESS Keywords Model predictive control; Labview; MPC; Temperature control; Tuning rule; Loop pro; PID Research Article Temperature Control for an Electrical Water Heater by LabVIEW’s Model Predictive Control (MPC) Tool Kit Larry K. Jang* Department of Chemical Engineering, California State University, Long Beach, CA, USA Abstract The temperature of water leaving a bench-top continuous-flow electrical heater is regulated by an algorithm developed in this work using the model predictive control (MPC) toolkit in LabVIEW. Hardware from National Instruments (Compact Rio with associated modules for analog input, analog output, digital output, and Internet communication) allows the system to be accessed and controlled remotely via Internet. Open-loop process dynamics around a desired operating condition is analyzed by fitting step response data to the first-order-plus-dead-time model using Loop Pro. The prediction horizon is set at about one time constant and the control horizon at half the prediction horizon. With the weighting factor Q for the output error fixed at 1.0 and the weighting factor R for the control action change varied between 0.5 and 50 in the cost function, the results of setpoint-tracking and disturbance rejection experiments are analyzed. The construction of the front panel and the wire diagram of the LabVIEW algorithms are described in the greatest possible details in this work. INTRODUCTION Traditional feedback controllers operate by adjusting controller output (or the manipulated variable MV) in response to a change in the setpoint of process variable (PV, or the controlled variable) and/or the disturbance variable (sometimes called process load). One of the most commonly used control algorithm is proportional-integral-derivative (PID) control, in which the control action is adjusted according to the extent of the current error ( (PV) set point - (PV) ), the integration of past errors, and the rate of change of current error. PID control is a very mature technology and many straightforward tuning rules have been developed for tuning PID controllers. In the 1980’s, industry started to accept control strategies based on model predictive control (MPC) since its introduction in the early 1960’s. The first known industrial application of linear MPC was known as dynamic matrix control (DMC) [1]. Detailed review of development and recent status of MPC and DMC has been reported in the literature [2]. The philosophy of MPC is very different from PID control. MPC is a technique that focuses on constructing controllers that can adjust the MV to follow PV setpoint even before the PV setpoint (or disturbance variable) actually changes. MPC is aiming at the prediction of future PV’s with the future control actions determined by the MPC controller. Propoi introduced the idea of a moving horizon approach to the optimization problem, which has since become the foundation of all MPC implementations [2,3]. Process dynamic models are used to predict the PV’s for N p steps (called prediction horizon) into the future using the MPC controller. Within the prediction horizon, the MPC controller computes the needed control action for N c steps (control horizon) into the future; the control action does not change after the control horizon ends. The MPC controller calculates a sequence of control action such that a cost function is minimized. Once this sequence of control action is computed, only the first step is actually implemented. Then, the prediction horizon and the control horizon move one step ahead. The controller collects data of PV, PV setpoint, and the disturbance variable, and recalculates the needed control action for next N c steps and the predicted PV’s for the next N p steps. The whole process repeats and the prediction horizon and the control horizon advance for one step after every cycle of computation and implementation are completed. The MPC controller computes a sequence of N c steps of future control action needed and predicts the future PV’s based on the principle of minimization of a cost function. For the simple single- input-single-output (SISO) case, the user needs to specify the values of weighting factors in the cost function. These weighting factors specify the relative priority pertinent to [(PV) setpoint - (PV)] (termed “output error” by some authors), rate of change in control action, and/or the error in control action. For multiple- input-multiple-output (MIMO) systems, these cost weights are matrices. Detailed mathematical expression for the cost function and its minimization theory are available in the literature and they are not presented in this work. Note that the weights in the cost function affect the sensitivity of the control action in MPC, very much like how proportional gain, integral time, and derivative time affect the sensitivity of a PID controller.

Transcript of Temperature Control for an Electrical Water Heater by ...Jang LK (2018) Temperature Control for an...

Page 1: Temperature Control for an Electrical Water Heater by ...Jang LK (2018) Temperature Control for an Electrical Water Heater by LabVIEW’s Model Predictive Control (MPC) Tool Kit. Chem

Central Chemical Engineering & Process Techniques

Cite this article: Jang LK (2018) Temperature Control for an Electrical Water Heater by LabVIEW’s Model Predictive Control (MPC) Tool Kit. Chem Eng Process Tech 4(1): 1053.

*Corresponding author

Larry K. Jang, Department of Chemical Engineering, California State University, Long Beach, CA, USA, Tel: 908-405-103, Email:

Submitted: 23 April 2018

Accepted: 18 May 2018

Published: 22 May 2018

ISSN: 2333-6633

Copyright© 2018 Jang

OPEN ACCESS

Keywords•Model predictive control; Labview; MPC;

Temperature control; Tuning rule; Loop pro; PID

Research Article

Temperature Control for an Electrical Water Heater by LabVIEW’s Model Predictive Control (MPC) Tool KitLarry K. Jang*Department of Chemical Engineering, California State University, Long Beach, CA, USA

Abstract

The temperature of water leaving a bench-top continuous-flow electrical heater is regulated by an algorithm developed in this work using the model predictive control (MPC) toolkit in LabVIEW. Hardware from National Instruments (Compact Rio with associated modules for analog input, analog output, digital output, and Internet communication) allows the system to be accessed and controlled remotely via Internet. Open-loop process dynamics around a desired operating condition is analyzed by fitting step response data to the first-order-plus-dead-time model using Loop Pro. The prediction horizon is set at about one time constant and the control horizon at half the prediction horizon. With the weighting factor Q for the output error fixed at 1.0 and the weighting factor R for the control action change varied between 0.5 and 50 in the cost function, the results of setpoint-tracking and disturbance rejection experiments are analyzed. The construction of the front panel and the wire diagram of the LabVIEW algorithms are described in the greatest possible details in this work.

INTRODUCTIONTraditional feedback controllers operate by adjusting

controller output (or the manipulated variable MV) in response to a change in the setpoint of process variable (PV, or the controlled variable) and/or the disturbance variable (sometimes called process load). One of the most commonly used control algorithm is proportional-integral-derivative (PID) control, in which the control action is adjusted according to the extent of the current error ( (PV)set point - (PV) ), the integration of past errors, and the rate of change of current error. PID control is a very mature technology and many straightforward tuning rules have been developed for tuning PID controllers. In the 1980’s, industry started to accept control strategies based on model predictive control (MPC) since its introduction in the early 1960’s. The first known industrial application of linear MPC was known as dynamic matrix control (DMC) [1]. Detailed review of development and recent status of MPC and DMC has been reported in the literature [2].

The philosophy of MPC is very different from PID control. MPC is a technique that focuses on constructing controllers that can adjust the MV to follow PV setpoint even before the PV setpoint (or disturbance variable) actually changes. MPC is aiming at the prediction of future PV’s with the future control actions determined by the MPC controller. Propoi introduced the idea of a moving horizon approach to the optimization problem, which has since become the foundation of all MPC implementations [2,3]. Process dynamic models are used to predict the PV’s for Np steps (called prediction horizon) into the future using the MPC

controller. Within the prediction horizon, the MPC controller computes the needed control action for Nc steps (control horizon) into the future; the control action does not change after the control horizon ends. The MPC controller calculates a sequence of control action such that a cost function is minimized. Once this sequence of control action is computed, only the first step is actually implemented. Then, the prediction horizon and the control horizon move one step ahead. The controller collects data of PV, PV setpoint, and the disturbance variable, and recalculates the needed control action for next Nc steps and the predicted PV’s for the next Np steps. The whole process repeats and the prediction horizon and the control horizon advance for one step after every cycle of computation and implementation are completed.

The MPC controller computes a sequence of Nc steps of future control action needed and predicts the future PV’s based on the principle of minimization of a cost function. For the simple single-input-single-output (SISO) case, the user needs to specify the values of weighting factors in the cost function. These weighting factors specify the relative priority pertinent to [(PV) setpoint - (PV)] (termed “output error” by some authors), rate of change in control action, and/or the error in control action. For multiple-input-multiple-output (MIMO) systems, these cost weights are matrices. Detailed mathematical expression for the cost function and its minimization theory are available in the literature and they are not presented in this work. Note that the weights in the cost function affect the sensitivity of the control action in MPC, very much like how proportional gain, integral time, and derivative time affect the sensitivity of a PID controller.

Page 2: Temperature Control for an Electrical Water Heater by ...Jang LK (2018) Temperature Control for an Electrical Water Heater by LabVIEW’s Model Predictive Control (MPC) Tool Kit. Chem

Central

Jang (2018)Email:

Chem Eng Process Tech 4(1): 1053 (2018) 2/11

The purpose of this work is not to present results of simulation nor advanced theoretical analysis of MPC, as many works have already appeared in the literature [2,4-11]. The main objective of this work is to demonstrate how MPC may be applied to a real-world bench-top experimental device using MPC toolkit of LabVIEW from National Instruments. The procedure outlined in this work is suitable for beginning engineering students and/or practicing engineers who want to gain practical hands-on experience of building and tuning a MPC controller for a real-world device. To simply matters, the author selected a SISO case, in which the value of cost weight Q for “output error” may be arbitrary chosen as 1.0 and the cost weight R for rate of change of control action is varied between 0.5 and 50 (relative to Q). Experimental results are compared and simplified tuning protocols are highlighted.

THE SYSTEMThe original system is a bench-top flow, temperature, and

liquid level control unit in the instructional laboratory in the author’s department. In recent years, the author retired the antiqued control system running on outdated QBasic algorithm and upgraded the communication and control system with Compact Rio (and associated modules for signal transmission) from National Instruments (NI) Corp. The communication module is connected to the departmental subnet, so that students running the experiments may get access to the system from any departmental computers. The author designed the feedback control systems for various unit operations in the laboratory using the PID control toolkit and the model predictive control (MPC) toolkit of NI LabVIEW. The picture of the device is shown in Figure 1.

For the upgraded temperature-flow-level unit, flow control is accomplished by a separate feedback algorithm designed by the author using NI LabVIEW’s PID control toolkit. In the algorithm of flow control, the analog signal (in the range of 0.004-0.020 Amp, denoted as (flow)amp) from the flow sensor (a differential pressure transducer attached to an orifice meter) is fed to the analog input module and converted by the formula

( ) 0.004(% max ) 100*

0.020 0.004ampflow

q flow−

=−

(1)

to express the flow rate in % maximum, where 100 % max flow rate corresponds to 0.5 gallon per minute calibrated by the original vendor. In Equation 1, the square root operation is needed because the range of the analog signal 0.004-0.020 Amp is linear with respect to 0-100 % pressure drop across the orifice meter, while the flow rate is proportional to the square root of the pressure drop across the orifice meter. The final control element of the flow control loop is an air-to-open, direct-acting pneumatic control valve. The valve is driven by compressed air of 3-15 psig pressure from an I/P transducer, which is connected to the analog output module of Compact Rio that provides feedback signal in the range of 0.004-0.020 Amp. From the past experience, PI control parameters Kc = 0.5 and τI = 0.1 minute offer satisfactory feedback control for the flow rate. The details of the design of the PID algorithm are not described here.

Water at ambient temperature is introduced to a vertical cylinder in which an electrical heater is installed. The temperature of water leaving the cylinder is measured by a thermocouple, which is connected to the internal circuit of the original system that produces an analog signal of 0.004-0.020 Amp corresponding linearly to water temperature of 20-120oF. This signal is fed to the analog input module of the Compact Rio unit. Digitized data is then sent via Internet network to the host computer. MPC algorithm computes the needed control action and the feedback signal travels in the opposite direction to arrive at the analog output module of the Compact Rio unit. Water temperature can then be regulated by adjusting the power supplied to the electrical heater based on the 0.004-0.020 Amp signal from the analog output module, as computed by the algorithm designed in this work using NI LabVIEW’s MPC toolkit.

The LabVIEW algorithm for controlling temperature of water leaving the heater is modified from the case stated in the LabVIEW manual [12] . Every LabVIEW algorithm is composed of two parts: (1) the front panel for operators to give instructions and results to be displayed, and (2) the wire diagram that contains math operations, flow of signals in the algorithm, and other necessary commands.

The LabVIEW front panel for the temperature control algorithm is given in Figure 2. To consolidate the front panel, “tabs” are created to organize front panel icons. Note that in Figure 2, only the tab containing commands for implementing the MPC controller is shown. Other tabs containing other functions will be described later.

The wire diagram of the MPC portion is given in Figure 3. The following vi’s (virtual instruments or subprograms) from NI LabVIEW’s MPC toolkit are used in the design of the temperature control algorithm:

CD_Create Transfer Function Model.vi

CD_Convert Transfer Function to State-Space Model.vi

CD_Convert Continuous to Discrete (ss).vi

CD_Draw State-Space Equation.vi

CD _Create MPC Controller (Dual).vi

CD _Set MPC Controller (Dual).vi

CD _Update MPC Window (Multiple).vi

CD _Implement MPC (MIMO).vi

The algorithm is constructed inside the “While Loop” with frequency of implementation set at 1 per second. Details about the construction of the algorithm are not described here. However, the author is very willing to make this temperature control algorithm available to interested readers upon request. One major difference between the algorithm designed in this work and the example in LabVIEW manual [12], is that the “shift registers” are removed because modern “While Loop” structure retains the most recent values of all variables as computation progresses. Therefore, there is no need to include shift registers in the wire diagram to pass data between steps of computation for this temperature control algorithm in this work.

Page 3: Temperature Control for an Electrical Water Heater by ...Jang LK (2018) Temperature Control for an Electrical Water Heater by LabVIEW’s Model Predictive Control (MPC) Tool Kit. Chem

Central

Jang (2018)Email:

Chem Eng Process Tech 4(1): 1053 (2018) 3/11

EXPERIMENTAL PROCEDURE

Step test for obtaining process model

To obtain process dynamic model, a step test is performed in the following manner:

(1) Open and run the PID control algorithm for flow control designed in this work. The solenoid valve of water supply is instructed to open by clicking the switch “Open the Solenoid Valve” from the front panel of the LabVIEW algorithm (not shown here), which is connected to the appropriate channel of the digital output module of Compact Rio.

(2) The pneumatic flow control valve is instructed to open by 50% in the manual mode. Flow rate is set at the desired value. Then the flow control is switched to the automatic mode (with flow rate set point = 30%, Kc = 0.5 and τI = 0.1 min).

(3) Open and run the MPC algorithm for temperature control designed in this work. The relay of the power supply to the heater is turned on by clicking “Turn on the Heater” switch on the front panel of the MPC algorithm.

(4) Heater output is initially set at 1 % maximum. When the steady-state temperature is established, heater output (the control action or manipulated variable) is increased to 11 % and the response of water temperature to this step change of controller output (111 %) is recorded by using the “Write to Spreadsheet” function of LabVIEW.

(5) The step response data is imported into the “Design Tool” of another simulation program Loop Pro (product of Control Station, Inc). The heater output is the manipulated variable (MV) and the temperature of water leaving the heater is the process variable (PV) for data fitting by Loop Pro. The user will then need to choose an appropriate dynamic model. The first-order-plus-dead-time (FOPDT) model is chosen based on the pattern of response. Finally, click “fit the model” and the result of model fitting is obtained (Figure 4). The process model parameters are process gain Kp = 0.251, first-order time constant τp = 46.3 seconds, and dead time θp = 7.77 seconds

(6) Repeat steps (3)-(5) by making a step change of heater output from 11 to 21 % and record the response of water temperature (Figure 5). The response data fit the FOPDT model with the model parameters: Kp = 0.262, τp = 30.5, θp = 8.39 seconds. By averaging the respective parameters obtained in steps (5) and (6), the following model parameters are used in this work: Kp = 0.257, τp = 38.4 seconds, θp = 8.06 seconds. The transfer function for the process model to be used in MPC (at water flow rate of 30% maximum)is

( )8.060.257

1 38.4 1

θ

t

− −∆= = =∆ + +

ps sp

pp

K eT eG su s s

(2)

where T is the temperature of water leaving the heater and u is the control action (heater output or manipulated variable) in % max, the symbol ∆ means the size of change.

Parameters for MPC controller

While the MPC algorithm is still running in the manual

Figure 1 Bench-top device for flow/temperature control. The arrow sign shows the direction of water flow. 1. Compact Rio2. Solenoid valve for inlet water 3. ½” brass pipe4. Differential pressure transducer connected to an orifice meter in

the inlet water pipeline 5. 0.004-0.020 Amp signal wire to the analog input module of

Compact Rio6. Feedback signal (0.004-0.020 Amp) from the analog output module

of Compact Rio computed by the PID algorithm for the flow loop7. I/P transducer that converts source compressed air (30 psig) to

3-15 psig according to the signal strength of 5.8. Air-to-open pneumatic control valve9. Thermocouple measuring the outgoing temperature of water,

which is in turn converted to 0.004-0.020 Amp analog signal corresponding linearly to 20-120°F by the circuit behind the unit

10. Electrical current supplied to the electrical heater according to the analog signal (0.004-0.020 Amp) from the analog output module of Compact Rio computed by the MPC algorithm for the temperature loop

11. Electrical heater12. Relays that turns the solenoid valve and the electrical heater

on/off according to the signal from the digital output module of Compact Rio

mode and with the dynamic model and model parameters as determined above, the tabs on the front panel of the MPC algorithm are clicked in sequence and values of the parameters are entered to the appropriate spaces:

Tab for conversion of transfer function to state-space model (Figure 6)

Enter the values of process model (Equation 2) to the spaces for the numerator, the denominator, and the delay for the transfer function. Since the loop rate, the unit of time in the process model, and the step size in the MPC algorithm are all chosen at 1 second, the values of the first-order time constant and the delay (dead time) are the same as those in the process model. Note that in LabVIEW, transfer functions must be entered in ascending order of the Laplace parameter s.

After the parameters of the dynamic model are entered to the transfer function, it will be converted to the discrete state-space model automatically as shown in the lower right corner of Figure 6. The discrete state-space model is needed in the

Page 4: Temperature Control for an Electrical Water Heater by ...Jang LK (2018) Temperature Control for an Electrical Water Heater by LabVIEW’s Model Predictive Control (MPC) Tool Kit. Chem

Central

Jang (2018)Email:

Chem Eng Process Tech 4(1): 1053 (2018) 4/11

Figure 2 Front panel of the LabVIEW algorithm for the model predictive controller designed in this work.

Figure 3 Wire diagram of the LabVIEW algorithm for the model predictive controller designed in this work.

implementation of MPC.

Tab for cost weighting (Figure 7)

Since this is a single-input-single-output (SISO) case and only the output error weighting factor Q and the control action change weighting factor R are considered in this work, the value of Q is set at 1.0 and the value of R is set at various values (0.5-50, relative to Q).

Tab for parameters for the MPC controller (Figure 8)

In this work, prediction horizon Np is set at 30 steps (or 30 seconds), control horizon Nc is set at 15 steps (or 15 seconds). Integral action is turned on. Note that one may choose different lengths in the prediction horizon and/or the control horizon. Although there are theories that would recommend much longer prediction horizon and control horizon, this work chooses the prediction horizon at just about one time constant and the control

Page 5: Temperature Control for an Electrical Water Heater by ...Jang LK (2018) Temperature Control for an Electrical Water Heater by LabVIEW’s Model Predictive Control (MPC) Tool Kit. Chem

Central

Jang (2018)Email:

Chem Eng Process Tech 4(1): 1053 (2018) 5/11

Figure 4 Step response data of water temperature as the control action (that regulates heat supply rate) is increased from 1 to 11 %. The data is fitted to the first-order-plus-dead-time model by Loop Pro. Best-fit results of Kp = 0.251, τp = 46.3 seconds, and θp = 7.77 seconds are obtained.

Figure 5 Step response data of water temperature as the control action (that regulates heat supply rate) is increased from 11 to 21 %. The data is fitted to the first-order-plus-dead-time model by Loop Pro. The best-fit results are Kp = 0.262, τp = 30.5, θp = 8.39. By averaging the respective parameters in Figures 4 and 5, the following model parameters are used in this work: Kp = 0.257, τp = 38.4 seconds, θp = 8.06 seconds.

Figure 6 The tab in the front panel that shows the conversion of transfer function (Laplace domain) into discrete space-state model.

Page 6: Temperature Control for an Electrical Water Heater by ...Jang LK (2018) Temperature Control for an Electrical Water Heater by LabVIEW’s Model Predictive Control (MPC) Tool Kit. Chem

Central

Jang (2018)Email:

Chem Eng Process Tech 4(1): 1053 (2018) 6/11

Figure 7 The tab in the front panel that allows the user to enter desired cost weighting factors of Q and R.

Figure 8 The tab in the front panel that allows the user to enter desired lengths (or time steps) of prediction horizon (= 30) and control horizon (= 15).

horizon at half of the prediction horizon. The rationale for such choices will be discussed later.

After all parameters are entered, desired values of the initial control action (i.e., initial heating rate in % maximum) are entered to the “Manual Heat Input” box of the front panel (Figure 2). Observe the condition of the system and set desired temperature setpoint. Start to save data on the appropriate file by entering

file location to the “file path” box on the front panel. Then click the button “Auto?” to switch the operation of the system to the automatic control mode. Observe the system performance in setpoint tracking while water flow rate is maintained at 30%. After the temperature setpoint is reached, change the flow rate setpoint on the separate PID algorithm to disturb water flow rate (to 40%, for example). Continue to observe the performance of

Page 7: Temperature Control for an Electrical Water Heater by ...Jang LK (2018) Temperature Control for an Electrical Water Heater by LabVIEW’s Model Predictive Control (MPC) Tool Kit. Chem

Central

Jang (2018)Email:

Chem Eng Process Tech 4(1): 1053 (2018) 7/11

Figure 9 Experimental results showing the performance of the MPC controller in tracking temperature setpoint and rejecting disturbance at Q = 1 and R = 0.5.

Figure 10 Experimental results showing the performance of the MPC controller in tracking temperature setpoint and rejecting disturbance at Q = 1 and R = 1.

Figure 11 Experimental results showing the performance of the MPC controller in tracking temperature setpoint and rejecting disturbance at Q = 1 and R = 5.

Figure 12 Experimental results showing the performance of the MPC controller in tracking temperature setpoint and rejecting disturbance at Q = 1 and R = 10.

Figure 13 Experimental results showing the performance of the MPC controller in tracking temperature setpoint and rejecting disturbance at Q = 1 and R = 25.

Figure 14 Experimental results showing the performance of the MPC controller in tracking temperature setpoint and rejecting disturbance at Q = 1 and R = 50.

Page 8: Temperature Control for an Electrical Water Heater by ...Jang LK (2018) Temperature Control for an Electrical Water Heater by LabVIEW’s Model Predictive Control (MPC) Tool Kit. Chem

Central

Jang (2018)Email:

Chem Eng Process Tech 4(1): 1053 (2018) 8/11

the system in rejecting disturbance (change in water flow rate) and record data.

RESULTS

Dynamic model

The first-order-plus-dead-time model that fits the step response data gives average values of Kp = 0.257 (oF/%), τp = 38.4 seconds, and θp = 8.06 seconds, for two step inputs (1 11%, and 11-21 % of heat supply) (Equation 2). Note that in the real world, dynamic models are not always precise. It is recognized that the model parameters may vary with operating condition. It is also assumed that possible disturbances (such as fluctuation of flow rate, inlet water temperature, and even power supplied to the electrical heater) are negligible during the step tests. In case additional information on model parameters is available, the operator can always input the new model parameters. However, as long as a reasonably good model is available, one may implement MPC satisfactorily.

The top portion of the wire diagram in Figure 3 deals with the conversion of transfer function in the Laplace domain to the discrete state-space model. “First Order Hold” method is chosen in predicting the condition of the next step. Sampling time of 1 second is chosen for calculation. The resultant discrete state-space model is shown in the lower right corner of Figure 6:

( ) [ ] ( ) [ ]1 0.974294 0.987091 ( )x k x k u k+ = + (3)

( ) [ ] ( ) [ ]0.00669271 0 ( )y k x k u k= + (4)

where x(k) is the state variable at step k, u(k) is the control action at step k, x(k+1) is the estimated state variable for the next step (k+1), and y(k) it the “output”, corresponding to the estimated PV or temperature in this case. The above conversions can be verified as follows: The continuous transfer function without dead time in the Laplace domain in Eq. 2 is converted to a continuous state-space model in the time domain

( ) ( )( ) p

p

Ky t T t x t

t= ∆ =

(5)

1 ( ) ( )t−

= = + ∆

p

dxx x t u tdt

(6)

In the standard format of state-space model

[ ] [ ]= + ∆ A x Bx u

(7)

[ ] [ ]y C x D u= + ∆

(8)

where the coefficient matrices [A], [B], [C], and [D] are scalar quantities in the SISO case with first-order process model. By comparing Equation 2 and Equation 5-8, we have [A] = -0.0260417. [B] = 1, [C] = 0.00669271, [D]= 0. Then the continuous state-space model is converted to discrete state-space model using zero-order hold method with step size of 1 second [12]

( )

( ) ( )

( )

1*1

0

1, 1 1

,

0.974294 0.987091 ( )

t t

+

= + ∆

= + ∆

th

A th A

x k at step or second after the k step

e x k at the k step B u k e d

x k u k (9)

The results of analysis above agree with those converted by LabVIEW’s MPC algorithm (Figure 6). It is noted that in the actual implementation, the length of model dead time is entered as “delay” in the front panel of “conversion of TF to State Space” tab (Figure 6).

Implementation of model predictive control

With the water flow rate controlled at the desire value and the discrete state-space model created, one may start to implement MPC. In this work, the author tested the performance of the MPC controller in this flow-through electrical heater by setting Q = 1

Figure 15 Setpoint-tracking followed by disturbance rejection using feedback PID control at Kc = 7.45 (% /°F) and τI = 0.64 min according to IMC tuning rule at τc = 0.20 minute (more aggressive tuning).

Figure 16 Setpoint-tracking followed by disturbance rejection using feedback PID control at Kc = 3.00 (% / oF) and τI = 0.64 min according to IMC tuning rule at τc = 0.70 minute (less aggressive tuning).

Page 9: Temperature Control for an Electrical Water Heater by ...Jang LK (2018) Temperature Control for an Electrical Water Heater by LabVIEW’s Model Predictive Control (MPC) Tool Kit. Chem

Central

Jang (2018)Email:

Chem Eng Process Tech 4(1): 1053 (2018) 9/11

and R varied between 0.5 and 50 (Figures 9-14). Each Figure is composed of two sections-setpoint tracking (with fixed water flow rate of 30% while changing temperature setpoint), followed by disturbance rejection (with temperature setpoint fixed while the water flow rate is changed from 30% to 40%). From Figures 8-13, it is clear that at R = 0.5, the response is very oscillatory. As the R value is increased beyond 1.0, the control action is less aggressive and the response becomes less oscillatory. As a matter of fact, no noticeable difference in the response patter is observed for R of 10 or greater. It is also observed that while the temperature has not yet reached the setpoint value, the controller output actually started to decrease. This is a clear demonstration of the predictive behavior of the MPC controller.

DISCUSSION

MPC control

One major challenge in the implementation of MPC is that this method has a large number of tunable parameters (dynamic model parameters, loop rate, prediction horizon, control horizon, model horizon, cost weights, etc). This paper is not intended to perform any numerical simulations nor has theoretical analysis because much published work already existed in the literature. Instead, the author would like to demonstrate how MPC controllers may be applied to a real-world device using LabVIEW technology. The results of this work suggest rather simple and straightforward tuning rules:

• As contrary to the school of thought that prediction needs to be done for sufficiently long time, this work only uses prediction horizon for about one time constant. It is known that for a pure first order process undergoing step response, the PV would respond by 63.2% after one time constant. It is recommended that the length of prediction horizon be set according to the needs of the system. In general, a short prediction horizon reduces the length of time during which the MPC predicts the PV. Therefore, a very short or zero prediction horizon makes MPC controller to function like a traditional feedback controller. Although a long prediction horizon increases the predictive ability of the MPC controller, the performance of the MPC controller would be decreased due to extra calculations needed. As shown by the results from this work, prediction horizon of about one time constant is likely to be adequate for practical applications.

• As far as the control horizon is concerned, a short control horizon would result in a few careful changes in control action. Since the control action stops changing after the control horizon is ended, a large control action at the end of the control horizon

may cause the response of PV to overshoot. On the contrary, a long control horizon produces more aggressive changes in control action, which may result in oscillatory response of PV and the control action. The result of this work suggests that the control horizon at about half the prediction horizon offers excellent response patterns.

In a recent review article by Garriga and Sorush [2], a large number of literature articles are reviewed and general tuning guidelines are provided. Again, due to the large number of tunable parameters in various kinds of model-based control (such as DMC and other methods), there are many tuning guidelines available [13-16]. But it may be difficult for beginning users to find straightforward tuning methods (like PID turning rules) for practical applications. In this work, it is discovered that after the cost weighting factor R increases beyond 1, the control action is reasonably fast without vigorous oscillation. Since the cost weighting factor Q is chosen as 1, the nature of R in this SISO case is very similar to the suppression coefficient λ in DMC. Smaller values of R would produce a more aggressive control action and it is true vice versa. It is proposed that λ be set at Γ* Kp

2, where Γ is set at 10 or higher [3]. If we adopt this rule, then the value of R (or λ) would be set at 10 * (0.257)2 ~ 0.66 or higher. This may explain that the MPC controller used in this work offers satisfactory performance at R value of 1 or higher. It is therefore proposed that for SISO where the cost weighting factor Q = 1, the cost weighting factor R may be set at Γ * Kp

2, where Γ is set at 10 or higher. More work needs to be done in order to establish more concrete, straightforward tuning guideline in this respect.

In the wire diagram (Figure 3), SISO is chosen for the [CD_Create Transfer Function Model.vi] primarily because only the process dynamic model at 30% flow rate is needed for the setpoint-tracking case. Such a simple structure offers satisfactory performance for disturbance rejection (when water flow rate is increased from 30 to 40%). In the future, the MPC controller may be expanded by choosing MIMO in the [CD_Create Transfer Function Model.vi] to include disturbance model (s) (generated by fixing the control action while making a step change in water flow rate]. The MPC controller would then offer inherent ability to reject disturbances without using strategies like decoupling PID (for MIMO) or feed forward PID (for SISO) in the traditional feedback control [17]. It may be needed to further fine-tune the process model (s) as water flow rate varies. In the MIMO case, not only the transfer functions but also the associated tuning parameters (like Q and R) will become matrices. Relative priorities between setpoint tracking and disturbance rejection would impact the selection of Qij and Rij.

PID control

The author created a separate feedback control algorithm using LabVIEW PID Toolkit for this device. The detailed LabVIEW algorithm is not shown here. The author is very willing to share the algorithm with the community upon request. With the dynamic model (Equation 2) at 30 % water flow rate, a variety of tuning rules may be used to obtain suggested values of PID controller settings. If internal model control (IMC) tuning method is chosen, Table 1 shows the PI-controller settings at a few selected values of the desired closed-loop time constants τc. As generally recognized, the process variable would reach the new

Table 1: PI-controller settings using IMC tuning rule for a few selected τc values.

τc (min) Kc (% / oF) tI (min)

0.10 10.63 0.64

0.20 7.45 0.64

0.30 5.73 0.64

0.70 3.00 0.64

1.00 2.20 0.64

Page 10: Temperature Control for an Electrical Water Heater by ...Jang LK (2018) Temperature Control for an Electrical Water Heater by LabVIEW’s Model Predictive Control (MPC) Tool Kit. Chem

Central

Jang (2018)Email:

Chem Eng Process Tech 4(1): 1053 (2018) 10/11

setpoint value after four or five time constants. The proportional gain Kc and the integral time τI are calculated as [18(a)]

1 pc

p c p

KK

tt θ

=+

(10)

I pt t= (11)

If Cohen-Coon tuning rule is chosen to tune the PI-controller [18(b)]

%0.9 17.0012

p pc o

p p p

KK Ft θθ t

= + = (12)

330

0.31 209

θθ

tt θ

t

+

= =+

pp

pI

p

p

minute

(13)

If Ziegler-Nichols method is used, the sustained oscillation condition for this simple FOPDT model can be found by solving for the critical angular velocity ωc (rad/min) that gives the overall phase angle of -π [18(c)]:

( )1c p c ptan ω t ω θ π− − − = −

(14)

The first term on the left-hand side of Equation 14 is due to the first-order component and the second term is due to the dead-time component of the process model. Using the parameters in Equation 2 with time expressed in minutes, ωc is found to be 12.61 rad/min. Then the ultimate proportional gain Kcu (the Kc that would produce the sustained oscillation condition using P-only control) can be calculated from the amplitude ratio between the input and the output (of the process unit) at ωc, and the ultimate period of oscillation Pu can be calculated from ωc as well:

2 21 %31.64c pcu o

p

KK Fω t+

= = (15)

0.4982 minu e2 tπω

= =uc

P (16)

Depending on the desired aggressiveness of the PI-controller, a factor of 0.18, 0.3, or 0.45 may be multiplied with the Kcu value to obtain the recommended Kc . If one chooses the factor 0.3 for medium degree of aggressiveness, the proportional gain Kc is calculated as

%0.3 9.493c cu oK KF

= = (17)

And, the integral time is calculated as

0.4152 minut1.

e2

t = =uI

P (18)

There are many other tuning rules for PID controllers based on FOPDT model. Each of the tuning method is based on certain expectations of the performance of the control loop.

The feedback control loop designed by the author using LabVIEW PID Toolkit is also implemented. The values of Kc and τI may be chosen within the ranges of those recommended by the above tuning rules. By using IMC tuning rule with τc set at 0.2 minute that results in Kc = 7.45, and τI = 0.64 minute, the results of setpoint tracking (temperature setpoint: 73 78oF) followed by disturbance rejection (flow rate: 3040 %) are shown in Figure 15. When less aggressive tuning parameters are chosen (Kc = 3.00, τI = 0.64 min with τc at 0.7 min), the results of setpoint tracking followed by disturbance rejection are shown in Figure 16.

In general, properly tuned PID controllers provide satisfactory performance of feedback control loops. Its tuning is rather straightforward and there are many well-established tuning methods. However, model predictive controllers are capable of predicting what may lie ahead and offers preemptive control action, which is not inherent in the traditional feedback PID control. This aspect of preemptive control action may offer favorable edge in energy production processes. This may be one important reason why many modern-day refineries are controlled by some aspects of model predictive control in order to ensure product quality and conserve energy in the production process.

CONCLUSIONS1. A controller constructed from NI LabVIEW’s model

predictive control (MPC) toolkit is able to control the temperature of water leaving a flow-through electrical heater satisfactorily.

2. A practical procedure of building the MPC controller is illustrated in this work. Simplified and straightforward tuning rules are suggested based on the performance of the system observed in this work.

3. It is recommended that for the SISO case with first-order-plus-dead-time process model, the following set of tuning parameters may be appropriate for practical applications:

a. Prediction horizon ~ one time constant

b. Control horizon ~ one-half prediction horizon

c. Cost weighting factor for output (process variable) error Q ~ 1

d. Cost weighting factor for control action change R ~ Γ * Kp

2, where Kp is process gain and Γ is typically set at 10 or higher

4. PID control loop based on IMC (and other tuning rules) offers satisfactory performance for the temperature control. However, the predictive ability offered by MPC is not inherent in the traditional feedback PID control.

Page 11: Temperature Control for an Electrical Water Heater by ...Jang LK (2018) Temperature Control for an Electrical Water Heater by LabVIEW’s Model Predictive Control (MPC) Tool Kit. Chem

Central

Jang (2018)Email:

Chem Eng Process Tech 4(1): 1053 (2018) 11/11

Jang LK (2018) Temperature Control for an Electrical Water Heater by LabVIEW’s Model Predictive Control (MPC) Tool Kit. Chem Eng Process Tech 4(1): 1053.

Cite this article

5. The MPC algorithm developed in this work may be expanded to a MIMO system that includes effects of disturbance variables.

REFERENCES1. Jang LK, Lo RC. Spreadsheet Procedure for Simulating Setpoint

Tracking in SISO by Dynamic Matrix Control. Chem Eng Educ. 2015; 49: 175-183.

2. Garriga JL, Soroush M. Model Predictive Control Tuning Methods: A Review. Ind Eng Chem Res. 2010; 49: 3505-3515.

3. Hinde RF, Cooper DJ. A pattern-based approach to excitation diagnostics for adaptive process control. Chem Eng Sci. 1994; 49: 1403-1415.

4. Rossiter JA. Model-Based Predictive Control: A Practical Approach. CRC Press. 2003.

5. Camacho EF, Alba CB. Model Predictive Control. Springer Science & Business Media. 2013.

6. Reble M. Model Predictive Control for Nonlinear Continuous-Time Systems with and without Time-Delays. Bilingual Edition, Logos Verlag, 2013.

7. Rawlings JB, Mayne DQ. Model Predictive Control Theory and Design. Nob Hill Pub. 2009.

8. Wade C. Model Predictive Control: Theory, Practices and Future Challenges. UK edn. New York: Nova Science Pub Inc. 2015.

9. Lee JH, Yu ZH. Tuning of model predictive controllers for robust performance. Comput Chem Eng. 1994; 18: 15-37.

10. Alamir M. A Pragmatic Story of Model Predictive Control: Self-Contained Algorithms and Case-Studies, 1st edn. Create Space Independent Publishing Platform. 2013.

11. Shridhar R, Cooper DJ. A Tuning Strategy for Unconstrained Multivariable Model Predictive Control. Ind Eng Chem Res. 1998; 37: 4003-4016.

12. Lab VIEW. Control Design User Manual. National Instruments Corp. 2006, Chapter 18.

13. Wojsznis W, Gudaz J, Blevins T, Mehta A. Practical approach to tuning MPC. ISA Transactions. 2003; 42: 149-162.

14. Trierweiler JO, Farina LA. RPN tuning strategy for model predictive control. J Process Cont. 2003; 13: 591-598.

15. Shah G, Engell S. Tuning MPC for desired closed-loop performance for MIMO systems. Proceedings of the 2011 American Control Conference. 2011 29 June - 1 July. USA. San Francisco: IEEE, 2011.

16. Al-Ghazzawi, Ali E, Nouh A, Zafiriou E. On-line tuning strategy for model predictive controllers. J Process Cont. 2001; 11: 265-284.

17. Jang LK. Feedback control for liquid level in a gravity-drained multi-tank system. Chem Eng Process Tech. 2017; 3: 1037-1046.

18. Riggs JB, Karim MN. Chemical and Bio-Process Control. 4th edn. Austin: Ferret Publishing. 2006, (a) 316-304, (b) 304, (c) 377-382.