# nmwilk/arduino_fanatec_wheel architecture

> Architecture diagram of the GitHub repository nmwilk/arduino_fanatec_wheel, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nmwilk/arduino_fanatec_wheel
- Repository: https://github.com/nmwilk/arduino_fanatec_wheel

## Overview

##### Project type and purpose
- This is a hardware-centric DIY embedded system with companion PC software.
- Purpose: enable a standard Arduino (Nano/Uno) steering-wheel “slave” to talk SPI with a Fanatec wheel-base, add buttons/D-pad and an alphanumeric display on the wheel, and optionally offer a Windows GUI for calibration/status.
- Key artifacts:
- Firmware (arduino_fanatec_wheel.ino) running on an Arduino Nano/Uno
- Level shifter circuit and PCB (KiCad project)
- 3D-printed mechanical fixtures (SolidWorks/STL in 3d Models)
- .NET WinForms display app (FanatecWindowsDisplay)
- TM1637 library for 7-segment display

##### File structure
- Top-level directories:
- “3d Models” → mechanical parts for connector, adapter, paddle shifters
- “Schematics & pcb layout” → KiCad source and Gerber for the board that integrates level shifter, connectors, buttons, display
- “libraries/TM1637” → driver library for alphanumeric display
- “FanatecWindowsDisplay” → C# WinForms project to show serial output
- Single source firmware at root: arduino_fanatec_wheel.ino
- README.md describes architecture: SPI comms, level shifting, analog inputs, diode isolation, serial-monitor calibration protocol

##### README for additional insights
- Describes hardware-electrical design:
- Fanatec base = SPI master, Arduino = SPI slave
- Level shifter recommended on MOSI/MISO/SCLK lines
- Diode in the 5 V supply line for isolation
- Buttons + D-pad wired as digital/analog inputs
- TM1637 alphanumeric display on two-wire interface
- Mentions calibration flow: D-pad and display drive interactive menu via serial or built-in controls

##### Main components and interactions (
a. Hardware blocks:
- Fanatec Wheel Base (SPI master, 3.3 V domain)
- Arduino Nano/Uno (SPI slave, 5 V domain)
- Logic Level Shifter (bidirectional on SPI lines)
- Diode on 5 V power rail (isolates wheel-base 5 V from USB 5 V)
- PCB Buttons & D-Pad (wired to digital/analog pins)
- TM1637 Alphanumeric Display (two‐wire bus to two digital pins)
- USB-Serial link (Arduino ↔ PC)
- 3D-Printed Connector/Adapter (mechanical interface)
b. Software blocks:
- Arduino Firmware (main loop: SPI_IRQ handler, button polling, display driver, serial handler)
- TM1637 Library (C++ abstraction for 7-segment display)
- Windows App (FanatecWindowsDisplay) reading serial port, rendering characters

c. Relationships & data flows:
- SPI lines (MISO/MOSI/SCLK/CS) flow between Wheel Base ↔ Level Shifter ↔ Arduino
- Arduino polls buttons & D-pad, updates SPI payload on next exchange
- Arduino drives TM1637 bus (CLK/DIO) to update display contents
- Arduino emits diagnostics/calibration messages over USB-Serial
- Windows App listens on COM port, parses messages, displays status

d. Architectural patterns & design principles:
- Hardware/Software separation: discrete blocks for power, logic, UI, mechanics
- Embedded event loop: interrupts for SPI, polling for inputs
- Isolation and voltage-domain crossing: diode and level shifter enforce 3.3 V vs 5 V boundaries
- Extensibility: 3D models and PC app are independent modules

