[go: up one dir, main page]

0% found this document useful (0 votes)
9 views29 pages

Arduino-and-Matlab-for-prototyping-and-manufacturing

The document provides an overview of using Arduino and MATLAB for prototyping and manufacturing, detailing the Arduino platform, programming basics, and its interaction with sensors and actuators. It covers essential components, programming structures, and the integration of MATLAB for enhanced data processing and visualization. Practical examples, such as blinking an LED and creating a touch lamp, are also included to illustrate the application of these technologies.

Uploaded by

Julio César
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views29 pages

Arduino-and-Matlab-for-prototyping-and-manufacturing

The document provides an overview of using Arduino and MATLAB for prototyping and manufacturing, detailing the Arduino platform, programming basics, and its interaction with sensors and actuators. It covers essential components, programming structures, and the integration of MATLAB for enhanced data processing and visualization. Practical examples, such as blinking an LED and creating a touch lamp, are also included to illustrate the application of these technologies.

Uploaded by

Julio César
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Arduino and Matlab for

prototyping and
manufacturing
Enrique Chacón Tanarro

Enrique Chacón Tanarro


11th - 15th December 2017 UBORA First Design School - Nairobi
e.chacon@upm.es
Index

1. Arduino
2. Arduino programming
3. Matlab controlling arduino

11th - 15th December 2017 UBORA First Design School - Nairobi 2


1. Ardunio

Arduino is an open-source electronic platform based on easy


to use hardware and software (https://www.arduino.cc/ )
ENVIROMENT ARDUINO ENVIROMENT
INTERACTION

Sensors: Actuators:
• Temperature • Motors
• Pressure • Relays
• Light • Valves
• Proximity • Piezoelectrics
• Acceleration • Diode led
• … • …
11th - 15th December 2017 UBORA First Design School - Nairobi 3
1.1. Enviroment

Arduino is an open-source electronic platform based on easy


to use hardware and software (https://www.arduino.cc/ )
ENVIROMENT ARDUINO ENVIROMENT
INTERACTION

Sensors: Actuators:
• Temperature • Motors
• Pressure • Relays
• Light • Valves
• Proximity • Piezoelectrics
• Acceleration • Diode led
• … • …
11th - 15th December 2017 UBORA First Design School - Nairobi 4
1.1. Enviroment

Arduino can receive environment information from 2 ways:


A) USER
• Physical: switches, buttons, potentiometers,…

• Virtual
Arduino PC - Matlab

11th - 15th December 2017 UBORA First Design School - Nairobi 5


1.1. Enviroment

Arduino can receive environment information from 2 ways:


B) SENSORS
Termoresistance Movement Microphone
sensor
Temperature Movement Sound

Piezoelectric Encoder
Position /
Pressure
Velocity
Mechanical contact Fluids

Accelerometers Fotoresistence

Aceleration Light Gas

11th - 15th December 2017 UBORA First Design School - Nairobi 6


1.1. Enviroment

EXAMPLE: How can we measure the luminosity of this room?


LDR resistance varies its
resistance as a function of light

Light Ω

A0 pin voltage depends on


the LDR resistance

11th - 15th December 2017 UBORA First Design School - Nairobi 7


1.2. Arduino board

What does ARDUNIO do with the information from sensors,


touchscreens, etc.
ENVIROMENT ARDUINO ENVIROMENT
INTERACTION

Sensors: Actuators:
• Temperature • Motors
• Pressure • Relays
• Light • Valves
• Proximity • Piezoelectrics
• Acceleration • Diode led
• … • …
11th - 15th December 2017 UBORA First Design School - Nairobi 8
1.2. Arduino board
Digital
Information Arduino ONE board

Programmable integrated circuit


Fundamental parts:
• CPU (calculation speed)
• Memory (code complexity)
• Input and output peripherals
(number of signals to be
controlled

Arduino board
https://www.robomart.com selection
Analogical Information
11th - 15th December 2017 UBORA First Design School - Nairobi 9
1.2. Arduino board

Arduino board selection


• Arduino Uno
• Arduino ProMini
• Arduino Nano
• Arduino Micro
• Arduino Mega 2560
• Arduino Mega ADK (android)

• Arduino Gemma

• Arduino Leonardo
• Arduino Yún (ethernet)
• Arduino Cactus (WiFi)

11th - 15th December 2017 UBORA First Design School - Nairobi 10


1.2. Arduino board

Arduino UNO board


Analogical input
• 6 input pins A0,A1,A2,...
• Voltage range: 0 - 5V
• Precision: 5V / 1024 values = 5mV

Digital input/output
• 14 pins 0-13
• Sensors and actuators are connected in these pins.
They must declared (software) is INPUT or OUTPUT.
• Voltage: 5V (HIGH) - 0V (LOW).
• Max. pin current: 40 mA. Max. total pins current: 200
mA.

11th - 15th December 2017 UBORA First Design School - Nairobi 11


1.2.1. Electronic components

What does ARDUNIO do with the information from sensors,


touchscreens, etc.?
ENVIROMENT ARDUINO ENVIROMENT
INTERACTION

Sensors: Actuators:
Protoboard

• Temperature • Motors
• Pressure • Relays
• Light • Valves
• Proximity • Piezoelectrics
• Acceleration ELECTRONIC • Diode led
• … COMPONENTS • …
11th - 15th December 2017 UBORA First Design School - Nairobi 12
1.2.1. Electronic components
Generate an output signal in response to an input signal
Functions: switch, amplifier, oscillator or rectifier collector
power

base
Transistors
emitter
Low input
signal Great output signal Switch
application
power

Current direction
Current circulation is only allowed in one direction
Many types: Generic
Photodiode
LED
Diodes Zener
(light emitting diode) Cathode Anode
Mostly used as rectifier for
Used as a constant Allows reverse current converting AC to DC and
voltage source when light falls on it motor protection

Correct resistance selection:


1, 2 or 3 red or yellow LED (1,8-2,1V)

Resistences

I = V/R

11th - 15th December 2017 UBORA First Design School - Nairobi 13


1.3. Environment interaction

What does ARDUNIO do with the information from sensors,


touchscreens, etc.
ENVIROMENT ARDUINO ENVIROMENT
INTERACTION

Sensors: Actuators:
• Temperature • Motors
• Pressure • Relays
• Light • Valves
• Proximity • Piezoelectrics
• Acceleration • Diode led
• … • …
11th - 15th December 2017 UBORA First Design School - Nairobi 14
1.3. Environment interaction
• Relays
• Valves Servomotor
• Motors or
• Etc.
Movement

Light, valve, etc.


open-close control

• Display
• Leds
• Buzzer
• Etc.

Signal

11th - 15th December 2017 UBORA First Design School - Nairobi 15


1.3.1. PWM outputs

¿Are there analogical outputs in ARDUINO?  Digital PWM


PWM pins allows us to simulate
an analog behaviour applying a
continuous value. Arduino ONE
board  pins 3, 5, 6, 9, 10 ,11
How does it work?
Instead of a continuous signal
Average

Period Pulses of square signals (490Hz)


Average
We can varied pulse duration
Pulse width
Desired analog voltage = voltage average

11th - 15th December 2017 UBORA First Design School - Nairobi 16


1.3.1. PWM outputs

EXAMPLE: How can we vary the DC electric motor speed?


Motor speed varies dependidng External power supply
Motor con diodo de
on the voltage applied to pin 9 protección

Transistor with
protection resistance

11th - 15th December 2017 UBORA First Design School - Nairobi 17


2. Arduino programming

1) Install the free software from arduino.cc/en/Main/Software


2) Conect Arduino board to the computer. Drivers will be
installed automatically.
3) Open the software

code writing area


Open
Compile
Upload

Save
New

Software messages: errors and actions

11th - 15th December 2017 UBORA First Design School - Nairobi 18


