← Back to Projects

Line-Following Robot with Closed-Loop Control

DC Motor Control Project • October 2024 • Principles of Integrated Engineering Class

Project Overview

This project integrated sensing and control with a two-wheeled robotic platform to autonomously follow a taped track on the floor. The system uses a closed-loop PD controller on an Arduino that can navigate a non-circular loop course. A key requirement was the ability to tune the controller and adjust robot performance in real-time via serial communication, without recompiling code, to achieve the fastest possible run times.

Line Follower Robot Assembled

Design Approach

We designed a custom chassis to precisely control wheel-to-wheel distances, sensor placements and heights, and other design elements that would optimize our code's performance. We implemented a proportional-derivative (PD) control scheme using five infrared sensors:

The control algorithm stays centered on the line using the main sensors, only using the far sensors when the main sensors lose sight of the line. This approach enabled fast line following with consistent sharp corner navigation.

System Architecture Diagram

Mechanical Design

Chassis Configuration

Our mechanical design focused on creating a stable, balanced platform. We positioned the motors and wheels in the back to maximize sensor turning radius and concentrate weight over the drive wheels for better traction. The chassis measures 5 inches wide by 6.5 inches long and uses a three-point contact system:

Chassis CAD Design

Chassis Design Features

All design choices were based on precise measurements of physical components using a caliper, with appropriate tolerances for assembly.

Sensor Array Evolution

Initially, we used three sensors positioned close together in the center. However, this design failed at sharp turns greater than 90 degrees because the sensors couldn't see the line during tight corners. To solve this, we added one sensor on each side, positioned slightly further back, to detect the line when the center sensors lost contact.

The sensors were positioned with 8mm spacing between the three center sensors - slightly wider than the tape. This made programming easier: when perfectly following the line, the middle sensor sees full tape color while the side sensors only partially see the line.

Sensor Array Configuration

Electronic Design

Component Specifications

Wiring Diagram

Sensor Circuit

Each IR reflectance sensor includes:

Control System Design

PD Control Algorithm

We implemented a Finite State Machine (FSM) with two primary states:

The PD controller calculates an error signal and applies proportional and derivative corrections:

ERROR = (LEFT_READING - RIGHT_READING)
CORRECTION = Kp * ERROR + Kd * (ERROR - LAST_ERROR)
LEFT_SPEED = BASE_SPEED + CORRECTION
RIGHT_SPEED = BASE_SPEED - CORRECTION

Tuned Parameters

Python GUI Interface

Real-Time Parameter Tuning

We created a Python GUI with serial communication that enabled runtime parameter adjustment without code recompilation. The interface features:

This dramatically accelerated the tuning process, allowing us to optimize performance through rapid iteration.

Sensor Data and Performance Graphs

Performance Results

Challenges Overcome

Challenge 1: Sharp Corners

Problem: Sharp corners (especially the "armpit") caused the 3-sensor design to lose the line.

Solution: Added 2 outer sensors and implemented FSM to detect and correct for line loss.

Challenge 2: Prototype Iteration

Problem: Initial solderable breadboard made component changes difficult.

Solution: Switched to solderless breadboard for rapid prototyping, then planned PCB for final version.

Challenge 3: Parameter Tuning Speed

Problem: Recompiling and re-uploading code for each tuning adjustment was time-consuming.

Solution: Developed Python GUI with serial communication for real-time parameter adjustment.

Key Learnings

Technical Specifications

← Back to All Projects