Set up and Blink - MATLAB and Simulink with Raspberry Pi

Similar documents
Set up and Blink - Simulink with Arduino

How to program a Zumo Robot with Simulink

Arduino Lesson 1. Blink

Installation Guide (No Router)

Adafruit's Raspberry Pi Lesson 5. Using a Console Cable

Using a USB Flash Drive to Back Up Your Data Files on a Mac Computer

Contents. ST9612 Model WIC Printer. Get the original printer s information. Edited 11/04/15

HL2170W Windows Network Connection Repair Instructions

Midland BT Updater BTUpdater Program Program file (x86) ), Midland

Guide for Updating Firmware and Troubleshooting Connection Issues

Virtual Desktop on any computer (incl. Desktop Bar Guide)

Yun Shield User Manual VERSION: 1.0. Yun Shield User Manual 1 / 22.

Contents. Business Everywhere user guide. 1. Introduction. 2. How to Install/Uninstall Business Everywhere. 3. The Business Everywhere interface

Work with Arduino Hardware

MATLAB on EC2 Instructions Guide

Adafruit's Raspberry Pi Lesson 5. Using a Console Cable

SSH to BeagleBone Black over USB

How to setup EW-7438RPn with a Windows computer to extend an existing Wi-Fi network

Introduction to Simulink

User Tutorial on Changing Frame Size, Window Size, and Screen Resolution for The Original Version of The Cancer-Rates.Info/NJ Application

1. Do I need to upgrade my Broadband at Home modem firmware?

Application Note. Example of user log on Magelis HMI with XB5S5B2L2 biometric switch. Advanced Technical Support - Brazil. Version: 1.

Before you start, you should prepare the following items

Raptor-CAN User Manual

IT Quick Reference Guides Using Windows 7

Addonics T E C H N O L O G I E S. NAS Adapter. Model: NASU Key Features

Connecting your Omega/BetaPAT PLUS to a PC via a USB

How to Download Images Using Olympus Auto-Connect USB Cameras and Olympus Master

AR1100 Resistive Touch Screen Controller Guide

AUDITVIEW USER INSTRUCTIONS

Network/Floating License Installation Instructions

If you are unable to set up your Linksys Router by using one of the above options, use the steps below to manually configure your router.

ERIKA Enterprise pre-built Virtual Machine

Raspberry Pi Setup Tutorial

User Manual. Thermo Scientific Orion

Crown Field Support Engineering

Windows 7 for beginners

USB Driver Installation for Windows XP

Quick Start Guide Vodafone Mobile Broadband USB Stick. Designed for Vodafone

We cannot use an ordinary Ethernet cable. That is the cable which plugs into the Broadband slot.

Shearwater Research Dive Computer Software Manual

Rako Lighting Driver. For use with: Driver software written and provided by:

Network Monitoring User Guide Pulse Appliance

Software Manual LSeries Manager V1.2 Software Manual June 18, LSeries Manager 1.2. Software Manual

AUDITVIEW USER INSTRUCTIONS

Quick Start Guide Vodafone Mobile Broadband USB Modem Stick. Designed for Vodafone

Installing Remote Desktop Connection

AT&T USBConnect Mercury Getting Started Guide

This tutorial provides detailed instructions to help you download and configure Internet Explorer 6.0 for use with Web Commerce application.

FileMover 1.2. Copyright Notice. Trademarks. Patents

SMART Board Software for Macintosh Computers FAQ

Adafruit's Raspberry Pi Lesson 5. Using a Console Cable. Created by Simon Monk

HomeSeer Technologies. HomeSeer Technologies LLC 35 Constitution Dr, Suite C Bedford NH,

Keri USB-A Connection and Configuration

To perform Ethernet setup and communication verification, first perform RS232 setup and communication verification:

How To Use An Apple Macbook With A Dock On Itunes Macbook V.Xo (Mac) And The Powerbar On A Pc Or Macbook (Apple) With A Powerbar (Apple Mac) On A Macbook

Adobe Reader Settings

Speedlink software will run on Windows NT, Windows 7, and Windows 8; it will run on both 32 byte and 64 byte versions of Windows.

Quick Start Guide. Vonage Device Motorola VT2142

Firmware Update Instruction Manual

PiFace Control & Display

Quick Start Guide Vodafone Mobile Connect USB Stick. Designed for Vodafone

OS X LION SET UP THE SYSTEM

Using your ios device, open the App Store, Search for, download and install the WeMo App.

How to use a SMART Board

VMware Horizon FLEX User Guide

SecureLock. User Manual

ScanShell.Net Install Guide

SMART Board Software for Macintosh FAQ

Actiontec Router Troubleshooting

Fusion. User s Guide: Updating the Fusion s Image

