Professional Documents
Culture Documents
Livro - Mastering Simulink PDF
Livro - Mastering Simulink PDF
James B. Dabney
and
Thomas L. Harman
University of Houston—Clear Lake
PEARSON
1'1111We
I Iall
Preface xvii
Using the Book xvii
New Users xvü
Experienced Users xviii
Advanced Users xviii
Acknowledgments xix
1 Introduction 1
1.1 What Is Simulink? 1
1.2 Simulink Examples 2
1.2.1 Steel Rolling Plant Modeling 2
1.2.2 Automotive Engine Modeling 3
1.3 Simulink Employment Strategies 4
1.3.1 Rapid Prototyping 4
1.3.2 Rapid Application Development 5
1.4 Selection Considerations 5
1.5 Outline of Text 6
References 6
2 Block Diagrams 7
2.1 Introduction 7
2.2 Continuous Systems 8
2.2.1 Gain Blocks 8
2.2.2 Sum Block 9
2.2.3 Derivative Block 9
2.2.4 Integrator 10
2.2.5 Simple Physical Models 11
2.2.6 Transfer Function Block 11
2.3 State-Space Block 13
2.3.1 The State-Space Concept ................. 13
2.3.2 Linear Single-Input, Single-Output Systems 15
2.3.3 Multiple Input, Multiple Output Systems 18
2.4 Discrete Systems 20
2.4.1 Discrete Gain Block 22
2.4.2 Discrete Sum Block 22
x Contents
2.4.3 Unit Delay 22
2.4.4 Discrete-Time Integrator Block 23
2.4.5 Simple Discrete System Models 24
2.4.6 Discrete Transfer Function Block 25
2.5 Discrete State-Space Block 26
2.6 Nonlinear Blocks 28
2.7 Hybrid Block Diagrams 28
2.8 Summary 30
References 30
3 Quick Start 32
3.1 Introduction 32
3.1.1 Typographical Conventions 32
3.2 Building a Simple Model 33
3.3 A More Complicated Model 38
3.4 The Simulink Help System 46
3.4.1 Opening the User's Guide Browser 46
3.4.2 User's Guide Browser Window . . . . . 47
3.5 Summary 48
References 48
4 Model Building 49
4.1 Introduction 49
4.1.1 Elements of a Model 49
4.2 Opening a Model 50
4.3 Model Window 50
4.3.1 Zooming 52
4.3.2 Block Data Tips 52
4.3.3 Simulink Block Library 52
4.4 Manipulating Blocks 53
4.4.1 Resizing a Block 53
4.4.2 Rotating a Block 54
4.4.3 Copying a Block within a Model 54
4.4.4 Deleting Blocks 55
4.4.5 Selecting Multiple Blocks 55
4.4.6 Changing a Block Label 56
4.4.7 Changing Label Location 57
4.4.8 Hiding a Label 57
.4.4.9 Adding a Drop Shadow 57
4.4.10 Using Color 58
4.4.11 Configuring Blocks 58
4.5 Signal Lines 58
4.5.1 Moving a Segment 59
4.5.2 Moving a Vertex 61
4.5.3 Deleting a Signal Line 61
4.5.4 Splitting a Signal Line 62
4.5.5 Labeling a Signal Line 62
Contents xi
5 Continuous Systems 90
5.1 Introduction 90
5.2 Scalar Linear Systems 90
5.2.1 Integrator Block 90
5.2.2 Transfer Function Blocks 94
5.3 Vector Linear Systems 96
5.3.1 Vector Signal Lines 96
5.3.2 State-Space Block 98
5.4 Modeling Nonlinear Systems 98
5.4.1 Function Blocks 102
5.5 Summary 105
References 106
10 S-Functions 219
10.1 Introduction 219
10.2 S-Function Block 219
10.3 S-Function Overview 220
10.4 M-file S-Functions 221
10.4.1 Initialization (f lag = 0) 222
10.4.2 Continuous State Derivatives (f lag = 1) 224
10.4.3 Discrete State Updates (f lag = 2) 224
10.4.4 Block Outputs (f lag = 3) 225
10.4.5 Next Sample Time (f lag = 4) . . .... 226
10.4.6 Terminate (f lag = 9) 226
10.4.7 Programming Considerations 226
10.4.8 M-file S-Function Examples 227
10.5 C Language S-Functions 235
10.5.1 C File Header 239
10.5.2 Initializing the Simulation Structure 240
10.5.3 Defining Sample Times and Offsets 242
10.5.4 Accessing Model Variables . . . . . . . ...... . . 243
10.5.5 Setting Initial Conditions 244
10.5.6 Setting the Output Vector 244
10.5.7 Updating the Discrete States 245
10.5.8 Computing the State Derivatives 245
10.5.9 End-of-Simulation Tasks 246
10.5.10 C S-Function File Trailer 246
xiv Contents
10.5.11 Programming Considerations 246
10.5.12 Compiling a C S-Function 250
10.5.13 C S-Function Examples 250
10.6 Summary 258
References 258
12 Debugging 273
12.1 Introduction 273
12.2 Finding Model-Building Errors 273
12.3 Finding Implementation Problems 275
12.3.1 Simulink Execution Errors 275
12.3.2 Slow Execution 275
12.3.3 Incorrect Results 277
12.4 Simulink Debugger 277
12.4.1 Running the Debugger 278
12.4.2 Block Index 279
12.4.3 Single-Step Execution 280
12.4.4 Breakpoints 281
12.4.5 Inspecting Block Data 283
12.4.6 Algebraic Loop Commands 283
12.4.7 Debugger Status Commands 284
12.4.8 Ending Debugging 284
12.4.9 Debugger Command Summary 284
12.5 Summary 286