If a car is programmed to travel 12?, how do we know is actually
traveled that distance? Often, the cars momentum will carry it past
the desired location even though the motors have stopped running.
The solution to this problem is a proportional control loop. By continually
monitoring the distance from the desired location, the motor speed
can be slowed as the car approaches. The governing formula is defined
as P*(desired-current) where P is an arbitrary constant.
In this program, a desired location is set at 50 degrees of the rotation
sensor. This value is continually subtracted by the current rotation traveled.
The difference is multiplied by two and this becomes the value of the "power" variable. The Compare Block determines the direction Motor C will travel: forward if "power" is positive, backward if "power" is negative. Thus, when the car
first starts off, its current position is zero and its desired position
is 50. Therefore, the power setting used is 100, which is full power forward. If the car overshoots its mark, the power
setting will become negative and the car will travel in reverse.
The goal of proportional control is to find a constant that will
get the system to equilibrium in the shortest time with the least
amount overshoot and the most accuracy.