1© 2012 The MathWorks, Inc.
Υπολογιστικά πειράματα με το MATLAB
Σύνδεση με Arduino & Raspberry Pi
Ζαχαρίας Γκέτσης
Μηχανικός Εφαρμογών
2
Project-Based Learning
Motivating Project-Based Learning: Sustaining the Doing, Supporting the Learning, Educational Psychologist Volume 26, Issue 3-4, 1991
Project-based learning is a comprehensive approach to classroom
teaching and learning that is designed to engage students in
investigation of authentic problems.
5
The leading environment for
technical computing
GUI-based block diagram
environment on top of MATLAB for
modeling, designing and solving
dynamic systems
Applications:Control systems
Electrical systems
Mechanical systems
Hydraulic systems
Signal processing
Video and image processing
Event-based systems
Any dynamic system
6
Using MATLAB in Courses
Typical foundation courses:Calculus, linear algebra
Numerical mathematics
Probability and statistics
Optimization
Physics
Typical application courses:Signals, systems, and control
Partial differential equations
Financial engineering
Mechanical engineering
Image processing
For more books, visit www.mathworks.com/books
7
1 DOF mass-spring-damper system
Problem: Model a 1 DOF mass-spring-
damper system within the Simulink
environment from first principles and
using physical modeling tools.
Model:
8
Derive the equations of motions of the system
Use Newton’s second law to derive EOM
Take Laplace Transform to get transfer function
xbkxtFm
x
xbkxtFxm
1
kbsmssF
sX
sXbssXksFsXms
2
2
1
9
Model the mass-spring-damper system
Using: First principles (EOM)
Transfer function
Physical models (mass, spring, damper)
Electrical equivalent of the system
(capacitor, resistor, power source)
10
Mechatronic Design and Simulation
Library of physical elements
Mechanical, hydraulic, electrical…
Tools for control designMechanical Hydraulic Electrical
Thermal Pneumatic Magnetic
N S
11
DC Motor Model
Problem: Model a DC motor in a
reusable way within the Simulink
environment
Solution: Use physical components to
model the electromechanical system
Model:
V+
V-
Shaft
Housing
14
MATLAB/Simulink Hardware Support for
Project-Based Learning
With just a click,
run your model on hardware
Selected Simulink Supported Target
Hardware:-Arduino® Uno ($30), Mega 2560 ($65)
-LEGO® MINDSTORMS® NXT ($280)
-Raspberry Pi Model B ($35)
-BeagleBoard-xM ($150)
-PandaBoard ($180)
-Gumstix® Overo hardware ($180)
Also Available in Student Version
15
Arduino
Arduino is an open-source microcontroller board, with
an associated development environment.
– Analog and Digital Input-Output directly from MATLAB code
– Motor control and System Design from command line and
Simulink models
– Large set of sensors and actuators
– Ideal for low budget projects
16
Same board… different approaches
Write code and
communicate with the
board
Tethered Approach
Develop a model and
program the board
Embedded Approach
17
DC Motor Control using Arduino Uno
Host Computer Arduino Uno DC Motor
Serial communication Motor driver
voltage
request
angle
voltage
angle
18
Raspberry Pi
What is it? – Credit-card sized, low-cost, single-board computer with audio and video input/output,
designed for teaching
Who created it?
Raspberry Pi Foundation: http://www.raspberrypi.org/
What are the specs?– Broadcom® system-on-a-chip which includes an ARM®11
processor running at 700 MHz with 512 MB RAM
– Peripheral connectivity for stereo audio and digital video
(1080p) and supports USB and Ethernet.
– It measures 85.6mm x 56mm x 21mm, with a little overlap
for the SD card and connectors. It weighs 45g.
Image from: http://www.raspberrypi.org/faqs
“Overall real world performance is something like a 300MHz Pentium 2”
19
Hardware Setup
What hardware do I need?– Raspberry Pi Model B
– Power cable (Micro USB-B needed by Raspberry
Pi)
Multiple options; I use USB-A to Micro USB-B cable for
power
– Ethernet cable
– SD Card
MicroSD card that sockets into SD shell will also work
– Open SD Card port (on host computer)
Need port to write firmware on SD Card / Micro SD card
Can use native port or USB-based device
– Open Ethernet port (on host computer)
Option: Can use USB-Ethernet dongle
– Case (nice to have)
– USB Webcam (UVC compatible)
21
Physical Interaction Benefits
Accessible
High Fidelity
Hands-On Learning
Unexpected Scenarios
Engaging
22
Physical
Interaction
Simulation
MATLAB/Simulink Solutions for Project-Based
Learning
Project-Based Learning – Learning by Doing
MATLAB and Simulink:
-Both simulation and hardware solutions
-Target affordable hardware platforms
-Industry-standard workflow for engineering education
23
Μάθετε τα νέα μας στο διαδίκτυο:
Τηλ: 210.60.31.121 - Fax: 210.60.31.024 - e-mail: [email protected]
Eπισκευθείτε το web site μας : www.mentorhellas.com
Join our group in : MATLAB seminars in Greece
http://www.linkedin.com/groups/MATLAB-seminars-in-Greece-3128153
Follow us on : twitter.com/mentorhellas
Eπικοινωνία & πληροφορίες
http://www.facebook.com/pages/Mentor-Hellas-Scientific-Engineering-Software/295004863886982
Mentor Hellas - Scientific Engineering Software