Modelagem Arduino em MATLAB-Simulink

Arduino modeling in MATLAB-Simulink

MATLAB-Simulink is a data flow graphical programming language tool for modeling and simulating multi-domain systems. It is developed and owned by MathWorks Inc. In other words, it is a block diagram environment for simulating various systems from different domains.

Recent versions of SIMULINK have a support package for Arduino (UNO, Mega2560, etc.), BeagleBone, etc. This made it easier to mock up and send designs directly to the board.

In this project, we will use the SIMULINK Tool to blink an LED connected to our Arduino UNO.

It is a block diagram based tool in which there is no need to write code in C or anything like that, instead the block diagram model is directly converted and loaded on the board by MATLAB tools. To start, we will generate an LED Blink code and run it on the Arduino-UNO.

But before you start, you need to check some prerequisites. Your computer must have Matlab-R2013 or higher (this tutorial is on MATLAB-R2014a). If you have the student version of MATLAB -2013 or 2014, it will do.

Now we need to install the Arduino Support Package from the official MathWorks website,

After completing the steps above, let's start creating our system design:

When you open MATLAB, a screen appears with several embedded windows, viz. Command window, etc. Select the SIMULINK library from the main window menu bar.

You will see a pop-up screen as follows:

Captura de tela da biblioteca Simulink no Matlab

Go to 'Simulink Support Package for Arduino' and you will see a screen like above.

Cont..

Select Digital Output from the list to control the LEAD . Right click and select 'Add to new template'.

Captura de tela da seleção de saída digital no Simulink

After that, you will see a Simulink model window as shown below:

Captura de tela do modelo Simulink no Matlab

'Digital Pin 9' is declared as OUTPUT. You can change the Pin setting by double-clicking it. When double-clicking, a pop-up window appears as shown here:

Captura de tela da janela Configuração de Pin no Simulink

After that, we need to generate a pulse , which will turn our LED on and off. To achieve this, click on Simulink Library again. Go to 'Sources' and select Pulse Generator from the list and add it to the template by right-clicking on it.

Captura de tela da adição de gerador de pulso no Simulink

Connect the two blocks together. Now double click on 'Pulse Generator' to edit its properties. You can set the delay, sampling time, etc. of your choice. As an example, you can define the ones shown below:

Captura de tela das propriedades do gerador de pulso no Simulink

After completing the above steps, we will define the 'Target Hardware' and set its properties. Go to ' Tools ' in the menu bar and select ' Run on target hardware ', a pop-up window will appear as shown below:

Captura de tela da seleção do hardware de destino no Simulink

Select the target hardware (say Arduino UNO) and choose the COM port. You can select it manually if it doesn't work automatically.

Captura de tela da seleção do Arduino Uno como hardware alvo no Simulink

Select 'Apply' and click OK. Congratulations…!!!

We are just one step away. From the menu bar, select the ' Deploy to hardware ' option.

Captura de tela do Simulink mostrando o botão ‘Implantar no hardware’

If you have correctly selected the hardware as well as the COM ports and correctly installed the support packages, the hardware will run on the first try.

If it shows errors, recheck the COM port from Device Manager->Ports.

As an extension of the above system, you can add input devices, add logic to your project or design your first line follower robot in Simulink..!!!

Conteúdo Relacionado

ESP32-CAM is a compact camera module that combines the...
A network of sensors is embedded in every vehicle,...
The motor controller is one of the most important...
A evolução dos padrões USB foi fundamental para moldar...
A SCHURTER anuncia um aprimoramento para sua conhecida série...
A Sealevel Systems anuncia o lançamento da Interface Serial...
A STMicroelectronics introduziu Diodos retificadores Schottky de trincheira de...
Determinar uma localização precisa é necessário em várias indústrias...
O novo VIPerGaN50 da STMicroelectronics simplifica a construção de...
A Samsung Electronics, fornecedora de tecnologia de memória avançada,...
O mercado embarcado tem uma necessidade de soluções de...
You have probably come across the term ' drag...
You probably have a support insulator if you've noticed...
You've probably seen stand an insulator sit on power...
You've probably seen shackle insulators enthroned on electricity poles,...
You have probably experienced situations where controlling a circuit...
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.