Link

Arduino Simple Field Oriented Control (FOC) project

License: MIT arduino-library-badge PlatformIO Registry status

GitHub release (latest by date) GitHub Release Date GitHub commits since tagged version GitHub commit activity (branch)

We live in very exciting times πŸ˜ƒ! BLDC motors are entering the hobby community more and more and many great projects have already emerged leveraging their far superior dynamics and power capabilities. BLDC motors have numerous advantages over regular DC motors but they have one big disadvantage, the complexity of control. Even though it has become relatively easy to design and manufacture PCBs and create our own hardware solutions for driving BLDC motors the proper low-cost solutions are yet to come. One of the reasons for this is the apparent complexity of writing the BLDC driving algorithms, Field oriented control (FOC) being an example of one of the most efficient ones. The solutions that can be found on-line are almost exclusively very specific for certain hardware configuration and the microcontroller architecture used. Additionally, most of the efforts at this moment are still channeled towards the high-power applications of the BLDC motors and proper low-cost and low-power FOC supporting boards are very hard to find today and even may not exist.
Therefore this is an attempt to:

  • 🎯 Demystify FOC algorithm and make a robust but simple Arduino library: Arduino SimpleFOClibrary
    • Support as many motor + sensor + driver + mcu combinations out there
  • 🎯 Develop modular and easy to use FOC supporting BLDC driver boards

NEW RELEASE πŸ“’: SimpleFOClibrary v2.3.4 see release

  • ESP32 MCUs extended support #414
    • Transition to the arduino-esp32 version v3.x (ESP-IDF v5.x) #387
    • New support for MCPWM driver
    • New support for LEDC drivers - center-aligned PWM and 6PWM available
    • Rewritten and simplified the fast ADC driver code (adcRead) - for low-side and inline current sensing.
  • Stepper motors current sensing support #421
    • Support for current sensing (low-side and inline) - see in docs
    • Support for true FOC control - foc_current torque control - see in docs
  • New current sense alignment procedure #422 - see in docs
    • Support for steppers
    • Much more robust and reliable
    • More verbose and informative
  • Support for HallSensors without interrupts #4224 - see in docs
  • Docs
    • A short guide to debugging of common issues - see in docs
    • A short guide to the units in the library - see in docs
  • See the complete list of bugfixes and new features of v2.3.4 fixes and PRs

Arduino SimpleFOClibrary - Read more …

License: MIT GitHub release (latest by date) GitHub Release Date

This video demonstrates the Simple FOC library basic usage, electronic connections and shows its capabilities.

Features

  • Easy install:
    • Arduino IDE: Arduino Library Manager integration
    • PlatformIO
  • Open-Source: Full code and documentation available on github
  • Goal:
    • Support as many sensor + motor + driver + current sense combination as possible.
    • Provide the up-to-date and in-depth documentation with API references and the examples
  • Easy to setup and configure:
    • Easy hardware configuration
    • Each hardware component is a C++ object (easy to understand)
    • Easy tuning the control loops
    • SimpleFOCStudio configuration GUI tool
    • Built-in communication and monitoring
  • Cross-platform:
    • Seamless code transfer from one microcontroller family to another
    • Supports multiple MCU architectures:
      • Arduino: UNO, MEGA, DUE, Leonardo, Nano, UNO R4, MKR ….
      • STM32
      • ESP32
      • Teensy
      • many more …

SimpleFOCBoards - Read more …

One of the goals of the SimpleFOCproject is to develop low-cost easy to use BLDC driver boards compatible with the SimpleFOClibraryand completely open source! Therefore, SimpleFOC team members have developed a set of boards, designed specifically for ease of use, to help you kickstart your FOC journey. In addition to being easy to use, the goal of these boards is serve as a reference design for the community to build upon. And finally, even though some of these boards are available in our shop, our docs provide a lot of documentation and step-by-step guides on how to fabricate the boards yourself.

In addition to the official boards, there are many other boards compatible with SimpleFOClibrary that you can explore, see the docs. Additionally, some other cool hardware designs have been proposed by the community. Check out our community forum for more info.

Here are some of the official boards developed by the SimpleFOC team:

