Skip to content

sarpharaj-09/RTOS_MICROMOUSE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RTOS Micromouse

A real-time operating system (FreeRTOS) based micromouse robot that solves line-following mazes using state machines and task-based concurrency.

Overview

This project implements a sophisticated maze-solving robot using:

  • Arduino Nano (ATmega328P) microcontroller
  • FreeRTOS for multitasking and real-time control
  • QTR Sensors for line detection (8-sensor array)
  • TB6612 Motor Driver for motor control
  • State Machine Architecture for robot behavior management

Features

  • ✅ Line following with PID control
  • ✅ Automatic sensor calibration
  • ✅ Left-hand and right-hand maze solving rules
  • ✅ Intersection detection and turn execution
  • ✅ Path optimization and simplification
  • ✅ Recovery mechanism for lost line detection
  • ✅ Watchdog task for timeout monitoring
  • ✅ Multi-threaded task scheduling with FreeRTOS

Hardware Setup

Pin Definitions

Motor Control (TB6612):
- AIN1: Pin 5
- AIN2: Pin 4
- PWMA: Pin 3
- BIN1: Pin 6
- BIN2: Pin 8
- PWMB: Pin 9

Sensors:
- QTR-8 Array: A0-A7 (Analog Pins)

Control Switches:
- SW1 (Start/Restart): Pin 10
- SW2 (Left Rule): Pin 11
- SW3 (Right Rule): Pin 12

Indicators:
- LED: Pin 7

Wiring

  • Connect TB6612 motor driver to specified pins
  • Connect 8-sensor QTR array to analog pins A0-A7
  • Connect switches with pull-up resistors to digital pins
  • Connect 2 DC motors to motor driver outputs

Software Setup

Requirements

  • PlatformIO (recommended) or Arduino IDE
  • Arduino Framework
  • Dependencies:
    • QTRSensors (v4.0.0+)
    • FreeRTOS (feilipu/FreeRTOS v10.5.1+)
    • Arduino core libraries

Build & Upload

# Install dependencies
platformio lib install

# Build the project
platformio run

# Upload to Arduino Nano
platformio run --target upload

# Monitor serial output
platformio device monitor --baud 9600

Operation

States

  1. IDLE: Waiting for calibration command
  2. CALIBRATING: Swinging left/right to calibrate sensors
  3. EXPLORING: Solving the maze following selected rule
  4. RECOVERY: Recovering when line is lost
  5. FINISHED: Maze solved, ready for optimized run

Workflow

  1. Power on the robot
  2. Press SW1 to start calibration
  3. Robot swings left/right to calibrate sensor thresholds
  4. Press SW2 for left-hand rule or SW3 for right-hand rule
  5. Robot explores and solves the maze
  6. LED indicates status (blinking = calibrating/exploring, solid = finished)

Task Structure

  • StateMachine Task (Priority 2): Executes state handlers every 50ms
  • Watchdog Task (Priority 3): Monitors for timeouts and hangs

PID Control Parameters

kp = 0.161  // Proportional gain
kd = 0.54   // Derivative gain
BaseSpeed = 230
MaxSpeed = 255

Memory Usage

  • Flash: 67.8% (20834 / 30720 bytes)
  • RAM: 74.2% (1519 / 2048 bytes)

Serial Output

The robot sends debug information at 9600 baud:

  • State transitions
  • Sensor calibration values
  • Maze solution path
  • Error messages and warnings

Troubleshooting

  • Robot spins in place: Check sensor wiring and calibration
  • Motor not moving: Verify motor driver pins and power supply
  • Poor line following: Adjust PID constants and sensor thresholds
  • Timeout errors: Increase timeout values or check line continuity

License

See LICENSE file for details.

About

RTOS based code for LineMazeSolver-Micromouse.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages