Getting Started with Simulink
By Luca Zamboni
4.5/5
()
About this ebook
Related to Getting Started with Simulink
Related ebooks
MATLAB and Simulink In-Depth: Model-based Design with Simulink and Stateflow, User Interface, Scripting, Simulation, Visualization and Debugging (English Edition) Rating: 0 out of 5 stars0 ratingsProgramming with MATLAB: Taken From the Book "MATLAB for Beginners: A Gentle Approach" Rating: 5 out of 5 stars5/5MATLAB® by Example: Programming Basics Rating: 4 out of 5 stars4/5Graphs with MATLAB (Taken from "MATLAB for Beginners: A Gentle Approach") Rating: 4 out of 5 stars4/5MATLAB for Beginners: A Gentle Approach - Revised Edition Rating: 3 out of 5 stars3/5Simulink Third Edition Rating: 0 out of 5 stars0 ratingsApplied Control Theory for Embedded Systems Rating: 4 out of 5 stars4/5Computer-Controlled Systems: Theory and Design, Third Edition Rating: 3 out of 5 stars3/5Applied Numerical Methods Using MATLAB Rating: 0 out of 5 stars0 ratingsMatlab: A Practical Introduction to Programming and Problem Solving Rating: 4 out of 5 stars4/5A Brief Introduction to MATLAB: Taken From the Book "MATLAB for Beginners: A Gentle Approach" Rating: 3 out of 5 stars3/5Feedback Control Theory Rating: 5 out of 5 stars5/5Power Electronics Applied to Industrial Systems and Transports, Volume 2: Power Converters and their Control Rating: 5 out of 5 stars5/5Simulation of Power Electronics Converters Using PLECS® Rating: 0 out of 5 stars0 ratingsDSP for Embedded and Real-Time Systems Rating: 5 out of 5 stars5/5Data Acquisition Using LabVIEW Rating: 0 out of 5 stars0 ratingsDigital Filters and Signal Processing in Electronic Engineering: Theory, Applications, Architecture, Code Rating: 0 out of 5 stars0 ratingsEngineering Digital Design: Revised Second Edition Rating: 0 out of 5 stars0 ratingsDigital Modulations using Matlab Rating: 4 out of 5 stars4/5MATLAB Programming for Biomedical Engineers and Scientists Rating: 4 out of 5 stars4/5Visual Media Processing Using MATLAB Beginner's Guide Rating: 0 out of 5 stars0 ratingsPower Electronics Handbook Rating: 4 out of 5 stars4/5Simulation of Digital Communication Systems Using Matlab Rating: 4 out of 5 stars4/5Power Electronics Design Handbook: Low-Power Components and Applications Rating: 4 out of 5 stars4/5Control System Design Guide: Using Your Computer to Understand and Diagnose Feedback Controllers Rating: 4 out of 5 stars4/5Beginning MATLAB and Simulink: From Novice to Professional Rating: 0 out of 5 stars0 ratingsRF Circuit Design Rating: 3 out of 5 stars3/5The Dynamics of Automatic Control Systems Rating: 5 out of 5 stars5/5Digital Signal Processing Demystified Rating: 5 out of 5 stars5/5Practical Design and Application of Model Predictive Control: MPC for MATLAB® and Simulink® Users Rating: 3 out of 5 stars3/5
Computers For You
Mastering ChatGPT: 21 Prompts Templates for Effortless Writing Rating: 5 out of 5 stars5/5Procreate for Beginners: Introduction to Procreate for Drawing and Illustrating on the iPad Rating: 0 out of 5 stars0 ratingsElon Musk Rating: 4 out of 5 stars4/5The Mega Box: The Ultimate Guide to the Best Free Resources on the Internet Rating: 4 out of 5 stars4/5ChatGPT Ultimate User Guide - How to Make Money Online Faster and More Precise Using AI Technology Rating: 0 out of 5 stars0 ratingsThe ChatGPT Millionaire Handbook: Make Money Online With the Power of AI Technology Rating: 0 out of 5 stars0 ratingsThe Best Hacking Tricks for Beginners Rating: 4 out of 5 stars4/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Deep Search: How to Explore the Internet More Effectively Rating: 5 out of 5 stars5/5How to Create Cpn Numbers the Right way: A Step by Step Guide to Creating cpn Numbers Legally Rating: 4 out of 5 stars4/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Everybody Lies: Big Data, New Data, and What the Internet Can Tell Us About Who We Really Are Rating: 4 out of 5 stars4/5Practical Lock Picking: A Physical Penetration Tester's Training Guide Rating: 5 out of 5 stars5/5People Skills for Analytical Thinkers Rating: 5 out of 5 stars5/5Slenderman: Online Obsession, Mental Illness, and the Violent Crime of Two Midwestern Girls Rating: 4 out of 5 stars4/5CompTIA Security+ Practice Questions Rating: 2 out of 5 stars2/5The Designer's Web Handbook: What You Need to Know to Create for the Web Rating: 0 out of 5 stars0 ratingsLearning the Chess Openings Rating: 5 out of 5 stars5/5The Professional Voiceover Handbook: Voiceover training, #1 Rating: 5 out of 5 stars5/5Web Designer's Idea Book, Volume 4: Inspiration from the Best Web Design Trends, Themes and Styles Rating: 4 out of 5 stars4/5CompTIA IT Fundamentals (ITF+) Study Guide: Exam FC0-U61 Rating: 0 out of 5 stars0 ratingsRemote/WebCam Notarization : Basic Understanding Rating: 3 out of 5 stars3/5Ultimate Guide to Mastering Command Blocks!: Minecraft Keys to Unlocking Secret Commands Rating: 5 out of 5 stars5/5101 Awesome Builds: Minecraft® Secrets from the World's Greatest Crafters Rating: 4 out of 5 stars4/5
Reviews for Getting Started with Simulink
4 ratings0 reviews
Book preview
Getting Started with Simulink - Luca Zamboni
Table of Contents
Getting Started with Simulink
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Instant Updates on New Packt Books
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Simulink Facts
What is Simulink?
Programming
Graphical
Problems solved by Simulink
Software specification
Software development
Software testing
Simulink drawbacks
Where Simulink excels
Summary
2. Creating a Model
The MATLAB environment
Command Window – how MATLAB talks to us
The workspace – our treasury chest
The working folder – where MATLAB saves our work
The path – where MATLAB finds the tools
The Simulink interface
Our first model – a cruise controller
Step 1 – create and save the model
Step 2 – do comment the code!
Step 3 – open Simulink Library Browser
Step 4 – add blocks to the model from Library Browser
Step 5 – rename the blocks
Step 6 – implement the algorithm
Step 7 – nest the logic into subsystems
Step 8 – declare workspace variables
Step 9 – do a first simulation
Our second model – the Alfa Romeo 147 GTA
Getting the speed – Newton's laws
The aerodynamic drag equation
The rolling resistance approximation
The engine force – engine, wheels, and transmission
Gearbox and differential
Wheel to RPM
Engine
Torque to force
The finishing touches
Summary
3. Simulating a Model
The mandatory theory
The simulation times – when the math is done
The solvers – these great unknown
Variable-step versus fixed-step solvers
Continuous versus discrete
Stiff versus nonstiff
Build the complete closed-loop system
Configuring the simulation
Simulation times
Solvers
Run our first serious simulation
Calibrate the PI controller
Calibrating Kp
Calibrating Ki
Test with other sources
Sine Wave
Ramp
Signal Builder
Summary
4. Using the Model
The external software – a Qt5 application
The Swiss army knife – S-functions
The simulation phases
Level 2 MATLAB S-function callbacks
The mandatory callbacks
The most useful optional callbacks
The work vector – DWork
MATLAB S-functions – file source and sink blocks
The filesink_msfun block
The MATLAB code
The filesource_msfun block
The MATLAB code
A quick test
Simulink and the real world
Forcing Simulink to sync
Preparing the cruise controller model
Running the simulation on the target application
Going further – C MEX S-functions
Setting up the mex tool
UNIX-like systems (GNU/Linux in particular)
Microsoft Windows systems
How C MEX S-functions work
The required callbacks
mdlInitializeSizes
mdlInitializeSampleTimes
mdlOutputs
mdlTerminate
The most useful optional callbacks
mdlStart
mdlInitializeConditions
mdlUpdate
The DWork vector
The elementary work vectors
The filesource S-function
The beginning – headers and includes
Block properties and memory usage – mdlInitializeSizes
Timings – mdlInitializeSampleTimes
Initial tasks – mdlStart
Core logic – mdlOutputs
Update memories – mdlUpdate
Cleanup – mdlTerminate
The happy ending
Compiling the S-function
Exercise – the filesink S-function
A quick test
Go for another ride
Summary
Index
Getting Started with Simulink
Getting Started with Simulink
Copyright © 2013 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: October 2013
Production Reference: 1181013
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78217-138-6
www.packtpub.com
Cover Image by Irene Sánchez Guillén (<irene.s.guillen@gmail.com>)
Credits
Author
Luca Zamboni
Reviewers
Robin T. Bye
Marco Caputano
Mohamed H. Zaher
Acquisition Editors
Edward Gordon
Kevin Colaco
Commissioning Editor
Poonam Jain
Technical Editors
Pramod Kumavat
Krutika Parab
Nadeem N. Bagban
Copy Editors
Dipti Kapadia
Gladson Monteiro
Sayanee Mukherjee
Kirti Pai
Project Coordinator
Sherin Padayatty
Proofreader
Sandra Hopper
Indexer
Monica Ajmera Mehta
Graphics
Yuvraj Mannari
Production Coordinator
Pooja Chiplunkar
Cover Work
Pooja Chiplunkar
About the Author
Luca Zamboni, born in Ivrea, Italy, obtained his Bachelor's and Master's degrees in Electronics Engineering from the Polytechnic of Turin. He worked as a network systems administrator for some years before becoming a consultant for the automotive industry. Now he works in FIAT's research center.
About the Reviewers
Robin T. Bye, got his Bachelor's, Master's, and PhD degrees, all in Electrical Engineering, from the University of New South Wales, Sydney, Australia. He has been working at the Aalesund University College (AAUC) in Norway since 2008 and is now an associate professor in automation engineering. Apart from teaching automation and computer engineering classes for cybernetics, microcontrollers, and intelligent systems, he also supervises PhD and bachelor students on their theses' topics. His main research interests belong to areas such as computational modeling and simulation of human movements, bio-inspired robotics and automation, and dynamic resource allocation.
Marco Caputano was born in Southern Italy in 1980. He has obtained an M.Sc. in Control Engineering from the University of Napoli Federico II in Italy. His final dissertation was on nuclear plasma modeling in the framework of nuclear fusion research. He broadened his academic education with a Masters in Mechatronic Systems Design obtained from the Engineering Polytechnic of Milano, Italy. His former work activities include modeling and numerical simulations for nuclear fusion research (CREATE consortium, Napoli, Italy), and in the field of aeronautical engineering (SAFRAN group, Paris, France). Currently, he works as a Mechatronics Engineer for ASML in the Netherlands.
Mohamed H. Zaher is from Egypt; he is a Mechatronics and Controls Engineer. He received both his Bachelor's and Master's degrees in Mechanical Engineering with System Dynamics and Mechatronics Focus from Cairo University in Egypt and his Ph.D from University of Illinois at Chicago. Mohamed taught mechanical engineering curriculum at both universities including the use of software tools such as MATLAB and Simulink. He also worked on contract at Caterpillar, Case New Holland, and Servo Tech Inc., where he worked with several professional tools on several developmental projects.
www.PacktPub.com
Support files, eBooks, discount offers and more
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read, and search across Packt's entire library of books.
Why Subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via web browser
Free Access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
Instant Updates on New Packt Books
Get notified! Find out when new books are published by following @PacktEnterprise on Twitter, or the Packt Enterprise Facebook page.
Preface
This book will give you a complete understanding of the Simulink software. You will learn by example, going through the three main phases of Simulink development—modeling, simulating, and interfacing with the external world while developing a cruise controller for a real car.
While reading this book, you'll be given a clear, no-frills explanation of the main components of Simulink and how to use them in order to achieve the desired result. After having read this book, you will be able to develop, test, and deploy your models without any difficulty.