BUILD #04 // ECE COMPETITION

AUTONOMOUS LINE-TRACKING CAR
— ECE COMPETITION

Arduino-based autonomous vehicle with IR sensor array, real-time PID correction, and adaptive speed. 1st place, ECE competition

Arduino C++ PID Control IR Sensors Motor Driver PWM
1ST PLACE — ECE COMPETITION
1st ECE Competition
5 IR Sensors
PID Control Loop
RT Real-Time Loop

What It Was

An autonomous car that follows a black line on a white track. Five IR sensors sample the line position, a PID controller calculates correction, and the correction drives differential motor speed. The car had to handle curves, gaps, and intersections without stopping or drifting off course.

The competition format was time-based. Fastest complete run wins. That meant the car had to be stable at higher speeds, not just creep along reliably. Stability at low speed is a different problem from stability at competition speed.

5x IR SENSOR ARRAY // PID CORRECTION LOOP
DIFFERENTIAL MOTOR DRIVE // ADAPTIVE SPEED
04

Control Architecture

The sensor array gives a weighted position reading each loop. The error is the difference between that reading and the center target. PID feeds on the error history and produces a motor correction value applied differentially to left and right wheels.

// SENSOR TO MOTOR PIPELINE
Sensor read5x IR sensors → weighted position value (0 to 4000)
Errorposition - 2000 (center target)
PID outputKp*err + Ki*integral + Kd*derivative
Motor correctionLeft = base + correction, Right = base - correction
Speed adaptationBase speed reduced when |correction| exceeds threshold
Loop rate~1000 Hz (tight as possible given Arduino overhead)

Tuning Process

The gains were tuned one at a time, in order. Kp first, then Kd, then Ki last. Changing two things at once makes it impossible to know which one improved or broke the behavior. This sounds obvious but it takes discipline to stick to when runs are going badly and the temptation is to just adjust everything.

Kp — PROPORTIONAL
Start low, increase until the car oscillates. Back off until oscillation stops. That's your Kp starting point. At this stage the car corrects but overshoots in every curve.
Kd — DERIVATIVE
Increase until overshoot drops without making the car sluggish. Kd damps the correction rate. Too high and the car becomes unresponsive to real position changes. This was the most important gain for handling tight curves at speed.
Ki — INTEGRAL
Added small amount to correct steady-state drift from track conditions. Left small to avoid windup. Most of the improvement came from Kp and Kd. Ki was a small trim.
BASE SPEED
Final step after gains were stable: push base speed up until the car failed, back off slightly. Competition speed was 20% higher than what worked during tuning runs at lower speed. Gained that through adaptive speed logic that slows on high corrections.

What Actually Mattered

The car won because of process, not because of any clever algorithm. The gains work because they were tuned systematically. The speed is high because the adaptation logic handles curves without needing the driver to manually reduce speed.

// LESSON FROM THIS BUILD
Logs and repeatable test segments made systematic tuning possible. Without notes, every run felt like the first one. With notes, you can see a trend across 30 runs and know which direction to go. Control systems punish guessing. They reward knowing what variable you changed and why.
[>]
1ST PLACE — ECE LINE TRACKING COMPETITION
University of Toronto, ECE program. Fastest complete run across all submitted teams.
Loading