Datasheet

Robot Control with Distance Detection • Chapter 8
Robotics with the BOE Shield-Bot 255
Our machine is the BOE Shield-Bot. The measured value we want it to maintain is the
distance to the leader-object, with a set point of 2 (for zone 2). The machine’s processor is
the Arduino. The IR LED/receiver pairs are the sensors that take distance value
measurements to the leader-object. If the measured distance is different from the set-point
distance, the servos are the mechanical actuators that rotate to move the BOE Shield-Bot
forward or backward as needed.
A Look Inside Proportional Control
Closed loop controlrepeatedly measuring a value and adjusting output in proportion to
error for maintaining a set pointworks very well for the BOE Shield-Bot shadow vehicle.
In fact, the majority of the control loop shown in the diagram below reduces to just one line
of code in a sketch. This block diagram describes the proportional control process that the
BOE Shield-Bot will use to control the wheel speed based on detection distance measured
with the IR LED/receiver pairs.
This block diagram could apply to either the left IR distance sensor and servo output or the
right. In fact, your code will maintain two identical control loops, one for each side of the
BOE Shield-Bot. Let’s walk through this example.
In the upper left, the set point = 2; we want the BOE Shield-Bot to maintain a zone-2 distance
between itself and its leader-object. Below that, the measured distance is zone 4, so the
leader-object is too far away. The arrows towards the symbols in the circle (called
a summing junction) indicate that you add (+) the set point and subtract (-) the measured
distance together to get the error, in this case 2 – 4 = -2.
Next, the error value feeds into the top squarean operator block. This block shows that the
error gets multiplied by -50, a proportionality constant (Kp). In this example, the operator
block gives us -2 × -50 = 100, so 100 is the output. In a sketch, this output value gets passed
to the
maneuver function. It turns the servo full speed forward to move the BOE Shield bot
closer to the leader-object.
The next block diagram shows another example. This time, the measured distance is 1,
meaning the leader-object is too close. So, the error is 1, and 1×50 = -50. Passing -50 to the
maneuver function turns the servo half-speed in reverse, backing the BOE Shield-Bot away
from the leader-object.