Design Model-Reference Neural Controller in Simulink
The neural model reference control architecture uses two neural networks: a controller network and a plant model network, as shown in the following figure. The plant model is identified first, and then the controller is trained so that the plant output follows the reference model output.
The following figure shows the details of the neural network plant model and the neural network controller as they are implemented in the Deep Learning Toolbox™ software. Each network has two layers, and you can select the number of neurons to use in the hidden layers. There are three sets of controller inputs:
Delayed reference inputs
Delayed controller outputs
Delayed plant outputs
For each of these inputs, you can select the number of delayed values to use. Typically, the number of delays increases with the order of the plant. There are two sets of inputs to the neural network plant model:
Delayed controller outputs
Delayed plant outputs
As with the controller, you can set the number of delays. The next section shows how you can set the parameters.
Use the Model Reference Controller Block
Note
To design a model reference adaptive controller, you can also use the Model Reference Adaptive Control (Simulink Control Design) Simulink® block.
This workflow is recommended because of these advantages:
Simplifies the controller design.
Requires only an initial guess of the plant model dynamics.
Automatically characterizes disturbances and model uncertainties such as single hidden layer neural networks. The block then updates controller parameters in real-time to cancel out these disturbances and uncertainties in the controlled system, removing the need for manual retuning. For more information on using single hidden layer neural networks, see Disturbance and Uncertainty Model (Simulink Control Design).
Supports code generation.
For an example showing how to use these tools, see Quadrotor Control Using Model Reference Adaptive Control (Simulink Control Design).
This section shows how the neural network controller is trained. The first step is to copy the Model Reference Controller block from the Deep Learning Toolbox blockset to Simulink Editor. See the Simulink documentation if you are not sure how to do this. This step is skipped in the following example.
An example model is provided with the Deep Learning Toolbox software to show the use of the model reference controller. In this example, the objective is to control the movement of a simple, single-link robot arm, as shown in the following figure:
The equation of motion for the arm is
where ϕ is the angle of the arm, and u is the torque supplied by the DC motor.
The objective is to train the controller so that the arm tracks the reference model
where yr is the output of the reference model, and r is the input reference signal.
This example uses a neural network controller with a 5-13-1 architecture. The inputs to the controller consist of two delayed reference inputs, two delayed plant outputs, and one delayed controller output. A sampling interval of 0.05 seconds is used.
To run this example:
Start MATLAB®.
Type
mrefrobotarm
in the MATLAB Command Window. This command opens the Simulink Editor with the Model Reference Controller block already in the model.Double-click the Model Reference Controller block. This opens the following window for training the model reference controller.
The next step would normally be to click Plant Identification, which opens the Plant Identification window. You would then train the plant model. Because the Plant Identification window is identical to the one used with the previous controllers, that process is omitted here.
Click Generate Training Data. The program starts generating the data for training the controller. After the data is generated, the following window appears.
Click Accept Data. Return to the Model Reference Control window and click Train Controller. The program presents one segment of data to the network and trains the network for a specified number of iterations (five in this case). This process continues, one segment at a time, until the entire training set has been presented to the network. Controller training can be significantly more time consuming than plant model training. This is because the controller must be trained using dynamic backpropagation (see [HaJe99]). After the training is complete, the response of the resulting closed loop system is displayed, as in the following figure.
Go back to the Model Reference Control window. If the performance of the controller is not accurate, then you can select Train Controller again, which continues the controller training with the same data set. If you would like to use a new data set to continue training, select Generate Data or Import Data before you select Train Controller. (Be sure that Use Current Weights is selected if you want to continue training with the same weights.) It might also be necessary to retrain the plant model. If the plant model is not accurate, it can affect the controller training. For this example, the controller should be accurate enough, so select OK. This loads the controller weights into the Simulink model.
Return to the Simulink Editor and start the simulation by choosing the menu option Simulation > Run. As the simulation runs, the plant output and the reference signal are displayed, as in the following figure.