EasyMP Multi PC Projection Operation Guide

Getting the most from your Maxtor OneTouch TM USB hard drive and Linksys Network Storage Link

How to use Matlab on the Virtual Labs

Select Correct USB Driver

Canvio Home FAQ. is designed to be very easy to install and use to back up, share, and remotely access the files from your computers.

MASTER GUIDE (MAC) Gaming on the go is now possible.

Tutorial How to upgrade firmware on Phison S8 controller MyDigitalSSD using a Windows PE environment

AgGPS 542 Receiver: Enable GLONASS through the Web Browser

Using a USB Flash Drive to Back Up Your Data Files on a Windows Computer

Troubleshooting Sprint Mobile Broadband USB Modem by Novatel Wireless TM (Ovation TM U727)

Honeywell Internet Connection Module

Maxtor OneTouch User's Guide

1 Installation. Note: In Windows operating systems, you must be logged in with administrator rights to install the printer driver.

System update procedure for Kurio 7 (For build number above 110)

3.5 EXTERNAL NETWORK HDD. User s Manual

Guide to Installing BBL Crystal MIND on Windows 7

TX3 Series TELEPHONE ACCESS SYSTEMS. Configurator Quick Start. Version 2.2 Mircom Copyright 2014 LT-973

Guide for Remote Control PDA

CANON FAX L360 SOFTWARE MANUAL

LabelWriter. Print Server. User Guide

A Teacher s Guide to Updating Multiple TI-Nspire. Handhelds

How to connect your Victron to a computer with VE Bus Quick Configure

Imation LOCK User Manual

Royal Mail Despatch Manager Online Printer Installation Guide

Super Pro Net TM Network Key Installation and Operation

Norms for Learning Centers

a. If necessary update the Beamage-3.0 s firmware, using the BeamageUpdater (refer to p.7);

Imation Clip USB 2.0 Flash Drive. Imation Drive Manager Software. User s Manual

Transcription:

Set up and Blink - MATLAB and Simulink with Raspberry Pi Created by Anuja Apte Last updated on 2015-04-16 05:50:07 PM EDT

Guide Contents Guide Contents Overview Parts and Hardware Set up MATLAB and Simulink support package for Raspberry Pi Using MATLAB Support Package and Raspberry Pi Common Error Messages Using Simulink Support Package and Raspberry Pi Resources 2 3 5 6 13 14 15 22 Page 2 of 22

Overview You can use MATLAB to communicate with a Raspberry Pi board and its peripheral devices using MATLAB Support Package for Raspberry Pi. You can program Raspberry Pi boards to run your algorithms using Simulink Support Package for Raspberry Pi Hardware. The support package generates code from your Simulink model in a click of a button that then runs on the Raspberry Pi board. This tutorial covers a step-by-step guide to: MATLAB Support Package 1. Set up the MATLAB support package for Raspberry Pi 2. Send commands from MATLAB to Raspberry Pi to blink the on-board LED Simulink Support Package 1. Set up the Simulink support package for Raspberry Pi 2. Build a simple Simulink model for controlling pins on the Raspberry Pi 3. Generate, download and run code on the Raspberry Pi to blink an LED This is the first tutorial in a series on using MATLAB and Simulink to program a Raspberry Pi. In this tutorial Raspberry Pi 2 is used as an example, however the same steps can be used for other Page 3 of 22

boards like Raspberry Pi Model B+ etc. Page 4 of 22

