Link
On this page

Supported microcontrollers

Arduino SimpleFOClibrary supports over 20 different microcontroller architectures, giving you flexibility to choose the best MCU for your specific project needs.

Supported Families

The main families supported off-the-shelf are:

And we continue extending support to more architectures! πŸ˜ƒ


Choosing the Right Microcontroller

There are three main parameters when choosing the microcontroller for your project:

  1. Processing power (clock speed, architecture, etc.) - this will determine the performance of the FOC algorithm and the maximum speed of your motor.
  2. PWM generation capabilities - this will determine the number of motors you can control and the control modes you can use.
  3. ADC sensing capabilities - this will determine the current sensing options you have for your project.

1. Processing power

When it comes to the processing power, the rule of thumb is:

  • The higher the clock speed the better.
  • Aim for the FOC execution time of loopFOC() to be above 1kHz (ideally above 5kHz) depending on the motor and sensor combination you are using.

This table gives you a rough comparison of the performance of different MCUs with this library. It gives an estimated loop frequency (loopFOC() + move()) for one motor and sensor combination (BLDC + sensor) that you can expect to achieve with the library on each MCU. The values are approximate and can vary depending on the specific board, motor, sensor, and other factors.

MCU Family Clock Bit Performance Expected loop frequency Example boards Recommended For
STM32 H7 480MHz 32 🟒 Prime >10kHz Nucleo-144 High-performance, multi-motor systems, High-end solution
STM32 F4/G4/F7 150-220 32 🟒 Excellent >5kHz Nucleo-64, Nucleo-144, B-G431B-ESC1 Best overall choice for FOC control
STM32 F1 72Hz 32 🟒 Good 1-5kHz Bluepill, Blackpill Budget-friendly, good performance (⚠️ sometimes limited in memory)
STM32 L4 80MHz 32 🟒 Good 1-5kHz Nucleo-64 Low-power applications, good performance
Teensy 4.x 600MHz 32 🟒 Prime >10kHz Teensy 4.0, 4.1 High-performance, High-end solution, comparable to STM32H7
(limited low-side ADC support)
Teensy 3.x 72-180MHz 32 🟒 Good 1-5kHz Teensy 3.2, 3.5, 3.6 Robotics, reliable real-time control
ESP32, ESP32-S2/S3 240MHz 32 🟒 Excellent >5kHz ESP32 DevKit, ESP3S2 QtPy Great performance, IoT integration, Dual-Core
ESP32-C2/C3/C6 120-160MHz 32 🟒 Good 1-5kHz ESP3C6 Xiao, ESP3C6 Xiao Good performance
Much worse than ESP32 or ESP32-S2/3 though
RP2040 (Pico) 125MHz 32 🟒 Good 5-10kHz Raspberry Pi Pico Dual-core projects, cost-effective
Arduino DUE 84MHz 32 🟑 Fair 1-5kHz Arduino DUE 32-bit Arduino, good option if you already have one on hand
SAMD51 120MHz 32 🟒 Good 5-10kHz Adafruit Feather M4, SparkFun Thing Plus, Metro M4 Good performance, not common
SAMD21 48MHz 32 🟑 Fair 1-5kHz Nano 33 IoT, QtPy SAMD21, XIAO SAMD21 Budget-friendly, OK performance (⚠️ sometimes limited in memory)
Renesas 48MHz 32 🟑 Fair 1-5kHz Arduino UNO R4 Modern Arduino, not the best performance but a significant upgrade over the AVR-based UNO
Silabs MGM240S 78MHz 32 🟒 Good 5-10kHz Arduino Nano Matter Matter/IoT integration (v2.4.0+)
AVR (8-bit) 16MHz 8 πŸ”΄ Limited <1kHz Arduino UNO, Arduino MEGA, Arduino Nano, Arduino Leonardo Learning FOC, simple single-motor projects
ESP8266 80MHz 32 πŸ”΄ Limited <1kHz ESP8266 NodeMCU, Wemos D1 Mini Good for IoT projects, very limited real-time performance

⚠️ Arduino UNO/MEGA Encoder Limitation

For Arduino UNO/MEGA with encoders, keep total system pulses under 20,000 pulses/second to avoid execution issues.

Example Calculation

With a 10,000 CPR encoder: Maximum motor speed = 120 RPM (2 rotations/second)

Recommendation: Use magnetic sensors (SPI/I2C) instead of encoders with 8-bit Arduino boards.

Performance Guidelines:

  • βœ… Optimal: Loop time < 0.5ms (>2kHz)
  • ⚠️ Acceptable: Loop time 1-4ms (250-1000Hz)
  • ❌ Poor: Loop time > 4ms (<250Hz)

Multi-Motor Systems: If you need to control multiple motors, remember to account for the total system load. Divide the expected loop frequency by the number of motors to ensure you stay within performance limits. The same performance guidelines apply.


2. PWM Generation Capabilities

Most supported MCUs can generate all PWM modes (2, 3, 4, and 6 PWM) with configurable frequencies. 2 and 4 PWM modes are used Stepper drivers (Stepper motors), while 3 and 6 PWM modes are used for BLDC drivers (BLDC motors and Steppers using hybrid control).

