CD Create MPC Controller VI

Control Design VI and Function

CD Create MPC Controller VI

Owning Palette: Predictive Control VIs

Installed With: Control Design and Simulation Module

Creates a model predictive control (MPC) controller for a state-space model. You must manually select the polymorphic instance to use.

If you want to create an MPC controller for a transfer function model or a zero-pole-gain model, you must first convert the model to a state-space model.

Note  Refer to Chapter 18, Creating and Implementing a Model Predictive Controller, of the LabVIEW Control Design User Manual for information about using this VI.

Examples

Use the pull-down menu to select an instance of this VI.

 Place on the block diagram  Find on the Functions palette

CD Create MPC Controller (Dual)

Dd specifies the direct feedthrough matrix for the disturbance in the system.
Bd specifies the input matrix for the disturbance in the system.
MPC Controller Parameters specifies execution parameters for the model predictive controller.
Prediction Horizon specifies the number of future discrete time samples that this VI considers for the output error term in the cost function.
Control Horizon specifies the number of future discrete time samples that this VI considers when calculating the control action. The value of this parameter must be less than the value of the Prediction Horizon parameter.
Initial Window specifies the initial range, or window, of plant output errors that this VI does not consider for the cost function. National Instruments recommends you specify the value of this parameter to be, at most, one sample less than the minimum delay of the model.

National Instruments recommends that you adjust the value of this parameter when the model has a delay of 10 or more samples. This adjustment reduces the internal calculations of the MPC controller. Because the control action does not affect the plant outputs for the duration of the delays, the initial window adjustment reduces the controller size significantly.
Integral Action? specifies whether the MPC Controller includes integral action. Integral action is important when the MPC controller model does not match the plant model.
State-Space Model specifies a discrete state-space representation of the plant you want to control. Providing an accurate model improves the performance of the MPC controller this VI creates.
MPC Cost Weights specifies the weight matrices this VI uses in the cost function.
Note  These weight matrices are different from the Q, R, and N parameters that define the state estimator.
Output Error Weightings specifies the weight matrix Q this VI uses for each plant output error in the cost function. The dimensions of this matrix must match the number of plant outputs.

To prevent this VI from returning sub-optimal values, this matrix must be positive semi-definite.
Control Action Change Weightings specifies the weight matrix R this VI uses for each rate of control action change in the cost function. The dimensions of this matrix must match the number of plant inputs.

To prevent this VI from returning sub-optimal values, this matrix must be positive definite.
Control Action Error Weightings specifies the weight matrix N this VI uses for each control action error change in the cost function.

National Instruments recommends that you specify Control Action Error Weightings for systems with more inputs than outputs.
Output Error Factors specifies the factors this VI uses to increase or decrease the weights for each plant output error along the Prediction Horizon in the cost function. This VI applies these factors at subsequent sample times within the Prediction Horizon.

Output Error Factors must be greater than 0. For each element, a value greater than 1 increases the weight. A value less than 1 decreases the weight. The default is 1, which specifies the same weight for the plant output error at each sample time within the Prediction Horizon.
Control Action Change Factors specifies the factors this VI uses to increase or decrease the weights for each rate of control action change along the Control Horizon in the cost function. This VI applies these factors at subsequent sample times within the Prediction Horizon.

Control Action Change Factors must be greater than 0. For each element, a value greater than 1 increases the weight. A value less than 1 decreases the weight. The default is 1, which specifies the same weight for the rate of control action change at each sample time within the Prediction Horizon.
Control Action Error Factors specifies the factors this VI uses to increase or decrease the weights for each control action error along the Control Horizon in the cost function. This VI applies these factors at subsequent sample times within the Prediction Horizon.

Control Action Error Factors must be greater than 0. For each element, a value greater than 1 increases the weight. A value less than 1 decreases the weight. The default is 1, which specifies the same weight for the control action error at each sample time within the Prediction Horizon.
MPC Constraints (Dual) specifies any constraints on the quadratic programming (QP) optimization algorithm using the dual optimization method. Each parameter specifies a minimum or maximum limit on the initial or final control action u, plant output y, or rate of change in control action du. If you specify only a minimum or a maximum limit for a parameter, LabVIEW assumes a constant profile for that parameter.
u min init specifies the initial minimum limit of the control action. This VI uses this limit for constraint optimization along the Control Horizon.

If you do not specify a limit, LabVIEW uses a limit of –∞.
u min final specifies the final minimum limit of the control action. This VI uses this limit for constraint optimization along the Control Horizon.

If you do not specify a limit, LabVIEW uses a limit of –∞.
u max init specifies the initial maximum limit of the control action. This VI uses this limit for constraint optimization along the Control Horizon.

If you do not specify a limit, LabVIEW uses a limit of ∞.
u max final specifies the final maximum limit of the control action. This VI uses this limit for constraint optimization along the Control Horizon.

If you do not specify a limit, LabVIEW uses a limit of ∞.
y min init specifies the initial minimum limit of the plant output. This VI uses this limit for constraint optimization along the Prediction Horizon.

If you do not specify a limit, LabVIEW uses a limit of –∞.
y min final specifies the final minimum limit of the plant output. This VI uses this limit for constraint optimization along the Prediction Horizon.

If you do not specify a limit, LabVIEW uses a limit of –∞.
y max init specifies the initial maximum limit of the plant output. This VI uses this limit for constraint optimization along the Prediction Horizon.

If you do not specify a limit, LabVIEW uses a limit of ∞.
y max final specifies the final maximum limit of the plant output. This VI uses this limit for constraint optimization along the Prediction Horizon.

If you do not specify a limit, LabVIEW uses a limit of ∞.
du min init specifies the initial minimum limit of the rate of change in control action. This VI uses this limit for constraint optimization along the Control Horizon.

If you do not specify a limit, LabVIEW uses a limit of –∞.
du min final specifies the final minimum limit of the rate of change in control action. This VI uses this limit for constraint optimization along the Control Horizon.

If you do not specify a limit, LabVIEW uses a limit of –∞.
du max init specifies the initial maximum limit of the rate of change in control action. This VI uses this limit for constraint optimization along the Control Horizon.

If you do not specify a limit, LabVIEW uses a limit of ∞.
du max final specifies the final maximum limit of the rate of change in control action. This VI uses this limit for constraint optimization along the Control Horizon.

If you do not specify a limit, LabVIEW uses a limit of ∞.
stopping criteria is the collection of conditions that terminate the optimization. If (function tolerance AND parameter tolerance AND gradient tolerance) OR max iterations OR max function calls then optimization terminates.
function tolerance is the relative change in function value and is defined as abs(current f – prev f)/(abs(curr f)+machine eps). If the relative change in the function value falls below function tolerance, the optimization terminates.
parameter tolerance is the relative change in parameter values and is defined as abs(current p – prev p)/(abs(curr p)+machine eps). If the relative change of all the parameter values falls below parameters tolerance, the optimization terminates.
gradient tolerance is the 2–norm of the gradient. If the 2–norm of the gradient falls below gradient tolerance, the optimization terminates.
max iterations is the largest number of iterations of the major loop of the optimization. If the number of major loop iterations exceeds max iterations, the optimization terminates.
max function calls is the largest number of objective function calls allowed before terminating the optimization process.
max time (sec) is the maximum amount of time LabVIEW allows between the start and the end of the optimization process. The default is –1. –1 indicates never to time out.
error in describes error conditions that occur before this VI or function runs. The default is no error. If an error occurred before this VI or function runs, the VI or function passes the error in value to error out. This VI or function runs normally only if no error occurred before this VI or function runs. If an error occurs while this VI or function runs, it runs normally and sets its own error status in error out. Use the Simple Error Handler or General Error Handler VIs to display the description of the error code. Use exception control to treat what is normally an error as no error or to treat a warning as an error. Use error in and error out to check errors and to specify execution order by wiring error out from one node to error in of the next node.
status is TRUE (X) if an error occurred before this VI or function ran or FALSE (checkmark) to indicate a warning or that no error occurred before this VI or function ran. The default is FALSE.
code is the error or warning code. The default is 0. If status is TRUE, code is a nonzero error code. If status is FALSE, code is 0 or a warning code.
source specifies the origin of the error or warning and is, in most cases, the name of the VI or function that produced the error or warning. The default is an empty string.
MPC State Estimator Parameters specifies the parameters of the state estimator that the MPC Controller uses to estimate the states of the plant.

Use the Q, R, and N parameters to define a state estimator by using the Noise Covariance method. This method results in a state estimator that uses the Kalman filter gain.
Note  These parameters are different from the Q, R, and N weight matrices in the cost function.


Use the Observer Poles parameter to define a state estimator by using the Pole Placement method.
Defining a state estimator is optional. If you do not define an estimator and can measure the plant states, you can wire the plant states to the Estimated State xhat(k) input terminal of the CD Implement MPC Controller VI.
Internal Estimator Gain Calculation specifies the method this VI uses to define the state estimator.