Parts and Hardware Software MATLAB and Simulink Student Suite Release 2015a - now available for $99 MathWorks (http://adafru.it/d5e) Amazon US (http://adafru.it/eoc) Amazon UK (http://adafru.it/eod) If you are not a student, you can purchase the MATLAB Home-Use license for personal use: MATLAB home-use (http://adafru.it/eoe) Hardware 1. Raspberry Pi 2 (http://adafru.it/2358) 2. USB cable (http://adafru.it/2008) 3. Ethernet cable (http://adafru.it/ey7) Page 5 of 22

Set up MATLAB and Simulink support package for Raspberry Pi Start MATLAB Open MATLAB and click the Add-Ons drop down menu on the top right Start Support Package Installer Click on Get Hardware Support Packages in the drop down menu to start the installer. Select 'Install from Internet' as the source for installing the support package Select Raspberry Pi from a list of support packages Click Next to see a list of support packages and select Raspberry Pi from the list to install both the support packages at once. Page 6 of 22

MathWorks Account Click next and log in to your MathWorks account. If you don't have a MathWorks account, you can create one during the install process or by visiting this page on the MathWorks website (http://adafru.it/eoa). (http://adafru.it/d5k) Page 7 of 22

Continue and Complete the Installation Accept the license agreement on the next screen and click Next through the following screens to finish the installation of both MATLAB and Simulink Support Package for Raspberry Pi. Page 8 of 22

Firmware Update Click Next and on the Firmware Update page select the appropriate board (for this tutorial, Raspberry Pi 2 Model B is chosen). Configure Network Click Next and in the configure network screen, select Direct connection to host computer (to follow along with this tutorial). Page 9 of 22

Select the drive In the next window 'Select a drive', the MicroSD cards that are detected by MATLAB will show up in a list format. If the MicroSD memory card does not get detected by MATLAB, but is detected by the OS - close MATLAB and restart MATLAB as an administrator. To continue with the process, the targetupdater command can be used in MATLAB. Page 10 of 22

Write firmware In the next window, select write option to erase existing items on the memory card and flash the latest firmware that is needed by the Support package. Page 11 of 22

Continue and Complete the Installation Click Next through the following screens to finish the installation for both MATLAB and Simulink Support Package for Raspberry Pi. Page 12 of 22

Using MATLAB Support Package and Raspberry Pi Now that we have the necessary software installed, it's time to blink the on-board LED. In this example, we will use the MATLAB support package. To establish a connection between MATLAB and Pi 2, the following command can be used from MATLAB. >> mypi = raspi This command connects MATLAB to the most recent successful connection to a Raspberry Pi board, including the setup process. A MATLAB variable by the name 'mypi' should now appear on the workspace or an error message indicating what went wrong. This object represents the connection that MATLAB has established with the physical object (Raspberry Pi). To switch on the on-board LED connected, execute the following command >> writeled(mypi,'led0',1) Here we are sending a request from MATLAB to Raspberry Pi board, to write the value of 1 on the on-board LED. This should switch ON your LED. To blink the LED, we have to switch it ON and OFF periodically. for i = 1:10 writeled(mypi,'led0',1); pause(0.5); writeled(mypi,'led0',0); pause(0.5); end Other functions that are related to the MATLAB Support Package for Raspberry Pi can also Page 13 of 22

be used along with the Raspberry Pi object 'mypi'. To take a look at the featured examples from MATLAB Support Package for Raspberry Pi, type raspi_examples in MATLAB Command Window. Common Error Messages Error using raspi (line 157) Cannot establish an SSH connection to the board with device address "169.254.0.2". Caused by: Error using raspi (line 153) Error executing command: FATAL ERROR: Network error: Network is unreachable Ensure that the Raspberry Pi board is connected to the computer that you are working with. Usually when the lights on the ethernet port and the ACT LED are blinking, there is a connection between the Pi board and the computer. If for some reason the connection between MATLAB and Raspberry Pi board is lost, the following error message appears. The host and client connection is lost. Make sure the board is plugged in and/or recreate arduino and its related objects. The best practices to follow to resolve this error - 1. Disconnect the USB cable and Ethernet cable from both the Pi board and computer 2. Clean up MATLAB by typing clear in MATLAB Command Window 3. Plug in the USB cable to computer and Pi board 4. Try connecting to the board from MATLAB by using raspi command Page 14 of 22

Using Simulink Support Package and Raspberry Pi Create your own Simulink model 1. In MATLAB, select New > Simulink Model under the HOME Tab 2. Click on the Library Browser Icon on the simulink model and go to Sources tab under Simulink in the Simulink Library Browser window Page 15 of 22

3. Drag the Pulse Generator block from the Sources library to your model and change the values as shown here 4. Use the LED Block from Simulink Support Package for Raspberry Pi Hardware in the Library Browser and change the parameters as shown here Page 16 of 22

Page 17 of 22

5. Drag and drop the Data Type Conversion block from the Signal Attributes tab under the Simulink library Page 18 of 22

6. When you move the mouse pointer close to the arrow on the block, it will change to a plus sign. Left click when you seee the plus sign and drag the mouse to make the intended connection. Once the connection is made you can release the left click button. Page 19 of 22

7. Save this model and to configure the model go to Tools > Run on Target Hardware > Prepare To Run... Page 20 of 22

8. When the Configuration Parameters page opens up, set the Target hardware parameter to Raspberry Pi. Do not change any other settings. 9. In your Simulink model, click the Deploy To Hardware button on the toolbar. Code will be generate from the model, which is then deployed to your Pi 2. The on-board LED should blink one time every second. Page 21 of 22

Resources Examples for getting started MATLAB examples (http://adafru.it/d5m) Simulink examples (http://adafru.it/eul) Full tutorials MATLAB Getting Started Tutorial (http://adafru.it/d5n) (3 hrs 15 mins) Simulink Getting Started Tutorial (http://adafru.it/d5n) (2 hrs 15 mins - 10 mins per module) Last Updated: 2015-04-16 05:50:07 PM EDT Page 22 of 22