Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BLDC Motor Speed Control Using PID in MATLAB/Simulink

1. Project Overview

This repository contains a rigorous, simulation-based engineering project for the closed-loop speed control of a Brushless DC (BLDC) motor. The project implements a continuous-time Proportional-Integral-Derivative (PID) controller architecture within MATLAB/Simulink, fully characterizing reference tracking, disturbance rejection, actuator saturation, and controller sensitivity.

2. Problem Statement

Precise speed control of BLDC motors is critical in applications ranging from robotics to industrial automation. However, high-performance control must manage nonlinear physical constraints such as actuator voltage saturation, load-torque disturbances, and integrator windup. This project addresses these challenges by designing and thoroughly analyzing a robust continuous-time PID controller under realistic electromechanical constraints.

3. Objectives

  • Formulate the linear mathematical model of the BLDC motor.
  • Design a continuous-time PID control architecture with derivative filtering.
  • Implement realistic $\pm 24\text{ V}$ actuator saturation limits.
  • Mitigate integrator windup using a clamping anti-windup configuration.
  • Evaluate the system across a broad reference-speed and load-torque envelope.
  • Validate reproducibility through a fully automated MATLAB test suite.

4. System Architecture

The closed-loop architecture operates via the following continuous-time signal flow:

Reference Speed [rad/s]
       │
       ▼
     [Error] ◄────────────────────────────────────────┐
       │                                              │
       ▼                                              │
[PID Controller] (with clamping & derivative filter)  │
       │                                              │
       ▼                                              │
 [Saturation] (±24V Limits)                           │
       │                                              │
       ▼                                              │
  [BLDC Motor] ◄──── [Disturbance Torque (TL)]        │
       │                                              │
       ▼                                              │
  Speed Feedback [rad/s] ─────────────────────────────┘

5. BLDC Motor Mathematical Model

The BLDC motor is governed by two interlinked linear differential equations:

Electrical Stator Dynamics (KVL): $$V(t) = R \cdot i(t) + L \frac{di(t)}{dt} + K_e \cdot \omega(t)$$

Electromechanical Torque Coupling: $$T_e(t) = K_t \cdot i(t)$$

