No license yet
MCDGF Self-Balancing Car
Wheeled 路 Intermediate
- Score
- Buildability 50 out of 100
- Cost
- Not stated
Software
From github.com/simplefoc/Arduino-FOC (opens in a new tab)
An Arduino-compatible library implementing Field Oriented Control for controlling brushless DC and stepper motors across many microcontroller families.
Checked on GitHub on 29 Nov 2026.
Read by Robotheca from LICENSE (opens in a new tab) (MIT) at commit b3d8f39 (opens in a new tab), on 16 Oct 2026.
Robotheca's summary of the project's documents, not the creator's words.
The robots on Robotheca that use it or can run it, each with how the link was found.
No license yet
Wheeled 路 Intermediate
Found by Robotheca in Code/BLE-ESP32-BalanceCar/platformio.ini (opens in a new tab)
How to install it, in the creator's words: The project's website (opens in a new tab)
Robotheca doesn't review code. Read it before running it.
Robotheca never hosts the code: each link goes to the creator's own page.
The creator's own README, copied as written: README.md by @simplefoc, at commit b3d8f39, under MIT (opens in a new tab). The original on GitHub (opens in a new tab).
based on the Arduino IDE and PlatformIO
(opens in a new tab) (opens in a new tab) (opens in a new tab) (opens in a new tab) (opens in a new tab) (opens in a new tab) (opens in a new tab)
(opens in a new tab) Image: PlatformIO Registry (opens in a new tab) (opens in a new tab) (opens in a new tab) Image: status (opens in a new tab) (opens in a new tab)
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. These 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 have been challenging to develop. One of the reasons for this is the apparent complexity of writing the driving algorithms, Field Oriented Control (FOC) being one of the most efficient ones. The solutions that can be found online are almost exclusively very specific for certain hardware configurations and microcontroller architectures. Similar to BLDCs, Stepper motors can hugely benefit from FOC control, but the solutions for FOC controlled stepper motors are even more scarce.
Therefore this is an attempt to:
NEW RELEASE 馃摙 : SimpleFOClibrary v2.4.0
- STM32
- Added support for ADC reads in addition to Lowside current sense #506 (opens in a new tab)
- Added support for multiple motors low-side CS (one per ADC) with ADC current sensing #503 (opens in a new tab)
- BG341 low-side current sense sync was lost in v2.3.5 - fixed #482 (opens in a new tab)
- ESP32
- Many ESP32 safety optimisations by @uLipe (opens in a new tab): #490 (opens in a new tab),#491 (opens in a new tab),#492 (opens in a new tab),#493 (opens in a new tab),#495 (opens in a new tab)
- Better ADC-Timer alignement for more stable current sensing See this commit (opens in a new tab)
- Now compiles for all v3.x arduino-esp32 versions (v2.3.5 was compatible with v3.2.x)
adcReadsmall refactor - no more magic numbers- Others
- Teensy4 support for phase state setting #498 (opens in a new tab) by @Ragiton (opens in a new tab)
- Added support for Arduino Nano Matter board by @silabs-szabog (opens in a new tab) : #485 (opens in a new tab)
- Major New features
- Add current and voltage feed forward terms to motor classes by @Copper280z (opens in a new tab) in #454 (opens in a new tab)
- Velocity Calculation rework by @Copper280z (opens in a new tab) in #45 (opens in a new tab)
- Motion control - docs (opens in a new tab)
- Added
custommotion control mode - see in docs (opens in a new tab) and in examples (opens in a new tab)- Added
angle_nocascadecontrol mode for position control without velocity cascade - see in docs (opens in a new tab) - #384 (opens in a new tab)- Now all the closed and open loop modes can be used with any torque control modes (voltage and current)
- Ex.
velocity_openloopwithfoc_currenttorque control- Torque control - docs (opens in a new tab)
- Added
estimated_currenttorque control mode for model-based current estimation without current sensing - see in docs (opens in a new tab)- Now we can easily switch between voltage and estimated current control
- Docs updates - see docs (opens in a new tab)
- Write the code page updated - see docs (opens in a new tab)
- Better step-by-step setup guides - see docs (opens in a new tab)
- New motion control documentation - see docs (opens in a new tab)
- New torque/FOC control documentation - see docs (opens in a new tab)
- Theory corner updated and extended - see docs (opens in a new tab)
- Library source updated and extended - see docs (opens in a new tab)
- Practical guides updated and extended - see docs (opens in a new tab)
- Motor parameter measurement guide - see docs (opens in a new tab)
- PID tuning guides - see docs (opens in a new tab)
- Examples
align_current_sense.inoexample added to theexamples/utils/current_sense_testallowing to verify the alignment between the driver and the current sense phases- Changelog
- See the release notes for more details: see release (opens in a new tab)
- See the milestones: v2.3.6 (unreleased) (opens in a new tab) and v2.4.0 (opens in a new tab)
Image (opens in a new tab) (opens in a new tab)
This video is a bit outdated but it demonstrates the SimpleFOClibrary basic usage, electronic connections and shows its capabilities.
Full API code documentation as well as example projects and step by step guides can be found on our docs website (opens in a new tab).

