Datasheet
Chapter 8 • Robot Control with Distance Detection
256 • Robotics with the BOE Shield-Bot
The next time through the loop, the measured distance might change, but that’s okay.
Regardless of the measured distance, this control loop will calculate a value that will cause
the servo to move to correct any error. The correction is always proportional to the error.
The two calculations involved:
set point – measured distance = error; error x Kp = output for maneuver
…can be easily combined and re-ordered into one expression for your sketch:
Output for maneuver = (Distance set point – Measured distance) x Kp
If you want to take a look at the sketch in detail, see How FollowingShieldBot Works on page
258.
Your Turn – Verify Control Loop with Other Distances
To prove that the proportional control loop responds correctly to all six measured distances,
fill in the table below. The block diagrams have been solved for two of the six conditions, so
you’ve only got four to try.
Condition
Measured
Distance
Set
Point
Error
(set point–
measured)
Output
(Kp × error)
Maneuver
Result
0 2
Too close 1 2 2 – 1 = 1 2 × –50 = -50 Slow reverse
Just right 2 2
3 2
Way too far 4 2 2 – 4 = -2 -2 × -50= -100 Fast forward
5 2