-
Adham Beshr authoredAdham Beshr authored
- 🚗 Autonomous Line-Following Car Project
- 🚀 Project Overview
- 💡 Key Features
- 🛠️ Hardware Components
- 💻 Software & Firmware
- 🔧 Microcontroller Peripherals Used
- 🛠️ Main Functionalities
- 🚧 Challenges & Innovative Solutions
- 🎉 Results
- 🔧 Installation Instructions
- 1. Install MCUXpresso IDE
- 2. Open the Project in MCUXpresso IDE
- 3. Connect the NXP K66F Microcontroller
- 4. Debug the Project
- 5. Test the Car
- 🌟 DriveX Team
🚗 Autonomous Line-Following Car Project
🚀 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 |
|
Camera Sensor |
|
BLDC Motor |
|
H-Bridge |
|
Servo Motor |
|
LED Matrix |
|
💻 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
-
📸 Image Capture: The ADC reads pixel intensity from the camera in real-time. -
🏁 Edge Detection: Tracks boundaries are detected by analyzing intensity differences between the track and surroundings. -
📊 Deviation Calculation: Constantly calculates how far the car is from the center of the track, ensuring precision. -
🚗 Motor & Steering Control: Adjusts speed and steering angle based on deviation, ensuring smooth navigation. -
⚡ 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