Coder Social home page Coder Social logo

eferu / hoverboard-sideboard-hack-stm Goto Github PK

View Code? Open in Web Editor NEW
42.0 7.0 39.0 73.13 MB

Hoverboard sideboard hack for STM32 boards

License: GNU General Public License v3.0

C 99.70% Assembly 0.25% Makefile 0.05%
sideboard hoverboard mpu-6050 imu accelerometer gyroscope mems euler gd32 stm32

hoverboard-sideboard-hack-stm's Introduction

hoverboard-sideboard-hack-STM

Build status License: GPL v3 paypal

This repository implements the firmware for the hoveboard sideboards. The hoveboard comes with two identical sideboards that can be flashed with this firmware.

► If you have a GD32 sideboard check-out the repo hoverboard-sideboard-hack-GD


Table of Contents


Hardware

The original sideboard hardware supports one 4-pin cable that originally was connected to the hoveboard mainboard. It breaks out GND, 12/15V and USART. Additionally, two ports are used to connect to the LED boards. On the back of the board, two Photo Interrupter Optical Switches can be found, originally used to detect if a human is standing on the hoverboard. sideboard

The LED boards consist of colored LEDs (blue, red, green, orange) used for design and to inform the user about the current hoverboard state. Below the pinout of the LED boards is shown. ledboard

The sideboard brain is an STM32F103C8T6 with the pinout shown in the follwing figure: MCU_pinout

A very important component of the sideboard is the IMU MPU-6050 from Invensense. The MPU-6050 determines the board orientation by combining a 3-axis gyroscope and a 3-axis accelerometer on the same silicon die, together with an onboard Digital Motion Processor™ (DMP™), which processes complex 6-axis MotionFusion algorithms. The DMP™ offers many features, such as:

  • Accelerometer and Gyroscope raw data output
  • Quaternion output
  • Temperature output
  • Pedometer
  • Interrupts on gesture events such as Tap on all axes or Orientation change
  • Low-power modes
  • Self-test and calibration

The MPU-6050 pinout and orientation of axes is shown in the follwing figure: MPU6050_pinout

For more details see the MPU-6050 datasheet and MPU-6050 registers.


Example Variants

This firmware offers currently these variants (selectable in platformio.ini or config.h):

  • VARIANT_DEBUG: In this variant the user can interact with sideboard by sending commands via a Serial Monitor to observe and check the capabilities of the sideboard
  • VARIANT_HOVERCAR: This variant can be used for Hovercar build. An RC receiver with iBUS protocol can be connected to the AUX serial Rx pin (see schematic)
  • VARIANT_HOVERBOARD: In this variant the sideboard is communicating with the mainboard of a hoverboard using the FOC firmware repository

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


Flashing

On the sideboard, there is a debugging header with GND, 3V3, SWDIO and SWCLK. Connect GND, SWDIO and SWCLK to your ST-Link V2 programmer. The 3V3 can be either obtained by connecting the pin to the ST-Link programmer or powering the sideboard with 12/15V.

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.

To build and flash choose one of the following methods:

Method 0: Using GitHub Fork

  • Fork the project
  • Modify desired source files and commit
  • Go to Actions (in the repo top menu)
  • Click on latest build
  • Download the build zip file from the Artifacts section
  • Upload desired firmware.bin file using ST-Link Utility

Method 1: Using Platformio IDE (recommended)

  • open the folder in the IDE of choice (vscode or Atom)
  • press the 'PlatformIO:Build' or the 'PlatformIO:Upload' button (bottom left in vscode).

Method 2: Using Keil uVision

  • in Keil uVision, open the sideboard-hack.uvproj
  • if you are asked to install missing packages, click Yes
  • click Build Target (or press F7) to build the firmware
  • click Load Code (or press F8) to flash the firmware.

Method 3: Using Linux CLI

  • prerequisites: install ST-Flash utility.
  • open a terminal in the repo check-out folder and if you have definded the variant in config.h type:
make

or you can set the variant like this

make -e VARIANT=VARIANT_####
  • flash the firmware by typing:
make flash

Wiring iBUS Receiver

An RC transmitter (Flysky FS-i6S or FS-i6X) can be connected to the sideboard using an FS-iA6B receiver as shown in the following schematic:

wiring_iBUS_pic


3D Visualization Demo

By converting Quaternions to Euler angles, we can make a 3D visualization example in Processing as shown below. For this Demo VARIANT_DEBUG was used.

sketch_pic


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


hoverboard-sideboard-hack-stm's People

Contributors

eferu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

hoverboard-sideboard-hack-stm's Issues

is that same board

hi
I bought a hoverboard and mainboard is not looks like same but i am not sure. Can I use this ?
WhatsApp Image 2020-06-22 at 13 19 21
WhatsApp Image 2020-06-22 at 12 23 59