Mechanical Rotor Dynamics (Newton's Second Law): $$J \frac{d\omega(t)}{dt} = T_e(t) - B \cdot \omega(t) - T_L(t)$$

Combining these yields the open-loop transfer function (from armature voltage to rotor speed): $$G(s) = \frac{10^7}{s^2 + 1001s + 501000}$$

6. Motor Parameters

The physical constants utilized in the mathematical model are defined in scripts/params.m:

  • $R$ (Armature Resistance): $0.5,\Omega$
  • $L$ (Armature Inductance): $0.5,\text{mH}$
  • $K_t$ (Torque Constant): $0.05,\text{N}\cdot\text{m/A}$
  • $K_e$ (Back-EMF Constant): $0.05,\text{V}\cdot\text{s/rad}$
  • $J$ (Rotor Inertia): $10^{-5},\text{kg}\cdot\text{m}^2$
  • $B$ (Viscous Friction): $10^{-5},\text{N}\cdot\text{m}\cdot\text{s/rad}$

7. PID Controller Design

A parallel continuous-time PID controller was designed with the following baseline gains:

  • $K_p$ (Proportional): $0.0100$
  • $K_i$ (Integral): $10.0000$
  • $K_d$ (Derivative): $0.001000$
  • $N$ (Filter Coefficient): $100\text{ rad/s}$

These parameters provide a validated operating point satisfying transient constraints ($< 25\text{ ms}$ rise time, $<3%$ overshoot, $0.0000%$ steady-state error).

8. Derivative Filtering

The derivative term incorporates a first-order low-pass filter ($N = 100\text{ rad/s}$) to suppress high-frequency noise amplification and introduce targeted transient damping, ensuring a smooth control signal.

9. Actuator Saturation and Anti-Windup

The project strictly models actuator saturation at $\pm 24\text{ V}$. During initial step acceleration, the linear PID algorithm demands a voltage exceeding this limit, resulting in actual applied voltage clipping.

To mitigate this, the controller uses a clamping anti-windup configuration. Under the tested saturation conditions, the clamping configuration limited integral accumulation during saturation, preventing delayed recovery and ensuring the measured steady-state error remained $0.0000%$.

10. Closed-Loop Simulation

The model is constructed in Simulink (models/bldc_cl_model.slx) and simulated using the continuous variable-step ode45 solver, providing a high-fidelity evaluation of the closed-loop system dynamics.

11. Baseline Performance

Under a nominal reference step of $100\text{ rad/s}$, the simulated baseline transient response yielded:

  • Rise time ($10\text{--}90%$): $\approx 23.35\text{ ms}$
  • Settling time ($2%$ band): $\approx 61.18\text{ ms}$
  • Percentage Overshoot: $\approx 2.83%$
  • Steady-State Error: $0.0000%$
  • Peak Control Voltage: $24.00\text{ V}$
  • Saturation Duration: $\approx 20.14\text{ ms}$

12. Reference Tracking

The dynamic scaling of the closed-loop system was evaluated across a multi-setpoint envelope to verify linearity. The tested reference sweep included:

  • $50, 75, 100, 125, 150, 200\text{ rad/s}$

Measured results confirmed that the percentage overshoot and steady-state error ($\le 0.001%$) scaled consistently across the tested points, while rise times tracked predictable limits dictated by the hard $24\text{ V}$ saturation ceiling.

13. Disturbance Rejection

The controller's robustness against external load variations was evaluated using a bidirectional step disturbance sweep spanning:

  • $-0.015, -0.010, 0, +0.005, +0.010, +0.015, +0.020, +0.025, +0.030\text{ N}\cdot\text{m}$

For the authoritative baseline disturbance ($T_L = 0.015\text{ N}\cdot\text{m}$ applied at $0.3\text{ s}$), the measured speed deviation (dip) was $\approx 1.39%$, with a final steady-state error recovering to $0.0000%$. Speed deviation increased approximately proportionally across the tested load-torque cases.

14. PID Sensitivity / Robustness Analysis

Parametric sweeps evaluating $\pm 25%$ variations in the isolated $K_p, K_i,$ and $K_d$ gains were conducted to characterize sensitivity. Retuning was not indicated by the measured results within the tested operating envelope, as the baseline gains maintained stable dynamics without high-frequency ringing.

15. Automated Validation

An automated test suite (scripts/run_all_tests.m) programmatically verifies system stability and numerical tolerances. The suite executes 10 distinct checks covering parameters, model integrity, transient metrics, anti-windup clamping, and disturbance recovery.

All automated validation checks passed, matching authoritative baseline evidence without regression.

16. Key Results

Metric Measured Result
Rise Time ($10\text{--}90%$) $23.35\text{ ms}$
Settling Time ($2%$ band) $61.18\text{ ms}$
Overshoot $2.83%$
Steady-State Error $0.0000%$
Baseline Disturbance Dip $1.39%$
Actuator Limit $\pm 24.00\text{ V}$
Saturation Duration $20.14\text{ ms}$
Reference-Speed Range $50\text{--}200\text{ rad/s}$
Load-Torque Range $-0.015\text{ to }+0.030\text{ N}\cdot\text{m}$

17. Repository Structure

Project1/
├── README.md
├── LICENSE
├── .gitignore
├── models/                     # Simulink (.slx) plant and closed-loop models
├── scripts/                    # Execution scripts and automated test suite
├── results/                    # Validated experimental CSV data and test logs

  • models/: The core continuous-time architecture.
  • scripts/: The master validation suite and component analysis scripts.
  • results/: The quantitative historical outputs and CSV datasets verifying performance.

18. Limitations

The results documented in this repository are subject to the following simulation constraints:

  • Simulation-Only Model: Continuous-time MATLAB/Simulink simulation utilizing the adaptive ode45 solver.
  • No Hardware Verification: The project does NOT include physical BLDC motor testing, STM32 MCU deployment, or Hardware-In-the-Loop (HIL) validation.
  • Idealized Parameters: Plant parameters are fixed, excluding real-world phenomena like temperature drift or magnetic saturation.
  • No Switching Harmonics: The inverter is modeled as a continuous voltage source; PWM switching harmonics, deadtime distortion, and inverter hardware limits are not simulated.
  • Ideal Sensing: Speed feedback is assumed instantaneous and noise-free, lacking encoder quantization or sensor noise validation.

19. Author

Developed as an engineering demonstration of applied continuous-time control theory in MATLAB/Simulink.

About

MATLAB/Simulink BLDC motor speed-control system using PID control, with anti-windup, reference tracking, disturbance rejection, and automated validation.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages