

Regardless of the measured distance, this control loop will calculate a value that will cause the servo to move to correct any error. The next time through the loop, the measured distance might change, but that’s okay.

Passing -50 to the maneuver function turns the servo half-speed in reverse, backing the BOE Shield-Bot away from the leader-object. This time, the measured distance is 1, meaning the leader-object is too close. The next block diagram shows another example.
#Cyber shadow chapter 8 full
It turns the servo full speed forward to move the BOE Shield bot closer to the leader-object. In a sketch, this output value gets passed to the maneuver function. In this example, the operator block gives us -2 × -50 = 100, so 100 is the output. This block shows that the error gets multiplied by -50, a proportionality constant (Kp). Next, the error value feeds into the top square-an operator block. 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. Below that, the measured distance is zone 4, so the leader-object is too far away. 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. In fact, your code will maintain two identical control loops, one for each side of the BOE Shield-Bot. This block diagram could apply to either the left IR distance sensor and servo output or the right. 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. In fact, the majority of the control loop shown in the diagram below reduces to just one line of code in a sketch. Closed loop control-repeatedly measuring a value and adjusting output in proportion to error for maintaining a set point-works very well for the BOE Shield-Bot shadow vehicle.