MCU 2 PWM 4 PWM 3 PWM 6 PWM Frequency Config
Arduino (8-bit) βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ (4kHz or 32kHz)
STM32 βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ
ESP32 (MCPWM/LEDC) βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ
Teensy βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ
SAMD21/51 βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ
Raspberry Pi Pico βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ
Renesas (UNO R4) βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ
Arduino Nano Matter βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ
nRF52 βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ
Arduino DUE βœ”οΈ βœ”οΈ βœ”οΈ ❌ βœ”οΈ
ESP8266 βœ”οΈ βœ”οΈ βœ”οΈ ❌ βœ”οΈ
Portenta H7 βœ”οΈ βœ”οΈ βœ”οΈ ❌ βœ”οΈ

Note: If you need 6 PWM mode (for specific drivers), avoid MCUs marked with ❌.

See the guide to choosing PWM-capable pins


3. Current Sensing (ADC) Capabilities

Most of the supported MCUs can perform inline current sensing using the ADC, which is the a very common method for FOC control. However, low-side current sensing is equaly as common for high-performance applications and is supported by a smaller subset of high-end MCUs. Make sure to check the table below if you need low-side sensing for your project.

MCU Inline Low-side High-side Notes
STM32 F1/F4/G4/L4/F7/H7 βœ”οΈ βœ”οΈ ❌ Best current sensing support
ESP32/ESP32-S3 βœ”οΈ βœ”οΈ ❌ Good ADC, dual-core advantage
Teensy 4 βœ”οΈ βœ”οΈ (one motor) ❌ High-speed ADC
SAMD21 βœ”οΈ βœ”οΈ (one motor) ❌ Limited testing
Arduino Nano Matter βœ”οΈ βœ”οΈ (one motor) βœ”οΈ (untested) Newest support (v2.4.0)
Arduino AVR (8-bit) βœ”οΈ ❌ ❌ Inline only
Arduino DUE βœ”οΈ ❌ ❌ Inline only
SAMD51 βœ”οΈ ❌ ❌ Inline only
Teensy 3 βœ”οΈ ❌ ❌ Inline only
Raspberry Pi Pico βœ”οΈ ❌ ❌ Inline only
ESP32-S2/C3 βœ”οΈ ❌ ❌ Inline only
Portenta H7 βœ”οΈ ❌ ❌ Inline only
nRF52 βœ”οΈ ❌ ❌ Inline only
Renesas (UNO R4) ❌ ❌ ❌ No current sensing yet
ESP8266 ❌ ❌ ❌ No ADC support for sensing
STM32 B-G431B-ESC1 ❌ βœ”οΈ (one motor) ❌ Dedicated ESC board

Most boards support inline current sensing. Low-side sensing is available primarily on STM32, ESP32, Teensy 4, and SAMD21.

See the guide to choosing ADC-capable pins


Quick Selection Guide

General Recommendations

  1. If possible, use STM32 - Best overall choice for FOC control
  2. ESP32 or Teensy - Excellent alternatives, each one with their own strengths and limitations
  3. Other 32-bit boards - Fine if current sensing isn’t required or not crucial for your project
  4. 8-bit Arduino - Acceptable for learning and simple single-motor projects
  5. Custom optimization - If you have specific requirements, start with what you have and optimize the library for your use case

Specific Use Cases

Best Overall Performance:

  • STM32 H7 - Top-tier performance for demanding applications and multi-motor systems
  • STM32 F4/G4/F7 - Excellent performance and features for most FOC projects

Alternative High-Performance Options with some limitations

  • Teensy 4.x - Amazing performance (comparable to STM32 H7), can handle fast multi-motor systems
    • ⚠️ limited low-side sensing support (one motor only)
  • ESP32 - Excellent for IoT/wireless projects, great performance
    • If possible, choose ESP32 or ESP32-S3 for better ADC performance and low-side sensing support
    • If using ESP32C2/C3/C6, be aware of the significantly lower CPU performance and lack of low-side sensing support
    • ⚠️ Aim for one motor with current sensing for optimal performance,
      • multi-motor systems with current sensing may require optimization and careful load management
      • multiple motors without current sensing should be fine

Budget-Friendly with Good Performance:

  • Need current sensing?
    • STM32 F1 - Best price/performance ratio (especially Bluepill/Blackpill boards)
      • ⚠️ check memory limits (use 128KB flash versions)
    • SAMD21 - Affordable with good enough performance for simple projects
      • ⚠️ check memory limits (should have more than 64kB flash)
  • Don’t need current sensing?
    • Arduino DUE - 32-bit Arduino with good performance if you already have one on hand
    • Raspberry Pi Pico (RP2040) - Dual-core capability at low cost, good for projects without current sensing
    • nRF52 - Good for low-power wireless projects without current sensing
    • SAMD51 - Good performance but less common, check availability

Other Options:

  • Arduino UNO/MEGA - Acceptable for learning and simple single-motor projects
    • ⚠️ limited performance with encoders, use magnetic sensors instead
    • ⚠️ poor current sensing capabilities (inline only, no low-side sensing)
  • ESP8266 - Good for IoT projects, very limited real-time performance, not recommended for FOC control
    • ⚠️ no ADC support for sensing, not suitable for FOC control

SimpleFOC Community

If you have ported the library to another device or need help porting to a specific platform, please visit our community forum!

You’ll find answered questions, implementation stories, and helpful community members ready to assist.