You are previewing Getting Started with Simulink.
O'Reilly logo
Getting Started with Simulink

Book Description

Written by an experienced engineer, this book will help you utilize the great user-friendly features of Simulink to advance your modeling, testing, and interfacing skills. Packed with illustrations and step-by-step walkthroughs.

  • Dig deep into Simulink

  • No unnecessary theory - start modelling right away

  • Complex concepts made easy through examples

  • Packed with illustrations and detailed step-by-step walkthroughs

  • In Detail

    Simulink is an engineer's Swiss army knife: instead of spending the day typing out complex formulas, Simulink enables you to both draw and execute them. Block after block, you can develop your ideas without struggling with obscure programming languages and you don't have to wait to debug your algorithm - just launch a simulation!

    Getting Started with Simulink will give you comprehensive knowledge of Simulink's capabilities. From the humble constant block to the S-function block, you will have a clear understanding of what modelling really means, without feeling that something has been left out. By the time you close the book, you'll be able to further extend your modelling skills without any help.

    We''ll start with a brief introduction, and immediately start placing the first blocks. Little by little, you'll build a car cruise controller model, followed by the mathematical model of a sports car in order to calibrate it. Then you'll learn how to interface your Simulink model with the external world. This book will give you an easy understanding of the tools Simulink offers you, guiding you through a complex exercise split into the three main phases of Simulink development: modelling, testing, and interfacing.

    Table of Contents

    1. Getting Started with Simulink
      1. Table of Contents
      2. Getting Started with Simulink
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers and more
          1. Why Subscribe?
          2. Free Access for Packt account holders
          3. Instant Updates on New Packt Books
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Simulink Facts
        1. What is Simulink?
          1. Programming
          2. Graphical
        2. Problems solved by Simulink
          1. Software specification
          2. Software development
          3. Software testing
        3. Simulink drawbacks
        4. Where Simulink excels
        5. Summary
      9. 2. Creating a Model
        1. The MATLAB environment
          1. Command Window – how MATLAB talks to us
          2. The workspace – our treasury chest
          3. The working folder – where MATLAB saves our work
          4. The path – where MATLAB finds the tools
        2. The Simulink interface
        3. Our first model – a cruise controller
          1. Step 1 – create and save the model
          2. Step 2 – do comment the code!
          3. Step 3 – open Simulink Library Browser
          4. Step 4 – add blocks to the model from Library Browser
          5. Step 5 – rename the blocks
          6. Step 6 – implement the algorithm
          7. Step 7 – nest the logic into subsystems
          8. Step 8 – declare workspace variables
          9. Step 9 – do a first simulation
        4. Our second model – the Alfa Romeo 147 GTA
          1. Getting the speed – Newton's laws
          2. The aerodynamic drag equation
          3. The rolling resistance approximation
          4. The engine force – engine, wheels, and transmission
            1. Gearbox and differential
            2. Wheel to RPM
            3. Engine
            4. Torque to force
          5. The finishing touches
        5. Summary
      10. 3. Simulating a Model
        1. The mandatory theory
          1. The simulation times – when the math is done
          2. The solvers – these great unknown
            1. Variable-step versus fixed-step solvers
            2. Continuous versus discrete
            3. Stiff versus nonstiff
        2. Build the complete closed-loop system
        3. Configuring the simulation
          1. Simulation times
          2. Solvers
        4. Run our first serious simulation
          1. Calibrate the PI controller
            1. Calibrating Kp
            2. Calibrating Ki
        5. Test with other sources
          1. Sine Wave
          2. Ramp
          3. Signal Builder
        6. Summary
      11. 4. Using the Model
        1. The external software – a Qt5 application
        2. The Swiss army knife – S-functions
          1. The simulation phases
          2. Level 2 MATLAB S-function callbacks
            1. The mandatory callbacks
            2. The most useful optional callbacks
          3. The work vector – DWork
        3. MATLAB S-functions – file source and sink blocks
          1. The filesink_msfun block
            1. The MATLAB code
          2. The filesource_msfun block
            1. The MATLAB code
          3. A quick test
        4. Simulink and the real world
          1. Forcing Simulink to sync
          2. Preparing the cruise controller model
          3. Running the simulation on the target application
        5. Going further – C MEX S-functions
          1. Setting up the mex tool
            1. UNIX-like systems (GNU/Linux in particular)
            2. Microsoft Windows systems
          2. How C MEX S-functions work
          3. The required callbacks
            1. mdlInitializeSizes
            2. mdlInitializeSampleTimes
            3. mdlOutputs
            4. mdlTerminate
          4. The most useful optional callbacks
            1. mdlStart
            2. mdlInitializeConditions
            3. mdlUpdate
            4. The DWork vector
            5. The elementary work vectors
          5. The filesource S-function
            1. The beginning – headers and includes
            2. Block properties and memory usage – mdlInitializeSizes
            3. Timings – mdlInitializeSampleTimes
            4. Initial tasks – mdlStart
            5. Core logic – mdlOutputs
            6. Update memories – mdlUpdate
            7. Cleanup – mdlTerminate
            8. The happy ending
            9. Compiling the S-function
          6. Exercise – the filesink S-function
          7. A quick test
          8. Go for another ride
        6. Summary
      12. Index