As mentioned earlier, instead of writing the program in the Arduino chip, we will use the Arduino only as IO server. The control program is running in a host PC. This type of setup is called Connected IO in MATLAB Simulink. For this purpose, an empty Simulink file has been provided. This empty file can be used as a starting template.

To use an Arduino Uno in a connected-IO configuration, follow these steps.

Create a new Simulink model from MATLAB main application.

Create a new Simulink model from MATLAB main application.

Go to MODELING tab → select: Model Settings → select Solver → follow the configuration shown by this figure.

Go to MODELING tab → select: Model Settings → select Solver → follow the configuration shown by this figure.

Still form the same window, select Hardware Implementation → Select Arduino Uno from Hardware Board → click OK to close the window.

Still form the same window, select Hardware Implementation → Select Arduino Uno from Hardware Board → click OK to close the window.

From Simulink main window, go to HARDWARE tab, make sure Connected IO is activated. When Connected IO is activated, the Run with IO button will appear.

From Simulink main window, go to HARDWARE tab, make sure Connected IO is activated. When Connected IO is activated, the Run with IO button will appear.

Adjust the Simulation Pacing, set simulation time per wall second to 1.

Adjust the Simulation Pacing, set simulation time per wall second to 1.

Fur running the Simulink code, ALWAYS use Run with IO button in HARDWARE tab!

Fur running the Simulink code, ALWAYS use Run with IO button in HARDWARE tab!