Introduction to Simulation for Mechatronics

 

1  Introduction

1.1  What sort of simulation?

Since this is part of an engineering course, the accent will be on control systems and their performance.  But simulations can come in many forms, such as economic predictions, building design or the spread of a virus.

In some, it is the time behaviour that is most important, in others animation can just be added to give visual effect.

There is a vast range of animation and simulation design software, too.  One mind-bending package is Bender, a 3D design package that includes animation, almost to Pixar standards.  But much simpler is JavaScript, very much like C to code, but which is at the heart of every web browser.

You have already met a number of JavaScript simulations, now is the time for you to learn how to construct them yourself.  But to whet your appetite, you might like to run billball\index.htm, written some years ago.

1.2  State variables

By now you should be well aware of the relevance of state equations.  Transfer functions are all very well for analysing feedback, but it is state variables that define what to draw in order to show the system in action.

The billball simulation is a simple ‘move the pictures’ example, but it abounds with state variables.  Each ball has four, two of position and two of velocity.  But it has another variable which is just ‘true’ or ‘false’ for whether the ball is moving.

As you will see if you right-click on the page and ‘view page source’, you can include impacts, friction and whatever else affects the state variables as time proceeds.

Do not waste too much time playing the game!