Essentials of Mechatronics ISBN: 0-471-72341-X- ©John Billingsley 2006 - published John Wiley & Sons, Inc
State space concepts grew from the principles of simulation.
Understand one and the other becomes clear. It is essential that
you should work through these examples and make sure that their
principles are clear to you.
Instead of 'black boxes' containing transfer functions, we consider
the set of variables that define what the system is doing 'right now'.
For our first example we look at a water tank that has a leak at the
bottom. The one and only state variable is the level of water in
the tank, which we will call x.
The rate at which the water leaks is proportional to the water level in
the tank. So how do we make a mathematical model?
State equations tell us the rate-of-change of the state
variable(s). So for the tank, the rate of change dx/dt
of the level will be proportional to -x.
We can write
where the 'dot' denotes 'rate of change'.
If we now add an 'input' to the system, a faucet that pours water
into
the tank at a rate that will raise the level (ignoring the leak) at a
rate u,
we have
By 'rate of change' we mean the change in x
over a very short interval, divided by the length of that
interval. So to a first approximation we can say that after an
interval dt
the new value of x
will be
so in this case, the new value is
In computer terms, we just execute the line of code
x = x + (- k x + u) * dt
and the simulation is advanced by time dt.t = t + dt
to keep track of the time, so that we can plot x against time.Routines for rescaling the plot window and changing colour have been
added 'behind the scenes', so that the
text in the
edit box will look as simple as possible. As well as seeing the
entire works with 'view page', you can save a
local copy
and set to work with any text editor (Notepad is useful) to hack
it into
your personal preference.
Do remember that these simulations use
Javascript and a Java applet - so you must permit scripts to run and
you must permit Java applets to make them work.
The later .htm files give a more complete simulation, some with two text windows instead of one. Be sure to inspect the code - you should try out a few modifications.
If you browse a page and edit the
code in one of the
text windows
and then save the page, you
will NOT have saved your changes!
You have to select and copy your code and paste it into a text editor, then save that as a named file.
To make permanent changes, you have to open the page in a text editor such as Notepad and edit the source text. Do NOT use a Web editor - it will mangle up the code!
To exit from a program page, use the Browser 'Back' button.