e. Technology stack:
- Arduino C/C++ + TM1637 library
- KiCad for PCB capture & Gerber generation
- SolidWorks/STL for mechanical parts (3d Models)
- C#/.NET WinForms for PC GUI

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Hardware components
    subgraph "Hardware Components"
        FWB["Fanatec Wheel Base (SPI Master)"]:::hardware
        LS["Level Shifter (SPI lines)"]:::hardware
        D["Diode (5 V isolation)"]:::hardware
        FW["Arduino Nano/Uno"]:::hardware
        BTN["Buttons/D-Pad"]:::hardware
        DISP["TM1637 Display"]:::hardware
        USB["USB-Serial Link"]:::hardware
    end

    %% Arduino firmware modules
    subgraph "Arduino Nano Firmware" 
        SPI["SPI Handler"]:::firmware
        IM["Input Manager"]:::firmware
        DC["Display Controller"]:::firmware
        SI["Serial Interface"]:::firmware
    end

    %% Windows app components
    subgraph "Windows GUI App" 
        PCA["Program.cs"]:::external
        PCF["Form1.cs"]:::external
        PCD["Form1.Designer.cs"]:::external
    end

    %% PCB designs
    subgraph "PCB Schematic & Layout" 
        SCH["arduino-fanatec-pcb.sch"]:::pcb
        PCB["arduino-fanatec-pcb.kicad_pcb"]:::pcb
    end
    subgraph "PCB Gerber Outputs" 
        GERB["arduino-fanatec-pcb-*.gbr"]:::pcb
    end
    subgraph "Legacy PCB Layouts" 
        LEG["Legacy kicad versions"]:::pcb
    end

    %% Mechanical parts
    subgraph "3D Printed Mechanical Parts"
        CONN["SPI Connector Assembly"]:::mech
        ADAPT["Adapter & PCB Fixtures"]:::mech
        SHFT["Paddle Shifters"]:::mech
    end

    %% Documentation
    subgraph "Documentation"
        RD1["README.md"]:::doc
        RD2["Schematics & pcb layout/README.md"]:::doc
    end

    %% Connections
    FWB -->|MISO/MOSI/SCLK/CS| LS
    LS -->|3.3 V⇄5 V boundary| SPI
    BTN -->|GPIO inputs| IM
    DC -->|CLK/DIO bus| DISP
    SPI --> IM
    SPI --> DC
    SPI --> SI
    SI -->|UART| USB
    USB --> PCA
    USB --> PCF
    USB --> PCD

    %% Documentation links
    SCH --> RD2
    PCB --> RD2
    GERB --> SCH
    LEG --> SCH

    %% Mechanical links
    FWB --> CONN
    FW --> ADAPT
    FW --> SHFT

    %% Arduino node linking firmware modules
    FW --> SPI
    FW --> IM
    FW --> DC
    FW --> SI

    %% Click events
    click FW "https://github.com/nmwilk/arduino_fanatec_wheel/blob/master/arduino_fanatec_wheel.ino"
    click SPI "https://github.com/nmwilk/arduino_fanatec_wheel/blob/master/arduino_fanatec_wheel.ino"
    click IM "https://github.com/nmwilk/arduino_fanatec_wheel/blob/master/arduino_fanatec_wheel.ino"
    click DC "https://github.com/nmwilk/arduino_fanatec_wheel/blob/master/arduino_fanatec_wheel.ino"
    click SI "https://github.com/nmwilk/arduino_fanatec_wheel/blob/master/arduino_fanatec_wheel.ino"
    click DISP "https://github.com/nmwilk/arduino_fanatec_wheel/blob/master/libraries/TM1637/TM1637Display.cpp"
    click PCA "https://github.com/nmwilk/arduino_fanatec_wheel/blob/master/FanatecWindowsDisplay/Program.cs"
    click PCF "https://github.com/nmwilk/arduino_fanatec_wheel/blob/master/FanatecWindowsDisplay/Form1.cs"
    click PCD "https://github.com/nmwilk/arduino_fanatec_wheel/blob/master/FanatecWindowsDisplay/Form1.Designer.cs"
    click SCH "https://github.com/nmwilk/arduino_fanatec_wheel/blob/master/Schematics & pcb layout/KiCad/arduino-fanatec-pcb.sch"
    click PCB "https://github.com/nmwilk/arduino_fanatec_wheel/blob/master/Schematics & pcb layout/KiCad/arduino-fanatec-pcb.kicad_pcb"
    click GERB "https://github.com/nmwilk/arduino_fanatec_wheel/blob/master/Schematics & pcb layout/KiCad/Gerber/arduino-fanatec-pcb-*.gbr"
    click LEG "https://github.com/nmwilk/arduino_fanatec_wheel/tree/master/Schematics & pcb layout/Legacy layouts/legacy kicad versions"
    click CONN "https://github.com/nmwilk/arduino_fanatec_wheel/blob/master/3d Models/Fanatec SPI connector/SPI connector exported files/fanatec SPI connector.STL"
    click ADAPT "https://github.com/nmwilk/arduino_fanatec_wheel/blob/master/3d Models/fanatec adapter & pcb fixtures/fanatec adapter & pcb fixtures exported files/pcb fixture.STL"
    click SHFT "https://github.com/nmwilk/arduino_fanatec_wheel/blob/master/3d Models/mangentic pedal shifters/Imported to Solidworks/10mm round magnet (instead of 8) exported files/shifter_unit_top.STL"
    click RD1 "https://github.com/nmwilk/arduino_fanatec_wheel/blob/master/README.md"
    click RD2 "https://github.com/nmwilk/arduino_fanatec_wheel/blob/master/Schematics & pcb layout/README.md"

    %% Styles
    classDef hardware fill:#D0E8FF,stroke:#3B78FF,color:#000;
    classDef firmware fill:#DFFFE0,stroke:#4CAF50,color:#000;
    classDef external fill:#FFE8B0,stroke:#FF9800,color:#000;
    classDef pcb fill:#E0F7FA,stroke:#0097A7,color:#000;
    classDef mech fill:#F0F0F0,stroke:#555,color:#000;
    classDef doc fill:#FFF3E0,stroke:#FB8C00,color:#000;
```
