Skip to content
Snippets Groups Projects
To learn more about this project, read the wiki.

🧑🏻 : Beshr , Adham / 22209885
📚 : Technische Hochschule Deggendorf, Bavaria
📄 : Wiki.
🦊 : GitLab Repository.

🚗 Autonomous Line-Following Car Project

NXP Car

🚀 Project Overview

This project involves building an autonomous vehicle that can follow a track using a line scan camera and a BLDC motor. The vehicle uses real-time image data to detect the track’s boundaries and calculates the deviation from the center of the track. Based on this information, the car adjusts its steering to stay on the track.

The system integrates image processing, motor control, and real-time sensor data to ensure smooth and accurate navigation. The BLDC motor runs in a sensorless mode, while a servo motor controls the steering, allowing the car to make precise turns and follow the path autonomously. This project demonstrates the application of embedded systems, motor control, and real-time data processing for building an autonomous vehicle.

💡 Key Features

  • 🌟 Real-time Image Processing: Using an ADC to read pixel intensities, the car’s eyes (the camera) are always on the lookout for the track’s boundaries.

  • 🎯 Precise Lane Following: Calculates deviation from the track's center, ensuring the car stays perfectly aligned.

  • Sensorless BLDC Motor Control: With back-EMF detection, the motor powers the vehicle efficiently, without additional sensors.

  • 🔄 Dynamic Steering with Servo Motors: The servo motor adjusts the steering based on real-time deviation calculations for fluid motion.

  • ⏱️ Efficient Interrupt-Driven Architecture: Real-time data acquisition with minimized CPU load, ensuring the system responds instantly.

🛠️ Hardware Components

Component Description
Microcontroller 🧠 NXP K66F, Cortex-M4, 180 MHz – The brain of the system
Camera Sensor 📸 TSL1401R-LF Line Scan Camera – The eyes that detect the track
BLDC Motor ⚙️ 6-step commutation – Powering the car’s movement
H-Bridge 🔌 Controls motor direction & speed – The heart of the motion
Servo Motor 🎮 Adjusts steering based on real-time deviations – Precision in motion
LED Matrix 💡 WS2812B – Illuminates the track for enhanced visibility

💻 Software & Firmware

All development is done using MCUXpresso IDE, which ensures efficient coding and debugging. The project utilizes an essential file, pins.mex, for configuring peripherals on the microcontroller.

🔧 Microcontroller Peripherals Used

  • FTM (FlexTimer Module): Generates PWM signals for the BLDC motor and servo motor for accurate control.
  • ADC (Analog-to-Digital Converter): Reads pixel intensity from the line scan camera for real-time image processing.
  • GPIO: Manages motor phase switching and camera signal control.
  • SPI: Powers the LED Matrix, enabling stunning track illumination.
  • DMA: Transfers data with minimal CPU involvement, ensuring real-time responsiveness.

🛠️ Main Functionalities

  1. 📸 Image Capture: The ADC reads pixel intensity from the camera in real-time.
  2. 🏁 Edge Detection: Tracks boundaries are detected by analyzing intensity differences between the track and surroundings.
  3. 📊 Deviation Calculation: Constantly calculates how far the car is from the center of the track, ensuring precision.
  4. 🚗 Motor & Steering Control: Adjusts speed and steering angle based on deviation, ensuring smooth navigation.
  5. Interrupt Handling: ADC and FTM interrupts allow for immediate reaction to environmental changes, enabling the car to respond to curves and obstacles instantly.

🚧 Challenges & Innovative Solutions

  • Unexpected Deviation Values
    Problem: The car was drifting due to incorrect deviation values on a straight track.
    Solution: Refined control by removing unnecessary functions and focusing on specific left/right turns for accurate lane corrections.

  • BLDC Motor Failure to Start
    Problem: The motor failed to initiate under forced commutation.
    Solution: A switch to Free-Running mode enabled successful commutation through back-EMF, enhancing motor efficiency.

  • Microcontroller Resetting
    Problem: The high LED intensity caused the MCU to reset during operation.
    Solution: Lowered the LED intensity by adjusting bit pattern values, stabilizing the system.

🎉 Results

  • The car successfully follows the track autonomously, demonstrating effective edge detection and steering.
  • Deviation-based steering ensures smooth and precise lane corrections.
  • The BLDC motor operates efficiently in sensorless mode, saving power and reducing complexity.

🔧 Installation Instructions

Follow the steps below to set up the development environment and test the autonomous vehicle project:

1. Install MCUXpresso IDE

  • Download and install the MCUXpresso IDE from the official NXP website.
  • Follow the installation instructions provided on the website for your operating system (Windows, macOS, or Linux).

2. Open the Project in MCUXpresso IDE

  • Launch the MCUXpresso IDE after installation.
  • Go to the File menu and select Open Projects from File System.
  • In the dialog that appears, click Browse and select the ZIP file containing the project, which is attached above.
  • Unzip the project and open it in the MCUXpresso IDE.

3. Connect the NXP K66F Microcontroller

  • Use a USB cable to connect your NXP K66F microcontroller to your computer.
  • Ensure that the microcontroller is properly powered and recognized by the IDE.

4. Debug the Project

  • In MCUXpresso IDE, click on the Debug button (represented by a bug icon) on the top toolbar.
  • Select All Sessions to start debugging.
  • The IDE will automatically load the project onto the NXP K66F microcontroller.

5. Test the Car

  • After successfully loading the project onto the microcontroller, test the autonomous vehicle.
  • Ensure that the vehicle follows the track as expected, making turns and adjusting based on the calculated deviation.
  • If available, observe the vehicle’s behavior and make any necessary adjustments to the system.

By following these steps, you should be able to successfully set up the development environment and test the autonomous vehicle with the NXP K66F microcontroller.

🌟 DriveX Team

👤 Adham Beshr – Embedded Systems Student
👤 Ismail Shah – IOT Student

🔎 For an in-depth breakdown of each component, visit the Wiki.