Home

Awesome

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:

<table> <tr> <td><a href="https://youtu.be/IgHCcj0NgWQ" title="Hovercar" rel="noopener"><img src="/docs/pictures/videos_preview/hovercar_intro.png"></a></td> <td><a href="https://youtu.be/gtyqtc37r10" title="Cruise Control functionality" rel="noopener"><img src="/docs/pictures/videos_preview/cruise_control.png"></a></td> <td><a href="https://youtu.be/jadD0M1VBoc" title="Hovercar pedal functionality" rel="noopener"><img src="/docs/pictures/videos_preview/hovercar_pedals.png"></a></td> </tr> <tr> <td><a href="https://youtu.be/UnlbMrCkjnE" title="Commutation vs. FOC (constant speed)" rel="noopener"><img src="/docs/pictures/videos_preview/com_foc_const.png"></a></td> <td><a href="https://youtu.be/V-_L2w10wZk" title="Commutation vs. FOC (variable speed)" rel="noopener"><img src="/docs/pictures/videos_preview/com_foc_var.png"></a></td> <td><a href="https://youtu.be/tVj_lpsRirA" title="Reliable Serial Communication" rel="noopener"><img src="/docs/pictures/videos_preview/serial_com.png"></a></td> </tr> </table>

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 methodComplexityEfficiencySmoothnessField WeakeningFreewheelingStandstill hold
Commutation--++n.a.n.a.+
Sinusoidal++++++++n.a.+
FOC VOLTAGE+++++++++n.a.+<sup>(2)</sup>
FOC SPEED+++++++++n.a.+++
FOC TORQUE++++++++++++++<sup>(1)</sup>n.a<sup>(2)</sup>

<sup>(1)</sup> By enabling ELECTRIC_BRAKE_ENABLE in config.h, the freewheeling amount can be adjusted using the ELECTRIC_BRAKE_MAX parameter.<br/> <sup>(2)</sup> 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

⚠️ If you re-calibrate the Field Weakening please take all the safety measures! The motors can spin very fast! Power consumption will be highly increase and you can trigger the overvoltage protection of your BMS ⚠️

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

<a/> <a/>

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