led function for other variant?

i really like the feature on the hovercar to have the led as battery indicator and show the board is on. i am now trying to setup a nunchuk project. it doesnt look like the nunchuk variant is supported on the sideboard. is there an easy way to modify the config file to just use the led as battery indicator like on the hovercar variant and connect to my nunchuk flashed mainboard?

dual inputs Serial + Sideboard not working

Hi
I am trying to get dual inputs working > https://github.com/EFeru/hoverboard-firmware-hack-FOC/issues/242
So now I am at "Serial + Side board "attempt:

1 Checked wiring polarity and unlocked with Cubeprogrammer
2 Flashed VARIANT_HOVERCAR to side-board (to use RC receiver and later incorporate mpu for acceleration)
3 Flashed main-board with VARIANT USART:

This is gonfig.h on main-board

`#ifdef VARIANT_USART
#define SIDEBOARD_SERIAL_USART2 0
//#define CONTROL_SERIAL_USART2 0 // left sensor board cable, disable if ADC....
//#define FEEDBACK_SERIAL_USART2 // left sensor board cable, disable if ADC or PPM is used! tk

// #define SIDEBOARD_SERIAL_USART3 0
#define CONTROL_SERIAL_USART3 1 // right sensor board cable. Number indicates priority.......
#define FEEDBACK_SERIAL_USART3 // right sensor board cable, disable if I2C (nunchuk or lcd) is used!

#define DUAL_INPUTS // UART*(Primary) + SIDEBOARD(Auxiliary). Uncomment this to use Dual-inputs
#define PRI_INPUT1 3, -1000, 0, 1000, 0 // TYPE, MIN, MID, MAX, DEADBAND. See INPUT FORMAT section
#define PRI_INPUT2 3, -1000, 0, 1000, 0 // TYPE, MIN, MID, MAX, DEADBAND. See INPUT FORMAT section
#ifdef DUAL_INPUTS
#define FLASH_WRITE_KEY 0x1102 // Flash memory writing key. Change this k.........
#define SIDEBOARD_SERIAL_USART2 0 // left sideboard
//#define SIDEBOARD_SERIAL_USART3 1 // right sideboard
//#define CONTROL_SERIAL_USART3 1 //tk added
#define AUX_INPUT1 3, -1000, 0, 1000, 0 // TYPE, MIN, MID, MAX, DEADBAND. See INPUT FORMAT section
#define AUX_INPUT2 3, -1000, 0, 1000, 0 // TYPE, MIN, MID, MAX, DEADBAND. See INPUT FORMAT section
#else
#define FLASH_WRITE_KEY 0x1002 // Flash memory writing key. Change thi.........
#endif

// #define SUPPORT_BUTTONS_LEFT // use left sensor board cable for button inputs. Disable DEBUG_SERIAL_USART2!
// #define SUPPORT_BUTTONS_RIGHT // use right sensor board cable for button inputs. Disable DEBUG_SERIAL_USART3!
#endif
// ######################## END OF VARIANT_USART SETTINGS #########################`

All I am getting is Serial on right cable > working(tested with Arduino)
but side-board left cable nothing(don't know how to check side-board function)
20211216_100828
Note: STM32F103C8T6

Connected RC receiver : picked 5v and ground from board and USARTT1_RX connected straight to IBUS on receiver
Whats the recommended resistor for?

Question: How to use this standing instead of lying

Hello,
how do i change the code to use the sideboard standing | instead of lying __ (regarding to MPU6050 chip orientation)?

I found following piece of code in MPU6050.c Line 55:
static signed char MPU_ORIENTATION[9] = {1, 0, 0, // [-] MPU Sensor orientation matrix: set this according to the sensor installation 0, 1, 0, 0, 0, 1};

but find nowhere a definition or tutorial what i need to change.

Also is in the MPU6050 part no function to set the offsets? found nothing useful until yet.

BTW: I think the processing example in the end of the Readme is broken ;)
It worked for me after i changed the array indexes from 2, 4, 6 to 1, 3, 5 (https://github.com/EFeru/hoverboard-sideboard-hack-STM/blob/master/docs/sketch_processing/sketch_processing.pde line 86++)

Upload Error

Hi.
While I am uploading firmware I get a error. Why does it happen?

Executing task: C:\Users\TOLGA.platformio\penv\Scripts\platformio.exe run --target upload <

Processing VARIANT_HOVERBOARD (platform: ststm32; framework: stm32cube; board: genericSTM32F103C8)

Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/genericSTM32F103C8.html
PLATFORM: ST STM32 6.1.0 > STM32F103C8 (20k RAM. 64k Flash)
HARDWARE: STM32F103C8T6 72MHz, 20KB RAM, 64KB Flash
DEBUG: Current (stlink) External (blackmagic, jlink, stlink)
PACKAGES:

  • framework-stm32cube 2.0.181130
  • tool-dfuutil 1.9.200310
  • tool-openocd 2.1000.190707 (10.0)
  • tool-stm32duino 1.0.2
  • toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
    Warning! Cannot find a linker script for the required board! Firmware will be linked with a default linker script!
    LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 11 compatible libraries
    Scanning dependencies...
    No dependencies
    Building in release mode
    Warning! '-Wl,-T' option for specifying linker scripts is deprecated. Please use 'board_build.ldscript' option in your 'platformio.ini' file.
    Checking size .pio\build\VARIANT_HOVERBOARD\firmware.elf
    Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
    RAM: [= ] 8.1% (used 1660 bytes from 20480 bytes)
    Flash: [===== ] 53.8% (used 35272 bytes from 65536 bytes)
    Configuring upload protocol...
    AVAILABLE: blackmagic, dfu, jlink, serial, stlink
    CURRENT: upload_protocol = stlink
    Uploading .pio\build\VARIANT_HOVERBOARD\firmware.elf
    xPack OpenOCD, 64-bit Open On-Chip Debugger 0.10.0+dev (2019-07-17-11:28)
    Licensed under GNU GPL v2
    For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
    debug_level: 1

hla_swd
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
** Programming Started **
Warn : no flash bank found for address 0x08008000
Warn : no flash bank found for address 0x08008674
** Programming Finished **
** Verify Started **
Error: timed out while waiting for target halted
Error: error executing cortex_m crc algorithm
embedded:startup.tcl:449: Error: ** Verify Failed **
in procedure 'program'
in procedure 'program_error' called at file "embedded:startup.tcl", line 494
at file "embedded:startup.tcl", line 449
*** [upload] Error 1
========================================================== [FAILED] Took 29.03 seconds ==========================================================

Environment Status Duration


VARIANT_DEBUG IGNORED
VARIANT_HOVERBOARD FAILED 00:00:29.032
===================================================== 1 failed, 0 succeeded in 00:00:29.032 =====================================================
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.
Ekran Alıntısı6
Ekran Alıntısı5
Ekran Alıntısı4
Ekran Alıntısı3
Ekran Alıntısı2
Ekran Alıntısı

Don't program only on 3.3V

Thanks for your github sources and documentation ! Well done.

Just tried to program one of the sideboards with an stlink V2, while connecting the 3.3V connection on the SWD pinout. , and was able to remove the protection, but not able to program. Afterwards it became unvisible to the stlink programmer.
I suspect that the 3.3V goes through the CPU and leaks back to the 5V where there is much more passive load. I'm guessing this leakage current killed the CPU.
Luckily I have another board and tried with the 5V supply of the STLINK connecting to the RF +5V , this worked fine.

Maybe adapt the README.MD in that sense ?

I saw also for the mainboard on other pages, it's not recommended to program just supplying the 3.3V

Hope this makes sense.

LED Control

Is there a way to control the LEDs. It would be nice to make them blink when going forward and turn on when in reverse.
So far I only see my LEDs turn on when I turn on the car.

Schematics seem to have inverted polarity for +12v input

Hi,

I've just exploded a 5V regulator and possibly a full sideboard while trying to test my very basic firmware : I only conencted +12V according to the schematics in the README.md.
On my board ground is on the gyroscope side and +12V on the ARM proc side.

(By the way mine is a GD32 while having the STM32 card layout...)

Thanks for your job !

Mainboard type

Does anyone knows this board? I can unlock and download this one but it does not work right now. The Power is only on as long as I hold the button.

IMG_3702

Program stalls when there is a I2C error

The read from I2C never times out when there is an issue.
Looks like a known bug for STM32
https://community.st.com/s/question/0D53W000007Wj9wSAC/hali2c-hangs-when-it-enters-i2cwaitonflaguntiltimeout-function
The Systick priority is lower than the USART interrupt and the clock doesn't advance to create the timeout.
image

static HAL_StatusTypeDef I2C_WaitOnFlagUntilTimeout(I2C_HandleTypeDef *hi2c, uint32_t Flag, FlagStatus Status, uint32_t Timeout, uint32_t Tickstart)
{
  /* Wait until flag is set */
  while (__HAL_I2C_GET_FLAG(hi2c, Flag) == Status)
  {
    /* Check for the Timeout */
    if (Timeout != HAL_MAX_DELAY)
    {
      if (((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U))

The above code in stm32f1xx_hal_i2c.c never times out
I tried to increase the priority of the systick handler.
No result so far.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.