0None (default)—Specifies that this VI does not define an internal state estimator. In this situation, you can provide the states to the CD Implement MPC Controller VI.
1Pole Placement—Specifies that this VI defines a state estimator by using the value of the Observer Poles parameter.
2Noise Covariance—Specifies that this VI defines a state estimator by using the values of the Q, R, and N parameters. This method results in a Kalman filter.
Observer Poles specifies the locations of the estimator poles. This parameter is valid only if you specify Pole Placement for the Internal Estimator Gain Calculation parameter.
Q specifies the auto-covariance matrix of the process noise vector.
N specifies the cross-covariance matrix between the process noise and the measurement noise vectors.
Note  If the process noise and measurement noise vectors are uncorrelated, either specify a matrix of zeros for this parameter or do not wire a value to this parameter.
R specifies the auto-covariance matrix of the measurement noise vector.
MPC Initial Conditions specifies the initial conditions for the MPC Controller.
Control Action (u) specifies the initial value(s) of the control action. The default is a vector of zeros.
Output (y) specifies the initial value(s) of the plant output. The default is a vector of zeros.
Disturbance (d) specifies the initial value(s) of the disturbance that affects the plant. The default is a vector of zeros.
State (x) specifies the initial value(s) of the states of the plant. The default is a vector of zeros.
Control Action Change (Du) specifies the initial values of the rate of change in control action. The default is a vector of zeros.
MPC Controller returns the predictive controller model that corresponds to the parameters this VI specifies.
error out contains error information. If error in indicates that an error occurred before this VI or function ran, error out contains the same error information. Otherwise, it describes the error status that this VI or function produces. Right-click the error out front panel indicator and select Explain Error from the shortcut menu for more information about the error.
status is TRUE (X) if an error occurred or FALSE (checkmark) to indicate a warning or that no error occurred.
code is the error or warning code. If status is TRUE, code is a nonzero error code. If status is FALSE, code is 0 or a warning code.
source describes the origin of the error or warning and is, in most cases, the name of the VI or function that produced the error or warning.

CD Create MPC Controller (Barrier)

Dd specifies the direct feedthrough matrix for the disturbance in the system.
Bd specifies the input matrix for the disturbance in the system.
MPC Controller Parameters specifies execution parameters for the model predictive controller.
Prediction Horizon specifies the number of future discrete time samples that this VI considers for the output error term in the cost function.
Control Horizon specifies the number of future discrete time samples that this VI considers when calculating the control action. The value of this parameter must be less than the value of the Prediction Horizon parameter.
Initial Window specifies the initial range, or window, of plant output errors that this VI does not consider for the cost function. National Instruments recommends you specify the value of this parameter to be, at most, one sample less than the minimum delay of the model.

National Instruments recommends that you adjust the value of this parameter when the model has a delay of 10 or more samples. This adjustment reduces the internal calculations of the MPC controller. Because the control action does not affect the plant outputs for the duration of the delays, the initial window adjustment reduces the controller size significantly.
Integral Action? specifies whether the MPC Controller includes integral action. Integral action is important when the MPC controller model does not match the plant model.
State-Space Model specifies a discrete state-space representation of the plant you want to control. Providing an accurate model improves the performance of the MPC controller this VI creates.
MPC Cost Weights specifies the weight matrices this VI uses in the cost function.
Note  These weight matrices are different from the Q, R, and N parameters that define the state estimator.
Output Error Weightings specifies the weight matrix Q this VI uses for each plant output error in the cost function. The dimensions of this matrix must match the number of plant outputs.

To prevent this VI from returning sub-optimal values, this matrix must be positive semi-definite.
Control Action Change Weightings specifies the weight matrix R this VI uses for each rate of control action change in the cost function. The dimensions of this matrix must match the number of plant inputs.

To prevent this VI from returning sub-optimal values, this matrix must be positive definite.
Control Action Error Weightings specifies the weight matrix N this VI uses for each control action error change in the cost function.

National Instruments recommends that you specify Control Action Error Weightings for systems with more inputs than outputs.
Output Error Factors specifies the factors this VI uses to increase or decrease the weights for each plant output error along the Prediction Horizon in the cost function. This VI applies these factors at subsequent sample times within the Prediction Horizon.

Output Error Factors must be greater than 0. For each element, a value greater than 1 increases the weight. A value less than 1 decreases the weight. The default is 1, which specifies the same weight for the plant output error at each sample time within the Prediction Horizon.
Control Action Change Factors specifies the factors this VI uses to increase or decrease the weights for each rate of control action change along the Control Horizon in the cost function. This VI applies these factors at subsequent sample times within the Prediction Horizon.

Control Action Change Factors must be greater than 0. For each element, a value greater than 1 increases the weight. A value less than 1 decreases the weight. The default is 1, which specifies the same weight for the rate of control action change at each sample time within the Prediction Horizon.
Control Action Error Factors specifies the factors this VI uses to increase or decrease the weights for each control action error along the Control Horizon in the cost function. This VI applies these factors at subsequent sample times within the Prediction Horizon.

Control Action Error Factors must be greater than 0. For each element, a value greater than 1 increases the weight. A value less than 1 decreases the weight. The default is 1, which specifies the same weight for the control action error at each sample time within the Prediction Horizon.
MPC Constraints (Barrier) specifies any constraints on the quadratic programming (QP) optimization algorithm using the barrier function method. Each parameter specifies a minimum limit, maximum limit, tolerance, or penalty on the initial or final control action u, plant output y, or rate of change in control action du. If you specify only a minimum or a maximum limit for a parameter, LabVIEW assumes a constant profile for that parameter.
u min init specifies the initial minimum limit of the control action. This VI uses this limit for constraint optimization along the Control Horizon.

If you do not specify a limit, LabVIEW uses a limit of –∞.
u min final specifies the final minimum limit of the control action. This VI uses this limit for constraint optimization along the Control Horizon.

If you do not specify a limit, LabVIEW uses a limit of –∞.
u min tolerance specifies the tolerance range for the minimum limit of the control action. The penalty on the cost function becomes active when u drops below u min + u min tolerance.
u min penalty specifies the penalty on the cost function for the minimum limit of the control action when u equals u min. The penalty on the cost function becomes active when u drops below u min + u min tolerance.
u max init specifies the initial maximum limit of the control action. This VI uses this limit for constraint optimization along the Control Horizon.

If you do not specify a limit, LabVIEW uses a limit of ∞.
u max final specifies the final maximum limit of the control action. This VI uses this limit for constraint optimization along the Control Horizon.

If you do not specify a limit, LabVIEW uses a limit of ∞.
u max tolerance specifies the tolerance range for the maximum limit of the control action. The penalty on the cost function becomes active when u exceeds u maxu max tolerance.
u max penalty specifies the penalty on the cost function for the maximum limit of the control action when u equals u max. The penalty on the cost function becomes active when u exceeds u maxu max tolerance.
y min init specifies the initial minimum limit of the plant output. This VI uses this limit for constraint optimization along the Prediction Horizon.

If you do not specify a limit, LabVIEW uses a limit of –∞.
y min final specifies the final minimum limit of the plant output. This VI uses this limit for constraint optimization along the Prediction Horizon.

If you do not specify a limit, LabVIEW uses a limit of –∞.
y min tolerance specifies the tolerance range for the minimum limit of the plant output. The penalty on the cost function becomes active when y drops below y min + y min tolerance.
y min penalty specifies the penalty on the cost function for the minimum limit of the plant output when y equals y min. The penalty on the cost function becomes active when y drops below y min + y min tolerance.
y max init specifies the initial maximum limit of the plant output. This VI uses this limit for constraint optimization along the Prediction Horizon.

If you do not specify a limit, LabVIEW uses a limit of ∞.
y max final specifies the final maximum limit of the plant output. This VI uses this limit for constraint optimization along the Prediction Horizon.

If you do not specify a limit, LabVIEW uses a limit of ∞.
y max tolerance specifies the tolerance range for the maximum limit of the plant output. The penalty on the cost function becomes active when y exceeds y maxy max tolerance.
y max penalty specifies the penalty on the cost function for the maximum limit of the plant output when y equals y max. The penalty on the cost function becomes active when y exceeds y maxy max tolerance.
du min init specifies the initial minimum limit of the rate of change in control action. This VI uses this limit for constraint optimization along the Control Horizon.

If you do not specify a limit, LabVIEW uses a limit of –∞.
du min final specifies the final minimum limit of the rate of change in control action. This VI uses this limit for constraint optimization along the Control Horizon.

If you do not specify a limit, LabVIEW uses a limit of –∞.
du min tolerance specifies the tolerance range for the minimum limit of the rate of change in control action. The penalty on the cost function becomes active when du drops below du min + du min tolerance.
du min penalty specifies the penalty on the cost function for the minimum limit of the rate of change in control action when du equals du min. The penalty on the cost function becomes active when du drops below du min + du min tolerance.
du max init specifies the initial maximum limit of the rate of change in control action. This VI uses this limit for constraint optimization along the Control Horizon.

If you do not specify a limit, LabVIEW uses a limit of ∞.
du max final specifies the final maximum limit of the rate of change in control action. This VI uses this limit for constraint optimization along the Control Horizon.

If you do not specify a limit, LabVIEW uses a limit of ∞.
du max tolerance specifies the tolerance range for the maximum limit of the rate of change in control action. The penalty on the cost function becomes active when du exceeds du maxdu max tolerance.
du max penalty specifies the penalty on the cost function for the maximum limit of the rate of change in control action when du equals du max. The penalty on the cost function becomes active when du exceeds du maxdu max tolerance.
error in describes error conditions that occur before this VI or function runs. The default is no error. If an error occurred before this VI or function runs, the VI or function passes the error in value to error out. This VI or function runs normally only if no error occurred before this VI or function runs. If an error occurs while this VI or function runs, it runs normally and sets its own error status in error out. Use the Simple Error Handler or General Error Handler VIs to display the description of the error code. Use exception control to treat what is normally an error as no error or to treat a warning as an error. Use error in and error out to check errors and to specify execution order by wiring error out from one node to error in of the next node.
status is TRUE (X) if an error occurred before this VI or function ran or FALSE (checkmark) to indicate a warning or that no error occurred before this VI or function ran. The default is FALSE.
code is the error or warning code. The default is 0. If status is TRUE, code is a nonzero error code. If status is FALSE, code is 0 or a warning code.
source specifies the origin of the error or warning and is, in most cases, the name of the VI or function that produced the error or warning. The default is an empty string.
MPC State Estimator Parameters specifies the parameters of the state estimator that the MPC Controller uses to estimate the states of the plant.

Use the Q, R, and N parameters to define a state estimator by using the Noise Covariance method. This method results in a state estimator that uses the Kalman filter gain.
Note  These parameters are different from the Q, R, and N weight matrices in the cost function.


Use the Observer Poles parameter to define a state estimator by using the Pole Placement method.
Defining a state estimator is optional. If you do not define an estimator and can measure the plant states, you can wire the plant states to the Estimated State xhat(k) input terminal of the CD Implement MPC Controller VI.
Internal Estimator Gain Calculation specifies the method this VI uses to define the state estimator.

0None (default)—Specifies that this VI does not define an internal state estimator. In this situation, you can provide the states to the CD Implement MPC Controller VI.
1Pole Placement—Specifies that this VI defines a state estimator by using the value of the Observer Poles parameter.
2Noise Covariance—Specifies that this VI defines a state estimator by using the values of the Q, R, and N parameters. This method results in a Kalman filter.
Observer Poles specifies the locations of the estimator poles. This parameter is valid only if you specify Pole Placement for the Internal Estimator Gain Calculation parameter.
Q specifies the auto-covariance matrix of the process noise vector.
N specifies the cross-covariance matrix between the process noise and the measurement noise vectors.
Note  If the process noise and measurement noise vectors are uncorrelated, either specify a matrix of zeros for this parameter or do not wire a value to this parameter.
R specifies the auto-covariance matrix of the measurement noise vector.
MPC Initial Conditions specifies the initial conditions for the MPC Controller.
Control Action (u) specifies the initial value(s) of the control action. The default is a vector of zeros.
Output (y) specifies the initial value(s) of the plant output. The default is a vector of zeros.
Disturbance (d) specifies the initial value(s) of the disturbance that affects the plant. The default is a vector of zeros.
State (x) specifies the initial value(s) of the states of the plant. The default is a vector of zeros.
Control Action Change (Du) specifies the initial values of the rate of change in control action. The default is a vector of zeros.
MPC Controller returns the predictive controller model that corresponds to the parameters this VI specifies.
error out contains error information. If error in indicates that an error occurred before this VI or function ran, error out contains the same error information. Otherwise, it describes the error status that this VI or function produces. Right-click the error out front panel indicator and select Explain Error from the shortcut menu for more information about the error.
status is TRUE (X) if an error occurred or FALSE (checkmark) to indicate a warning or that no error occurred.
code is the error or warning code. If status is TRUE, code is a nonzero error code. If status is FALSE, code is 0 or a warning code.
source describes the origin of the error or warning and is, in most cases, the name of the VI or function that produced the error or warning.

Examples

Refer to the following VIs for examples of using the CD Create MPC Controller VI:

  • CDEx MPC with Barrier Constraints VI: labview\examples\Control and Simulation\Control Design\MPC

     Open example  Browse related examples

  • CDEx MPC with Dual Constraints VI: labview\examples\Control and Simulation\Control Design\MPC

     Open example  Browse related examples