A sophisticated closed-loop motor driver platform designed for precise robotic control applications.
DEMIR is an advanced motor control system developed as a final year engineering project. It combines hardware and software to deliver high-precision motor control with intelligent feedback mechanisms.
- Closed-loop Control: Encoder-based PID position controller
- Profile Generation: Smooth motion profiles for precise movements
- Multi-motor Support: Control up to 4 motors simultaneously
- Real-time Communication: UART/Serial interface for commands
- Hardware Integration: Built around ATmega328P microcontroller and VNH7070 motor driver
- Microcontroller: ATmega328P (Arduino UNO compatible)
- Motor Driver: VNH7070 H-bridge driver
- Encoder Support: Quadrature encoder input
- Communication: UART (9600 baud default)
- Power Supply: 12V DC input for motors
- Operating Voltage: 5V logic level
- PID Controller: Tunable proportional, integral, and derivative gains
- Velocity Profiling: Configurable acceleration and deceleration ramps
- Position Accuracy: High-precision positioning with encoder feedback
- Real-time Monitoring: Live position and velocity feedback
- Serial command interface
- Status reporting
- Parameter configuration
- Emergency stop functionality
.
βββ .github
β βββ workflows
β βββ build.yml
βββ include
β βββ board
β β βββ DEMIRv1
β β βββ hardware.h
β β βββ pins_DEMIRv1.h
β βββ com_def.h
β βββ conf.h
β βββ controller.h
β βββ encoder.h
β βββ Motion.h
β βββ motor.h
β βββ MotorDriver.h
β βββ PID.h
β βββ PLANNER.h
β βββ README
β βββ SerialParser.h
β βββ SerialSolver.h
β βββ vnh7070.h
βββ src
β βββ com_def.cpp
β βββ controller.cpp
β βββ encoder.cpp
β βββ main.cpp
β βββ Motion.cpp
β βββ motor.cpp
β βββ MotorDriver.cpp
β βββ PID.cpp
β βββ PLANNER.cpp
β βββ README
β βββ SerialParser.cpp
β βββ SerialSolver.cpp
β βββ vnh7070.cpp
βββ .clang-format
βββ .gitignore
βββ .travis.yml
βββ LICENSE
βββ platformio.ini
βββ README.md
- Arduino IDE or Arduino CLI
- ATmega328P compatible board (Arduino UNO)
- C++14 compatible compiler
-
Clone the repository:
git clone https://github.com/dsm/demir_firmware.git cd demir_firmware
-
Using Arduino IDE:
- Open
src/main.cpp
in Arduino IDE - Select Arduino UNO board
- Upload to your device
- Open
-
Using Arduino CLI:
arduino-cli compile --fqbn arduino:avr:uno --build-property "compiler.cpp.extra_flags=-std=c++14" arduino-cli upload --fqbn arduino:avr:uno --port /dev/ttyUSB0
Configure motor parameters in include/conf.h
:
#define MOTORS 4 // Number of motors (1-4)
#define ENCODER_PPR 1024 // Pulses per revolution
#define MAX_VELOCITY 1000 // Maximum velocity (pulses/sec)
#define PID_KP 2.0 // Proportional gain
#define PID_KI 0.1 // Integral gain
#define PID_KD 0.05 // Derivative gain
- Baud Rate: 9600 (configurable)
- Data Format: 8N1
- Flow Control: None
M<id> P<position>
- Move motor to positionM<id> V<velocity>
- Set motor velocityM<id> S
- Stop motorSTATUS
- Get system statusRESET
- Emergency reset
M1 P1000 # Move motor 1 to position 1000
M2 V500 # Set motor 2 velocity to 500
STATUS # Get current status
The system provides real-time feedback including:
- Current position for each motor
- Target position
- Current velocity
- PID error values
- System status
Enable debug mode in configuration for detailed logging:
#define DEBUG_MODE 1
Run automated tests using the GitHub Actions workflow:
- Compilation verification
- Code linting
- Memory usage analysis
- Connect motors and encoders
- Upload firmware
- Use serial monitor for command testing
- Verify position accuracy and response
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- Position Accuracy: Β±1 encoder pulse
- Response Time: <10ms for position commands
- Maximum Update Rate: 1kHz control loop
- Memory Usage: ~26% of ATmega328P flash memory
- Motor not moving: Check power supply and wiring
- Position drift: Verify encoder connections
- Communication errors: Check baud rate and serial settings
- Compilation errors: Ensure C++14 support is enabled
- Enable debug output
- Monitor serial communication
- Check hardware connections
- Verify configuration parameters
This project is licensed under the MIT License - see the LICENSE file for details.
[Muhammet ΕΓΌkrΓΌ Demir] - Final Year Engineering Project
- Arduino community for excellent development tools
- VNH7070 documentation and support
- University advisors and project mentors
Note: This project is part of a final year engineering project and is actively under development. Features and documentation are continuously being improved.