Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (1 vote)
88 views

Arduino MATLAB Interface - How To Interface Arduino With MALTAB

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
88 views

Arduino MATLAB Interface - How To Interface Arduino With MALTAB

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?

ELECTRONICS HUB
P R OJ E C T S | T U TO R I A L S | C O U R S E S | K I T S

HOME PROJECTS MINI PROJECTS FREE CIRCUITS TUTORIALS SYMBOLS DIY

PROJECT KITS COURSES CONTACT US

HOME » GENERAL » ARDUINO MATLAB INTERFACE MADE EASY – HOW TO INTERFACE ARDUINO WITH MALTAB?

Arduino MATLAB Interface Made Easy –


How to Interface Arduino with MALTAB?
DECEMBER 28, 2017 BY RAVI — LEAVE A COMMENT

In this project, I’ll show you how the Arduino MATLAB Interface works and all the steps
involved in interfacing Arduino with MATLAB.

Arduino is one of the favorite prototyping platform among makers and hobbyists. MATLAB, on
the other hand, is a professional numerical computing tool used by engineers and scientists.
Interfacing Arduino with MATLAB makes things interesting as one is aimed at an entry and
hobbyist level of users while the other is a very complex tool used by professionals.

Table of Contents 
1. How Arduino MATLAB Interface Works?
2. Installing MATLAB Support Package for Arduino
3. Interfacing Arduino with MATLAB and Testing the Support Package
4. Programming Arduino using MATLAB
5. CODE
6. Summary of Arduino MATLAB Interface
7. Applications of Arduino MATLAB Interface

How Arduino MATLAB Interface Works?


We normally use Arduino IDE to write and upload programs (or Sketches) to Arduino. This is
ne for regular use but if you want to plot the data obtained from sensors, then the
programming becomes a time consuming task.

https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+ElectronicsH… 1/12
12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?

MATLAB addresses several such problems in Arduino Programming with the help of two types
of processes:

Reading, writing and analyzing data from Sensors


Developing Algorithms that run as standalone program on Arduino

In order to achieve this, we need an extra package for MATLAB called MATLAB Support
Package for Arduino. This is o cially released by MATLAB and is available for free in their
website (you need to have an account to download this package).

Installing MATLAB Support Package for Arduino


Now we’ll see how to install the MATLAB Support package for Arduino. First, start the MATLAB
Application and in the RESOURCES Tab, go to Add-ons and select Get Hardware Support
Packages option.

After initializing the add-on, you will then get an options of how to install the package i.e. from
the internet or from a le already that is already downloaded. I’ve chosen to install from the
internet.

You will then get a list of all the available Support Packages. Select Arduino and check the
MATLAB Support Package. There are Arduino Support Packages for Simulink as well but we
will leave it for later.

https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+ElectronicsH… 2/12
12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?

Now, the MATLAB Application will ask you to login to you MathWorks Account. If you have an
account, use those credentials and login or you can create an account during installation.
Next, accept the license terms and continue to download the package.

MATLAB will now download and install the selected packages. Sit back and relax until it is
done. 

Also read MATLAB PROJRCTS FOR ENGINEERING STUDENTS

Interfacing Arduino with MATLAB and Testing the Support


Package
After installing the Arduino Package for MATLAB, we will now see how to interface Arduino
and MATLAB. Connect the Arduino board to the computer that is running MATLAB and open
MATLAB Application.

In the command window, type the following and hit enter.

a = arduino ()

This step will create a connection between MATLAB and Arduino and returns with the
properties of the Arduino Board like COM Port, Name, etc. as shown in the screenshot below.

https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+ElectronicsH… 3/12
12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?

If more than one Arduino board is connected to the computer and if you want to communicate
with a speci c board, use the following command.

a = arduino (‘com8’, ’Mega2560’)

NOTE: You have to clear the variable ‘a’ using the command ‘clear a’.

Programming Arduino using MATLAB


We will now see how to program the Arduino Board using MATLAB Programming. For this, I
will be using the Arduino Mega Board. It has an on-board LED connected to Digital Pin 13.

I’ll write a MATLAB Program in order to blink this LED for 10 times with a delay of 1 second.
Alternatively, you can connect an external LED with a current limiting resistor to the Digital Pin
13 and the following image shows the circuit diagram for this connection.

https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+ElectronicsH… 4/12
12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?

In the le tab, go to New and select Script option. A blank editor will be opened. Paste the
code mentioned in the following section and save the le. It will be save as a .m le, which is
the extension for MATLAB Programs.

NOTE: Change the COM Port and Arduino Board according to your needs in the code.

