Newsgroups: comp.robotics
Path: brunix!uunet!munnari.oz.au!manuel!gorton.anu.edu.au!jaa101
From: jaa101@gorton.anu.edu.au (James Ashton)
Subject: Re: Motor Control Problem
Message-ID: <1992Feb19.014248.20776@newshost.anu.edu.au>
Sender: news@newshost.anu.edu.au
Organization: The Australian National University, Canberra
References:  <1992Feb17.222714.842@gnv.ifas.ufl.edu>
Date: Wed, 19 Feb 92 01:42:48 GMT

In article <1992Feb17.222714.842@gnv.ifas.ufl.edu>, fme@gnv.ifas.ufl.edu writes:
> This group seems to center most closely on a device control problem I have,
> so here goes ...
> 
...
>
> Now, the problem. When motor-1 settles at some steady speed for whatever
> period of time, motor-2 tries to speed-up or slow-down to match it. Alas,
> there is oscillation in the speed of motor-2 ... it tends to over/undershoot
> the proper speed and then tries to compensate for the overcompensation. 
> As a result, the damned thing never settles nicely. The RPM is correct if 
> you average it out over say 15 seconds ... but that accuracy falls-off 
> sharply when you average over a shorter period. My cheap attempts at making
> a software 'damper' just hurts sensitivity at the very low speed ranges.

You're looking for the PID algorithm - Proportional Interal
Derivative.  Keep a track of the desired versus real position (position
error = p), integral of position error (= i) and desired versus real
velocity (velocity error = d).  These are three error terms each of
which is the derivate with respect to time of its precessor.

You obviously need to know desired position and velocity but in your
case these are easily determined from the other motor.  The power
output to the motor under is equal to the sum of p, i, and d each
multiplied by some constant (kp, ki and kd respectively).  Obviously
the sign of the constants is important.

Start with ki = kd = 0 and ramp up kp until you get oscillation (just
like you're currently seeing).  Then ramp up kd to damp the
oscillations.  Pushing kd too high will also result in oscillations.
You can keep increasing and juggling these values to achieve the
desired results.  There's all manner of theory on critical damping but
I think in this case experimentation is the fastest way to a
satisfactory result.  You can think of the system like damped spring.
kp is the strength of the spring and should be set as high as possible
without oscillations.  kd is the amount of damping and should be set as
high as needed to stop oscillations due to kp.  ki may be left at 0 in
dynamic situations like yours.  It's main role is to bring the rotor to
the desired position when some force is acting to prevent it.  Play
with this if you think you need it but it's difficult to advise on this
one.

Try to keep the control loop as fast as possible.  The faster you can
recalculate, the higher you can set kp without oscillation setting in.
This may be a problem for you.
