File Exchange

image thumbnail

Real Time Embedded Target Application of MPC

version 1.0.0.1 (1.56 MB) by Nassim Khaled
Practical Design and Application of Model Predictive Control- Chapter 9

39 Downloads

Updated 29 Oct 2018

View License

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.

Cite As

Nassim Khaled (2019). 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 .

Comments and Ratings (2)

Updates

1.0.0.1

Updated the website for the project.

1.0.0.0

We added a tag: Arduino.

MATLAB Release Compatibility
Created with R2017a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Communities

Chapter_9/Section_6

Chapter_9/Section_6/Chapter_9_Section_6_Model_ert_rtw

Chapter_9/Section_7

Chapter_9/Section_8