Skip to content

Henrado/hoverboard-RC-hack

 
 

Repository files navigation

Hoverboard-RC-hack

License: GPL v3

Dette reoet implementerer Field Oriented Control (FOC) for vanlige hoverboards. Sammenlignet med kommuteringsmetoden (som de kommer med) tilbyr denne FOC-kontrollmetoden overlegen ytelse med:

  • redusert støy og vibrasjoner
  • jevnt dreiemoment og forbedret motoreffektivitet. Dermed lavere energiforbruk
  • feltsvekkelse for å øke maksimalt hastighetsområde
  • Mulighet for å kontrollere motorene over seriell komunikaskjon.

Innholdsfortegnelse

For hvordan FOC kontrolleren fungerer sjekk ut EmanuelFeru sin forklaring i repoet:

Videoer og bilder:

Dette er bare noe av det man kan bruke den til:

Slik har jeg implement min robot:



**BILDER**

Planen fremover

  1. (DONE) Gå over til "tank" mode slik at leg slipper å bruke hoverbordet sin mixer og jeg kan gi helt konkret fart på hvert hjul -- implement Emanuels suggestion for tank mode
  2. Imoplementere ROS til å gjøre det samme som nå
  3. Få ROS til å kontrollere roboten enten inne med lidar eller ute med GPS

Stepp 2 og videre blir inspirasjon fra: Converting a hoverboard into a self-driving mobile robot with ROS


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:

  • Commutation
  • SIN (Sinusoidal)
  • FOC (Field Oriented Control) with the following 3 control modes:
    • VOLTAGE MODE: in this mode the controller applies a constant Voltage to the motors. Recommended for robotics applications or applications where a fast motor response is required.
    • SPEED MODE: in this mode a closed-loop controller realizes the input speed target by rejecting any of the disturbance (resistive load) applied to the motor. Recommended for robotics applications or constant speed applications.
    • TORQUE MODE: in this mode the input torque target is realized. This mode enables motor "freewheeling" when the torque target is 0. Recommended for most applications with a sitting human driver.

Jeg har valgt å bruke FOC i VOLTAGE MODE for nøyaktighet

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

  • By default the Field weakening is disabled. You can enable it in config.h file by setting the FIELD_WEAK_ENA = 1
  • The Field Weakening is a linear interpolation from 0 to FIELD_WEAK_MAX or PHASE_ADV_MAX (depeding if FOC or SIN is selected, respectively)
  • The Field Weakening starts engaging at FIELD_WEAK_LO and reaches the maximum value at FIELD_WEAK_HI
  • The figure below shows different possible calibrations for Field Weakening / Phase Advance Field Weakening
  • If you re-calibrate the Field Weakening please take all the safety measures! The motors can spin very fast!

Parameters

  • All the calibratable motor parameters can be found in the 'BLDC_controller_data.c'. I provided you with an already calibrated controller, but if you feel like fine tuning it feel free to do so
  • The parameters are represented in Fixed-point data type for a more efficient code execution
  • For calibrating the fixed-point parameters use the Fixed-Point Viewer tool
  • The controller parameters are given in this table

Flashing

Right to the STM32, there is a debugging header with GND, 3V3, SWDIO and SWCLK. Connect GND, SWDIO and SWCLK to your SWD programmer, like the ST-Link found on many STM devboards. If you have never flashed your sideboard before, the MCU is probably locked. To unlock the flash, check-out the wiki page How to Unlock MCU flash. Do not power the mainboard from the 3.3V of your programmer! This has already killed multiple mainboards. Make sure you hold the powerbutton or connect a jumper to the power button pins while flashing the firmware, as the STM might release the power latch and switches itself off during flashing. Battery > 36V have to be connected while flashing.

Det flere forskjellige måter å kompilere repet men jeg valgte å bruke: RoboDurden's online compiler:https://pionierland.de/hoverhack/

Videre fulgte jeg en guide av skaperen Niklas Fauth som forklarer hvordan man skal gjøre det: http://bauhausinteraction.org/opl/how-to-control-a-hoverboard-with-an-arduino/


Diagnostics

The errors reported by the board are in the form of audible beeps:

  • 1 beep (low pitch): Motor error (see possible causes)
  • 2 beeps (low pitch): ADC timeout
  • 3 beeps (low pitch): Serial communication timeout <-- Skjer ofte/arduinoen mister kontakten med hoverbordet
  • 4 beeps (low pitch): General timeout (PPM, PWM, Nunchuk)
  • 5 beeps (low pitch): Mainboard temperature warning
  • 1 beep slow (medium pitch): Low battery voltage < 36V
  • 1 beep fast (medium pitch): Low battery voltage < 35V
  • 1 beep fast (high pitch): Backward spinning motors

For a more detailed troubleshooting connect an FTDI Serial adapter or a Bluetooth module to the DEBUG_SERIAL cable (Left or Right) and monitor the output data using the Hoverboard Web Serial Control tool developed by Candas.


Projects and Links


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.


About

With Field Oriented Control (FOC)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 97.7%
  • Assembly 2.2%
  • Other 0.1%