[DPRG] PID Loop Question  Defining the Error Term
Subject: [DPRG] PID Loop Question  Defining the Error Term
From: Dick Swan
dickswan at sbcglobal.net
Date: Wed Feb 24 02:45:02 CST 2010
So far I haven't seen any discussion on how exactly to define the PID error
term which can have significant impact on the performance. Consider the case
of speed regulation for a motor.
1. I've seen one definition for error that uses the difference between
the cumulative target encoder position vs the actual position as the error
term. The target encoder position is simply cumulative time multiple by
target velocity. Note that the derivative of this error is the current
velocity.
2. A different definition that I've seen uses the difference of the of
the current instantaneous velocity vs the target velocity. So this error
term is the same as the derivative error from the first definition.
It's my experience that both definitions seem to work pretty well.
Depending on the problem, speed regulation of a motor might not even be the
right error to measure. For example,
1. One of the DPRG contests is driving around a square and returning
to a stop as close as possible to the original position. In this case the
error term doesn't involve speed but rather distance from the desired stop
point.
2. There are cases where you want to drive on a straight line with a
robot using one motor for each of the left and right wheels. Simply
independently driving each motor with a PDI loop will not cause robot to go
in straight line. You want a different error term that includes the speed
differential between the two motors.
Another item that I haven't seen discussed is the choice of the update
interval for the PID calculation. An initial assumption might be faster is
better  say use a 25 millisecond interval rather than 100 milliseconds. Now
consider the real world example of the LEGO NXT motors:
. Full speed during PID calculation is set at 1000 encoder counts
per second. The encoder has 360 counts per motor revolution. Using 1:1 gear
ratio and medium sized wheels gives a full speed of just over two feet per
second  quite a reasonable speed.
. Suppose you wanted to run a motor at 80% of full speed  800
counts per second.
. Suppose you wanted to use a PID update interval of 25
milliseconds. Or 20 encoder counts per update interval.
. It's my experience that PID keeps speed very close to target. For
this case most of the actual encoder counts in a typicaly interval are 19,
20 or 21. Resulting in a derivative value of 1, 0 or +1. Which does not
give very many discrete steps.
. Using the same numbers but with an update interval of 100
milliseconds, then the derivative values would have a larger range of 4 to
+4 giving 8 different ranges.
 next part 
An HTML attachment was scrubbed...
URL: http://list.dprg.org/pipermail/dprglist/attachments/20100224/7b9dde86/attachment.html
More information about the DPRG mailing list