After saving the le, click on Run option. The MATLAB program will interact with the Arduino
Board and will perform the desired option.

An important point to be noted is that the program will not be uploaded to Arduino and hence
if you reset or restart the Arduino Board, the program will be lost and you need to perform the
above steps once again.

There is another way to program Arduino Board through MATLAB, but we will see that later.

https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+ElectronicsH… 5/12
12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?

CODE

1 % create an arduino object


2
3 a = arduino('com8', 'Mega2560');

4
5 % start the loop to blink led for 10 seconds
6
7 for i = 1:5

8
9 writeDigitalPin(a, 'D13', 1);
10
11 pause(1);
12
13 writeDigitalPin(a, 'D13', 0);
14
15 pause(1);
16
17 end
18
19 %end communication with arduino
20
21 clear a

Arduino_MATLAB_LED_Blink.m hosted with by GitHub view raw

Summary of Arduino MATLAB Interface


Download and Install the Arduino Hardware Support Package for MATLAB.
Connect the Arduino board to the computer running MATLAB and check if the Arduino
can be communicated through MATLAB.
Make a simple circuit for blinking an LED connected to one of the Digital Pins of Arduino.
Write a MATLAB program for blinking the LED and save it as a .m le.
Run the MATLAB Program and the LED connected to Arduino should start blinking as per
the program.

Applications of Arduino MATLAB Interface


By interfacing Arduino with MATLAB, we can acquire Sensor Data from Arduino and start
plotting various graphs.
We can create GUI (Graphical User Interface) for controlling our Arduino with the help of
MATLAB.
A wide range of projects related to image processing and signal processing can be
implemented using Arduino and MATLAB.
Some of the projects can be Color Detection, Object Tracking, Face Detection, etc.

https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+ElectronicsH… 6/12
12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?

New

FILED UNDER: ARDUINO, GENERAL

Leave a Reply
Your email address will not be published. Required elds are marked *

Comment

Name *

Email *

Website

https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+ElectronicsH… 7/12
12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?

POST COMMENT

Search this website …

https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+ElectronicsH… 8/12
12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?

Suggest A Topic [or] Project

ads by media.n

3D Data Visualization Software

Microsoft Excel Data Analysis

Teacher Education

Education Grants

Schools

Educational Leadership

Degrees

Mi Max 2 (Black … OnePlus 5T …


Rs. 15,999.00 Rs. 37,999.00
(details + delivery) (details + delivery)

https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+ElectronicsH… 9/12
12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?

ads by media.net

College Education Online

Universities

Early Childhood Education

Student Education

Scholarships For College

Jobs In Education

International Online Education

Online Education Courses

MBA

Executive Education

Education Grants

Continuing Education

Bachelor Degrees

Higher Education Ideas

Teaching

PROJECTS BY CATEGORY

Arduino Projects (200+)


Electronics Projects (250+)
Mini Project Circuits (160+)
Mini Project Ideas (150+)
ECE Projects (150+)
EEE Projects (150+)
8051 Projects (110+)
Raspberry Pi Projects (101+)
Electrical Project Ideas (100+)
Embedded Projects (100+)
Latest Electronics Ideas (100+)
Microcontroller Mini Projects (100+)
Robotics Projects (100+)
https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+Electronics… 10/12
12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?

VLSI Projects (100+)


Solar Projects (100+)
IOT Projects (100+)

Communication Projects (70+)


LED Projects (70+)
Power Electronics Projects (60+)
RFID Projects (60+)
Home Automation Projects (50+)
Matlab Projects (50+)
EIE Projects (50+)
Wireless Projects (50+)
LabView Projects (45+)
Zigbee Projects (45+)
GSM Projects (40+)
555 Timer Circuits (40+)
Sensor Projects (40+)
ARM Projects (60+)
DTMF Projects (30+)
PIC Projects (30+)
Electrical Mini Projects (25)

GENERAL PROJECTS PROJECTS

Tutorials Electrical Mini projects

Symbols Electronics Microcontroller

Courses Embedded Arduino

Calculator Power Solar

Contact Robotics Free circuits

ARM Home Automation


IOT Seminar Topics

Electronics
Questions

TUTORIALS TUTORIALS FOLLOW US

Capacitors Ampli ers Instagram


Resistors IO Devices Youtube

Filters Thyristors Facebook

Diodes DC Circuits Google Plus

Transistors Number System Twitter

https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+Electronics… 11/12
12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?

Copyright © 2017 Electronicshub.org

https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+Electronics… 12/12

You might also like