SlideShare uma empresa Scribd logo
1 de 91
Baixar para ler offline
Table of Contents
Preface
1. Preparing Development Environment
1.1 Arduino
1.1.1 Arduino Uno
1.1.2 Arduino Leonardo
1.1.3 Arduino Mega 2560
1.1.4 Arduino Due
1.2 Electronic Components
1.2.1 Arduino Starter Kit
1.2.2 Fritzing
1.2.3 Cooking-Hacks: Arduino Starter Kit
1.2.4 Arduino Sidekick Basic kit
1.3 Matlab Simulink
1.4 Arduino Software
1.5 Testing
2. Matlab Simulink and Arduino
2.1 Matlab
2.2 Installing Arduino for Simulink Target
3. Hello World - Matlab Simulink and Arduino
3.1 Hello World
3.2 Creating Arduino Simulink
3.2.1 Configuring Arduino Digital Output
3.2.2 Configuring Pulse Generator
3.2.3 Configuring Scope
3.3 Configuring Arduino
3.3 Running Simulink
4. Simulink with Arduino Digital I/O
4.1 Working with Arduino Digital I/O
4.2 Digital Sources
4.3 Simulink with Arduino Digital I/O
4.3.1 Digital Input
4.3.2 Digital Output
4.3.3 Logical Operator
4.3.4 Pulse Generator
4.3.5 Configuring Hardware
4.4 Testing
5. Simulink with Arduino Analog I/O
5.1 Simulink with Arduino Analog Input
5.1.1 Reading Temperature Analog Sensor
5.1.2 Building Simulink Model
5.1.3 Executing Simulink Model
5.2 Simulink with Arduino Analog Output
5.2.1 Controlling RGB LED Color
5.2.2 Building Simulink Model
5.2.3 Executing Simulink Model
6. Simulink with Arduino Serial
6.1 Arduino Serial Communication
6.2 Configuring Arduino
6.3 Building a Simulink Model
6.3.1 Serial Transmit
6.3.2 Serial Receive
6.3.3 Counter Limited
6.3.4 Data Type Conversion
6.4 Testing
7. Simulink with Arduino and Servo Motor
7.1 Servo Motor
7.2 Building A Simulink Hardware
7.3 Building A Simulink Model with Arduino and Servo Motor
7.3.1 Standard Servo Write
7.3.2 Standard Servo Read
7.3.3 Counter Limited
7.3.4 Serial Transmit
7.4 Testing
Contact
Preface
This book was written to help anyone wants to get started in Arduino and Matlab Simulink. It
describes all the basic elements of the Arduino and Matlab Simulink with step-by-step approach.
Agus Kurniawan
Berlin, September 2013
1. Preparing Development Environment
To develop a program with Matlab Simulink and Arduino, you need the following required
environment:
Arduino
Matlab
Arduino software
Electronic components for testing
In this chapter, I'm going to explain in brief required items for Matlab simulink and Arduino
development.
1.1 Arduino
Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware
and software. This board uses Atmel microcontroller series. There are many Arduino hardware
models that you can use. Further information about Arduino products, you can visit on
website http://arduino.cc/en/ .
You must one Arduino hardware to follow practices in this book. I recommend to obtain one of the
following Arduino hardware:
Arduino Uno
Arduino Leonardo
Arduino Mega 2560
Arduino Due
You can buy this product on your local electronic store. You also can order it by online. Find it
on http://arduino.cc/en/Main/Buy. The following is the list of Arduino store you can buy
Arduino store, http://store.arduino.cc/
Amazon, http://www.amazon.com
Cooking-hacks, http://www.cooking-hacks.com/index.php/shop/arduino.html
RS Components, http://www.rs-components.com
Element 14, http://www.element14.com
EXP-Tech, http://www.exp-tech.de
Because Arduino is an open-source hardware, people can build it. It's called Arduino compatible.
Generally it's sold in low prices.
1.1.1 Arduino Uno
The Arduino Uno is a microcontroller board based on the ATmega328. You can download the
datasheet file, http://www.atmel.com/dyn/resources/prod_documents/doc8161.pdf .
Further information about Arduino Uno, you can read it
on http://arduino.cc/en/Main/ArduinoBoardUno .
1.1.2 Arduino Leonardo
The Arduino Leonardo is a microcontroller board based on the ATmega32u4. Download dataset for
this product on http://www.atmel.com/dyn/resources/prod_documents/7766S.pdf .
Visit this product to get the further information
on http://arduino.cc/en/Main/ArduinoBoardLeonardo .
1.1.3 Arduino Mega 2560
The Arduino Mega 2560 is a microcontroller board based on the ATmega2560. You can download
the dataset file on http://www.atmel.com/dyn/resources/prod_documents/doc2549.PDF.
Further information about Arduino Mega 2560, you can visit
on http://arduino.cc/en/Main/ArduinoBoardMega2560 .
1.1.4 Arduino Due
The Arduino Due is a microcontroller board based on the Atmel SAM3X8E ARM Cortex-M3 CPU.
You can download the datasheet, http://www.atmel.com/Images/doc11057.pdf.
If you want to know about Arduino Due, I recommend to visit this
website, http://arduino.cc/en/Main/ArduinoBoardDue.
1.2 Electronic Components
We need electronic components to build our testing, for instance, Resistor, LED, sensor devices and
etc. I recommend you can buy electronic component kit.
1.2.1 Arduino Starter Kit
Store website: http://arduino.cc/en/Main/ArduinoStarterKit
1.2.2 Fritzing
Store website: http://shop.fritzing.org/ .
You can buy Fritzing Starter Kit with Arduino UNO or Fritzing Starter Kit with Arduino Mega.
1.2.3 Cooking-Hacks: Arduino Starter Kit
Store website: http://www.cooking-hacks.com/index.php/shop/arduino/starter-kits/arduino-starter-
kit.html
1.2.4 Arduino Sidekick Basic kit
Store website: http://www.seeedstudio.com/depot/arduino-sidekick-basic-kit-p-775.html
Alternative online store
http://www.amazon.com/Arduino-Sidekick-Basic-Kit-Version/dp/B007B14HM8/
http://www.exp-tech.de/Zubehoer/Arduino-Sidekick-Basic-Kit.html
1.3 Matlab Simulink
You can work with Matlab Simulink with targeting on Arduino using Matlab 2013a or the latest
version. You also can work with Matlab 2013a Student Version.
1.4 Arduino Software
To develop application based on Arduino board, we need Arduino software. You can obtain it
on http://arduino.cc/en/Main/Software . Please install based on your platform.
If your platform is Ubuntu, you can install by writing this script
sudo apt-get install arduino
For Windows platform, you can download setup file and install it.
The following is a screenshot of Arduino software on Ubuntu platform.
Here is Arduino software on Windows 8 platform.
If you run Arduino software on Windows platform, you should configure arduino.exe running as
Administrator. You can change it by editing file property. Click Compatibility and then checked Run
this program as an administrator.
1.5 Testing
For testing, I used Arduino Uno and Arduino Mega 2560 on Ubuntu and Windows 8 platforms.
I also used Arduino Sidekick Basic kit for electronic components.
2. Matlab Simulink and Arduino
This chapter explains how to work with Matlab Simulink and Arduino Software.
2.1 Matlab
You can work with Matlab Simulink with targeting on Arduino using Matlab 2013a or the latest
version. You also can work with Matlab 2013a Student Version.
2.2 Installing Arduino for Simulink Target
You need internet connection to download Arduino package.
Now run your Matlab and then click Add-Ons. You can see the menu as below.
Select Get Hardware Support Packages.
Then you will obtain a dialog, called Support Package Installer.
Select Internet (recommended).
You may log in to MathWorks Account to continue installation process. Click Log In and then entry
your username and password.
After that, click Next button.
Check Arduino and then click Next button.
You will see a license agreement as below.
Checked I accept. If done, click Next button.
Click Next button.
Click Install button.
It will download Arduino package and then install it.
If success, you will obtain a dialog as below.
Click Finish button.
Now you see Arduino on Simulink Library Browser.
3. Hello World - Matlab Simulink and Arduino
In this chapter we create as simple Matlab Simulink with Arduino.
3.1 Hello World
We are going to build a simple Matlab Simulink with Arduino, called Hello World. In this scenario,
we work with LED on Arduino.
If you see Matlab Simulink Library on Arduino, you can see Digital Output library. This library
generates digital output on Arduino. We will use this library on our model to turn on and off our LED.
3.2 Creating Arduino Simulink
Now we are ready to build a "hello world" Matlab Simulink with Arduino. Follow all steps.
Firstly run your Matlab 2013a or the latest version.
On Home, click + New icon. Then you will obtain a menu as below.
Select Simulink Model.
Then you obtain a Simulink dialog as below.
Next step, we build a simulink model.
On the Simulik Model dialog, click menu Tools -> Library Browser.
Then you will the list of Simulink library include Arduino library.
Click Simulink Support Package for Arduino Hardware, then you will see all Arduino installed
library.
For our scenario, hello world, we create a simulink as below.
You need three libraries as follows
Digital Output on Simulink Support Package for Raspberry Pi Hardware
Pulse Generator on Sources
Scope on Commonly Used Blocks
After all items connected, we configure these.
3.2.1 Configuring Arduino Digital Output
To configure Arduino Digital Output, double-click Digital Output on model. Then you obtain a dialog
as below
You entry which digital pin on your Arduino board that LED is connected. If finished, click OK
button.
3.2.2 Configuring Pulse Generator
Double click on Pulse Generator so you obtain a dialog as below
For testing, we use configurations as follows:
Pulse type: Sample based
Time (t): Use simulation time
Amplitude: 1
Period: 10
Pulse width: 5
Phase delay: 0
Sample time: 0.2
Checked Interpret vector parameters as 1-D
If done, click OK button.
3.2.3 Configuring Scope
You don't need configure anything for scope library. You can do a double click on scope library and
then you can see a graphic.
3.3 Configuring Arduino
Now you can configure your LED to plug into Arduino. The following is Arduino and LED
configuration. LED is connected to digital pin 10. You may change this digital pin.
3.3 Running Simulink
Save your model, for instance, helloworld.
You test and validate your model. Make sure you select Normal. Then, click Arrow, shown in Figure
below.
If success, you don't see the error dialog.
Now you are ready to deploy to Arduino and run it.
To run this model to Arduino, you must configure. How? Click menu Tools -> Run on Target
Hardware -> Prepare to Run.
Then you will obtain a dialog as below.
Select Arduino on Target hardware. In this scenario, I used Arduino Mega 2560.
Click OK button.
After that, you will see Arduino configuration.
Choose Set host COM port for your Arduino device. Make sure your Arduino already connected.
For COM setting, I chosen Automatically.
Checked Enable External mode to obtain feedback results from Arduino.
If done, click OK button.
To deploy and run on Arduino, click menu Tools -> Run on Target Hardware -> Run .
Matlab will be compile the model and send it to Arduino. You can see the compiling process shown
in Figure below.
If process is success, you will see the LED is blinked.
Then you also can see a graphic on Scope as follow.
4. Simulink with Arduino Digital I/O
This chapter explains how to program simulink using Arduino Digital I/O.
4.1 Working with Arduino Digital I/O
Arduino provides digital I/O that we can use easily. In this scenario, we will build a simple
simulation for Matlab simulink. We use digital sources as Arduino digital input. You can use any
digital source, for instance, digital sensor, button, etc. I use Arduino Uno as digital source.
The following is our scenario for building Matlab simulink.
4.2 Digital Sources
I build a simple Arduino code to generate digital signal.
Open your arduino application and write this script
int signal = 13;
void setup() {
pinMode(signal, OUTPUT);
}
void loop() {
digitalWrite(signal, HIGH);
delay(2000);
digitalWrite(signal, LOW);
delay(1000);
digitalWrite(signal, HIGH);
delay(1000);
digitalWrite(signal, LOW);
delay(500);
}
You also can see a sample code as below.
4.3 Simulink with Arduino Digital I/O
In this section, we're going to a simulink model with Arduino and LED.
The following is a simulink model.
Notes:
Digital Input and Digital Output on Simulink Support Package for Arduino Hardware
Logical Operator on Commonly Used Blocks
Scope on Commonly Used Blocks
Pulse Generator on Sources
Now we start to build a simulink model and configure it.
4.3.1 Digital Input
Arduino digital input will be connected to digital source, such as digital sensor. You can configure
what digital input pin is be used on Arduino. In this scenario, I used digital input pin 8.
The following is a screenshot of digital input dialog.
If done, click OK button.
4.3.2 Digital Output
After you open a Digital Output dialog, you will obtain a dialog shown in Figure below.
Fill pin for Arduino digital output. I used pin 10 for my scenario.
If finished, click OK button.
4.3.3 Logical Operator
Double click Logical Operator library and then you will a dialog shown in Figure below.
Chosen AND on Operator and Number of Input ports is 2.
Click OK if finished.
4.3.4 Pulse Generator
The next task is to configure a pulse generator library. Double click this library and then you will
obtain a dialog as follows.
The following is my configuration for the pulse generator library:
Pulse type : Sample based
Time (t): Use simulation time
Amplitude: 1
Period: 10
Pulse width: 5
Phase delay: 0
Sample time: 0.2
If done, click OK button.
4.3.5 Configuring Hardware
Now you can connect your hardware, Arduino, digital source and LED. For my scenario, I used
Arduino as digital source and connect to digital pin 8. The following is my hardware configuration.
4.4 Testing
After we build a simulink model and Arduino hardware, we can build and deploy to Arduino. Please
read chapter 3 section 3.3 if you don't know how to build and run a Arduino simulink.
If your model run successfully, you see that LED turned on and off.
You also can open Scope for digital input. Then you see the digital signal (pulse signal) graphic on
Scope library. The following is a sample graphic.
Open Scope library for pulse generator too. You can see a sample graphic as below.
Scope for AND operation shows the result of AND operation between digital input and pulse
generator. The following is a sample graphic.
5. Simulink with Arduino Analog I/O
This chapter explains how to work with Arduino Analog I/O and Matlab Simulink. We build two
simulink models to illustrate how to use Arduino analog I/O. The following are our scenarios:
Reading temperature sensor using Arduino analog input
Controlling RGB LED color using Arduino analog output (PWM)
5.1 Simulink with Arduino Analog Input
Arduino can be interfaced with sensor devices. You can see the list of sensor interface
on http://playground.arduino.cc/Main/InterfacingWithHardware .
In this scenario, we use cheap temperature sensor device, thermistor. Thermistor can be used to
measure temperature. I have thermistor 503 from Arduino Sidekick Basic kit. Thermistor 508 can be
shown in Figure below.
Now we can start to build simulink model to read temperature analog sensor.
5.1.1 Reading Temperature Analog Sensor
To build sensor hardware, we need resistor 50k ohm. If your thermistor is 10k ohm, you should use a
resistor with 10k ohm.
The following is a circuit schema for thermistor sensor.
We use a divider approach. One of sensor pin is connected to 5V Arduino pin. Thermistor 503 is
attached to the Analog In of Arduino, A4. The following is hardware implementation.
Normally Arduino ADC generates value 0 - 1023. To read sensor data, I used an approach based on
this site, http://playground.arduino.cc/ComponentLib/Thermistor2 . In this scenario I used Celsius
unit. How to read and to convert to Celsius unit you can use the following function.
double Thermister(int RawADC) {
double Temp;
Temp = log(((10240000/RawADC) - 10000));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* T
Temp = Temp - 273.15; // Convert Kelvin to Celcius
return Temp;
}
RawADC is a sensor value from Arduino analog input. This function will be implemented in simulink
model.
5.1.2 Building Simulink Model
Now you can build simulink model. The following is a simulink model to read temperature sensor.
For analog input, I used pin 4. You may change it based on your hardware implementation.
The second module is subsystem. This module is Thermistor function implementation. The following
is function implementation.
Notes:
Devide, Add, Subtract, Product, Math Function on Math Operations
Constant on Commonly Used Blocks
Make sure all modules must be configured Output data type as double. The following is a sample of
Output data type.
You also can use Matlab function that you can create to change a Subsystem.
5.1.3 Executing Simulink Model
After build simulink model, plug in your hardware into computer. Now you can execute your
simulink. Read chapter 3 to configure simulink for Arduino.
The following is a scope output of Arduino input.
You can see Arduino read sensor values around 524-525. After that, these values will be converted to
Celcius using Thermistor function.
The following is a scope output from Thermistor function.
You can see the temperature data, for instance, on time 2 temperature has 26.16 Celcius.
5.2 Simulink with Arduino Analog Output
The second scenario we build a simulink to control RGB LED color using Arduino Analog output
(PWM). RGB LED has 4 pins that you can see it on Figure below.
To understand these pins, you can see the following Figure.
Note:
Pin 1: Red
Pin 2: Common pin
Pin 3: Green
Pin 4: Blue
Now we can start to build a simulink and hardware implementation.
5.2.1 Controlling RGB LED Color
Firstly we implement sensor hardware. The following is a hardware schema.
Note:
RGB LED pin 1 is connected to Arduino PWM pin 6
RGB LED pin 2 is connected to Arduino VCC 5V
RGB LED pin 3 is connected to Arduino PWM pin 5
RGB LED pin 4 is connected to Arduino PWM pin 4
Here is a sample implementation.
5.2.2 Building Simulink Model
Now we can build a simulink mode. Run your Matlab application and create a new Model.
Build a model as follows.
Note:
Repeating Sequence library can be found on Sources.
On PWM library you can set Arduino PWM pin. In this case, I used Arduino PWN pins: 6, 5, and 4.
On Repeating Sequence for PWM pin 6, you configure as follows.
Configure Repeating Sequence for PWM pin 5 as below.
Finally you can configure Repeating Sequence for PWM pin 4 as follows.
If done, save your a simulink model.
5.2.3 Executing Simulink Model
Plug your Arduino with RGB LED into computer. After that, compile your model. If success,
configure a model with Arduino hardware target. Read chapter 3 to configure a model for Arduino.
If your model doesn't has any error while deploying to Arduino, you will see RGB LED shows some
colors based on RGB value. The following is a sample output for Arduino and RGB LED.
You also can see the output of red values shown on Figure below.
The output of green values can be seen as below.
The last you can see the output of blue values as below.
6. Simulink with Arduino Serial
This chapter explains how to program simulink using Arduino Serial.
6.1 Arduino Serial Communication
Arduino provides serial port that we can use easily. In this scenario, we will build a simple
simulation for Matlab simulink. The following is information related to Arduino serial
Arduino Uno has serial port: Rx (pin 0) and Tx (pin 1)
Arduino Mega has 4 serial ports: Rx 0 (pin 0) Tx 0 (pin 1), Rx 1 (pin 19) Tx (pin 18), Rx 2
(pin 17) Tx 2 (pin 16), Rx 3 (pin 15) Tx 3 (pin 14)
For Arduino Mega, you can not use serial port 0 (Rx 0 and Tx 0).
In this scenario, we use 2 Arduino devices, Arduino Mega 2560 and Arduino Mega 1280. The second
Arduino is be used as "bridge". It receives serial data from the first Arduino and then it will be sent
back to the first Arduino.
6.2 Configuring Arduino
To build a serial communication with two Arduino devices, you must interchange between Rx and Tx
cables. The following is a Arduino schema for serial communication.
In this scenario, I used serial Rx 1 Tx 1 connected to the second Arduino on Rx 0 Tx 0.
You can see a sample implementation as below.
As I said, the second Arduino is be used as "bridge". We must write code to receive serial data and
send back to serial port.
Now open Arduino application. Then write this code.
int data = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
if (Serial.available() > 0) {
data = Serial.read();
Serial.write(data);
}
}
The following is a code implementation on Arduino application.
Save all codes for the second Arduino. Before you compile and upload codes to the second Arduino,
you must unplug cables from Rx 0 Tx 0. If not, you fail to upload codes to Arduino because it seems
serial port 0 that is be used.
6.3 Building a Simulink Model
In this section, we're going to a simulink model with Arduino serial port.
The following is a simulink model.
Notes:
Serial Transmit and Serial Receive on Simulink Support Package for Arduino Hardware
Scope on Commonly Used Blocks
Data Type Conversion on Commonly Used Blocks
Now we start to build a simulink model and configure it.
6.3.1 Serial Transmit
Arduino transmit library is be used to send data. I used serial port 1.
The following is a screenshot of serial transmit dialog.
Fill 1 on Port number. If done, click OK button.
6.3.2 Serial Receive
After you open Serial receive library, you will obtain a dialog shown in Figure below.
Fill 1 for Port number. If finished, click OK button.
6.3.3 Counter Limited
Double click Counter Limited library and then you will a dialog shown in Figure below.
Fill 10 for Upper limit. Click OK if finished.
6.3.4 Data Type Conversion
The next task is to configure a data type conversion library. Double click this library and then you
will obtain a dialog as follows.
Change Output data type uint8. If done, click OK button.
6.4 Testing
After we build a simulink model and Arduino hardware, we can build and deploy to Arduino. Please
read chapter 3 section 3.3 if you don't know how to build and run a Arduino simulink.
If success, open scope library. You can see values that was be sent to to serial transmit on the first
Arduino.
Now open the second scope. As you know, the second Arduino will send back the received data from
serial input (Rx 0). After that, the first Arduino will receive this data. You can see the result the
following Figure as below.
You can see on time 0 to 1, the first Arduino received noise signal data. After time 1, the first Arduino
received the normal data.
7. Simulink with Arduino and Servo Motor
This chapter explains how to program simulink using Arduino and Servo motor.
7.1 Servo Motor
Servo motor provides a shaft movement 360 degree. We can control this movement based on its
degree. In this scenario, you can use any DC motor (servo) that will be connected to Arduino. I used a
mini servo from Arduino Sidekick Basic kit.
The following is a picture of my mini servo motor.
To understand servo's cables, you can identify as follows:
Red cable is be connected to 5V
Black or brown cable is be connected to GND
The rest (yellow or orange cable) is be connected to Arduino PWM pin
The next step we are going to build a simulink with Arduino and servo motor.
7.2 Building A Simulink Hardware
In a simulink scenario, we will control a servo from Matlab. We also read the shaft position of servo
and show the result on graphic and serial port. The following is a general idea that we will
implement.
I used two Arduino devices, Arduino Mega 2560 and Arduino Mega 1280. The second Arduino is be
used to receive serial data so we check on a serial monitor application to see serial data.
The following is my hardware implementation.
Ok, let's build our simulink hardware. Firstly, we build a program for the second Arduino.
Open your Arduino application and write this script
int data = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
if (Serial.available() > 0) {
data = Serial.read();
Serial.print("received: ");
Serial.println(data);
}
}
You also can see a sample code as below.
Save the code. Then compile and upload code to the second Arduino. Don't forget to change board
and port based on your Arduino model. When you upload a program to Arduino, please unplug any
cable from serial pins (Rx Tx pins).
7.3 Building A Simulink Model with Arduino and Servo Motor
In this section, we're going to a simulink model with Arduino and servo motor.
The following is a simulink model that we will build.
Notes:
Standard Servo Write, Standard Servo Read and Serial Transmit on Simulink Support Package
for Arduino Hardware
Scope on Commonly Used Blocks
Counter Limited on Sources
Now we start to build a simulink model and configure it.
7.3.1 Standard Servo Write
Arduino servo write library is be used to control a servo. In this scenario, I used digital input pin 10.
The following is a screenshot of digital input dialog.
If done, click OK button.
To work with standard servo write, we can give input between 0 and 180 to this library.
7.3.2 Standard Servo Read
After you open standard servo read library, you will obtain a dialog shown in Figure below.
Fill pin same as pin value on standard servo write library. Fill 0.5 on Sample time.
If finished, click OK button.
We will obtain a value from this library between 0 and 180.
7.3.3 Counter Limited
Counter limited library is be used to generate a value for standard servo write library. Double click
counter limited library and then you will a dialog shown in Figure below.
Fill 180 for Upper limit and Sample time is 0.5.
Click OK button if finished.
7.3.4 Serial Transmit
The output of standard servo read can be sent to serial port. We can use serial transmit library.
Configure this library as follows.
Fill serial port pin. It depends on your Arduino model.
Click OK button if finished.
7.4 Testing
After we build a simulink model and Arduino hardware, we can build and deploy to Arduino. Please
read chapter 3 section 3.3 if you don't know how to build and run a Arduino simulink.
Before you run the simulink model, set simulation stop time about 90. You can change it that depends
on your period time. Now you run this the simulink model.
Now you can open a scope library to see data from the standard servo read library.
You can open a serial monitor on the second Arduino to see incoming serial data.
If you run your simulink model with disabled Enable External mode, I recommend to change period
time into 1 and simulation stop time 180.
Contact
If you have question related to this book, please contact me at aguskur@hotmail.com . My blog:
http://blog.aguskurniawan.net .
Source code can be downloaded on http://www.aguskurniawan.net/book/matlab_arduino.zip .

