Skip to content

talelas/line-follower-sofisticated-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

STM32 Enhanced Line Follower Robot

Overview

This project is a high-performance line follower robot firmware designed for the STM32F103C8T6 (Blue Pill) microcontroller. It features an advanced navigation system capable of handling multiple complex zones, including:

  • Black Box: Initial blind navigation.
  • Curved Sections: Smooth PID control for sinuous lines.
  • Hexagon Zone: Logic for navigating complex polygonal paths.
  • Checkerboard: Handling discontinuous lines.
  • Brain/Color Zone: Special logic for color inversion or specific tasks.

The system uses a 6-channel IR sensor array for line detection and an H-Bridge motor driver for differential drive control.

Hardware Requirements

  • Microcontroller: STM32F103C8T6 (Blue Pill)
  • Motor Driver: L298N, TB6612FNG, or similar H-Bridge driver.
  • Sensors: 6-Channel Analog IR Line Sensor Array (e.g., QTR-8A or generic).
  • Chassis: Differential drive robot chassis.
  • Power: LiPo battery (2S or 3S recommended).

Wiring & Pinout

Motor Connections

Based on Core/Inc/motor_control.h:

Function STM32 Pin Timer/Channel Description
Left Motor PWM PB6 TIM4 CH1 Speed control for Left Motor
Left Motor Dir PA4 GPIO Output Direction for Left Motor
Right Motor PWM PB7 TIM4 CH2 Speed control for Right Motor
Right Motor Dir PA5 GPIO Output Direction for Right Motor

Note: Ensure your motor driver supports PWM+Direction control. If using L298N with IN1/IN2/EN pins, connect PWM to EN and Direction to IN1 (with IN2 inverted via hardware or code modification).

Sensor Connections

The system expects 6 Analog Sensors. Current Configuration Note: The generated main.c currently initializes ADC1 on PA0. You must configure the remaining ADC channels in STM32CubeMX or main.c to match your hardware (typically PA0-PA3, PA6-PA7, avoiding the motor pins PA4/PA5).

Sensor Index Recommended Pin Description
Sensor 0 (Left) PA0 ADC1 Channel 0
Sensor 1 PA1 ADC1 Channel 1
Sensor 2 PA2 ADC1 Channel 2
Sensor 3 PA3 ADC1 Channel 3
Sensor 4 PA6 ADC1 Channel 6
Sensor 5 (Right) PA7 ADC1 Channel 7

Other Peripherals

  • LED: PC13 (On-board LED) - Used for calibration status.
  • Debug/Aux: PA8, PA9, PA10, PA11 are configured as outputs (usage defined in user code).

Software Architecture

Core Files

  • Core/Src/enhanced_line_follower_fixed.c: The main entry point and control loop. Replaces the standard main.c logic.
  • Core/Inc/motor_control.h: Motor control logic and pin definitions.
  • Core/Src/sensor_processing.c: Sensor data normalization, calibration, and line position calculation.
  • Core/Src/calibration.c: Routines for calibrating sensor min/max values.

Zone Logic

The robot uses a state machine to switch between different navigation strategies:

  1. Calibration: On startup, the robot calibrates sensors (rotate over line).
  2. Black Box: Blind acceleration.
  3. Line Follow: PID control based on weighted average of sensor inputs.
  4. Special Zones: Detected via specific sensor patterns (e.g., all white, all black, specific widths).

How to Build and Flash

  1. Open in STM32CubeIDE:

    • Select File > Open Projects from File System...
    • Point to the project directory.
  2. Configuration:

    • Open final test i hope.ioc if you need to change pin assignments using CubeMX. Warning: Regenerating code might overwrite manual changes in main.c.
  3. Build:

    • Click the "Hammer" icon or Project > Build Project.
  4. Flash:

    • Connect ST-Link V2.
    • Click "Run" or "Debug".

Calibration

On startup, the robot expects to be placed on the line. It may perform a calibration sequence (spinning left/right) to learn the white/black values. Ensure the LED (PC13) indicates the calibration state.

Credits

Strategy analysis and zone logic based on robot_strategy.md.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors