Top Banner

of 22

MathWorks MATLAB and Simulink for LEGO

Feb 20, 2018

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    1/22

    1

    2014 The MathWorks, Inc.

    MATLAB and Simulink for Embedded

    Systems and Robotics

    Sean de Wolski

    Application Engineer

  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    2/22

    2

    Agenda for today

    MATLAB & SIMULINK

    Theory to Practice

    Trying out concepts from Controls, Signal Processing,

    Communications, Mapping, etc.

    Testing on low-cost hardware

  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    3/22

    3

    Demo: Exploring Rover

  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    4/22

    4

    Why an Embedded System?

  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    5/22

    5

    MathWorks products

    MATLAB + Toolboxes Data Analysis and Visualization

    Statistical analysis

    Mathematical Modeling

    Signal Processing

    Etc.

    Simulink + Blocksets System modeling, simulation, testing

    and implementation

    Communication system design

    Physical system design

    hydraulic,

    mechanical, electrical, etc.

    Controller designing, tuning and

    implementation

    Etc.

  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    6/22

    6

    MATLAB for Data Analysis and Visualization

    Reporting and

    Documentation

    Outputs for Design

    Deployment

    ShareExplore & Discover

    Data Analysis

    & Modeling

    Algorithm

    Development

    Application

    Development

    Files

    Software

    Hardware

    Access

    Code & Applications

    Automate

  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    7/227

    Simulink

    Block-diagram environment

    Model, simulate and analyze

    multi-domain systems

    Accurately design, implement, and test: Control systems Signal processing systems

    Communications systems And other dynamic systems

    Platform for Model-Based Design

    The leading environment for modeling, simulating, andimplementing dynamic and embedded systems

  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    8/228

    MATLAB & Simulink in industry

    8

    Eurocopter: HelicoptersEaton: Hybrid Delivery Truck

    Caterpillar: Construction Machine

    IAV: CNG/LPG EMSGM: HVAC

    Delphi: Common Rail Diesel

    Dongfeng: BMSHoneywell: Flight Controls

    GM: Hybrid Powertrain

    Daimler: Vehicle ControllerLear: BCM

    Vodafone: Telematics

  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    9/229

    Targeting Hardware

    ANSI-C Code generation forembedded microprocessors MATLAB Coder

    Simulink Coder

    Embedded Coder

    HDL Code Generation for FPGAsand ASICs

    HDL Coder HDL Verifier

    PLC Code Generation Simulink PLC Coder

  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    10/2210

    Simulink Hardware Support for Project-

    Based Learning

    With just a click, your model moves fromSimulink onto hardware

    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)

    Available in Student Version

    Run Simulink models onlow-cost target hardware

  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    11/2211

    Demo: MATLAB Rover

  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    12/2212

    We will discuss:

    Part 1: Simulink for

    Embedded Logic Design, Test and Implementation

    Part 2: Stateflow for designing

    Event-driven systems, asynchronous sequencing logic

    Part 3: MATLAB, Simulink and Stateflow working together

    Part 4: MATLAB for Data Analysis and Visualization Plotting data on maps

  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    13/2213

    LEGO MINDSTORMS NXT Technology

    3 Actuator Ports

    4 Sensor Ports

    NXT Intelligent Brick

    1 USB Port

  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    14/2214

    Part 1: Embedded Logic Design, Test and

    Implementation

    Design complex dynamicbehavior and program

    robot

    Task for robot: Maintain:

    Stop if: . . <

    Approach

    Model intelligent behavior inSimulink

    Program the robot using

    Hardware Support Package

    . .

  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    15/2215

    Part 2: State Machine Design with Stateflow

    Designing event-driven systems

    and sequencing logic

    Task for robot:

    Exist in IDLE or MOVING States Change States based on obstruction

    distance

    Approach

    Design state machine using Stateflow

    Program robot

  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    16/2216

    Part 3: Interfacing with MATLAB

    Interface MATLAB and

    Simulink

    Task:

    Control block parameters usingMATLAB commands

    Log sensor data and save toMATLAB workspace

    Approach

    Use SET_PARAM command

    Use SINK blocks with model inEXTERNAL MODE

  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    17/22

    17

    Part 4: Post-process data in MATLAB

    MATLAB for Data Analysis

    and Visualization

    Task:

    Display collected data on maps

    Approach

    Use tools in

    Mapping Toolbox

  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    18/22

    18

    Demo: MATLAB Rover

    Hardware Support Package forLEGO MINDSTORMS NXT

    Simulink & Stateflow

    Tune Parameters

    Log Sensor Data

    USB & Bluetooth

    Change ModelParameters

    MATLAB GUI

    Analyze andVisualize

    Logged Data

    View Logged Data

  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    19/22

    19

    Video Demo: Arduino Bumper Bot

  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    20/22

    20

    Video Demo: Raspberry Pi Object Detection

  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    21/22

    21

    Key takeaways

    MATLAB commands to remember>> targetinstaller

    >> simulink

    >> doc

    To learn more MATLAB and Simulink based Interactive Tutorials

    http://www.mathworks.com/academia/student_center/tutorials/

    Supported hardware for project based learning:

    http://www.mathworks.com/academia/hardware-resources/

    http://www.mathworks.com/academia/student_center/tutorials/http://www.mathworks.com/academia/hardware-resources/http://www.mathworks.com/academia/hardware-resources/http://www.mathworks.com/academia/hardware-resources/http://www.mathworks.com/academia/student_center/tutorials/
  • 7/24/2019 MathWorks MATLAB and Simulink for LEGO

    22/22

    22 2014 The MathWorks Inc