Mais conteúdo relacionado

Mais procurados

Acer Predator 15 Laptop - G9-593-77WF manual PDF download (English) / User ...
  Acer Predator 15 Laptop - G9-593-77WF manual PDF download (English) / User ...  Acer Predator 15 Laptop - G9-593-77WF manual PDF download (English) / User ...
Acer Predator 15 Laptop - G9-593-77WF manual PDF download (English) / User ...manualsheet
 
Embeded microcontroler
Embeded microcontrolerEmbeded microcontroler
Embeded microcontrolerYugo Sulistyo
 
Acer Aspire E 15 Laptop (E5-575-51GG) User manual PDF download / User Guide
  Acer Aspire E 15 Laptop (E5-575-51GG) User manual PDF download  / User Guide  Acer Aspire E 15 Laptop (E5-575-51GG) User manual PDF download  / User Guide
Acer Aspire E 15 Laptop (E5-575-51GG) User manual PDF download / User Guidemanualsheet
 
Arduino: Starter kit for arduino(manual de usuario)
Arduino: Starter kit for arduino(manual de usuario)Arduino: Starter kit for arduino(manual de usuario)
Arduino: Starter kit for arduino(manual de usuario)SANTIAGO PABLO ALBERTO
 
Acer Predator GX-792 Manual / User Guide
Acer Predator GX-792 Manual / User GuideAcer Predator GX-792 Manual / User Guide
Acer Predator GX-792 Manual / User Guidemanualsheet
 
Introduction to Arduino and Circuits
Introduction to Arduino and CircuitsIntroduction to Arduino and Circuits
Introduction to Arduino and CircuitsJason Griffey
 
Acer Nitro AN515-31 Manual/User Guide
Acer Nitro AN515-31 Manual/User GuideAcer Nitro AN515-31 Manual/User Guide
Acer Nitro AN515-31 Manual/User Guidemanualsheet
 
Ardublock tutorial
Ardublock tutorialArdublock tutorial
Ardublock tutorialJakie_Li
 
Advanced view arduino projects list use arduino for projects (4)
Advanced view arduino projects list  use arduino for projects (4)Advanced view arduino projects list  use arduino for projects (4)
Advanced view arduino projects list use arduino for projects (4)WiseNaeem
 
Acer Swift 7 SF713-51-M90J Manual / User Guide
Acer Swift 7 SF713-51-M90J Manual / User GuideAcer Swift 7 SF713-51-M90J Manual / User Guide
Acer Swift 7 SF713-51-M90J Manual / User Guidemanualsheet
 
Acer Swift 3 SF314-51-57CP Manual / User Guide
Acer Swift 3 SF314-51-57CP Manual / User GuideAcer Swift 3 SF314-51-57CP Manual / User Guide
Acer Swift 3 SF314-51-57CP Manual / User Guidemanualsheet
 
