Essentials of Mechatronics ISBN: 0-471-72341-X-
©John Billingsley 2006 - published
John
Wiley & Sons, Inc
Simulation of position control
1. Open-loop second order system
This simple 'action input' example shows the difficulty of
controlling a second order system without feedback.
When you click on the buttons or tap the number keys, you change the
acceleration of the motor directly. Bringing the position error
to zero and keeping it there is no easy problem.
You will see that the .htm version now shows code in two
windows. The upper one is the 'initialise' window in which the
screen is drawn and initial values are set. The lower window is
run repeatedly to step the
model through the simulation.
Run 01motor.bas or 01motor.htm
2. Adding feedback
The action input in this second example is now used to set a demand for
the position target.
You can input the feedback and damping in the .bas version, or change
them by editing the "f=" and "d=" values in the upper box in the .htm
browser. The suggested and default values are sufficiently bad to
be 'interesting'. You should be able to find much better
values. Try the values 200 for the feedback and 25 for the
damping in this and the following examples.
Run 02feedback.bas or 02feedback.htm.
3. Real motors have limits
A 'real' position control system has a motor that has a limit on the
drive.
The acceleration limit has been set to 4 - but you can edit the code to
change it. The plot becomes red when the drive hits the
limit. In the previous example, the response shewed a dramaic
improvement when you tried values of 200 and 25 - but what happens this
time?
Run 03limit.bas or 03limit.htm.
4. Introducing the phase plane
When we are faced with nonlinearities such as limits, we can get more
insight if we plot velocity against position rather than position
against time. But if we plot actual position the plot can get
rather muddled. (There are no limits this time.)
Run 04phase.bas, 04phase.htm
or 04phase.frm - there is a VB version this
time.
5. The error phase plane
If instead we plot velocity against the position error, we see the plots
heading for the origin every time the target is disturbed. These
plots are termed 'trajectories'. Try various values of feedback
and damping to see that while under-damped values send the trajectories
in spirals around the origin, other values of damping can send them
heading straight in.
Run 05plane.bas, 05plane.htm
or 05plane.frm.
6. Phase plane with drive limits
Now let us put the drive limits back in and see the effect in the phase
plane. You will see that there is a region in the shape of a
diagonal 'band' in which the drive is not limited.
But you will also see that with feedback and damping of 200 and 25 the
trajectories rattle around the origin, rather than heading straight
in. We need a much higher value of damping.
Run 06planelim.bas or 06planelim.htm.
7. Disturbing forces
In a real situation, it is not just the way a position controller
responds to commands that matters. Of great importance is the
system's ability to resist disturbances. A manufacturing robot
mst be able to hold the workpiece steady against machining forces,
deflecting no more than a small fraction of a millimeter.
If very big values of gain are used, the drive will be almost
always saturated. Try values 400 and 200 for f and d in the
simulation you have just tried.
You will see that there
is a line crossing the origin, to which the trajectory
"sticks". Anywhere else the drive saturates.
This is termed a "sliding regime". It is important in
"variable structure control".
Note that feedback values 400, 100 give a steeper and faster
sliding zone, but overshoots can happen.
Now we have some code that tests the responses from a fixed range of
initial conditions. By tapping keys or clicking on buttons between
runs, you can apply a range of disturbing forces and see how
'stiff' the feedback parameters make the system.
Run 07offset.bas or 07offset.htm.
8.Time domain
You can see the same results plotted as position against time by running
08Toffset.bas 0r 08Toffset.htm
9. Natural dampng
Suppose that the damping is not achieved through feedback, but
is built into the motor. Suppose also that just position feedback
is applied to u, but that u is limited to between +/-4 as before.
What will the phase-plane look like?
Try values of f=6, d=5 for feedback and damping.
The buttons again allow you to inject an offset force. You
can see that
with these gain values, the control is very 'soft' and forces can
lead to
large errors.
Can you improve matters by increasing f ? What is the effect
of making f=100?
Try changing the scale to see more detail (in the ScaleWindow line in
the htm version).
Run 09damp.bas or 09damp.htm.
10. Nonlinear feedback
If we add position and velocity in bang-bang control so that there
is 'just' no overshoot for an initial position error of 1, then the
response from an error of 2 will have an overshoot.
There is a compromise to make of overshoot versus speed of response.
However if we limit the postion term in the sum, we can arange that
there is no overshoot for any
size of initial error.
See this in action in 10nonlin.htm
We can go further. We take a nonlinear function of the
position error that will give near optimal control. The function
involves a square root. See it in action by running either of
10curve.bas, 10curve.htm
or 10curve.frm
11 Two graphic demonstrations
This simulation of a saturating position
controller might be easier to
visualise.
Here is a simulation of a
mass-spring problem where the only damping is friction.