A sophisticated camera auto-tracking system built with STM32F103 (Blue Pill) that uses stepper motors and FreeRTOS for smooth and precise object tracking. This project demonstrates advanced embedded systems programming with real-time task management and motor control.
- Real-Time Object Tracking: Responsive camera movement using FreeRTOS task management
- Smooth Stepper Motor Control: Precision movement with AccelStepper library
- Multi-Axis Control: Pan and tilt functionality for complete 3D tracking
- Computer Vision Integration: Processes camera input for target detection and tracking
- Low-Latency Response: Optimized for real-time performance
- Professional PCB Design: Custom mainboard integration for reliable operation
- STM32F103C8T6 (Blue Pill development board)
- Clock Speed: 72MHz
- Memory: 64KB Flash, 20KB RAM
- 2x Stepper Motors (NEMA 17 recommended)
- 2x Stepper Motor Drivers (A4988 or DRV8825)
- Power Supply: 12V for motors, 3.3V for microcontroller
- Camera module (compatible with computer vision processing)
- Custom STM32 Blue Pill mainboard (see related repository)
- Mechanical mount for pan/tilt assembly
- PlatformIO: Development environment
- STM32duino Framework: Arduino-compatible STM32 development
- AccelStepper Library: Advanced stepper motor control
- STM32duino FreeRTOS: Real-time operating system
- ST-Link: Programming and debugging interface
git clone https://github.com/Mohamed-U3/Autotracking-with-camera.git
cd Autotracking-with-camera# Install PlatformIO Core
pip install platformio
# Or use PlatformIO IDE extension for VS Code| STM32F103 Pin | Component | Function |
|---|---|---|
| PA0-PA3 | Stepper 1 | Step/Dir/Enable |
| PA4-PA7 | Stepper 2 | Step/Dir/Enable |
| PB0-PB1 | Serial | Camera Communication |
| PC13 | LED | Status Indicator |
# Build the project
pio build
# Upload to STM32 (ST-Link required)
pio upload
# Monitor serial output
pio device monitor- Tick Rate: 1000 Hz (1ms precision)
- Max Priorities: 5 levels
- Heap Size: 10KB
- Preemptive Scheduling: Enabled
// Stepper motor parameters (adjustable in main.cpp)
#define STEPS_PER_REV 200
#define MAX_SPEED 1000
#define ACCELERATION 500- Power On: Connect 12V power supply and USB for serial monitoring
- Initialization: System automatically calibrates stepper motors
- Camera Input: Connect computer vision system via serial communication
- Tracking: Send target coordinates via serial (X, Y format)
- Real-Time Response: Camera smoothly tracks to target position
Input Format: "X:123,Y:456\n"
- X: Horizontal position (-1000 to 1000)
- Y: Vertical position (-1000 to 1000)
- Response Time: < 50ms from input to motor movement
- Positioning Accuracy: Β±0.1 degrees
- Max Tracking Speed: 360Β°/second
- Operating Range: Β±180Β° pan, Β±90Β° tilt
- Power Consumption: 2A @ 12V (motors), 100mA @ 3.3V (MCU)
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β Camera βββββΆβ Computer βββββΆβ STM32 β
β Module β β Vision β β F103 β
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β
βΌ
βββββββββββββββββββ
β FreeRTOS Tasks β
β βββββββββββββββ β
β βSerial Input β β
β βMotor Controlβ β
β βStatus Updateβ β
β βββββββββββββββ β
βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β Stepper Motors β
β Pan & Tilt β
βββββββββββββββββββ
- IDE: Visual Studio Code with PlatformIO extension
- Framework: Arduino-compatible STM32duino
- Debugger: ST-Link V2
- Version Control: Git with semantic commits
- STM32 Blue Pill Mainboard: Custom PCB design for this project
- BMS Protection Mainboard: Power management solution
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Mohamed Yousry Ragab
- GitHub: @Mohamed-U3
- LinkedIn: Mohamed Yousry
- Email: Contact via GitHub issues
- STMicroelectronics for STM32 ecosystem
- PlatformIO community for excellent development tools
- FreeRTOS team for real-time operating system
- Arduino community for accessible embedded programming
β Star this repository if you find it helpful!
This project demonstrates professional embedded systems development with real-time constraints and precision motor control.