Acer Swift 5 Ultra SF514 Manual / User Guide
Acer Swift 5 Ultra SF514 Manual / User GuideAcer Swift 5 Ultra SF514 Manual / User Guide
Acer Swift 5 Ultra SF514 Manual / User Guidemanualsheet
 
Capabilities of Arduino (including Due)
Capabilities of Arduino (including Due)Capabilities of Arduino (including Due)
Capabilities of Arduino (including Due)Sudar Muthu
 
IOT Talking to Webserver - how to
IOT Talking to Webserver - how to IOT Talking to Webserver - how to
IOT Talking to Webserver - how to Indraneel Ganguli
 
Bitdefender 2015 av_user_guide antivirus
Bitdefender 2015 av_user_guide antivirusBitdefender 2015 av_user_guide antivirus
Bitdefender 2015 av_user_guide antivirus74689899
 
Projects 1224 at mega32 avr projects
Projects  1224 at mega32 avr projectsProjects  1224 at mega32 avr projects
Projects 1224 at mega32 avr projectsAshraf11111
 
Projects at mega32-avr-projects-list-1197-projects
Projects   at mega32-avr-projects-list-1197-projectsProjects   at mega32-avr-projects-list-1197-projects
Projects at mega32-avr-projects-list-1197-projectsAshraf11111
 
Introduction to Arduino Programming
Introduction to Arduino ProgrammingIntroduction to Arduino Programming
Introduction to Arduino ProgrammingJames Lewis
 
Cassiopeia Ltd - standard Arduino workshop
Cassiopeia Ltd - standard Arduino workshopCassiopeia Ltd - standard Arduino workshop
Cassiopeia Ltd - standard Arduino workshoptomtobback
 

Mais procurados (20)

Acer Predator 15 Laptop - G9-593-77WF manual PDF download (English) / User ...
  Acer Predator 15 Laptop - G9-593-77WF manual PDF download (English) / User ...  Acer Predator 15 Laptop - G9-593-77WF manual PDF download (English) / User ...
Acer Predator 15 Laptop - G9-593-77WF manual PDF download (English) / User ...
 
Embeded microcontroler
Embeded microcontrolerEmbeded microcontroler
Embeded microcontroler
 
Acer Aspire E 15 Laptop (E5-575-51GG) User manual PDF download / User Guide
  Acer Aspire E 15 Laptop (E5-575-51GG) User manual PDF download  / User Guide  Acer Aspire E 15 Laptop (E5-575-51GG) User manual PDF download  / User Guide
Acer Aspire E 15 Laptop (E5-575-51GG) User manual PDF download / User Guide
 
Arduino: Starter kit for arduino(manual de usuario)
Arduino: Starter kit for arduino(manual de usuario)Arduino: Starter kit for arduino(manual de usuario)
Arduino: Starter kit for arduino(manual de usuario)
 
Acer Predator GX-792 Manual / User Guide
Acer Predator GX-792 Manual / User GuideAcer Predator GX-792 Manual / User Guide
Acer Predator GX-792 Manual / User Guide
 
Introduction to Arduino and Circuits
Introduction to Arduino and CircuitsIntroduction to Arduino and Circuits
Introduction to Arduino and Circuits
 
Acer Nitro AN515-31 Manual/User Guide
Acer Nitro AN515-31 Manual/User GuideAcer Nitro AN515-31 Manual/User Guide
Acer Nitro AN515-31 Manual/User Guide
 
Ardublock tutorial
Ardublock tutorialArdublock tutorial
Ardublock tutorial
 
Advanced view arduino projects list use arduino for projects (4)
Advanced view arduino projects list  use arduino for projects (4)Advanced view arduino projects list  use arduino for projects (4)
Advanced view arduino projects list use arduino for projects (4)
 
Acer Swift 7 SF713-51-M90J Manual / User Guide
Acer Swift 7 SF713-51-M90J Manual / User GuideAcer Swift 7 SF713-51-M90J Manual / User Guide
Acer Swift 7 SF713-51-M90J Manual / User Guide
 
Acer Swift 3 SF314-51-57CP Manual / User Guide
Acer Swift 3 SF314-51-57CP Manual / User GuideAcer Swift 3 SF314-51-57CP Manual / User Guide
Acer Swift 3 SF314-51-57CP Manual / User Guide
 
Acer Swift 5 Ultra SF514 Manual / User Guide
Acer Swift 5 Ultra SF514 Manual / User GuideAcer Swift 5 Ultra SF514 Manual / User Guide
Acer Swift 5 Ultra SF514 Manual / User Guide
 
Capabilities of Arduino (including Due)
Capabilities of Arduino (including Due)Capabilities of Arduino (including Due)
Capabilities of Arduino (including Due)
 
User manual acer notebook
User manual acer notebookUser manual acer notebook
User manual acer notebook
 
IOT Talking to Webserver - how to
IOT Talking to Webserver - how to IOT Talking to Webserver - how to
IOT Talking to Webserver - how to
 
Bitdefender 2015 av_user_guide antivirus
Bitdefender 2015 av_user_guide antivirusBitdefender 2015 av_user_guide antivirus
Bitdefender 2015 av_user_guide antivirus
 
Projects 1224 at mega32 avr projects
Projects  1224 at mega32 avr projectsProjects  1224 at mega32 avr projects
Projects 1224 at mega32 avr projects
 
Projects at mega32-avr-projects-list-1197-projects
Projects   at mega32-avr-projects-list-1197-projectsProjects   at mega32-avr-projects-list-1197-projects
Projects at mega32-avr-projects-list-1197-projects
 
Introduction to Arduino Programming
Introduction to Arduino ProgrammingIntroduction to Arduino Programming
Introduction to Arduino Programming
 
Cassiopeia Ltd - standard Arduino workshop
Cassiopeia Ltd - standard Arduino workshopCassiopeia Ltd - standard Arduino workshop
Cassiopeia Ltd - standard Arduino workshop
 

Semelhante a comenzando con MATLAB y Simulink para Arduino

FinalThesisdraft
FinalThesisdraftFinalThesisdraft
FinalThesisdraftSyed Kazmi
 
Intro to arduino
Intro to arduinoIntro to arduino
Intro to arduinoJosé Faria
 
Una guía de inicio rápido de MATLAB a matlab GUI para controlar Arduino
Una guía de inicio rápido de MATLAB a matlab GUI para controlar ArduinoUna guía de inicio rápido de MATLAB a matlab GUI para controlar Arduino
Una guía de inicio rápido de MATLAB a matlab GUI para controlar ArduinoSANTIAGO PABLO ALBERTO
 
Using arduino and raspberry pi for internet of things
Using arduino and raspberry pi for internet of thingsUsing arduino and raspberry pi for internet of things
Using arduino and raspberry pi for internet of thingsSudar Muthu
 
Arduino Development For Beginners
Arduino Development For BeginnersArduino Development For Beginners
Arduino Development For BeginnersFTS seminar
 
Arduino Full Tutorial
Arduino Full TutorialArduino Full Tutorial
Arduino Full TutorialAkshay Sharma
 
Advanced View Arduino Projects List - Use Arduino for Projects 4.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 4.pdfAdvanced View Arduino Projects List - Use Arduino for Projects 4.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 4.pdfWiseNaeem
 
Advanced View Arduino Projects List - Use Arduino for Projects 5.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 5.pdfAdvanced View Arduino Projects List - Use Arduino for Projects 5.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 5.pdfWiseNaeem
 
Steps to be done in arduino ide for monitoring
Steps to be done in arduino ide for monitoringSteps to be done in arduino ide for monitoring
Steps to be done in arduino ide for monitoringCitharthan Durairaj
 
What are the different types of arduino boards
What are the different types of arduino boardsWhat are the different types of arduino boards
What are the different types of arduino boardselprocus
 
Arduino-Workshop-4.pptx
Arduino-Workshop-4.pptxArduino-Workshop-4.pptx
Arduino-Workshop-4.pptxHebaEng
 

Semelhante a comenzando con MATLAB y Simulink para Arduino (20)

FinalThesisdraft
FinalThesisdraftFinalThesisdraft
FinalThesisdraft
 
notes about Arduino
notes about Arduinonotes about Arduino
notes about Arduino
 
Practicas con arduino
Practicas con arduinoPracticas con arduino
Practicas con arduino
 
Intro to arduino
Intro to arduinoIntro to arduino
Intro to arduino
 
Garagino doc
Garagino docGaragino doc
Garagino doc
 
Arduino: Tutorial de Arduino
Arduino: Tutorial de ArduinoArduino: Tutorial de Arduino
Arduino: Tutorial de Arduino
 
Una guía de inicio rápido de MATLAB a matlab GUI para controlar Arduino
Una guía de inicio rápido de MATLAB a matlab GUI para controlar ArduinoUna guía de inicio rápido de MATLAB a matlab GUI para controlar Arduino
Una guía de inicio rápido de MATLAB a matlab GUI para controlar Arduino
 
Using arduino and raspberry pi for internet of things
Using arduino and raspberry pi for internet of thingsUsing arduino and raspberry pi for internet of things
Using arduino and raspberry pi for internet of things
 
Arduino Development For Beginners
Arduino Development For BeginnersArduino Development For Beginners
Arduino Development For Beginners
 
Arduino Full Tutorial
Arduino Full TutorialArduino Full Tutorial
Arduino Full Tutorial
 
What is Arduino ?
What is Arduino ?What is Arduino ?
What is Arduino ?
 
What is arduino
What is arduinoWhat is arduino
What is arduino
 
Advanced View Arduino Projects List - Use Arduino for Projects 4.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 4.pdfAdvanced View Arduino Projects List - Use Arduino for Projects 4.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 4.pdf
 
Advanced View Arduino Projects List - Use Arduino for Projects 5.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 5.pdfAdvanced View Arduino Projects List - Use Arduino for Projects 5.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 5.pdf
 
Steps to be done in arduino ide for monitoring
Steps to be done in arduino ide for monitoringSteps to be done in arduino ide for monitoring
Steps to be done in arduino ide for monitoring
 
Embedded system application
Embedded system applicationEmbedded system application
Embedded system application
 
Power supply learning kit for uno
Power supply learning kit for unoPower supply learning kit for uno
Power supply learning kit for uno
 
What are the different types of arduino boards
What are the different types of arduino boardsWhat are the different types of arduino boards
What are the different types of arduino boards
 
Arduino-Workshop-4.pptx
Arduino-Workshop-4.pptxArduino-Workshop-4.pptx
Arduino-Workshop-4.pptx
 
Arduino-Workshop-4.pptx
Arduino-Workshop-4.pptxArduino-Workshop-4.pptx
Arduino-Workshop-4.pptx
 

Mais de SANTIAGO PABLO ALBERTO

Manual de teoría y practica electroneumática avanzada
Manual de teoría y practica electroneumática avanzadaManual de teoría y practica electroneumática avanzada
Manual de teoría y practica electroneumática avanzadaSANTIAGO PABLO ALBERTO
 
Programacion de PLC basado en Rslogix 500 por Roni Domínguez
Programacion de PLC basado en Rslogix 500 por Roni Domínguez Programacion de PLC basado en Rslogix 500 por Roni Domínguez
Programacion de PLC basado en Rslogix 500 por Roni Domínguez SANTIAGO PABLO ALBERTO
 
Programación de microcontroladores PIC en C con Fabio Pereira
Programación de microcontroladores PIC en  C con Fabio PereiraProgramación de microcontroladores PIC en  C con Fabio Pereira
Programación de microcontroladores PIC en C con Fabio PereiraSANTIAGO PABLO ALBERTO
 
Análisis y Diseño de Sistemas de Control Digital por Ricardo Fernandez del Bu...
Análisis y Diseño de Sistemas de Control Digital por Ricardo Fernandez del Bu...Análisis y Diseño de Sistemas de Control Digital por Ricardo Fernandez del Bu...
Análisis y Diseño de Sistemas de Control Digital por Ricardo Fernandez del Bu...SANTIAGO PABLO ALBERTO
 
Programación de autómatas PLC OMRON CJ/CP1
Programación de  autómatas PLC OMRON CJ/CP1Programación de  autómatas PLC OMRON CJ/CP1
Programación de autómatas PLC OMRON CJ/CP1SANTIAGO PABLO ALBERTO
 
Manual del sistema del controlador programable S7-200 SMART
Manual del sistema del controlador programable S7-200 SMARTManual del sistema del controlador programable S7-200 SMART
Manual del sistema del controlador programable S7-200 SMARTSANTIAGO PABLO ALBERTO
 
PLC: Buses industriales y de campo practicas de laboratorio por Jose Miguel R...
PLC: Buses industriales y de campo practicas de laboratorio por Jose Miguel R...PLC: Buses industriales y de campo practicas de laboratorio por Jose Miguel R...
PLC: Buses industriales y de campo practicas de laboratorio por Jose Miguel R...SANTIAGO PABLO ALBERTO
 
PLC y Electroneumática: Electricidad y Automatismo eléctrico por Luis Miguel...
PLC y Electroneumática: Electricidad y Automatismo eléctrico por  Luis Miguel...PLC y Electroneumática: Electricidad y Automatismo eléctrico por  Luis Miguel...
PLC y Electroneumática: Electricidad y Automatismo eléctrico por Luis Miguel...SANTIAGO PABLO ALBERTO
 
Electrónica: Diseño y desarrollo de circuitos impresos con Kicad por Miguel P...
Electrónica: Diseño y desarrollo de circuitos impresos con Kicad por Miguel P...Electrónica: Diseño y desarrollo de circuitos impresos con Kicad por Miguel P...
Electrónica: Diseño y desarrollo de circuitos impresos con Kicad por Miguel P...SANTIAGO PABLO ALBERTO
 
