how to use matlab with raspberry pi to collect and analyze ... · pdf filecollect and analyze...
TRANSCRIPT
![Page 1: How to use MATLAB with Raspberry Pi to Collect and Analyze ... · PDF fileCollect and Analyze Data from Sensors and Imaging Devices Eric Wetjen. 2 Agenda](https://reader034.vdocument.in/reader034/viewer/2022042600/5ab13db57f8b9a00728c1481/html5/thumbnails/1.jpg)
1© 2014 The MathWorks, Inc.
How to use MATLAB with Raspberry Pi to
Collect and Analyze Data from Sensors and
Imaging Devices
Eric Wetjen
![Page 2: How to use MATLAB with Raspberry Pi to Collect and Analyze ... · PDF fileCollect and Analyze Data from Sensors and Imaging Devices Eric Wetjen. 2 Agenda](https://reader034.vdocument.in/reader034/viewer/2022042600/5ab13db57f8b9a00728c1481/html5/thumbnails/2.jpg)
2
Agenda
Introduction to MATLAB
Installation of Support Package
– Setting up MATLAB to talk to your Raspberry Pi
Camera Board demo
– Setting up Camera Board and detecting faces
I2C and SPI sensor demos
– Sparkfun TMP102 Temperature sensor
Setting up sensor and plotting temperature data
– Sparkfun LIS331 Triple axis accelerometer
Setting up sensor and taking measurements
Using data to visualize orientation
Conclusion and Additional Resources
![Page 3: How to use MATLAB with Raspberry Pi to Collect and Analyze ... · PDF fileCollect and Analyze Data from Sensors and Imaging Devices Eric Wetjen. 2 Agenda](https://reader034.vdocument.in/reader034/viewer/2022042600/5ab13db57f8b9a00728c1481/html5/thumbnails/3.jpg)
3© 2014 The MathWorks, Inc.
Introduction to MATLAB
![Page 4: How to use MATLAB with Raspberry Pi to Collect and Analyze ... · PDF fileCollect and Analyze Data from Sensors and Imaging Devices Eric Wetjen. 2 Agenda](https://reader034.vdocument.in/reader034/viewer/2022042600/5ab13db57f8b9a00728c1481/html5/thumbnails/4.jpg)
4
Using MATLAB with Raspberry Pi
Design Algorithms/
Analyze Acquired
Data
Command
Device World
Actuate
Sense
Response
MATLAB
Raspberry Pi
![Page 5: How to use MATLAB with Raspberry Pi to Collect and Analyze ... · PDF fileCollect and Analyze Data from Sensors and Imaging Devices Eric Wetjen. 2 Agenda](https://reader034.vdocument.in/reader034/viewer/2022042600/5ab13db57f8b9a00728c1481/html5/thumbnails/5.jpg)
5© 2014 The MathWorks, Inc.
Installing Raspberry Pi Support for MATLAB
![Page 6: How to use MATLAB with Raspberry Pi to Collect and Analyze ... · PDF fileCollect and Analyze Data from Sensors and Imaging Devices Eric Wetjen. 2 Agenda](https://reader034.vdocument.in/reader034/viewer/2022042600/5ab13db57f8b9a00728c1481/html5/thumbnails/6.jpg)
7
Setting up Support Package
![Page 7: How to use MATLAB with Raspberry Pi to Collect and Analyze ... · PDF fileCollect and Analyze Data from Sensors and Imaging Devices Eric Wetjen. 2 Agenda](https://reader034.vdocument.in/reader034/viewer/2022042600/5ab13db57f8b9a00728c1481/html5/thumbnails/7.jpg)
8
Uploading firmware
![Page 8: How to use MATLAB with Raspberry Pi to Collect and Analyze ... · PDF fileCollect and Analyze Data from Sensors and Imaging Devices Eric Wetjen. 2 Agenda](https://reader034.vdocument.in/reader034/viewer/2022042600/5ab13db57f8b9a00728c1481/html5/thumbnails/8.jpg)
9
Detecting Raspberry Pi
![Page 9: How to use MATLAB with Raspberry Pi to Collect and Analyze ... · PDF fileCollect and Analyze Data from Sensors and Imaging Devices Eric Wetjen. 2 Agenda](https://reader034.vdocument.in/reader034/viewer/2022042600/5ab13db57f8b9a00728c1481/html5/thumbnails/9.jpg)
10
Completing Installation
![Page 10: How to use MATLAB with Raspberry Pi to Collect and Analyze ... · PDF fileCollect and Analyze Data from Sensors and Imaging Devices Eric Wetjen. 2 Agenda](https://reader034.vdocument.in/reader034/viewer/2022042600/5ab13db57f8b9a00728c1481/html5/thumbnails/10.jpg)
11© 2014 The MathWorks, Inc.
Demo: Capturing an image with the Camera
Board and Detecting Faces
![Page 11: How to use MATLAB with Raspberry Pi to Collect and Analyze ... · PDF fileCollect and Analyze Data from Sensors and Imaging Devices Eric Wetjen. 2 Agenda](https://reader034.vdocument.in/reader034/viewer/2022042600/5ab13db57f8b9a00728c1481/html5/thumbnails/11.jpg)
12
Connecting the Camera Board
![Page 12: How to use MATLAB with Raspberry Pi to Collect and Analyze ... · PDF fileCollect and Analyze Data from Sensors and Imaging Devices Eric Wetjen. 2 Agenda](https://reader034.vdocument.in/reader034/viewer/2022042600/5ab13db57f8b9a00728c1481/html5/thumbnails/12.jpg)
13
Summary: Using Camera Board from MATLAB
Create raspi object
Create Camera Board
object
View/Change Camera
Board Settings
Use snapshot to take
acquire image
Create loop to acquire
video
Perform face detection on
the acquired video
![Page 13: How to use MATLAB with Raspberry Pi to Collect and Analyze ... · PDF fileCollect and Analyze Data from Sensors and Imaging Devices Eric Wetjen. 2 Agenda](https://reader034.vdocument.in/reader034/viewer/2022042600/5ab13db57f8b9a00728c1481/html5/thumbnails/13.jpg)
14© 2014 The MathWorks, Inc.
Demo: Measuring temperature with an
I2C temperature sensor
![Page 14: How to use MATLAB with Raspberry Pi to Collect and Analyze ... · PDF fileCollect and Analyze Data from Sensors and Imaging Devices Eric Wetjen. 2 Agenda](https://reader034.vdocument.in/reader034/viewer/2022042600/5ab13db57f8b9a00728c1481/html5/thumbnails/14.jpg)
15
Connecting an I2C sensor
Sensor pinout for TMP102 temperature sensor
We need to connect:
• SDA to GPIO 2 (I2C1_SDA)
• SCL to GPIO 3 (I2C1_SCL)
• VCC to 3.3V
• GND to GND
• ADD0 to GND
![Page 15: How to use MATLAB with Raspberry Pi to Collect and Analyze ... · PDF fileCollect and Analyze Data from Sensors and Imaging Devices Eric Wetjen. 2 Agenda](https://reader034.vdocument.in/reader034/viewer/2022042600/5ab13db57f8b9a00728c1481/html5/thumbnails/15.jpg)
16
Summary: Reading from TMP102 I2C sensor
Create raspi object
Scan I2C bus for address of sensor (0x48)
Create i2cdevice object
Read temperature register
Decode temperature using formula in datasheet
![Page 16: How to use MATLAB with Raspberry Pi to Collect and Analyze ... · PDF fileCollect and Analyze Data from Sensors and Imaging Devices Eric Wetjen. 2 Agenda](https://reader034.vdocument.in/reader034/viewer/2022042600/5ab13db57f8b9a00728c1481/html5/thumbnails/16.jpg)
17© 2014 The MathWorks, Inc.
Demo: Orientation Sensing with an SPI
accelerometer
![Page 17: How to use MATLAB with Raspberry Pi to Collect and Analyze ... · PDF fileCollect and Analyze Data from Sensors and Imaging Devices Eric Wetjen. 2 Agenda](https://reader034.vdocument.in/reader034/viewer/2022042600/5ab13db57f8b9a00728c1481/html5/thumbnails/17.jpg)
18
Connecting an SPI sensor
Sensor pinout for LIS331 accelerometer
We need to connect:
• SDA to GPIO 10 (SPIO_MOSI)
• SAO to GPIO 9 (SPIO_MISO)
• SCL to GPIO 11 (SPIO_CLK)
• CS to GPIO 8 (CEO)
• VCC to 3.3V
• GND to GND
![Page 18: How to use MATLAB with Raspberry Pi to Collect and Analyze ... · PDF fileCollect and Analyze Data from Sensors and Imaging Devices Eric Wetjen. 2 Agenda](https://reader034.vdocument.in/reader034/viewer/2022042600/5ab13db57f8b9a00728c1481/html5/thumbnails/18.jpg)
19
Summary : Reading from LIS331 3- axis accelerometer
Create raspi object
Enable SPI
Create Acceleration Sensor
object
– Object decodes
– Object maps registers
Take readings
Do something interesting
– Simple Orientation
Sensor
![Page 19: How to use MATLAB with Raspberry Pi to Collect and Analyze ... · PDF fileCollect and Analyze Data from Sensors and Imaging Devices Eric Wetjen. 2 Agenda](https://reader034.vdocument.in/reader034/viewer/2022042600/5ab13db57f8b9a00728c1481/html5/thumbnails/19.jpg)
20
Wrap-Up
How to install Raspberry Pi MATLAB Support
How to acquire images using Camera Board
How to use I2C and SPI sensors from MATLAB with your Raspberry
Pi
Application examples
– Face Detection
– Plotting temperature
– Orientation sensing
![Page 20: How to use MATLAB with Raspberry Pi to Collect and Analyze ... · PDF fileCollect and Analyze Data from Sensors and Imaging Devices Eric Wetjen. 2 Agenda](https://reader034.vdocument.in/reader034/viewer/2022042600/5ab13db57f8b9a00728c1481/html5/thumbnails/20.jpg)
21
How to buy MATLAB and Simulink
More information at:
https://www.mathworks.com/store/index.do
![Page 21: How to use MATLAB with Raspberry Pi to Collect and Analyze ... · PDF fileCollect and Analyze Data from Sensors and Imaging Devices Eric Wetjen. 2 Agenda](https://reader034.vdocument.in/reader034/viewer/2022042600/5ab13db57f8b9a00728c1481/html5/thumbnails/21.jpg)
22
Get started today!
Get your Raspberry Pi
– www.element14.com
Install MATLAB & Simulink
– https://www.mathworks.com/store/index.do
Get the Raspberry Pi support package
– http://www.mathworks.com/hardware-
support/raspberry-pi-matlab.html
Visit MakerZone other project ideas
– www.makerzone.mathworks.com
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be
trademarks or registered trademarks of their respective holders. © 2014 The MathWorks, Inc.