2. Arduino programming

Arduino is programmed in C/C++


The algorithm consist of:
• Fundamental structures

• Variables y constants

• Mathematical, logical and


Boolean operators

• Control structures
(conditionals, cycles)

• Functions

11th - 15th December 2017 UBORA First Design School - Nairobi 19


2.1. Fundamental structures

Initial configuration code


Only executed once

loop() is executed after setup ()


and keeps running until the
Arduino is disconnected

Both functions are usually preceded by void  These are functions without an output
or result.

11th - 15th December 2017 UBORA First Design School - Nairobi 20


2.2. Variables, constants, mathematical,
logical and Boolean operators

• Variables: Boolean open=true; int conta=5; char id=‘a’;


• Constants: const float pi = 3.14

• Mathematical operators: = , - , + , / ,…
• Logical operators: == , > , != , <= ,…
• Boolean operators: && (and) , II (or) ,…

11th - 15th December 2017 UBORA First Design School - Nairobi 21


2.3. Control structures

For
Switch/case
for (int a=0; a>10; a++)
If switch (var) { {
case 1: // repeated action
if (input<500)
// action A }
{
break;
// action A
case 2:
} else
// action B
{ While
break;
// action B
default: while (a<10) {
}
// action B // repeated action
} a++;
}

11th - 15th December 2017 UBORA First Design School - Nairobi 22


2.4. Functions

Digital functions Analytical functions


pinMode() digitalWrite() analogRead()
Configurates a pin Writes 1 or 0 in a digital pin Reads an analog pin (0-1023)
PinMode(pin,mode) digitalWrite(pin,state) analogRead(pin)
pinMode(13, OUTPUT); digitalWrite(13, HIGH); int a = analogRead(A0);
pinMode(a, INPUT); digitalWrite(13, LOW);
analogWrite()  PWM
digitalRead() Reads an analog value (0-255)
Reads 1 or 0 in a digital pin analogWrite(pin, PWM value)
digitalRead(pin) analogWrite(9, 134);
int a = digitalRead(13);

11th - 15th December 2017 UBORA First Design School - Nairobi 23


2.4. Functions

Random numbers Time Communication

Mathematical

Advance

External interruptions

11th - 15th December 2017 UBORA First Design School - Nairobi 24


3. Arduino programming with Matlab

Benefits of using MATLAB for Arduino programming:


• Read/write sensor data interactively without waiting for your code to compile
• Analyze your sensor data using pre-built Matlab functions for signal processing,
machine learning, mathematical modeling, …
• Quickly visualize your data (MATLAB plot types)
Disadvantage:
• Speed data trasnmision

NOTES:
• Is our arduino board compatible? https://es.mathworks.com/hardware-support/arduino-
matlab.html
• Only allowed Matlab 2014 and later versions

More info: https://es.mathworks.com/discovery/arduino-programming-matlab-simulink.html

11th - 15th December 2017 UBORA First Design School - Nairobi 25


3. Arduino programming with Matlab

Examples Ultrasonic
distance
• Mapping your surroundings using MATLAB and Arduino sensor
https://www.youtube.com/watch?v=iaF81W-l6Xg

Servomotor
11th - 15th December 2017 UBORA First Design School - Nairobi 26
4. Practical studies

Case 1: Blink led L


Aim: Arduino software/conect introduction

Steps:
1. Open arduino software
2. Open “blink” example
3. Read the code and understand it
4. Select the board and the port.
5. Load the code on the Arduino board. Few seconds after the
"uploaded“ message appears, we see the LED blinking

11th - 15th December 2017 UBORA First Design School - Nairobi 27


4. Practical studies

Case 2: Touch lamp

11th - 15th December 2017 UBORA First Design School - Nairobi 28


This project has received funding from the European Union’s Horizon 2020 research and innovation
programme under grant agreement No 731053

11th - 15th December 2017 UBORA First Design School - Nairobi 29

You might also like