PLC: Diseño, construcción y control de un motor doble Dahlander(cuatro veloci...
PLC: Diseño, construcción y control de un motor doble Dahlander(cuatro veloci...PLC: Diseño, construcción y control de un motor doble Dahlander(cuatro veloci...
PLC: Diseño, construcción y control de un motor doble Dahlander(cuatro veloci...SANTIAGO PABLO ALBERTO
 
Electrónica digital: Introducción a la Lógica Digital - Teoría, Problemas y ...
Electrónica digital:  Introducción a la Lógica Digital - Teoría, Problemas y ...Electrónica digital:  Introducción a la Lógica Digital - Teoría, Problemas y ...
Electrónica digital: Introducción a la Lógica Digital - Teoría, Problemas y ...SANTIAGO PABLO ALBERTO
 

Mais de SANTIAGO PABLO ALBERTO (20)

secuencia electroneumática parte 1
secuencia electroneumática parte 1secuencia electroneumática parte 1
secuencia electroneumática parte 1
 
secuencia electroneumática parte 2
secuencia electroneumática parte 2secuencia electroneumática parte 2
secuencia electroneumática parte 2
 
Manual de teoría y practica electroneumática avanzada
Manual de teoría y practica electroneumática avanzadaManual de teoría y practica electroneumática avanzada
Manual de teoría y practica electroneumática avanzada
 
Programacion de PLC basado en Rslogix 500 por Roni Domínguez
Programacion de PLC basado en Rslogix 500 por Roni Domínguez Programacion de PLC basado en Rslogix 500 por Roni Domínguez
Programacion de PLC basado en Rslogix 500 por Roni Domínguez
 
Programación de microcontroladores PIC en C con Fabio Pereira
Programación de microcontroladores PIC en  C con Fabio PereiraProgramación de microcontroladores PIC en  C con Fabio Pereira
Programación de microcontroladores PIC en C con Fabio Pereira
 
Análisis y Diseño de Sistemas de Control Digital por Ricardo Fernandez del Bu...
Análisis y Diseño de Sistemas de Control Digital por Ricardo Fernandez del Bu...Análisis y Diseño de Sistemas de Control Digital por Ricardo Fernandez del Bu...
Análisis y Diseño de Sistemas de Control Digital por Ricardo Fernandez del Bu...
 
Arduino: Arduino de cero a experto
Arduino: Arduino de cero a expertoArduino: Arduino de cero a experto
Arduino: Arduino de cero a experto
 
Fisica I
Fisica IFisica I
Fisica I
 
Quimica.pdf
Quimica.pdfQuimica.pdf
Quimica.pdf
 
Manual básico PLC OMRON
Manual básico PLC OMRON Manual básico PLC OMRON
Manual básico PLC OMRON
 
Programación de autómatas PLC OMRON CJ/CP1
Programación de  autómatas PLC OMRON CJ/CP1Programación de  autómatas PLC OMRON CJ/CP1
Programación de autómatas PLC OMRON CJ/CP1
 
Manual del sistema del controlador programable S7-200 SMART
Manual del sistema del controlador programable S7-200 SMARTManual del sistema del controlador programable S7-200 SMART
Manual del sistema del controlador programable S7-200 SMART
 
Catálogo de PLC S7-200 SMART
Catálogo de PLC S7-200 SMART Catálogo de PLC S7-200 SMART
Catálogo de PLC S7-200 SMART
 
PLC: Automatismos industriales
PLC: Automatismos industrialesPLC: Automatismos industriales
PLC: Automatismos industriales
 
PLC: Buses industriales y de campo practicas de laboratorio por Jose Miguel R...
PLC: Buses industriales y de campo practicas de laboratorio por Jose Miguel R...PLC: Buses industriales y de campo practicas de laboratorio por Jose Miguel R...
PLC: Buses industriales y de campo practicas de laboratorio por Jose Miguel R...
 
PLC y Electroneumática: Electricidad y Automatismo eléctrico por Luis Miguel...
PLC y Electroneumática: Electricidad y Automatismo eléctrico por  Luis Miguel...PLC y Electroneumática: Electricidad y Automatismo eléctrico por  Luis Miguel...
PLC y Electroneumática: Electricidad y Automatismo eléctrico por Luis Miguel...
 
Electrónica: Diseño y desarrollo de circuitos impresos con Kicad por Miguel P...
Electrónica: Diseño y desarrollo de circuitos impresos con Kicad por Miguel P...Electrónica: Diseño y desarrollo de circuitos impresos con Kicad por Miguel P...
Electrónica: Diseño y desarrollo de circuitos impresos con Kicad por Miguel P...
 
PLC: Diseño, construcción y control de un motor doble Dahlander(cuatro veloci...
PLC: Diseño, construcción y control de un motor doble Dahlander(cuatro veloci...PLC: Diseño, construcción y control de un motor doble Dahlander(cuatro veloci...
PLC: Diseño, construcción y control de un motor doble Dahlander(cuatro veloci...
 
PLC: Motor Dahlander
PLC: Motor DahlanderPLC: Motor Dahlander
PLC: Motor Dahlander
 
Electrónica digital: Introducción a la Lógica Digital - Teoría, Problemas y ...
Electrónica digital:  Introducción a la Lógica Digital - Teoría, Problemas y ...Electrónica digital:  Introducción a la Lógica Digital - Teoría, Problemas y ...
Electrónica digital: Introducción a la Lógica Digital - Teoría, Problemas y ...
 

Último

AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsvanyagupta248
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...Amil baba
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...drmkjayanthikannan
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxSCMS School of Architecture
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdfKamal Acharya
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network DevicesChandrakantDivate1
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiessarkmank1
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"mphochane1998
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEselvakumar948
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdfKamal Acharya
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxNadaHaitham1
 

Último (20)

AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptx
 

comenzando con MATLAB y Simulink para Arduino

  • 1.
  • 2. Table of Contents Preface 1. Preparing Development Environment 1.1 Arduino 1.1.1 Arduino Uno 1.1.2 Arduino Leonardo 1.1.3 Arduino Mega 2560 1.1.4 Arduino Due 1.2 Electronic Components 1.2.1 Arduino Starter Kit 1.2.2 Fritzing 1.2.3 Cooking-Hacks: Arduino Starter Kit 1.2.4 Arduino Sidekick Basic kit 1.3 Matlab Simulink 1.4 Arduino Software 1.5 Testing 2. Matlab Simulink and Arduino 2.1 Matlab 2.2 Installing Arduino for Simulink Target 3. Hello World - Matlab Simulink and Arduino 3.1 Hello World 3.2 Creating Arduino Simulink 3.2.1 Configuring Arduino Digital Output 3.2.2 Configuring Pulse Generator 3.2.3 Configuring Scope 3.3 Configuring Arduino 3.3 Running Simulink 4. Simulink with Arduino Digital I/O 4.1 Working with Arduino Digital I/O
  • 3. 4.2 Digital Sources 4.3 Simulink with Arduino Digital I/O 4.3.1 Digital Input 4.3.2 Digital Output 4.3.3 Logical Operator 4.3.4 Pulse Generator 4.3.5 Configuring Hardware 4.4 Testing 5. Simulink with Arduino Analog I/O 5.1 Simulink with Arduino Analog Input 5.1.1 Reading Temperature Analog Sensor 5.1.2 Building Simulink Model 5.1.3 Executing Simulink Model 5.2 Simulink with Arduino Analog Output 5.2.1 Controlling RGB LED Color 5.2.2 Building Simulink Model 5.2.3 Executing Simulink Model 6. Simulink with Arduino Serial 6.1 Arduino Serial Communication 6.2 Configuring Arduino 6.3 Building a Simulink Model 6.3.1 Serial Transmit 6.3.2 Serial Receive 6.3.3 Counter Limited 6.3.4 Data Type Conversion 6.4 Testing 7. Simulink with Arduino and Servo Motor 7.1 Servo Motor 7.2 Building A Simulink Hardware 7.3 Building A Simulink Model with Arduino and Servo Motor 7.3.1 Standard Servo Write
  • 4. 7.3.2 Standard Servo Read 7.3.3 Counter Limited 7.3.4 Serial Transmit 7.4 Testing Contact
  • 5. Preface This book was written to help anyone wants to get started in Arduino and Matlab Simulink. It describes all the basic elements of the Arduino and Matlab Simulink with step-by-step approach. Agus Kurniawan Berlin, September 2013
  • 6. 1. Preparing Development Environment To develop a program with Matlab Simulink and Arduino, you need the following required environment: Arduino Matlab Arduino software Electronic components for testing In this chapter, I'm going to explain in brief required items for Matlab simulink and Arduino development. 1.1 Arduino Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. This board uses Atmel microcontroller series. There are many Arduino hardware models that you can use. Further information about Arduino products, you can visit on website http://arduino.cc/en/ . You must one Arduino hardware to follow practices in this book. I recommend to obtain one of the following Arduino hardware: Arduino Uno Arduino Leonardo Arduino Mega 2560 Arduino Due You can buy this product on your local electronic store. You also can order it by online. Find it on http://arduino.cc/en/Main/Buy. The following is the list of Arduino store you can buy Arduino store, http://store.arduino.cc/ Amazon, http://www.amazon.com Cooking-hacks, http://www.cooking-hacks.com/index.php/shop/arduino.html RS Components, http://www.rs-components.com Element 14, http://www.element14.com EXP-Tech, http://www.exp-tech.de
  • 7. Because Arduino is an open-source hardware, people can build it. It's called Arduino compatible. Generally it's sold in low prices. 1.1.1 Arduino Uno The Arduino Uno is a microcontroller board based on the ATmega328. You can download the datasheet file, http://www.atmel.com/dyn/resources/prod_documents/doc8161.pdf . Further information about Arduino Uno, you can read it on http://arduino.cc/en/Main/ArduinoBoardUno . 1.1.2 Arduino Leonardo The Arduino Leonardo is a microcontroller board based on the ATmega32u4. Download dataset for this product on http://www.atmel.com/dyn/resources/prod_documents/7766S.pdf . Visit this product to get the further information on http://arduino.cc/en/Main/ArduinoBoardLeonardo .
  • 8. 1.1.3 Arduino Mega 2560 The Arduino Mega 2560 is a microcontroller board based on the ATmega2560. You can download the dataset file on http://www.atmel.com/dyn/resources/prod_documents/doc2549.PDF. Further information about Arduino Mega 2560, you can visit on http://arduino.cc/en/Main/ArduinoBoardMega2560 . 1.1.4 Arduino Due The Arduino Due is a microcontroller board based on the Atmel SAM3X8E ARM Cortex-M3 CPU. You can download the datasheet, http://www.atmel.com/Images/doc11057.pdf. If you want to know about Arduino Due, I recommend to visit this
  • 9. website, http://arduino.cc/en/Main/ArduinoBoardDue. 1.2 Electronic Components We need electronic components to build our testing, for instance, Resistor, LED, sensor devices and etc. I recommend you can buy electronic component kit. 1.2.1 Arduino Starter Kit Store website: http://arduino.cc/en/Main/ArduinoStarterKit
  • 10. 1.2.2 Fritzing Store website: http://shop.fritzing.org/ . You can buy Fritzing Starter Kit with Arduino UNO or Fritzing Starter Kit with Arduino Mega.
  • 11. 1.2.3 Cooking-Hacks: Arduino Starter Kit Store website: http://www.cooking-hacks.com/index.php/shop/arduino/starter-kits/arduino-starter- kit.html 1.2.4 Arduino Sidekick Basic kit Store website: http://www.seeedstudio.com/depot/arduino-sidekick-basic-kit-p-775.html Alternative online store
  • 12. http://www.amazon.com/Arduino-Sidekick-Basic-Kit-Version/dp/B007B14HM8/ http://www.exp-tech.de/Zubehoer/Arduino-Sidekick-Basic-Kit.html 1.3 Matlab Simulink You can work with Matlab Simulink with targeting on Arduino using Matlab 2013a or the latest version. You also can work with Matlab 2013a Student Version. 1.4 Arduino Software
  • 13. To develop application based on Arduino board, we need Arduino software. You can obtain it on http://arduino.cc/en/Main/Software . Please install based on your platform. If your platform is Ubuntu, you can install by writing this script sudo apt-get install arduino For Windows platform, you can download setup file and install it. The following is a screenshot of Arduino software on Ubuntu platform. Here is Arduino software on Windows 8 platform.
  • 14. If you run Arduino software on Windows platform, you should configure arduino.exe running as Administrator. You can change it by editing file property. Click Compatibility and then checked Run this program as an administrator.
  • 15. 1.5 Testing For testing, I used Arduino Uno and Arduino Mega 2560 on Ubuntu and Windows 8 platforms.
  • 16. I also used Arduino Sidekick Basic kit for electronic components.
  • 17. 2. Matlab Simulink and Arduino This chapter explains how to work with Matlab Simulink and Arduino Software. 2.1 Matlab You can work with Matlab Simulink with targeting on Arduino using Matlab 2013a or the latest version. You also can work with Matlab 2013a Student Version. 2.2 Installing Arduino for Simulink Target You need internet connection to download Arduino package. Now run your Matlab and then click Add-Ons. You can see the menu as below.
  • 18. Select Get Hardware Support Packages. Then you will obtain a dialog, called Support Package Installer. Select Internet (recommended). You may log in to MathWorks Account to continue installation process. Click Log In and then entry your username and password.
  • 19. After that, click Next button.
  • 20. Check Arduino and then click Next button. You will see a license agreement as below.
  • 21. Checked I accept. If done, click Next button.
  • 23. Click Install button. It will download Arduino package and then install it. If success, you will obtain a dialog as below.
  • 24. Click Finish button. Now you see Arduino on Simulink Library Browser.
  • 25.
  • 26. 3. Hello World - Matlab Simulink and Arduino In this chapter we create as simple Matlab Simulink with Arduino. 3.1 Hello World We are going to build a simple Matlab Simulink with Arduino, called Hello World. In this scenario, we work with LED on Arduino. If you see Matlab Simulink Library on Arduino, you can see Digital Output library. This library generates digital output on Arduino. We will use this library on our model to turn on and off our LED.
  • 27. 3.2 Creating Arduino Simulink Now we are ready to build a "hello world" Matlab Simulink with Arduino. Follow all steps. Firstly run your Matlab 2013a or the latest version. On Home, click + New icon. Then you will obtain a menu as below.
  • 28. Select Simulink Model. Then you obtain a Simulink dialog as below.
  • 29. Next step, we build a simulink model. On the Simulik Model dialog, click menu Tools -> Library Browser. Then you will the list of Simulink library include Arduino library. Click Simulink Support Package for Arduino Hardware, then you will see all Arduino installed library.
  • 30. For our scenario, hello world, we create a simulink as below.
  • 31. You need three libraries as follows Digital Output on Simulink Support Package for Raspberry Pi Hardware Pulse Generator on Sources Scope on Commonly Used Blocks After all items connected, we configure these. 3.2.1 Configuring Arduino Digital Output To configure Arduino Digital Output, double-click Digital Output on model. Then you obtain a dialog as below
  • 32. You entry which digital pin on your Arduino board that LED is connected. If finished, click OK button. 3.2.2 Configuring Pulse Generator Double click on Pulse Generator so you obtain a dialog as below
  • 33. For testing, we use configurations as follows: Pulse type: Sample based Time (t): Use simulation time Amplitude: 1 Period: 10 Pulse width: 5 Phase delay: 0 Sample time: 0.2 Checked Interpret vector parameters as 1-D
  • 34. If done, click OK button. 3.2.3 Configuring Scope You don't need configure anything for scope library. You can do a double click on scope library and then you can see a graphic. 3.3 Configuring Arduino Now you can configure your LED to plug into Arduino. The following is Arduino and LED configuration. LED is connected to digital pin 10. You may change this digital pin. 3.3 Running Simulink Save your model, for instance, helloworld. You test and validate your model. Make sure you select Normal. Then, click Arrow, shown in Figure below.
  • 35. If success, you don't see the error dialog. Now you are ready to deploy to Arduino and run it. To run this model to Arduino, you must configure. How? Click menu Tools -> Run on Target Hardware -> Prepare to Run. Then you will obtain a dialog as below.
  • 36. Select Arduino on Target hardware. In this scenario, I used Arduino Mega 2560. Click OK button. After that, you will see Arduino configuration.
  • 37. Choose Set host COM port for your Arduino device. Make sure your Arduino already connected. For COM setting, I chosen Automatically. Checked Enable External mode to obtain feedback results from Arduino. If done, click OK button. To deploy and run on Arduino, click menu Tools -> Run on Target Hardware -> Run .
  • 38. Matlab will be compile the model and send it to Arduino. You can see the compiling process shown in Figure below. If process is success, you will see the LED is blinked.
  • 39. Then you also can see a graphic on Scope as follow.
  • 40. 4. Simulink with Arduino Digital I/O This chapter explains how to program simulink using Arduino Digital I/O. 4.1 Working with Arduino Digital I/O Arduino provides digital I/O that we can use easily. In this scenario, we will build a simple simulation for Matlab simulink. We use digital sources as Arduino digital input. You can use any digital source, for instance, digital sensor, button, etc. I use Arduino Uno as digital source. The following is our scenario for building Matlab simulink. 4.2 Digital Sources I build a simple Arduino code to generate digital signal. Open your arduino application and write this script int signal = 13; void setup() {
  • 41. pinMode(signal, OUTPUT); } void loop() { digitalWrite(signal, HIGH); delay(2000); digitalWrite(signal, LOW); delay(1000); digitalWrite(signal, HIGH); delay(1000); digitalWrite(signal, LOW); delay(500); } You also can see a sample code as below. 4.3 Simulink with Arduino Digital I/O
  • 42. In this section, we're going to a simulink model with Arduino and LED. The following is a simulink model. Notes: Digital Input and Digital Output on Simulink Support Package for Arduino Hardware Logical Operator on Commonly Used Blocks Scope on Commonly Used Blocks Pulse Generator on Sources Now we start to build a simulink model and configure it. 4.3.1 Digital Input Arduino digital input will be connected to digital source, such as digital sensor. You can configure what digital input pin is be used on Arduino. In this scenario, I used digital input pin 8.
  • 43. The following is a screenshot of digital input dialog. If done, click OK button. 4.3.2 Digital Output After you open a Digital Output dialog, you will obtain a dialog shown in Figure below.
  • 44. Fill pin for Arduino digital output. I used pin 10 for my scenario. If finished, click OK button. 4.3.3 Logical Operator Double click Logical Operator library and then you will a dialog shown in Figure below.
  • 45. Chosen AND on Operator and Number of Input ports is 2. Click OK if finished. 4.3.4 Pulse Generator The next task is to configure a pulse generator library. Double click this library and then you will obtain a dialog as follows.
  • 46. The following is my configuration for the pulse generator library: Pulse type : Sample based Time (t): Use simulation time Amplitude: 1 Period: 10 Pulse width: 5 Phase delay: 0 Sample time: 0.2 If done, click OK button.
  • 47. 4.3.5 Configuring Hardware Now you can connect your hardware, Arduino, digital source and LED. For my scenario, I used Arduino as digital source and connect to digital pin 8. The following is my hardware configuration. 4.4 Testing After we build a simulink model and Arduino hardware, we can build and deploy to Arduino. Please read chapter 3 section 3.3 if you don't know how to build and run a Arduino simulink. If your model run successfully, you see that LED turned on and off.
  • 48. You also can open Scope for digital input. Then you see the digital signal (pulse signal) graphic on Scope library. The following is a sample graphic.
  • 49. Open Scope library for pulse generator too. You can see a sample graphic as below. Scope for AND operation shows the result of AND operation between digital input and pulse generator. The following is a sample graphic.
  • 50.
  • 51. 5. Simulink with Arduino Analog I/O This chapter explains how to work with Arduino Analog I/O and Matlab Simulink. We build two simulink models to illustrate how to use Arduino analog I/O. The following are our scenarios: Reading temperature sensor using Arduino analog input Controlling RGB LED color using Arduino analog output (PWM) 5.1 Simulink with Arduino Analog Input Arduino can be interfaced with sensor devices. You can see the list of sensor interface on http://playground.arduino.cc/Main/InterfacingWithHardware . In this scenario, we use cheap temperature sensor device, thermistor. Thermistor can be used to measure temperature. I have thermistor 503 from Arduino Sidekick Basic kit. Thermistor 508 can be shown in Figure below. Now we can start to build simulink model to read temperature analog sensor. 5.1.1 Reading Temperature Analog Sensor To build sensor hardware, we need resistor 50k ohm. If your thermistor is 10k ohm, you should use a resistor with 10k ohm.
  • 52. The following is a circuit schema for thermistor sensor. We use a divider approach. One of sensor pin is connected to 5V Arduino pin. Thermistor 503 is attached to the Analog In of Arduino, A4. The following is hardware implementation.
  • 53. Normally Arduino ADC generates value 0 - 1023. To read sensor data, I used an approach based on this site, http://playground.arduino.cc/ComponentLib/Thermistor2 . In this scenario I used Celsius unit. How to read and to convert to Celsius unit you can use the following function. double Thermister(int RawADC) { double Temp; Temp = log(((10240000/RawADC) - 10000)); Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* T Temp = Temp - 273.15; // Convert Kelvin to Celcius return Temp; } RawADC is a sensor value from Arduino analog input. This function will be implemented in simulink model. 5.1.2 Building Simulink Model Now you can build simulink model. The following is a simulink model to read temperature sensor.
  • 54. For analog input, I used pin 4. You may change it based on your hardware implementation.
  • 55. The second module is subsystem. This module is Thermistor function implementation. The following is function implementation.
  • 56. Notes: Devide, Add, Subtract, Product, Math Function on Math Operations Constant on Commonly Used Blocks
  • 57. Make sure all modules must be configured Output data type as double. The following is a sample of Output data type. You also can use Matlab function that you can create to change a Subsystem. 5.1.3 Executing Simulink Model After build simulink model, plug in your hardware into computer. Now you can execute your simulink. Read chapter 3 to configure simulink for Arduino. The following is a scope output of Arduino input.
  • 58. You can see Arduino read sensor values around 524-525. After that, these values will be converted to Celcius using Thermistor function. The following is a scope output from Thermistor function.
  • 59. You can see the temperature data, for instance, on time 2 temperature has 26.16 Celcius. 5.2 Simulink with Arduino Analog Output The second scenario we build a simulink to control RGB LED color using Arduino Analog output (PWM). RGB LED has 4 pins that you can see it on Figure below.
  • 60. To understand these pins, you can see the following Figure. Note: Pin 1: Red Pin 2: Common pin Pin 3: Green Pin 4: Blue
  • 61. Now we can start to build a simulink and hardware implementation. 5.2.1 Controlling RGB LED Color Firstly we implement sensor hardware. The following is a hardware schema. Note: RGB LED pin 1 is connected to Arduino PWM pin 6 RGB LED pin 2 is connected to Arduino VCC 5V RGB LED pin 3 is connected to Arduino PWM pin 5 RGB LED pin 4 is connected to Arduino PWM pin 4 Here is a sample implementation.
  • 62. 5.2.2 Building Simulink Model Now we can build a simulink mode. Run your Matlab application and create a new Model. Build a model as follows.
  • 63. Note: Repeating Sequence library can be found on Sources. On PWM library you can set Arduino PWM pin. In this case, I used Arduino PWN pins: 6, 5, and 4.
  • 64. On Repeating Sequence for PWM pin 6, you configure as follows.
  • 65. Configure Repeating Sequence for PWM pin 5 as below. Finally you can configure Repeating Sequence for PWM pin 4 as follows.
  • 66. If done, save your a simulink model. 5.2.3 Executing Simulink Model Plug your Arduino with RGB LED into computer. After that, compile your model. If success, configure a model with Arduino hardware target. Read chapter 3 to configure a model for Arduino. If your model doesn't has any error while deploying to Arduino, you will see RGB LED shows some colors based on RGB value. The following is a sample output for Arduino and RGB LED. You also can see the output of red values shown on Figure below.
  • 67. The output of green values can be seen as below.
  • 68. The last you can see the output of blue values as below.
  • 69. 6. Simulink with Arduino Serial This chapter explains how to program simulink using Arduino Serial. 6.1 Arduino Serial Communication Arduino provides serial port that we can use easily. In this scenario, we will build a simple simulation for Matlab simulink. The following is information related to Arduino serial Arduino Uno has serial port: Rx (pin 0) and Tx (pin 1) Arduino Mega has 4 serial ports: Rx 0 (pin 0) Tx 0 (pin 1), Rx 1 (pin 19) Tx (pin 18), Rx 2 (pin 17) Tx 2 (pin 16), Rx 3 (pin 15) Tx 3 (pin 14) For Arduino Mega, you can not use serial port 0 (Rx 0 and Tx 0). In this scenario, we use 2 Arduino devices, Arduino Mega 2560 and Arduino Mega 1280. The second Arduino is be used as "bridge". It receives serial data from the first Arduino and then it will be sent back to the first Arduino. 6.2 Configuring Arduino To build a serial communication with two Arduino devices, you must interchange between Rx and Tx cables. The following is a Arduino schema for serial communication.
  • 70. In this scenario, I used serial Rx 1 Tx 1 connected to the second Arduino on Rx 0 Tx 0. You can see a sample implementation as below.
  • 71. As I said, the second Arduino is be used as "bridge". We must write code to receive serial data and send back to serial port. Now open Arduino application. Then write this code. int data = 0; void setup() { Serial.begin(9600); } void loop() { if (Serial.available() > 0) { data = Serial.read(); Serial.write(data); } }
  • 72. The following is a code implementation on Arduino application. Save all codes for the second Arduino. Before you compile and upload codes to the second Arduino, you must unplug cables from Rx 0 Tx 0. If not, you fail to upload codes to Arduino because it seems serial port 0 that is be used. 6.3 Building a Simulink Model In this section, we're going to a simulink model with Arduino serial port. The following is a simulink model.
  • 73. Notes: Serial Transmit and Serial Receive on Simulink Support Package for Arduino Hardware Scope on Commonly Used Blocks Data Type Conversion on Commonly Used Blocks Now we start to build a simulink model and configure it. 6.3.1 Serial Transmit Arduino transmit library is be used to send data. I used serial port 1. The following is a screenshot of serial transmit dialog.
  • 74. Fill 1 on Port number. If done, click OK button. 6.3.2 Serial Receive After you open Serial receive library, you will obtain a dialog shown in Figure below.
  • 75. Fill 1 for Port number. If finished, click OK button. 6.3.3 Counter Limited Double click Counter Limited library and then you will a dialog shown in Figure below.
  • 76. Fill 10 for Upper limit. Click OK if finished. 6.3.4 Data Type Conversion The next task is to configure a data type conversion library. Double click this library and then you will obtain a dialog as follows.
  • 77. Change Output data type uint8. If done, click OK button. 6.4 Testing After we build a simulink model and Arduino hardware, we can build and deploy to Arduino. Please read chapter 3 section 3.3 if you don't know how to build and run a Arduino simulink. If success, open scope library. You can see values that was be sent to to serial transmit on the first Arduino.
  • 78. Now open the second scope. As you know, the second Arduino will send back the received data from serial input (Rx 0). After that, the first Arduino will receive this data. You can see the result the following Figure as below. You can see on time 0 to 1, the first Arduino received noise signal data. After time 1, the first Arduino received the normal data.
  • 79.
  • 80. 7. Simulink with Arduino and Servo Motor This chapter explains how to program simulink using Arduino and Servo motor. 7.1 Servo Motor Servo motor provides a shaft movement 360 degree. We can control this movement based on its degree. In this scenario, you can use any DC motor (servo) that will be connected to Arduino. I used a mini servo from Arduino Sidekick Basic kit. The following is a picture of my mini servo motor. To understand servo's cables, you can identify as follows: Red cable is be connected to 5V Black or brown cable is be connected to GND The rest (yellow or orange cable) is be connected to Arduino PWM pin
  • 81. The next step we are going to build a simulink with Arduino and servo motor. 7.2 Building A Simulink Hardware In a simulink scenario, we will control a servo from Matlab. We also read the shaft position of servo and show the result on graphic and serial port. The following is a general idea that we will implement. I used two Arduino devices, Arduino Mega 2560 and Arduino Mega 1280. The second Arduino is be used to receive serial data so we check on a serial monitor application to see serial data. The following is my hardware implementation.
  • 82. Ok, let's build our simulink hardware. Firstly, we build a program for the second Arduino. Open your Arduino application and write this script int data = 0; void setup() { Serial.begin(9600); } void loop() { if (Serial.available() > 0) { data = Serial.read();
  • 83. Serial.print("received: "); Serial.println(data); } } You also can see a sample code as below. Save the code. Then compile and upload code to the second Arduino. Don't forget to change board and port based on your Arduino model. When you upload a program to Arduino, please unplug any cable from serial pins (Rx Tx pins). 7.3 Building A Simulink Model with Arduino and Servo Motor In this section, we're going to a simulink model with Arduino and servo motor.
  • 84. The following is a simulink model that we will build. Notes: Standard Servo Write, Standard Servo Read and Serial Transmit on Simulink Support Package for Arduino Hardware Scope on Commonly Used Blocks Counter Limited on Sources Now we start to build a simulink model and configure it. 7.3.1 Standard Servo Write
  • 85. Arduino servo write library is be used to control a servo. In this scenario, I used digital input pin 10. The following is a screenshot of digital input dialog. If done, click OK button. To work with standard servo write, we can give input between 0 and 180 to this library. 7.3.2 Standard Servo Read After you open standard servo read library, you will obtain a dialog shown in Figure below.
  • 86. Fill pin same as pin value on standard servo write library. Fill 0.5 on Sample time. If finished, click OK button. We will obtain a value from this library between 0 and 180. 7.3.3 Counter Limited Counter limited library is be used to generate a value for standard servo write library. Double click counter limited library and then you will a dialog shown in Figure below.
  • 87. Fill 180 for Upper limit and Sample time is 0.5. Click OK button if finished. 7.3.4 Serial Transmit The output of standard servo read can be sent to serial port. We can use serial transmit library. Configure this library as follows.
  • 88. Fill serial port pin. It depends on your Arduino model. Click OK button if finished. 7.4 Testing After we build a simulink model and Arduino hardware, we can build and deploy to Arduino. Please read chapter 3 section 3.3 if you don't know how to build and run a Arduino simulink. Before you run the simulink model, set simulation stop time about 90. You can change it that depends on your period time. Now you run this the simulink model. Now you can open a scope library to see data from the standard servo read library.
  • 89. You can open a serial monitor on the second Arduino to see incoming serial data. If you run your simulink model with disabled Enable External mode, I recommend to change period time into 1 and simulation stop time 180.
  • 90.
  • 91. Contact If you have question related to this book, please contact me at aguskur@hotmail.com . My blog: http://blog.aguskurniawan.net . Source code can be downloaded on http://www.aguskurniawan.net/book/matlab_arduino.zip .