This repository contains the embedded C firmware for an autonomous two-wheeled robot designed to navigate dynamic maze environments. The system is built on the Xilinx Basys3 FPGA (Artix-7), utilizing a MicroBlaze soft-core processor to handle real-time control logic.
Unlike standard microcontroller implementations (e.g., Arduino), this project demonstrates Hardware/Software Co-Design by instantiating a soft processor within programmable logic to interface with custom hardware peripherals.
- Real-Time PID Control: Implemented a custom Proportional-Integral-Derivative (PID) controller to correct motor speed errors in real-time, ensuring straight-line tracking and precise 90-degree turns.
- Sensor Fusion: Integrates data from Quadrature Encoders (for odometry) and Ultrasonic Sensors (for environment mapping).
- Hardware-Based Timing: Developed custom drivers using hardware timers to measure ultrasonic echo pulse widths with microsecond precision, offloading timing overhead from the main CPU.
- State Machine Logic: Features a robust Finite State Machine (FSM) for wall-following behaviors, obstacle avoidance, and maze traversal.
- Language: Embedded C
- Hardware: Xilinx Basys3 FPGA (Artix-7), Digilent PmodHB3 Motor Bridge, HC-SR04 Ultrasonic Sensors
- Processor: Xilinx MicroBlaze (Soft-Core)
- Tools: Xilinx Vitis (IDE), Git
main.c- Core application logic containing the PID control loop and State Machine
The firmware operates on a bare-metal environment (No-OS) on the MicroBlaze processor.
- Initialization: Configures GPIO, Timer/Counter, and Interrupt Controller
-
Control Loop: Reads encoder ticks
$\rightarrow$ Calculates Error$\rightarrow$ Computes PID Output$\rightarrow$ Adjusts PWM Duty Cycle -
Navigation Logic: The FSM determines the robot's state (e.g.,
FORWARD,TURN_LEFT,CORRECT_RIGHT) based on filtered sensor inputs