The Project is an autonomous vehicle designed to navigate a track using a line scan camera and a BLDC motor. The system processes real-time image data to detect the track's boundaries, calculates deviation from the center, and adjusts the steering accordingly. The project integrates motor control, real-time processing, and sensor fusion to achieve smooth navigation.
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.
## Features
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.
- 🚗 Real-time image processing using an ADC to read pixel intensities
## 💡 **Key Features**
- 🎯 Deviation calculation for precise lane following
- ⚡ BLDC motor control with sensorless back-EMF detection
- 🔄 Servo motor steering for dynamic maneuvering
- ⏱️ Interrupt-driven architecture for efficient data acquisition
## Hardware Components
- 🌟 **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.
| Component | Description |
- 🎯 **Precise Lane Following**: Calculates deviation from the track's center, ensuring the car stays perfectly aligned.
- 🔄 **Dynamic Steering with Servo Motors**: The servo motor adjusts the steering based on real-time deviation calculations for fluid motion.
| Camera Sensor | TSL1401R-LF Line Scan Camera |
- ⏱️ **Efficient Interrupt-Driven Architecture**: Real-time data acquisition with minimized CPU load, ensuring the system responds instantly.
| BLDC Motor | 6-step commutation with free running |
| H-Bridge | Controls motor direction & speed |
| Servo Motor | Adjusts steering based on deviation |
| LED Matrix | WS2812B for track illumination |
## Software & Firmware
## 🛠️ **Hardware Components**
All development work was done using MCUXpresso IDE. The `pins.mex` file, which was included with the project materials, was used for configuring microcontroller peripherals.
| **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 |
### Microcontroller Peripherals Used
## 💻 **Software & Firmware**
-**FTM (FlexTimer Module)**: Generates PWM for BLDC motor & servo motor.
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.
-**ADC (Analog-to-Digital Converter)**: Reads pixel intensity from the line scan camera.
-**GPIO**: Controls motor phase switching & camera signals.
-**SPI**: Communicates with the LED Matrix.
-**DMA**: Transfers data efficiently, reducing CPU load.
## Main Functionalities
### 🔧 **Microcontroller Peripherals Used**
-**Image Capture**: ADC reads pixel intensities from the camera.
-**FTM (FlexTimer Module)**: Generates PWM signals for the BLDC motor and servo motor for accurate control.
-**Edge Detection**: Identifies track boundaries by analyzing intensity differences.
-**ADC (Analog-to-Digital Converter)**: Reads pixel intensity from the line scan camera for real-time image processing.
-**Deviation Calculation**: Determines car's position relative to the center.
-**GPIO**: Manages motor phase switching and camera signal control.
-**Motor & Steering Control**: Adjusts speed & steering angle based on deviation.
-**SPI**: Powers the **LED Matrix**, enabling stunning track illumination.
-**Interrupt Handling**: Uses ADC & FTM interrupts for real-time response.
-**DMA**: Transfers data with minimal CPU involvement, ensuring real-time responsiveness.
## Challenges & Solutions
## 🛠️ **Main Functionalities**
-**Issue**: Deviation Values Were Unexpected
1.**📸 Image Capture**: The ADC reads pixel intensity from the camera in real-time.
**Problem**: Expected deviation on a straight track was 0, but it was actually 24, causing incorrect turns.
2.**🖼️ Edge Detection**: Tracks boundaries are detected by analyzing intensity differences between the track and surroundings.
**Solution**: Removed `centerServo()` function and relied on `turnLeft()` & `turnRight()` for better control.
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.
-**Issue**: Car Didn’t Move with Forced Commutation
## 🚧 **Challenges & Innovative Solutions**
**Problem**: The BLDC motor couldn’t start properly.
**Solution**: Implemented Free-Running mode, which triggers commutation based on back-EMF.
-**Issue**: Microcontroller Reset Due to LED Matrix
-**❌ Unexpected Deviation Values**
**Problem**: High LED intensity caused the MCU to reset.
**Problem**: The car was drifting due to incorrect deviation values on a straight track.
**Solution**: Reduced LED intensity by adjusting the bit pattern values.
**Solution**: Refined control by removing unnecessary functions and focusing on specific left/right turns for accurate lane corrections.
## Results
-**❌ 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.
-✅ The car successfully follows the track autonomously.
-**❌ Microcontroller Resetting**
- ✅ The deviation-based steering ensures smooth lane corrections.
**Problem**: The high LED intensity caused the MCU to reset during operation.
- ✅ The BLDC motor runs efficiently in sensorless mode.
**Solution**: Lowered the LED intensity by adjusting bit pattern values, stabilizing the system.
## Future Improvements
## 🎉 **Results: Mission Accomplished**
-🚀 Implement Kalman filtering for more precise edge detection.
-✅ The car successfully follows the track autonomously, demonstrating effective edge detection and steering.
-🚀 Improve PID tuning for smoother motion control.
-✅ **Deviation-based steering** ensures smooth and precise lane corrections.
-🚀 Add adaptive speed control based on track curvature.
-✅ The **BLDC motor** operates efficiently in sensorless mode, saving power and reducing complexity.