EFeru / hoverboard-firmware-hack-FOC

With Field Oriented Control (FOC)
GNU General Public License v3.0
1.12k stars 932 forks source link
bldc control field-oriented-control foc hoverboard motor

hoverboard-firmware-hack-FOC

Build status License: GPL v3 paypal

This repository implements Field Oriented Control (FOC) for stock hoverboards. Compared to the commutation method, this new FOC control method offers superior performance featuring:

Table of Contents

The hoverboards with mainboards also come with 2 sideboards(not splitboards), check the following wiki about this firmware

For the FOC controller design, see the following repository:

Videos:


Hardware

mainboard_pinout

The original Hardware supports two 4-pin cables that originally were connected to the two sideboards. They break out GND, 12/15V and USART2&3 of the Hoverboard mainboard. Both USART2&3 support UART, PWM, PPM, and iBUS input. Additionally, the USART2 can be used as 12bit ADC, while USART3 can be used for I2C. Note that while USART3 (right sideboard cable) is 5V tolerant, USART2 (left sideboard cable) is not 5V tolerant.

Typically, the mainboard brain is an STM32F103RCT6, however some mainboards feature a GD32F103RCT6 which is also supported by this firmware.

For the reverse-engineered schematics of the mainboard, see 20150722_hoverboard_sch.pdf


FOC Firmware

In this firmware 3 control types are available, it can be set in config.h file via CTRL_TYP_SEL parameter:

Comparison between different control methods

Control method Complexity Efficiency Smoothness Field Weakening Freewheeling Standstill hold
Commutation - - ++ n.a. n.a. +
Sinusoidal + ++ ++ +++ n.a. +
FOC VOLTAGE ++ +++ ++ ++ n.a. +(2)
FOC SPEED +++ +++ + ++ n.a. +++
FOC TORQUE +++ +++ +++ ++ +++(1) n.a(2)

(1) By enabling ELECTRIC_BRAKE_ENABLE in config.h, the freewheeling amount can be adjusted using the ELECTRIC_BRAKE_MAX parameter.
(2) The standstill hold functionality can be forced by enabling STANDSTILL_HOLD_ENABLE in config.h.

In all FOC control modes, the controller features maximum motor speed and maximum motor current protection. This brings great advantages to fulfil the needs of many robotic applications while maintaining safe operation.

Field Weakening / Phase Advance

Parameters

FOC Webview

To explore the controller without a Matlab/Simulink installation click on the link below:

https://eferu.github.io/bldc-motor-control-FOC/


Example Variants

Of course the firmware can be further customized for other needs or projects.


Projects and Links


Stargazers

Stargazers over time


Contributions

Every contribution to this repository is highly appreciated! Feel free to create pull requests to improve this firmware as ultimately you are going to help everyone.

If you want to donate to keep this firmware updated, please use the link below:

paypal