Arduino UNO working
standalone with the model compiled and simulated from Simulink.
One interested task if you have experience working with Simulink, and
you want to run your Simulink models in the Arduino board, is not a big deal
when your read this memory.
Your requirements are:
Software:
1.
Matlab with Simulink R2011a Version 7.12.0.635 or
newer.
2.
The IDE Arduino software to program the Arduino
UNO board . “ arduino-0023.zip “
3.
Simulink package for the Arduino. “ Simulink_support_package_arduino.zip ”
Hardware:
- Arduino™ UNO rev3 aprox. 22€
- USB cable aprox. 4€
- Some
LEDs to check your first programs with some 220 Ohms resistors.
Process:
- Install
the driver for Windows of the Arduino UNO
- Unzip “
arduino-0023.zip “ -> For
instance at: 'C:\arduino-0023’
- It
will create the folder 'C:\arduino-0023\arduino-0023’
- In
this folder you will find the IDE file, the arduino.exe (This is the file that Simulink will
call to compile the target file to send from Simulink environment to the
Arduino Board via the USB port.
- You should have already the Matlab + Simulink
in your PC.
- Unzip
the file ‘ Simulink_support_package_arduino.zip ‘
- It
will create 3 folders:
i.
\arduino It
has inside the folder +arduino and inside it a file Prefs.m
ii.
\blocks
iii.
\demos It
contains simulink mdl files like the example ‘demo_arduino_blink.mdl’ This make flashing one led in the pin 13
- Open Matlab and type:
- cd C:\simulink_support_package_arduino
- addpath(fullfile(pwd,'arduino'),fullfile(pwd,'blocks'),fullfile(pwd,'demos'))
- savepath
- arduino.Prefs.setArduinoPath('C:\arduino-0023\arduino-0023')
- comPorts=arduino.Prefs.searchForComPort
- arduino.Prefs.setComPort('com3')
- arduino.Prefs.setBoard('uno')
- demo_arduino_blink
This will select the
board as Arduino uno and the com port will be shown.
Note that you need to
have the Windows driver installed to recognize the Arduino UNO board as
hardware.
- Once
the model demo_arduino_blink.mdl is loaded
in Simulink, if you have the board connected, you only need to do this to
download the model on the board, to execute it stand alone. After this the
board will not need to be connected to the PC.
- Build
and deploy the executable by pressing Ctrl+B, or choosing
Tools > Code Generation > Build Model.
If the deployment is
successful, you should
see the LED connected to PIN 13 blinking
once per second.
If you did like this project you can donate some cents of Bitcoins SV in the following address.
1sAZQMy5Ci1G88CmbucFJDsF7TxeXAcko
or bitcoin cash in the address:
qzmjpeqrlgd3flltpavm9t2xh0nz8y97mggajvvqnv