Simulink Interfacing With Arduino (Manual)
Simulink Interfacing With Arduino (Manual)
i
1. Making MathWorks Account
Fill the necessary details and follow the instruction step by step to complete the sign up. And
note down your User id an and Password.
1
Once you will click on Log In a pop up will open asking your user Id and Password as shown
below.
Use the User ID and Password that you noted down in step one and hit the Sign in button.
Once you Login Successfully on Top Right Corner your First Name will be displayed instead
of Log In button.
2
2. Downloading Hardware Support Packages
One file will be downloaded as soon as you hit the download button.
3
If you are using Link 2 you will be redirected to the page shown below.
One file will be downloaded as soon as you hit the download button.
You can either follow the Link 1 or Link 2. Extra Link is provided if you face any
difficulty with the one of the links or if one of the servers may have down time when
you need urgently.
In both the links file named “arduino .mlpkginstall” will be downloaded
4
3. Installing Hardware Support Package
Step 1: Locating downloaded package in MATLAB
Open main window of MATLAB and select Open under the Home Tab
As soon as you will hit the Open button Pop-Up shown below will open
Here pre selected file format is ALL MATLAB Files instead of that select ALL Files from
the drop down menu.
5
Once you select the ALL Files option locate the hardware support package file named
“arduino .mlpkginstall” and press the Open button as shown below.
6
Once you click, I Accept button you will be redirected to the screen given below. Hit the Next
button as shown below.
Once you hit Next button Download and Installation process will be started as shown below.
(Downloading and installation process depends on your connection speed it may take up to 30
min)
7
Once download & installation will be completed you will see the screen given below. Then
click Setup Now button as shown below.
Once you click Setup Now button you will see the screen sown below. Connect your Arduino
to your PC with the help of compatible Arduino cable. Then and then only press Next Button
8
Once you will click Next button MATLAB will automatically start detecting your board as
shown below.
And then it will automatically show the board that you have connected as shown below. I have
connected my Arduino mega, so MATLAB has detected it. Once your board is detected press
Next.
9
After pressing Next, you will see the screen shown below. Press Next to test Arduino
connection. Make sure your Arduino board is connected to your PC pressing Next.
Once you press next you will be redirected to the screen shown below. Then press Test
Connection button
10
4. Deploying a Simulink Model in Arduino
Before proceeding understand the Arduino pins which are given below.
11
Once you finish setting up your Arduino with MATLAB. Open a new Simulink model and
follow the steps as shown below. Here we will deploy a Simulink model to Arduino to generate
the required pulses.
12
Step 4:Now go to the Simulation Tab and select Model Configuration
Parameters
13
Step 6: Than go to Hardware Implementation Tab and Select the Hardware
Board. And hit OK button.
14
Step: 7 Than go to main window of MATLAB. You will see the main
directory will be C:\Program Files\MATLAB\R2018a\bin
Change that default directory to Any Drive:\Folder (for e.g. E:\Pulse)
Once you will hit the deploy to hardware button your model will be deployed in your
board.
15
5. External Mode
For external mode settings are same as we saw in deployment mode. Only difference is that in
external mode whatever the controller pin will read we will be able to see on the scope of the
Simulink.
Steps:
16
Step 4: At the output of Analog pin connect a data type converter. Connect
the output of converter to the Scope. Select External Mode in place of Normal
Mode. Now click on Run button and it will run your model in the controller
and whatever the controller will read you will be able to see on your scope.
17
Step 5: Take constants and Gain blocks to calibrate your voltage or current.
And re-run the simulation.
18