The recent versions of SIMULINK have support package for Arduino (UNO, Mega2560, etc.), BeagleBone, etc. This has made it easier to simulate and upload the designs directly to the board.
In this project, we’ll use the SIMULINK tool to blink an LED connected to our Arduino UNO.
It is a block diagram based tool in which there’s no requirement to write a code in C or so, rather the block diagram model is directly converted and uploaded to the board by MATLAB tools. To begin with, we will generate an LED Blink code and run it on Arduino-UNO.
But Before getting to it, you need to check for some pre-requisites. Your computer must have Matlab-R2013 or above, (This tutorial is on MATLAB-R2014a). If you have student version of MATLAB -2013 or 2014, it will do.
Now we need to install the Arduino Support Package from the official MathWorks site,
When you open MATLAB, a screen appears which has several windows embedded in it, viz. Command window, etc. Select SIMULINK library from the Menu Bar in the main window.
You will see a pop-up screen as follows:
Go to ‘Simulink Support Package for Arduino’ and you will see a screen as above.
Contd..
After this you will see a Simulink model window as shown below:
After this, we need to generate a pulse, which will turn our LED ON and OFF. To get this, again click on Simulink Library. Go to ‘Sources’ and select Pulse Generator from the list, and add it to the Model by a right click on it.
Connect both blocks with each other. Now Double click on ‘Pulse Generator’ to edit its properties. You can have the delay, sample time, etc., of your own choice. As an example, you can set the ones shown below:
After having completed above steps, we will set the ‘Target Hardware’ and set its properties. Go to ‘Tools’ from the Menu Bar, and select ‘Run on Target Hardware’, a pop-up window will appear, as shown below:
Select the Target Hardware (say Arduino UNO) and choose the COM Port. You can select it manually if it doesn’t work automatically.
Select ‘Apply’ and click OK. Congratulations…!!!
If it shows errors, re-check the COM port from Device Manager->Ports.
Filed Under: Arduino Projects, Electronic Projects
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.