Depending on if you want to use this library as the plug and play Arduino library or you want to get insight in the algorithm and make changes there are two ways to install this code.
The simplest way to get hold of the library is directly by using Arduino IDE and its integrated Library Manager.
Tools > Manage Libraries....Simple FOC library and install the latest version.File > Examples > Simple FOC.Clone or Download > Download ZIP.Arduino Libraries folder. Windows: Documents > Arduino > libraries.File > Examples > Simple FOC.cd #Arduino libraries folder
git clone https://github.com/simplefoc/Arduino-FOC.git
File > Examples > Simple FOC.For all the questions regarding the potential implementation, applications, supported hardware and similar please visit our community forum (opens in a new tab) or our discord server (opens in a new tab).
It is always helpful to hear the stories/problems/suggestions of people implementing the code and you might find a lot of answered questions there already!
Please do not hesitate to leave an issue if you have problems/advices/suggestions regarding the code!
Pull requests are welcome, but let's first discuss them in community forum (opens in a new tab)!
If you'd like to contribute to this project but you are not very familiar with github, don't worry, let us know either by posting at the community forum , by posting a github issue or at our discord server.
If you are familiar, we accept pull requests to the dev branch!
This is a simple Arduino code example implementing the velocity control program of a BLDC motor with encoder.
NOTE: This program uses all the default control parameters.
#include <SimpleFOC.h>
// BLDCMotor( pole_pairs )
BLDCMotor motor = BLDCMotor(11);
// BLDCDriver( pin_pwmA, pin_pwmB, pin_pwmC, enable (optional) )
BLDCDriver3PWM driver = BLDCDriver3PWM(9, 10, 11, 8);
// Encoder(pin_A, pin_B, CPR)
Encoder encoder = Encoder(2, 3, 2048);
// channel A and B callbacks
void doA(){encoder.handleA();}
void doB(){encoder.handleB();}
void setup() {
// initialize encoder hardware
encoder.init();
// hardware interrupt enable
encoder.enableInterrupts(doA, doB);
// link the motor to the sensor
motor.linkSensor(&encoder);
// power supply voltage [V]
driver.voltage_power_supply = 12;
// initialise driver hardware
driver.init();
// link driver
motor.linkDriver(&driver);
// set control loop type to be used
motor.controller = MotionControlType::velocity;
// initialize motor
motor.init();
// align encoder and start FOC
motor.initFOC();
}
void loop() {
// FOC algorithm function
motor.loopFOC();
// velocity control loop function
// setting the target velocity or 2rad/s
motor.move(2);
}
You can find more details in the SimpleFOC documentation (opens in a new tab).
Here are some of the SimpleFOClibrary and SimpleFOCShield application examples.
Image (opens in a new tab) (opens in a new tab) Image (opens in a new tab) (opens in a new tab) Image (opens in a new tab) (opens in a new tab) Image (opens in a new tab) (opens in a new tab)
We are very happy that SimpleFOClibrary has been used as a component of several research project and has made its way to several scientific papers. We are hoping that this trend is going to continue as the project matures and becomes more robust! A short resume paper about SimpleFOC has been published in the Journal of Open Source Software:
SimpleFOC: A Field Oriented Control (FOC) Library for Controlling Brushless Direct Current (BLDC) and Stepper Motors.
A. Skuric, HS. Bank, R. Unger, O. Williams, D. Gonz谩lez-Reyes
Journal of Open Source Software, 7(74), 4232, https://doi.org/10.21105/joss.04232 (opens in a new tab)
If you are interested in citing SimpleFOClibrary or some other component of SimpleFOCproject in your research, we suggest you to cite our paper:
@article{simplefoc2022,
doi = {10.21105/joss.04232},
url = {https://doi.org/10.21105/joss.04232},
year = {2022},
publisher = {The Open Journal},
volume = {7},
number = {74},
pages = {4232},
author = {Antun Skuric and Hasan Sinan Bank and Richard Unger and Owen Williams and David Gonz谩lez-Reyes},
title = {SimpleFOC: A Field Oriented Control (FOC) Library for Controlling Brushless Direct Current (BLDC) and Stepper Motors},
journal = {Journal of Open Source Software}
}
Robotheca lists software as a reference: nothing is hosted or run here, and every fact links to where it was read.