How sguan-zhouqing/sguanfoc_library works
SguanFOC is a pure-C motor-control library for MCU-based brushless-motor field-oriented control. The documented workflow configures a control mode and motor parameters, then application main-loop and interrupt hooks run initialization/communications, high-frequency current/angle/PWM work, and low-frequency status and fault handling. The repository preserves several float/Q31 and sensored/sensorless releases plus a v4 modular redesign. The v3.1.0 algorithm branches are documented in the README; where their internal call wiring was not excerpted, edges are documented or left unasserted.
Main entry points: SguanFOC.c FOC Core · Sguan_Transfer.c Transfer Modules · Sguan_printf.c JustFloat Serial · UserData_Parameter.h Motor Parameters
Components 23
FOC Runtime
- FOC Core
SguanFOC库v3.1.0(无感foc,浮点运算,进阶)/SguanFOC.c - Motor State
SguanFOC库v3.1.0(无感foc,浮点运算,进阶)/Sguan_MotorStatus.c - Transforms Math
SguanFOC库v3.0.0(有感foc,浮点运算,初阶)/Sguan_math.c - Sensored Q31
SguanFOC库v3.0.1(有感foc,Q31定点,初阶)/SguanFOC.c - Sensorless Q31
SguanFOC库v3.1.1(无感foc,Q31定点,进阶)/SguanFOC.c
Control Algorithms
- PWM Modulation
SguanFOC库v3.1.0(无感foc,浮点运算,进阶)/Sguan_SVPWM.c - Loop Controllers
SguanFOC库v3.1.0(无感foc,浮点运算,进阶)/Sguan_PID.c - Advanced Control
SguanFOC库v3.1.0(无感foc,浮点运算,进阶) - Motor Optimization
SguanFOC库v3.1.0(无感foc,浮点运算,进阶)/Sguan_Optimize.c - Signal Filters
SguanFOC库v3.1.0(无感foc,浮点运算,进阶)/Sguan_Filter.c
Sensing And Estimation
- HFI Injection
SguanFOC库v3.1.0(无感foc,浮点运算,进阶)/Sguan_HFI.c - SMO Observer
SguanFOC库v3.1.0(无感foc,浮点运算,进阶)/Sguan_SMO.c - NLFO Observer
SguanFOC库v3.1.0(无感foc,浮点运算,进阶)/Sguan_NLFO.c - Hall And Identify
SguanFOC库v3.1.0(无感foc,浮点运算,进阶)
Configuration And Interfaces
- Motor Parameters
SguanFOC库v3.1.0(无感foc,浮点运算,进阶)/UserData_Parameter.h - Hardware Hooks
SguanFOC库v3.1.0(无感foc,浮点运算,进阶)/UserData_Function.h - JustFloat Serial
SguanFOC库v3.1.0(无感foc,浮点运算,进阶)/Sguan_printf.c
Modular v4
- Transfer Modules
SguanFOC库v4.0.0(高度自由模块化foc,终阶)/Sguan_Transfer.c - Math Services
- State Management
- Modbus Transfer
- Unit Integration
Other components
- MCU Application
Connections 23
- MCU Application → FOC Core: calls task loops
- MCU Application → Hardware Hooks: implements hooks
- MCU Application → JustFloat Serial: feeds serial data
- Motor Parameters → FOC Core: configures modes
SguanFOC库v3.1.0(无感foc,浮点运算,进阶)/SguanFOC.c - FOC Core → Motor State: runs low loop
- FOC Core → Loop Controllers: runs current control
- FOC Core → PWM Modulation: generates PWM
- FOC Core → HFI Injection: supports HFI
- FOC Core → SMO Observer: supports SMO
- FOC Core → NLFO Observer: supports NLFO
- FOC Core → Hall And Identify: supports sensing
SguanFOC库v3.1.0(无感foc,浮点运算,进阶)/SguanFOC.c - FOC Core → Motor Optimization: supports optimization
- FOC Core → Advanced Control: supports advanced control
SguanFOC库v3.1.0(无感foc,浮点运算,进阶)/SguanFOC.c - FOC Core → Signal Filters: supports filtering
- FOC Core → Transforms Math: uses transforms
- FOC Core → JustFloat Serial: provides serial loop
- Unit Integration → Transfer Modules: integrates modules
- Transfer Modules → Math Services: uses math services
SguanFOC库v4.0.0(高度自由模块化foc,终阶)/Sguan_Transfer.c - State Management → Unit Integration: uses situation unit
- Transfer Modules → Unit Integration: uses patch unit
- MCU Application → Sensored Q31: selects release
- MCU Application → Sensorless Q31: selects release
- Unit Integration → Modbus Transfer: integrates communications