How eferu/bldc-motor-control-foc works
This repository is a MATLAB/Simulink BLDC motor field-oriented-control project, with generated fixed-point C intended for real-time deployment. The main workflow accepts Hall and phase-current measurements plus control inputs, estimates rotor state, selects a control type and mode, computes motor phase outputs, and reports diagnostics. The README also documents the controller’s Commutation and Sinusoidal options, Speed/Voltage/Torque modes, and diagnostics. The graph reflects documented architecture and sampled generated-code interfaces; internal Simulink signal routing is not fully shown in the excerpts.
Main entry points: BLDC_controller.c Generated Controller · BLDCmotor_FOC_R2017b_fixdt.slx Simulink Controller · rtwtypes.h Fixed-Width Types · BLDC_controller_data.c Controller Parameters
Components 20
FOC Control
- Rotor Estimation
BLDC_controller_ert_rtw/BLDC_controller.c - Motor Diagnostics
BLDC_controller_ert_rtw/BLDC_controller.c - Control Manager
BLDC_controller_ert_rtw/BLDC_controller.c - FOC Algorithm
BLDC_controller_ert_rtw/BLDC_controller.c - Control Type Manager
BLDC_controller_ert_rtw/BLDC_controller.c
Generated Runtime
- Generated Controller
BLDC_controller_ert_rtw/BLDC_controller.c - I/O and State Types
BLDC_controller_ert_rtw/BLDC_controller.h - Controller Parameters
BLDC_controller_ert_rtw/BLDC_controller_data.c - ERT Entry Point
BLDC_controller_ert_rtw/ert_main.c - Fixed-Width Types
BLDC_controller_ert_rtw/rtwtypes.h
Modeling and Parameters
- Simulink Controller
BLDCmotor_FOC_R2017b_fixdt.slx - Simulated Motor Plant
01_Libraries/02_Plant - Controller Library
01_Libraries/01_Controller/BLDC_controller_Lib.slx - Parameter Table Tools
03_CreateParamTable/create_tableParamType.m - Controller Webview
docs/index.html
Archived Utilities
- Archived Low-Pass Filter
99_RecycleBin/Filter_fixdt/filtLowPass_ert_rtw_sFix32En16/filtLowPass.c - Archived Mixer
99_RecycleBin/Mixer_fixdt/mixer.c - Archived Rate Limiter
99_RecycleBin/RateLimiter_fixdt/rateLimiter.c
Other components
- Control Inputs
- BLDC Motor
Connections 21
- Control Inputs → Generated Controller: sets targets
README.md - BLDC Motor → Generated Controller: provides measurements
- Generated Controller → BLDC Motor: drives phases
- Generated Controller → Rotor Estimation: estimates state
README.md - Generated Controller → Motor Diagnostics: detects faults
README.md - Generated Controller → Control Manager: manages modes
README.md - Generated Controller → FOC Algorithm: computes control
README.md - Generated Controller → Control Type Manager: selects type
README.md - ERT Entry Point → Generated Controller: initializes runtime
BLDC_controller_ert_rtw/ert_main.c - ERT Entry Point → Controller Parameters: sets parameters
BLDC_controller_ert_rtw/ert_main.c - Generated Controller → I/O and State Types: uses interface
BLDC_controller_ert_rtw/BLDC_controller.c - Generated Controller → Fixed-Width Types: uses types
- Controller Parameters → I/O and State Types: defines defaults
BLDC_controller_ert_rtw/BLDC_controller_data.c - Simulink Controller → Generated Controller: generates code
README.md - Simulink Controller → Controller Library: uses library
- Simulink Controller → Simulated Motor Plant: simulates against
- Parameter Table Tools → Controller Parameters: supports tuning
- Controller Webview → Simulink Controller: presents model
README.md - Archived Low-Pass Filter → Fixed-Width Types: includes types
- Archived Mixer → Fixed-Width Types: includes types
- Archived Rate Limiter → Fixed-Width Types: includes types