[ODE] Servo to reach a target position

Royce Mitchell III Royce Mitchell III <royce3 at ev1.net>
Thu Apr 10 19:19:02 2003


Hello David,

You're welcome!

However, I think I owe you an apology. You've gotten me to really
think about exactly how PID works, and I think I was wrong in
dismissing your use of dT. In the argument I presented, I only dealt
with the P term.

I think, to be perfectly technically correct, you need to incorporate
dT for I and D ( multiplying for I and dividing for D ). I will caveat
all this with the fact that a well-tuned process running at a decent
update rate will have no need for dT, we're only talking about being
perfectly "correct". However, when talking about game development,
there is a wider range of update times the code will see, as opposed
to industrial equipment where the update rate is solid. So, if you
happen to want to model a system that is very sensitive, you could run
into an issue where it works fine on one computer, but not on the
next.

To present an example:

We have to CPUs, running at different speeds. CPU A's dT is .01 and
CPU B's dT is .02.

without dT, CPU A's I term will react faster, causing a need for less
Ki, which is not what we want. Multiplying E by dT would cause A's I
to accumulate at the same rate in real-time.

Dividing by dT for D is a little more tricky, tho. The only thing I
can think of is this: a system that updates more often can afford to
throw out more D to compensate for change in E because it will be back
sooner to take it out as E stabilizes. On the flip side, a slower
system can't afford to have D too high, because if it reacts hard, it
won't be back as soon to fix the problem, leading to instability.
However, I'm not quite convinced of this argument. The only reason I'm
leaning more towards it than against it is b/c it doesn't make sense
to apply dT to I but not D.

If it's any consolation, PID looks simple on the surface, but I've
seen it as a source of heated debates. People can't even agree on the
math to use. One of the links you can find doing a search on PID will
explain that there are at least 3 different *common* ways to code PID.
It's further complicated because the way hardware PID algos work
doesn't match mathematical PID algos, at least as far as the I term
goes.

Any thoughts?

--
Royce3