This project presents a complete DC motor speed control system using MATLAB/Simulink for modeling and simulation, together with an STM32 implementation package for embedded motor control. The work focuses on understanding the dynamic behavior of a DC motor, generating PWM-based actuation, and designing a closed-loop control structure to regulate motor speed.
The repository includes:
- A MATLAB parameter file for the DC motor model
- Simulink models for motor modeling, PWM control, and closed-loop speed control
- An STM32 archive containing the embedded implementation files
- A final project report documenting the design and results
The main objectives of this project are:
- Model the electrical and mechanical behavior of a DC motor
- Simulate motor response in MATLAB/Simulink
- Design PWM-based speed control
- Implement closed-loop feedback control for speed regulation
- Prepare the project for embedded deployment using STM32
- Compare and document system behavior through a final report
A DC motor speed control system adjusts the input voltage applied to the motor in order to control its angular speed. In practical systems, this is commonly achieved using Pulse Width Modulation (PWM) and a feedback controller.
The typical closed-loop structure is:
Reference Speed ──► Controller ──► PWM Driver ──► DC Motor ──► Speed Output
▲ │
└────────────────────── Feedback Sensor ◄────────────────┘
The controller compares the desired speed with the measured speed and adjusts the PWM duty cycle to reduce the speed error.
The MATLAB parameter file defines the main motor and load parameters used in the simulation:
| Parameter | Meaning | Value |
|---|---|---|
Va |
Armature voltage | 240 V |
Ra |
Armature resistance | 0.78 Ω |
La |
Armature inductance | 0.016 H |
B |
Viscous friction coefficient | 0.02 |
J |
Moment of inertia | 5 |
T1 |
Load torque | 30 |
K |
Motor constant | 1.4 |
These parameters are used to describe the motor dynamics and evaluate its speed response under different control conditions.
A simplified separately excited DC motor can be described using the following equations:
Where:
Vais the armature voltageRais the armature resistanceLais the armature inductanceiais the armature currentebis the back electromotive forceJis the motor inertiaBis the viscous friction coefficientKis the motor constantωis the angular velocityTLis the load torque
The repository also includes stm32.rar, which contains files related to the embedded implementation of the motor control system.
The STM32 part is intended to connect the control concept from simulation to a microcontroller-based environment. Depending on the extracted project structure, it may include configuration files, source code, peripheral setup, PWM generation, or feedback processing.
Suggested STM32 workflow:
- Extract
stm32.rar - Open the extracted project in STM32CubeIDE or a compatible IDE
- Check the configured peripherals, especially PWM timer outputs and feedback input channels
- Build the project
- Flash it to the selected STM32 board
- Test the motor driver and feedback loop carefully with a suitable power supply and motor driver circuit
The project demonstrates how a DC motor speed can be controlled using a feedback-based control structure. The expected outcomes include:
- Simulated DC motor dynamic response
- PWM signal generation for motor actuation
- Closed-loop speed tracking
- Reduced speed error compared with open-loop operation
- Embedded implementation path using STM32
| Category | Tools / Concepts |
|---|---|
| Modeling | MATLAB, Simulink |
| Control | Closed-loop control, feedback control, PWM |
| Embedded System | STM32 |
| Electrical System | DC motor model, armature circuit, back EMF |
| Documentation | Final project report |
Through this project, the following topics are practiced:
- DC motor dynamic modeling
- Electrical and mechanical system equations
- PWM-based motor actuation
- Closed-loop speed regulation
- MATLAB/Simulink simulation workflow
- Embedded control implementation using STM32
- Control system documentation and reporting
Mohammad Barabadi
GitHub: @mohammadbrd
Linkedin: @mohammadbrd
No license file is currently included in this repository. If you plan to reuse or distribute this project, please contact the author or add an appropriate open-source license.