Autonomous Lane-Following Car
EEC 195AB - Senior Design Project
EEC 195AB - Senior Design Project
— PROJECT NAME
Autonomous Car Senior Design Project
— ASSOCIATED COURSE
EEC 195AB - Autonomous Car Project
— COLLABORATORS
— DATE
Winter / Spring Quarter 2025
— KEYWORDS
Python, Lane-Following, Blob Detection, PID Control
The overall objective of this senior design project was to develop an autonomous lane-following car by creating or integrating the necessary hardware, software, and mechanical components.
We started with an existing chassis equipped with a servo and DC motor.
Lane following was implemented using closed-loop PD control driven by visual feedback to adjust steering.
The system used an OpenMV microcontroller / camera for real-time image processing to detect lane boundaries and serve as the controller's feedback element.
A custom-designed PCB managed all electronic connections
3D-printed housing and mounts were used to secure all components to the chassis.
(1) Electrical Design
PCB Connections. Own Work.
To create an autonomous lane-following car, it was necessary to create a custom two-layer PCB to manage all electrical connections between the system modules (servo, battery, microcontroller, and infrared sensor). The PCB was also used to implement two distinct motor control circuits. One of which used an H-Bridge integrated circuit (VNH5019ATR-E), which incorporated reverse battery protection [5, pp. 15 - 16]. The second method employed a MOSFET (IRF3205PBF) driven by a MAX4427CPA+ gate driver chip to boost the servo PWM signal to 5V logic. The board also featured two (low-dropout) voltage regulation circuits. One which output 5V to power the microcontroller (LM2940CT-5.0) and another to output 6V for the servo (LM1086CT-ADJ).
To mitigate electrical noise, several methods were used:
High-current components were isolated with separate ground planes ("star ground"). These planes were connected with vias and a common grounding point.
Decoupling Capacitors were placed strategically.
Large electrolytic capacitors (470μF - 1kμF) were used to suppress low-frequency noise on power input lines.
Small ceramic capacitors (0.01μF - 0.1μF) were placed near critical pins to filter high-frequency noise.
Very small ceramic capacitors (3nF - 10nF) were also used to attenuate noise in communication lines.
PCB Layout. Own Work.
PCB Schematic. Own Work.
(2) Servo Control
Image Processing Visualization. Own Work.
Image Processing
The OpenMV camera was configured in grayscale mode with a resolution of HQVGA (240x160). Across this we defined six horizontal regions of interest (ROIs) spaced vertically across the image, each 200×20 pixels in size (See: white rectangles).
Within each ROI, we used blob detection to locate areas that differed from their surrounding based on the level of brightness. This was based on a preset threshold of brightness.
After filtering the detected blobs to exclude those with an area less than 100 or greater than 350 pixels, we selected the two closest objects to the image center from the left and right (see: black rectangles).
Once we found this, we were able to calculate the horizontal error between the center of the two white lines and the center of the image.
PID Control
PID control was used to continuously determine the required correction based on the difference between the desired setpoint (0 pixels) and the horizontal error computed by the OpenMV. Since the horizontal error was calculated for each of the ROIs, the error was averaged before being compared to the setpoint. This made the controller more robust.
integral term clamped to +/- 100 as an anti-windup measure
proportional gain is dynamically tuned based on the horizontal error
Steering is handled by subtracting the pulse width in nanoseconds which sets the servo to neutral by the control signal from the controller.
Control System Diagram. Own Work.
(3) Mechanical Design
Microcontroller Case and Mount. Own Work.
PCB Mounts. Own Work.
Infrared Sensor Mount. Own Work.
(4) Evaluation and Next Steps
Visualization of OEM chassis and 3D-Printed Mounts. Own Work.
Evaluation
We encountered significant performance issues due to lighting variations across the track, especially in areas with light gray carpet, uneven ambient lighting, significant reflections, or large shadows.
This was addressed by manually tuning the grayscale threshold values to enhance the contrast, in effect, making the whites appear whiter and suppressing the influence of reflective or gray surroundings. In addition, we found it very helpful to turn on auto white balancing and auto gain tuning algorithms on the microcontroller. Lastly, averaging the horizontal error across ROIs helped mitigate local errors.
Next Steps
Revise PCB Layout
There were a number of non-fatal errors on the PCB: (1) VDD should be connected to Vout-LDO-5. (2) The layout trace connecting the B pin of the DC Motor 2 terminal to Q2 should be thicker. (3) On the PCB, we should add a diode in parallel across B and Vbat pins the DC Motor 2 terminal.
Integrate Motor PID Control
Our team implemented both motor and servo PID control in isolation. However due to time constraints, we did not manage to integrate both methods. Therefore our demonstration of autonomous lane following used PD control to adjust steering but set the motor signal to a constant duty cycle. This meant it didn't change speed to adjust for surface friction.
[1] Analog Devices, MAX4427CPA+ Datasheet, Rev. 2, Analog Devices, Inc.,
2014. [Online]. Available: https://www.analog.com/media/en/technical-documentation/data-sheets/MAX4426-MAX4428.pdf
[2] L. Halsted, EEC 195A - Autonomous Vehicle Design Project [Lecture Notes], 2025.
[3] Infineon Technologies, IRF3205PBF Datasheet, International Rectifier, 2005. [Online]. Available: https://www.infineon.com/dgdl/irf3205pbf.pdf?fileId=5546d462533600a4015355def244190a
[4] OpenMV, "Quick reference for the OpenMV Cam," OpenMV Documentation. [Online]. Available: https://docs.openmv.io/openmvcam/quickref.html
[5] STMicroelectronics, VNH5019ATR-E H-Bridge IC Datasheet, STMicroelectronics, 2020. [Online]. Available: https://www.st.com/resource/en/datasheet/vnh5019a-e.pdf
[6] Texas Instruments, LM1086CT-ADJ Datasheet, Texas Instruments. [Online]. Available: https://www.ti.com/general/docs/suppproductinfo.tsp?distId=10&gotoUrl=https%3A%2F%2Fwww.ti.com%2Flit%2Fgpn%2Flm1086
[7] Texas Instruments, LM2940CT-5.0 Datasheet, Texas Instruments, 2016. [Online]. Available: https://www.ti.com/lit/ds/symlink/lm2940-n.pdf
[8] Traxxas, Rustler Model 37054 Owner’s Manual, Traxxas, LLC. [Online]. Available: https://traxxas.com/media/productattach/C-24054-8/2/24054-36054-37054-8-om-en-r00.pdf