Time vs Theta
Implementing Two Motors
10 11 12
Motors with propellers have a
lot of inertia. If a motor is spinning in
one direction and it's suddenly
commanded to turn in the opposite
direction, it will take a lot of time to
stop and start spinning in reverse.
The implementation with one motor
relies on gravity to push the pendulum
in the opposite direction when
needed. By adding a second motor,
we avoid the inertia problem and we
avoid relying on gravity to stabilize
■ FIGURE 8. Kp=0.028, Ki=0.7,
Kd=0, Tetharef =0.08 radians
Theta Theta ref
Controlling The Robot
Using Two Motors
well. You should also have in mind how the proportional,
integral, and derivative controllers affect the behavior of the
system. From a theoretical point of view, one can never
achieve a given set point with just a proportional controller.
Even if it were possible, just a proportional controller by
itself would not suffice.
Any system will wear out with time, requiring the controller to apply different control efforts, depending on those
changes. In order to avoid this problem, one must use an
integral controller. Integral controllers scale the integrated
(accumulated) error in time. This means that even if the
error is zero, the control effort will not necessarily be zero.
This behavior could be thought of as the system building up
memory as time passes by. It has a drawback, though. If
friction is huge or the system gets stuck for any reason, the
control effort will keep building up until it saturates. This
could possibly damage the controller or the actuators.
The last control element is the derivative which slows
down the response of the system. This controller scales the
rate of change of the error, decreasing the control effort if
the system reacts too fast. This is useful to avoid overshoot.
However, it may slow the system's response too much.
■ FIGURE 9. System stability.
In this case, we used the same PID we designed
previously. The only difference is that the control effort is
split to activate each motor individually. The second motor
takes a negative control effort such that if one motor needs
to speed up to push the pendulum in one direction, the
other slows down. Figure 10 shows the block diagram for
the new setup.
Software Architecture For Two Motors
The architecture for two motors is pretty much the
same as the one for a single motor. The main difference is
the addition of a calibration routine. We did this to avoid
determining the bias for each motor individually. The bias is
approximately 50% of the maximum control effort each
motor can take. This allows the controller to speed up or
slow down the motors within their operation region while
keeping the system in equilibrium. Figure 11 shows the
new flow diagram.
Controller's Code For Two Motors
The only addition to the previous code is the calibration
function acCalibMotorBias(). The goal of the function is to
■ FIGURE 10. Block
diagram (two motors).
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.1 0.1 0.1 0.1 0.1
56 SERVO 02.2009