Programming With MATLAB/Simulink - NDSU · PDF fileBEST Robotic, Inc. MATLAB/Simulink Team...

download Programming With MATLAB/Simulink - NDSU · PDF fileBEST Robotic, Inc. MATLAB/Simulink Team Training Programming With MATLAB/Simulink September 20, 2013 BISON BEST

If you can't read please download the document

Transcript of Programming With MATLAB/Simulink - NDSU · PDF fileBEST Robotic, Inc. MATLAB/Simulink Team...

  • BEST Robotic, Inc.

    MATLAB/Simulink Team Training

    Programming With MATLAB/Simulink

    September 20, 2013 1BISON BEST

    What Youll Need Minimum System Requirements

    Microsoft Windows XP or Later 32-bit or 64-bit machine Administrator Access on the PC Internet connection DVD drive

    Software required MATLAB R2013a provided on DVD - only one side Intellitek EasyC V4 StudentCompetitionInstaller.exe downloaded from

    http://www.mathworks.com/BESTinstall BESTRoboticsInstaller_1.1.5.exe downloaded from

    http://www.mathworks.com/BESTinstallSeptember 20th, 2013 2Bison BEST

  • Installation

    Follows instruction at www.mathworks.com/BESTinstall Insert the MATLAB DVD in your computer; if the autoinstaller

    runs, you MUST STOP it. Run StudentInstaller.exe downloaded from mathworks

    website You will be required to enter the installation key provided on

    your DVD

    At the end of the installation, you must register and activate your MATLAB at Mathworks.com. For immediate results, do it by internet. You will be required nto enter the activation key provided on

    your DVD

    Run BESTRoboticsInstaller_1.5.1.exe downloaded from mathworks website.

    August 1, 2010 3Copyright 2010 BEST Robotics, Inc. All rights reserved.

    Key Software Locations

    August 1, 2010 4Copyright 2010 BEST Robotics, Inc. All rights reserved.

  • Click on the MATLAB r2013A link

    Starting MATLAB

    August 1, 2010 5Copyright 2010 BEST Robotics, Inc. All rights reserved.

    MATLAB command window opens along with the BEST Robotics Library menu

    starting

    August 1, 2010 6Copyright 2010 BEST Robotics, Inc. All rights reserved.

  • Something on MATLAB

    August 1, 2010 7Copyright 2010 BEST Robotics, Inc. All rights reserved.

    August 1, 2010

    8

    Copyright 2010 BEST Robotics, Inc. All rights reserved.

    MATLAB - Command Window

    A semicolon prevents echoing

  • MATLAB scripting

    August 1, 2010 9Copyright 2010 BEST Robotics, Inc. All rights reserved.

    MATLAB scripting

    August 1, 2010 10Copyright 2010 BEST Robotics, Inc. All rights reserved.

    A script is a text file; It can be written using any text editor. Save with an extension .m

    To run the script, just type its name in the MATLAB command window.

  • MATLAB Simulink

    Simulink is MATLABs graphical programming interface. Programming is accomplished by connecting various graphical

    icons in a specific order. Simulink graphical icons are collected in what are known as

    Libraries.

    To write a Simulink program (or Model), first open the Simulink Library collections

    August 1, 2010 11Copyright 2010 BEST Robotics, Inc. All rights reserved.

    Creating a new Simulink Model

    August 1, 2010 12Copyright 2010 BEST Robotics, Inc. All rights reserved.

  • Simulink

    August 1, 2010 13Copyright 2010 BEST Robotics, Inc. All rights reserved.

    August 1, 2010 Copyright 2010 BEST Robotics, Inc. All rights reserved. 14

    Simulink BEST Library

  • Simulink BEST Robot Model The robot can be driven either in Tank or in

    Arcade mode. The joystick has four analog channels and

    four digital channels The controller can drive

    Up to 10 motors and servos in analog mode Up to 4 servos in digital mode Can read up to 8 analog sensors (such as potentiometers) Can read up to 8 digital sensors (such as limit switches)

    Simulink library has an icon for each of the possible functions: to read the joystick, to drive motors and servos, and to read sensors

    August 1, 2010 15Copyright 2010 BEST Robotics, Inc. All rights reserved.

    Creating a Robot Program

    Open a robot model window by clicking the Open new model button on the BEST Robotics Library window.

    September 20th, 2013 Bison BEST 16

  • The BEST Robot Model

    August 1, 2010 17Copyright 2010 BEST Robotics, Inc. All rights reserved.

    + 127

    + 127

    -127

    -127

    + 127

    + 127

    -127

    -127

    The joystick and accelerometer limit return values are +127 and -127 as shown in the figure. The buttons have a return value of 0 when pressed and 1 when released.

    Accelerometer rotate right limit + 127

    Accelerometer rotate left limit - 127

    Accelerometer rotate forward limit + 127

    Accelerometer rotate back limit -127

    Reading the Joystick

    Y Axis

    X A

    xis

    August 1, 2010 18Copyright 2010 BEST Robotics, Inc. All rights reserved.

  • August 1, 2010 19Copyright 2010 BEST Robotics, Inc. All rights reserved.

    September 20th, 2013 Bison BEST 20

  • Actuating Motors and Servos

    August 1, 2010 21Copyright 2010 BEST Robotics, Inc. All rights reserved.

    August 1, 2010 22Copyright 2010 BEST Robotics, Inc. All rights reserved.

  • August 1, 2010 23Copyright 2010 BEST Robotics, Inc. All rights reserved.

    Other Model Functions

    August 1, 2010 24Copyright 2010 BEST Robotics, Inc. All rights reserved.

  • Bring as Many Functions asNeeded, and Connect

    August 1, 2010 25Copyright 2010 BEST Robotics, Inc. All rights reserved.

    Now, Set the Channels

    August 1, 2010 26Copyright 2010 BEST Robotics, Inc. All rights reserved.

  • After Building the Model

    August 1, 2010 27Copyright 2010 BEST Robotics, Inc. All rights reserved.

    Save the simulink model file You may want to Simulate the model before

    downloading into your Vex Controller.

    August 1, 2010 28Copyright 2010 BEST Robotics, Inc. All rights reserved.

  • Simulating the Arcade

    August 1, 2010 29Copyright 2010 BEST Robotics, Inc. All rights reserved.

    Simulation Control

    August 1, 2010 30Copyright 2010 BEST Robotics, Inc. All rights reserved.

  • After Simulation

    Remove all simulation signals Save your model file Compile the model to generate C-codes

    August 1, 2010 31Copyright 2010 BEST Robotics, Inc. All rights reserved.

    After compiling, MATLAB automatically opens EasyC loaded with the Simulink generated C-codes

    September 20th, 2013 Bison BEST 32

  • Compile and Download in your Robot

    Compile Project Build and Download

    September 20th, 2013 Bison BEST 33

    Additional support

    http://www.mathworks.com/hardware-support/vex.html

    September 20th, 2013 Bison BEST 34