$ show ranenbg/Arduino-FFB-wheel
This repository provides a complete firmware solution for building a DIY force feedback (FFB) steering wheel for sim racing, targeting Arduino Leonardo/Micro/ProMicro (ATmega32U4). The firmware implements a custom USB HID joystick with full FFB support (constant, ramp, spring, damper, inertia, friction, periodic effects) and runs a 500 Hz control loop. It supports multiple hardware configurations: optical or magnetic encoders, PWM or DAC motor output, load cell pedals, button matrices, shift registers, and more. The codebase is a heavily modified fork of the BRWheel project, with custom Arduino core modifications to enable FFB HID descriptors. The repository includes precompiled HEX files for dozens of hardware variant combinations, wiring diagrams, and a serial configuration interface. While functionally complete and actively maintained, the code exhibits high technical drift due to reliance on Arduino IDE 1.8.5 and manual core patching, and the monolithic structure with extensive conditional compilation makes maintenance and reuse challenging.
The LLM identified 3 files worth highlighting for reuse:
Implements the core FFB effect processing: sine, square, triangle, sawtooth, ramp, and envelope generation. Contains speed/acceleration observers with configurable tap counts and a main torque calculation loop. The effect generation functions are self-contained and could be extracted for other FFB projects with minimal adaptation.
Handles optical quadrature encoder reading with interrupt-driven position tracking, including Z-index support. Provides clean functions for reading position, velocity, and direction. This module is isolated and could be reused in any project requiring high-resolution rotary encoder input.
Contains the custom USB HID report descriptor for a joystick with force feedback (PID). The descriptor is built as a byte array in PROGMEM and defines axes, buttons, hat switch, and FFB effect types. This pattern of constructing HID descriptors programmatically is reusable for any custom USB game controller project.