Link

Current sensing

Arduino SimpleFOClibrary has as a goal to support FOC implementation with (at least) three most standard types of current sensing:

up to this moment ( check the releases ), Arduino SimpleFOClibrary supports in-line current sensing for almost all platforms and low-side current sensing on ESP32 boards, stm32 (f1, f4 and g4 families - one motor), SAMD21 (one motor) and on the STM32 based B-G431B-ESC1 boards (one motor).

Each one of the current sensing classes will implement all the necessary functionalities for simple and robust implementation of FOC algorithm:

  • Hardware config
    • ADC resoluton and frequency
    • Automatic zero offset finding
  • Driver synchronisation
    • ADC acquisition events triggering
    • Adaptive alignment with driver phases
  • Reading the phase currents
    • Calculation of the current vector magnitude
    • Calculation of the FOC D and Q currents

Each of the implemented classes can be used as stand-alone classes and they can be used to read current values on BLDC driver outputs out of scope of the Arduino SimpleFOClibrary, see example codes in utils > current_sense_test. In order for FOC algorithm to work the current sense classes are linked to a BLDCMotor class which uses the driver to read the FOC currents.

🎯 Our implementation goals

The current sense code will be written in a way to support as many different drivers out there as possible and in a way to be fully interchangeable. Due to the very hardware specific implementations of the ADC acquisition for different MCU architectures and due to very different driver/adc synchronisation requirements for different current sensing approaches this task is probably one of the most complex challenges for the SimpleFOClibrary so far. Therefore the work will be done in iterations and each release will better and better support. Please make sure to follow out github and check the releases .

Also make sure to follow our community forum, a lot of discussions is being held about current sensing and its applications!

Current sensing support per MCU architecture

MCUIn-lineLow-sideHigh-side
Arduino (8-bit)✔️
Arduino DUE✔️
stm32 (in general)✔️
stm32f1 family✔️✔️ (one motor)
stm32f4 family✔️✔️ (one motor)
stm32g4 family✔️✔️ (one motor)
stm32l4 family✔️✔️ (initial)
stm32 B_G431B_ESC1✔️ (one motor)
esp32/esp32s3✔️✔️
esp32s2/esp32c3✔️
esp8266
samd21✔️✔️ (one motor)
samd51✔️
teensy✔️
Raspberry Pi Pico✔️
Portenta H7✔️
nRF52✔️
Renesas (UNO R4)

Note: current sensing on Renesas MCUs will be added in a future release.

Digging deeper

For more theoretical explanations and source code implementations of the current sensing and its integration into the FOC and motion check out the digging deeper section.