Skip to content

Latest commit

 

History

History
74 lines (44 loc) · 2.53 KB

File metadata and controls

74 lines (44 loc) · 2.53 KB

Embedded-FOC-Library

A lightweight, modular C library for Field Oriented Control (FOC) of PMSM and BLDC motors. Featuring Clarke/Park transforms, PI controllers, Space Vector Modulation (SVM), and Sliding Mode Observer (SMO) for sensorless applications.

Embedded FOC Library

License Platform

A professional, high-performance C library for implementing Field Oriented Control (FOC) on microcontrollers. This library is designed to be modular, easy to integrate, and optimized for MCUs with Floating Point Units (FPU).

image

🚀 Features

  • Mathematical Transforms:
    • Optimized Clarke & Park Transforms.
    • Inverse Park Transform for voltage synthesis.
  • Control & Modulation:
    • PID/PI Controller with Anti-Windup (Clamping method).
    • Space Vector Modulation (SVM) for efficient DC bus utilization.
  • Sensorless Estimation:
    • Sliding Mode Observer (SMO) for position and speed estimation.
  • Hardware Agnostic: Written in standard C, easily portable to STM32, ESP32, or TI C2000.

🛠 Implementation Details

Sliding Mode Observer (SMO)

The sensorless algorithm is based on state-of-the-art research papers:

  1. Contributions to Discrete-Time Sliding Mode Observers for Permanent Magnet Synchronous Motor Drive Systems (IEEE).
  2. A High-Speed Sliding-Mode Observer for the Sensorless Speed Control of a PMSM (IEEE).

Mathematical Optimization

The library uses float types and is optimized for ARM CMSIS-DSP compatible environments. It prioritizes execution speed while maintaining high numerical precision.

📂 Project Structure

  • foc.c / foc.h: Core algorithms and transforms.
  • main.c: Example integration with STM32 HAL.

🏁 Getting Started

  1. Include foc.h in your project.
  2. Initialize the structures using the provided default macros:
    CLARKE_TYPEDEF clarke = CLARKE_DEFAULT;
    PI_TYPEDEF pi_q = PI_DEFAULT;
    

3.Call the function pointers within your PWM or ADC interrupt:

clarke.clarke_fcn_ptr(&clarke);

⚠️ Requirements

Microcontroller with FPU (Floating Point Unit) is highly recommended.

If using low-end MCUs, consider converting to Fixed-Point arithmetic.

👤 Author

Mohammad Hosseini

Embedded Systems & Motor Control Specialist

www.esfdrive.ir

📄 License This project is licensed under the MIT License