IEK AIGALEW

Υπολογιστικά πειράματα με το MATLAB
Σύνδεση με Arduino & Raspberry Pi
Ζαχαρίας Γκέτσης
Μηχανικός Εφαρμογών
© 2012 The MathWorks, Inc.1
Project-Based Learning
Project-based learning is a comprehensive approach to classroom
teaching and learning that is designed to engage students in
investigation of authentic problems.
Motivating Project-Based Learning: Sustaining the Doing, Supporting the Learning, Educational Psychologist Volume 26, Issue 3-4, 1991
2
Two Avenues for Project-Based Learning
Simulation
Physical
Interaction
3
Simulation
Algorithm
Device
World
4
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
5
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
6
1 DOF mass-spring-damper system
Model:
Problem: Model a 1 DOF mass-springdamper system within the Simulink
environment from first principles and
using physical modeling tools.
7
Derive the equations of motions of the system


Use Newton’s second law to derive EOM
Take Laplace Transform to get transfer function
mx  F t   kx  bx

1

x  m F t   kx  bx 
ms 2 X s   F s   kX s   bsX s 

 X s 
1
 F s   ms 2  bs  k

8
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)
9
Mechatronic Design and Simulation

Library of physical elements


Mechanical, hydraulic, electrical…
Tools for control design
Mechanical Hydraulic
Thermal
Electrical
Pneumatic Magnetic
N
S
10
DC Motor Model
Model:
V+
Shaft
VHousing
Problem: Model a DC motor in a
reusable way within the Simulink
environment
Solution: Use physical components to
model the electromechanical system
11
Simulation Benefits
Inexpensive
Accessible
Robust
“What-If” Scenarios
“See” the Algorithms
12
Physical Interaction
Algorithm
Device
World
13
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
14
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
15
Same board… different approaches
Write code and
communicate with the
board
Develop a model and
program the board
Tethered Approach
Embedded Approach
16
DC Motor Control using Arduino Uno
Host Computer
Arduino Uno
DC Motor
voltage
request
voltage
angle
angle
Serial communication
Motor driver
17
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”
18
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)
19
Raspberry Pi (Model B) Support from Simulink
20
Physical Interaction Benefits
Accessible
High Fidelity
Unexpected Scenarios
Hands-On Learning
Engaging
21
MATLAB/Simulink Solutions for Project-Based
Learning
Project-Based Learning – Learning by Doing
Simulation
MATLAB and Simulink:
-Both simulation and hardware solutions
-Target affordable hardware platforms
-Industry-standard workflow for engineering education
Physical
Interaction
22
Eπικοινωνία & πληροφορίες
Τηλ: 210.60.31.121 - Fax: 210.60.31.024 - e-mail: [email protected]
Μάθετε τα νέα μας στο διαδίκτυο:
Eπισκευθείτε το web site μας :
www.mentorhellas.com
Mentor Hellas - Scientific Engineering Software
http://www.facebook.com/pages/Mentor-Hellas-Scientific-Engineering-Software/295004863886982
Follow us on
: twitter.com/mentorhellas
Join our group in
: MATLAB seminars in Greece
http://www.linkedin.com/groups/MATLAB -seminars-in-Greece-3128153
23