Arduino Build Doxygen Action

DIY-Sim-Racing-FFB-Pedal

Disclaimer

This repository documents my research progress. I wanted to understand the necessary signal processing and control theory algorithms behind such a device.

The FFB pedal is a robot and can be dangerous. Please watch The Terminator before continuing. If not interacted with care, it may cause harm. I'm not responsible for any harm caused by this design suggestion. Use responsibly and at your own risk.

Discord

A Discord server has been created to allow joint research.

Hardware

Electronics

Control PCB

The embedded code of this DIY FFB pedal runs on an ESP32 microcontroller. The PCB design was developed to prove the concept. It holds the ESP32, the ADC, a level shifter, and connectors. Currently, version 3 of this PCB design is used which introduced sensorless homing of the servo. The PCB design and pinout diagram can be found here. If you use Simucube wheelbase, you can use the D15 accessory port for input, detail was list here

Here is an image of the plain PCB:

Here is an image of the assembled PCB:

Wiring

The PCB has three connectors with the following wiring:

Servo motion port

Connector at PCB Servo
Dir- Dir-
Dir+ Dir+
Pul- Pul-
Pul+ Pul+

Servo debug port

Connector at PCB Servo
Gnd Gnd
Tx Rx
Rx Tx

Loadcell port

Connector at PCB Loadcell
5V V+
Gnd V-
Gnd Shield
S+ S+
S- S-

Servo power port

It is recommended to use a Schottky diode in the positive line from the PSU to the servo. The plated side faces the servo.

PSU Servo
36V/48V Vdd+
Gnd Gnd

Power PCB

Depending on the load direction, the servo will act as a generator. It will produce an additional current flow from the servo to the PSU which could trigger the over-voltage protection from the PSU and the servo. To prevent the reverse current flow to the PSU and thus prevent over-voltage protection from the PSU, a Schottky diode was added to the power line. To prevent the trigger of the over-voltage protection from the servo a large capacitor was added in the power-line.

Component Link
SR5100 Schottky diode Amazon.de
100V 10kF capacitor Amazon.de

To hold the components, a power PCB was developed, which also featured a port to hold XT30 connectors. The

Here is an image of the plain PCB:

Here is an image of the assembled PCB:

Mechanical design

Here are some examples of mechanical designs awesome DIYers have done:

Design Link
Tjfenwick design
Bjoes design
GWiz design

BOM

The BOM refers to the pedal design which I have chosen, see here.

Software

ESP32 code

Architecture

A Doxygen report of the sources can be found here.

Install ESP32 driver

The drivers can be found here here.

Firmware generation and flashing

Firmware can be built and flashed via Arduino-IDE or Arduino-CLI.

Built from source (via Arduino-IDE)

  1. Install the ESP32 dependencies in Arduino-IDE, see e.g. here
  2. Install the libraries
  3. Flash the code, e.g. via Ardiuno-IDE to esp32.

Built from source (via Arduino-CLI)

  1. Install the Arduino CLI
  2. Execute the build script from a local repo.
  3. Flash the binaries via e.g. web installer, see below.

Flash prebuilt binaries via web flasher

The binaries are available here. They can be flashed via the ESP webflasher.

Memory address File
0x1000 Main.ino.bootloader.bin
0x8000 Main.ino.partitions.bin
0xe000 boot_app0.bin
0x10000 Main.ino.bin

iSV57T-130 servo config tuning

The iSV57T allows parameter tuning via its RS232 interface. To tune the servo towards this application, I executed the following steps.

With the current PCB design, the ESP can directly communicate with the iSV57T servo. Manual tuning as described before isn't necessary anymore. A description of the steps I undertook to decode the communication protocol can be found on the Disord server. Additional features such as sensorless homing and lost-step recovery were developed and integrated with the help of this communication.

SimHub plugin:

The SimHub plugin was designed to communicate with the ESP to (a) modify the pedal configuration, e.g. the force vs. travel parameterization and (b) to trigger effects such as ABS oscillations.

image

To install the plugin, the plugin binaries, hidden inside the SimHub_plugin.zip, have to be copied to the SimHub directory, e.g. C:/Program Files (x86)/SimHub

Steps after flashing the firmware

The pedal will not move initially after flashing. One has to open the SimHub plugin, connect to the pedal, and send a config with non-zero PID values. Recommended PID values are:

P=0.2-0.4
I=50-150
D=0

After sending the initial config, power cycling of the pedal is necessary. The pedal should move afterward.

Error handling

Pedal doesn't move after initial setup

  1. Make sure, that you follow the above instructions. The default PID values are set to 0 thus the pedal will not move. You have to send non-zero PID values and restart the pedal to observe pedal travel.
  2. Open the serial monitor in Arduino IDE, set the baud rate to 921600, and restart the pedal. You should see some debug info. Make a screenshot and kindly ask the Discord server for help.

Misc

Pedal kinematics calculation

To get a better understanding of the motion and forces, a python script for simulation of the pedal angle, the pedal angular velocity and maximum pedal force has been written. Feel free to tune the pedal geometry as needed. The simulation result for my pedal geometry looks as follows:

Todo

ESP code:

  • Add automatic system identification of pedal response
  • Add model-predictive-control to the ESP code for the improved pedal response
  • Add field to select joystick output to be conputed from force or travel

SimHub plugin:

Misc:

  • Create a video describing the build progress and the features
  • Add Doxygen + Graphviz to the project to automatically generate documentation, architectural design overview, etc.