Presentation Title

Presentation Title
Raspberry Pi Programming using Simulink
Brian McKay
Technical Marketing
[email protected]
© 2013 The MathWorks, Inc.
Introduction to Raspberry Pi
Software Setup
– Installation of Simulink Support Package for Raspberry Pi
Hardware Setup
– Test that hardware is connected and working
Build and run model
– Image Inversion
– Object detection
– Barcode reader
Introduction to 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:
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.
“Overall real world performance is something like a 300MHz Pentium 2”
Image from:
Introduction to Raspberry Pi
What’s the difference between Model A and Model B?
– Model A has 256MB RAM, one USB port and no Ethernet (network connection).
– Model B has 512MB RAM, 2 USB ports and an Ethernet port.
– MathWorks only supports Raspberry Pi Model B
How much does it cost?
– Approximately $35 US for the Raspberry Pi Model B
– Cases, peripherals, and starter bundles are available
OK, where do I get one?
– Premier Farnell/Element 14 and RS Components
For more info:
Software Setup
What software do I need?
– MathWorks Software:
MATLAB and Simulink (including Student Version) Release R2013a, or later
Note: Raspberry Pi support is available on 32-bit and 64-bit Microsoft Windows only
– Compiler (for MathWorks software):
See Supported and Compatible Compilers
For my 64-bit Windows 7 installation, I am using Microsoft Windows SDK 7.1 (available at no charge)
– Simulink Support Package for Raspberry Pi Hardware
Simulink Support Package for Raspberry Pi Hardware
What is it?
– A set of Simulink blocks that allow you to generate programs that run on a Raspberry Pi
– It’s downloadable and it’s free!
Where do I get it?
– Get from the MATLAB Toolstrip: Add-Ons  Get Hardware Support Packages
– Get from the MATLAB Command Line: >> targetinstaller
Simulink Support Package for Raspberry Pi Hardware
Installation Process:
– The Support Package Installer will lead you through the installation process and install
all the software you need to run on a Raspberry Pi from Simulink
Let’s go get it!
Summary: Simulink Support Package for Raspberry Pi Hardware
Support Package Installer installs all the software elements you need to
connect to and run on a Raspberry Pi
Requires MathWorks Account Login
– (but don’t worry if you don’t have one, you can create one when you get to the screen)
Firmware onto SD card
– need to do this on the first installation
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)
Hardware setup
Connect Raspberry Pi
– Plug in USB Ethernet Adapter to PC, and Ethernet
cable into adapter and Raspberry Pi
– Plug USB webcam into Raspberry Pi
– Insert SD card (which may be a carrier for SD
micro) into Raspberry Pi
– Attach USB power cable – USB A to PC, and USB
micro B to power port on Raspberry Pi
Wait a minute for Raspberry Pi to boot
Let’s go test it!
Summary: Simulink + Raspberry Pi Testing
Check for Support Package Installation
– Simulink Support Package for Raspberry Pi
Hardware should be in your Simulink Library
– Can also type at MATLAB Command line:
Test your connection (PC to Raspberry Pi)
– Type at the MATLAB command line:
– You should see the result:
Summary: Simulink + Raspberry Pi Testing (con’t)
Open Raspberry Pi Image Inversion model: raspberrypi_inversion
Click Tools -> Run on Target Hardware -> Options
– Check to make sure Target hardware = Raspberry Pi.
– Also check the IP address.
Click Run button
– We used the “External” simulation mode.
– External mode allows you to tune parameters and monitor signals
in the model while the application is running on hardware
– You can use “Deploy to Hardware” button if you want to run on the
hardware with no interaction from the host
The model is now running on the Raspberry Pi
Two Examples
Object Detection
– Locate and mark the center of green object
Barcode scanner
– Scan barcode and output numerical digits
Simulink Hardware Support
Lego NXT
Raspberry Pi
Gumstix Overo
Selected Simulink Supported Target Hardware:
Raspberry Pi Model B ($40)
Arduino® Uno, Mega 2560, Nano, Ethernet Shield ($30-$70)
BeagleBoard-xM ($150)
PandaBoard ($180)
Gumstix® Overo hardware ($180)
Available in Student Version!
Additional Resources
© 2013 The MathWorks, Inc. MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See for a list of additional trademarks. Other product or brand names may be
trademarks or registered trademarks of their respective holders.
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF