Proportional line follower

The proportional algorithm will make a correction to the motor speeds, which is proportional to the magnitude of the error between the setpoint and the sensor value. Each wheel has a given base speed, which we correct by either adding or subtracting a factor proportional to the error. If the right wheel is faster, the robot turns to the left. If the left wheel is faster, the robot will turn to the right. A critical number for efficient line tracking is the proportional gain constant. If the gain is too large, the robot will overcompensate for errors and wiggle back and forth. If the gain is too small, the robot will have trouble following tighter curves.

Entering gain and speed

You could enter the gain and speed directly ...

Get Learning LEGO MINDSTORMS EV3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.