Arduino Simple Field Oriented Control (FOC) library v2.1
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 + current sense + driver + mcu combinations out there
- 🎯 Develop a modular FOC supporting BLDC driver boards:
- Low-power gimbal driver (<5Amps) : Arduino SimpleFOCShield .
- NEW 📢: Medium-power BLDC driver (<30Amps): Arduino SimpleFOCPowerShield .
- See also @byDagor’s fully-integrated ESP32 based board: Dagor Brushless Controller
NEW RELEASE 📢: SimpleFOClibrary v2.1
- Initial current sensing support
🎉 - See in docs
- Inline current sensors
- adaptive zero finding and shunt direction
- Implemented real torque control - See in docs
- using voltage
- using current magnitude (one current)
- using FOC currents ( d-q currents ) - real foc control
- Support SVPWM full implementation d+q axis
- Simplified sensor implementation
📢 - See in docs
- For new sensor implementation only one function necessary
getAngle()
- New MCU support - See in docs
- Support for Arduino DUE - everything except the 6PWM mode
- Support for ATMega328pb
- Support for samd21 boards by @runger1101001
- pull request #56
- Upgrade of the HallSensor implementation by @owennewo
- bugfix for the Teensy boards ( setting 3pwm )
- extended support for 2PWM stepper drivers - by @zjor
- included F macro for shrinking string memory usage - moved to programming memory
- disable phase support for 3pwm driver
- not yet for 6pwm
- rewritten
initFOC()
- can be skipped and outputs much more info
- align sensor: direction + zero offset + pole pair check
- align current sense
- sensor offset supported (
motor.sensor_offset
)- refactored motor commands interface - See in docs
- much more flexible and easy to extend
- very easy to add new commands and function callbacks
- implemented motor+pid+lpf commands of-the-shelf
- Added step/dir interface - See in docs
- integrated as an optional communication channel
BEWARE
📢 slight API changes included - See in docs
ControlType
renamed intoMotionControlType
ControlType::voltage
does not exist any more now -MotionControlType::torque
Arduino SimpleFOClibrary v2.1
This video demonstrates the Simple FOC library basic usage, electronic connections and shows its capabilities.
Features
- Arduino compatible:
- Arduino library code
- Arduino Library Manager integration
- Open-Source: Full code and documentation available on github
- Easy to setup and configure:
- Easy hardware configuration
- Easy tuning the control loops
- Modular:
- Supports as many sensors, BLDC motors and driver boards as possible
- Supports multiple MCU architectures:
- Plug & play: Arduino SimpleFOCShield
Arduino SimpleFOCShield v2.0.3
Features
- Plug & play: In combination with Arduino SimpleFOClibrary - github
- Low-cost: Price of €15 - Check the pricing
- In-line current sensing: Up to 3Amps/5Amps bidirectional
- configurable: 3.3Amps - 3.3V adc, 5Amps - 5V adc
- Integrated 8V regulator:
- Enable/disable by soldering pads
- Max power 120W - max current 5A, power-supply 12-24V
- Designed for Gimbal motors with the internal resistance >10 Ωs.
- 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: Fully available fabrication files - how to make it yourself
If you are interested in this board as a product, find more information on this link: Arduino SimpleFOCShield
Alternative FOC supporting projects
These are just a few of the alternative FOC supporting projects which provide hardware and software solutions.
Odrive | Trinamic | Infineon | FOC-Arduino-Brushless |
---|---|---|---|
✔️ Open Source | ❌ Open Source | ✔️ Open Source(recently) | ✔️ Open Source |
✔️Simple to use | ✔️ Simple to use | ✔️Simple to use | ❌ Simple to use |
❌ Low cost ($100) | ❌ Low cost ($100) | ✔️Low cost ($40) | ✔️ Low cost |
❌ Low power (>50A) | ✔️ Low power | ✔️ Low power | ✔️ Low power |
❌ Stepper support | ❌ Stepper support | ❌ Stepper support | ❌ Stepper support |