SimpleFOCShield

License: MIT GitHub release (latest by date) GitHub Release Date

Features

  • DRV8313 based - datasheet
    • Power supply: 8-35V
    • Max current: 2A per phase (3Amp peak)
  • Absolute max ratings - Designed for Gimbal motors with the internal resistance >10 Ξ©s.
    • Max current: 3A,
    • Max input voltage: 35V
  • In-line current sensing: Up to 5Amps bidirectional
    • ACS712 hall current sensor
  • Integrated 8V regulator:
    • Enable/disable by soldering pads
  • Stackable: running 2 motors in the same time
  • Encoder/Hall sensors interface: Integrated 3.3kΞ© pullups (configurable)
  • I2C interface: Integrated 4.7kΞ© pullups (configurable)
  • Configurable pinout: Hardware configuration - soldering connections
  • Arduino headers: Arduino UNO, Arduino MEGA, STM32 Nucleo boards…
  • Open Source:
  • Low-cost:
    • JLCPCB production cost ~10-15€
    • Available in the shop: 15-30€

SimpleFOCMini

License: MIT GitHub release (latest by date) GitHub Release Date

Features

  • DRV8313 based - datasheet
    • Power supply: 8-35V
    • Max current: 2A per phase (3Amp peak)
  • Absolute max ratings - Designed for Gimbal motors with the internal resistance >10 Ξ©s.
    • Max current: 3A,
    • Max input voltage: 35V
  • Small size: 26x21 mm
  • Open Source:
  • Low-cost:
    • JLCPCB production cost ~3-5€
    • Available in the shop: 7-15€

A short demo video for the SimpleFOCShield (its a bit outdated but still relevant)

Find out more about the boards and how to make them yourself in the boards section.

Alternative FOC supporting projects

The focus of SimpleFOC is making the FOC simple (:D) and supporting as many motor + sensor + driver + mcu combinations as possible. If you are a bit less concerned with the firmware simplicity and don’t mind trading-off cross-platform flexibility for performance, there are several other projects out there that also use FOC and could provide a more compact, more prefromant or more robust solutions for your applications. Many of these projects are open-source and have been our inspiration from the start, especially VESC and Odrive. Make sure to check them out if you are starting your FOC journey!

P.S. None of these projects uses SimpleFOClibrary, but SimpleFOClibrary can be used as a firware for several driver boards developed in these projects.

Project Open Source Hardware Open source firmware Simple to use Low cost Power rating Stepper Support SimpleFOC support

Odrive
βœ”οΈ/(❌ from recently) βœ”οΈ/(❌ from recently) βœ”οΈ ❌ (>200$) High >50A ❌ βœ”οΈ

Vesc
βœ”οΈ βœ”οΈ βœ”οΈ ❌ (>100$) Vey High >100A ❌ βœ”οΈ

Trinamic
❌ ❌ βœ”οΈ ❌ (>200$) Low ~10A βœ”οΈ ❌

Infineon
βœ”οΈ ❌ βœ”οΈ βœ”οΈ (50$) Low ~10A ❌ ❌

FOC-Arduino-Brushless
βœ”οΈ βœ”οΈ ❌ βœ”οΈ (Price ?) Low ~10A ❌ ? (not tested)

Tinymovr R5.2
❌ βœ”οΈ βœ”οΈ ❌ (~90$) High (~30A) ❌ ? (not tested)

Tinymovr M5.2
❌ βœ”οΈ βœ”οΈ ❌ (~90$) Low (~6Amps) ❌ ? (not tested)

Mjbots moteus
βœ”οΈ βœ”οΈ βœ”οΈ ❌ (70-160$) Mid (20Amps)
to
High (100Amps)
❌ ? (not tested)


Open robotics initiative
MicroDriver
βœ”οΈ βœ”οΈ ❌ βœ”οΈ(~50$) Mid (~20Amps) ❌ ? (not tested)


SOLO
❌ ❌ βœ”οΈ ❌(70$-600$) Mid (~16Amps)
to
Very high (~120Amps)
❌ ❌
⚠️ This list is certainly not exhaustive, feel free to contribute to extending/completing/correcting it!