These are the files for Chapter 9 for the book " Practical Design and Application of Model Predictive Control" by Elsevier (eBook ISBN: 9780128139196, Paperback ISBN: 9780128139189).
This chapter guides the user through the process of controlling speed of a DC motor using MPC and run the controller on a real time hard-ware.
To collect data for system identification, run Chapter_9_Section_6_Model.slx and then Chapter_9_Section_6_Script.m to plot the results. It is assumed that the user has Arduino Mega connected per instructions in chapter_9.
Run Chapter_9_Section_7_Script.m to assess nonlinearity of the motor. In this step, the data of the DC motor is already embedded in the script. Use your collected data instead of the one in the script.
Run Chapter_9_Section_8_Script.m to perform system identification.
In folder Section_9, you will find the 3 linear models for the DC motor. You can use these to create MPC controller.
The MPC sessions are saved under MPC_DesignTask_Chapter_9_Section_9_MPC_1.mat , MPC_DesignTask_Chapter_9_Section_9_MPC_2.mat and MPC_DesignTask_Chapter_9_Section_9_MPC_3.mat
The exported MPC controllers are saved under Motor_Linear_MPC_Mode_1.mat, Motor_Linear_MPC_Mode_2.mat and Motor_Linear_MPC_Mode_3.mat
To run the Multi-Mode MPC controller on Arduino, go to Chapter_9/Section_10 folder and follow these instructions:
Make sure the motor hardware and the Arduino Mega board are connected to the computer with an open session of Matlab®(preferably R2017a). Set Matlab® directory to Chapter_9/Section_10 directory. In the Matlab® command window load the MPC controller .mat files by typing the commands load Motor_Linear_MPC_Mode_1.mat; load Motor_Linear_MPC_Mode_2.mat; load Mo-tor_Linear_MPC_Mode_3.mat. Open Simulink® model Chapter_9_Section_10_Model_1.slx. Then Click on the Run button to generate code from the model, compile and deploy into the Arduino Mega.
Nassim Khaled (2021). Real Time Embedded Target Application of MPC (https://www.mathworks.com/matlabcentral/fileexchange/67401-real-time-embedded-target-application-of-mpc), MATLAB Central File Exchange. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!