Skip to content

simachines/hoverboard-firmware-hack-FOC

 
 

Repository files navigation

Hoverboard Driver FOC Motor Control with Encoder and Brake Resistor Support

Build License: GPL v3

This is a fork of the hoverboard-firmware-hack-FOC project that adds AB encoder support and brake resistor functionality for precision motor control applications.

For instructions please check wiki

For general setup instructions, hardware information, and base firmware features, please refer to the original repository.


Key Improvements Over Original Repository

  1. Smooth Torque Output at Zero RPM

Encoder feedback enables true zero-speed torque control with no cogging or vibration. Perfect for FFB devices like direct drive wheel base, ffb joystick, seatbelts.

  1. PSU Support

Integrated brake resistor support allows safe operation from bench power supplies. The brake resistor dissipates regenerative energy that would otherwise cause voltage spikes and damage PSUs or trip overvoltage protection.

  1. High-Quality Input Control Performance

Enhanced PWM input processing (both hardware and software implementations) provides:

  • low latency 1000hz polling
  • Noise-free
  • High Resolution

For information on all improvments see Pull Request #3.


My Use Case: Direct Drive FFB Wheelbase, FFB Joystick, Seatbelt Tensioner, Rudder Pedals

Wheelbase and Joystick project Arduino-FFB-wheel by Miloš Ranković

Wheelbase compatible project OpenFFB by Yannick Richter

Any usb controller capable of outputting PWM and Reading ab encoder signals will work, in this case I am using Rane's firmware with arduino pro micro. For exact wiring connections and components to get check wiki page

20251106_053714_1_H264_1080p.mp4

Quick Start Guide

1. Select Your Variant

In platformio.ini, uncomment your desired configuration:

default_envs = ONE_AXIS_VARIANT    ; Single motor with encoder
;default_envs = TWO_AXIS_VARIANT   ; Dual motors with encoders

2. Essential Configuration

Edit Inc/config.h with your specific parameters:

Battery Configuration

#define BAT_CELLS               10      // Your battery cell count:
                                        // 6s  = 24V (22.2V - 25.2V)
                                        // 10s = 36V (37V - 42V)
                                        // 13s = 48V (48.1V - 54.6V)

Encoder Configuration

#define ENCODER_X
#define ENCODER_X_PPR              2048     // Your encoder pulses per revolution
#define ALIGNMENT_X_POWER          6553     // Sensor alignment voltage out of 16000 for HW & SW-PWM, out of 1000 for the others

Internal Brake Resistor

Uses the left motor driver as a brake resistor (left motor must be disabled).

#define INTBRK_L_EN                         // Enable internal brake on left driver

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.


License

This project inherits the GPLv3 license from the original hoverboard-firmware-hack-FOC repository.


Support

For issues, please open an issue in this repository.

For general hoverboard firmware questions, refer to the original repository and its wiki.



Recent Changes (This Fork)

  • Added AB quadrature encoder support for precise motor control
  • Implemented internal and external brake resistor functionality
  • Enhanced PWM input processing (hardware and software)
  • Added ADC watchdog handling
  • Performance, safety and reliability improvements

For more changes, see Pull Request #3.

About

With Field Oriented Control (FOC)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 97.8%
  • Assembly 2.2%