Getting Started Doing simulations

Why Simulate?

       Any time you design a circuit or control system (or if you are in other branches of engineering, think of motors, chemical processes, etc.) you will usually want detailed predictions of how the system will behave.  Think about these situations.

        You need to realize that it is really important to be able to predict how a system will respond to an arbitrary input.  Moreover, as you think about it you realilze that those predictions should be numerical.  If we want to land a plane automatically - or any other task identified above or many others - then we need to be able to predict where the plane will be at any given time as it lands.  We need to be able to predict altitude, position along and across the runway, changes in those positions,  rotation in three axes (roll, pitch and yaw) and rates of change of those rotation angles.

        That raises the question:

    How do you calculate numerical values for the response of systems like those above?
This question was first raised many years ago.  The first answer to the question was to build electronic circuits that could produce voltage waveforms that reproduced the position waveforms of the aircraft.  Those electronic units were known as analog computers.  A fairly substantial industry grew up to produce analog computers and to educate users in the use of analog computers.  As digital computers came on the scene, the first thing that happened was that people wrote programs for digital computers that required thinking like you were using an analog computer.  (Click here for a comment on that kind of thing.)  Later computational methods were built into numerous digital computer programs including Mathcad, Matlab, etc.

        If you examine those computer programs, you will realize that there is another question buried there.  That question is:

    How do you represent the system so that you can get numerical values for variables as a function of time?  There are many options for system representation including
You need to have a method of representation for the system, and you need a way to use that representation to produce numerical predictions of variables as functions of time.  Let us consider the representation methods listed above and how they can be used to obtain numerical solutions.

      Differential Equations can be solved using a variety of analytical techniques.  (See any differential equation book.)  Then you can take the expression that results in an analytical solution and plug in different values of time and plot what you get.  The problem with that is that it may be difficult to get an analytical solution since some systems are much harder than others to do.  On the other hand, there are no general methods for getting numerical solutions of differential equations that are second or higher order.  In practice, the only general numerical techniques available are for first order systems.

      Transfer Functions are frequency-based representations of systems.  For example, there are numerous techniques for computing the transfer function of a system from a frequency response measurement.  And, if you have a transfer function and you have an input function, then you can use a table of inverse Laplace transforms to get the time function that describes the output.  On the other hand, transfer functions can only be used to describe linear systems.  If there are any nonlinearities - like saturating amplifiers, resistors that get hot and change value, sensors that go out of range, or sensors that are inherently nonlinear like thermistors and thermocouples, whatever - then you can't use a transfer function to describe the system.  People try really hard to get around that by linearizing around operating points, for example, but you can't use those models to predict what happens when signals get large and the system experiences a range of signals that moves it through nonlinear operating areas.

      Impulse Responses are an interesting concept, and you can use a convolution integral to compute an output if you have an impulse response.  Generations of students have studiously tried to avoid doing convolution integrals, and besides that impulse response can only be used for linear systems.  Remember that the Laplace transform of the impulse response is the transfer function so these guys are intimately related.

      State Equations are the one last hope for doing computations.  Even though state equations are as assiduously avoided as impulse responses, they are sets of first order differential equations, and there are lots of numerical algorithms for solving first order differential equations.  So, welcome to the word of state equations!

        Most mathematical packages like Mathcad, Matlab and Mathematica all have functions that you can use to integrate a set of state equations.  That means that your problem is the following.

Learn how to write state equations for systems.
Learn how to use numerical integration techniques once you have the state equation description for a system.
        We'll discuss that in the next lesson.