Book Image

Getting Started with Simulink

By : Luca Zamboni
Book Image

Getting Started with Simulink

By: Luca Zamboni

Overview of this book

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 (11 chapters)

Run our first serious simulation


Let's place a Step block in the model, connect it to the Target Goto (whose corresponding From block is connected to the Target speed controller input), and set its Final value to 100 km/h.

Run the simulation and open the Scope block. The speed graph should be like this one:

Quite an overshoot! The vehicle speed reaches almost 150 km/h when the controller closes the throttle. This is due to a too high integral gain, Ki, forcing the vehicle to go a lot faster than intended. Who wants a ride?

Calibrate the PI controller

To calibrate the PI controller constants, Kp and Ki, we'll use this manual method of keeping Ki to zero and finding the Kp value to where the Throttle signal begins to oscillate.

Then we'll halve the found value and save it into Kp and tune Ki in order to reach the target speed with a minimum overshoot.

Calibrating Kp

Prepare the model by setting Ki to zero with this MATLAB command: Ki = 0.

We'll start with an insanely high proportional gain value,...