# bigtreetech/manta-m5p architecture

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

- Interactive diagram: https://gitdiagram.com/bigtreetech/manta-m5p
- Repository: https://github.com/bigtreetech/manta-m5p

## Overview

##### Project type and purpose
- This is the repository for the BIGTREETECH MANTA M5P 3D-printer control board. It contains hardware schematics, firmware configurations, and documentation for running Klipper and Marlin on the STM32-based M5P board.
- Purpose: provide firmware (Klipper image, config files) and hardware resources (schematics, pinouts) to drive stepper motors, heaters, sensors, and peripherals on a BIGTREETECH MANTA M5P board.

##### File structure
- Top level:
- 3D/ – mechanical model, CAD & user manuals
- Firmware/Klipper/ – Klipper firmware image, config, README
- Hardware/ – electrical schematics, board size drawings
- Key files:
- firmware-USB.bin – prebuilt Klipper firmware for STM32 MCU
- generic-bigtreetech-manta-m5p.cfg – default Klipper config for the board
- BIGTREETECH MANTA M5P V1.0-SCH.pdf – full electrical schematic

##### README for insights
- A detailed pinout table mapping MCU pins to functions: stepper drivers (X, Y, Z, E0, E1), SPI bus, heaters, thermistors, endstops, fans, BLTouch/proximity, Neopixels, USB, FDCAN, EXP1 (LCD), EXP2 (SD, buttons), onboard SD.

a. Main components:
- Host PC (Klipper host & optional OctoPrint/Cura)
- USB/OTG_FS interface
- FDCAN1 bus (optional remote MCU/expansions)
- STM32 MCU (onboard) running Klipper firmware
- Stepper driver modules (M5P driver chips) connected via STEP/DIR/EN pins and SPI2 bus
- MOSFET circuits for heaters (E0, E1, bed) and fans
- Temperature sensors (NTC/PT100 inputs)
- Endstop switches and BLTouch/probes
- Onboard SD card (SPI2), Expansion headers (EXP1 LCD, EXP2 SD & IO)
- Neopixel RGB outputs

b. Relationships & interactions:
- Host PC → USB (or FDCAN) → STM32 MCU: sends G-code, receives status
- MCU → digital lines → stepper drivers for motion control
- MCU ↔ SPI2 bus → stepper driver CS lines for diagnostics & microstep config
- MCU → MOSFET gates → heaters/fans; MCU reads thermistor ADC inputs for temperature feedback
- MCU → GPIO inputs ← endstops, probe triggers
- MCU ↔ Onboard SD (SPI) for local print jobs
- MCU → EXP1 → LCD and encoder for UI
- MCU → EXP2 → SD card detect, buttons, SPI lines (shared with SPI2)

c. Architectural patterns & design principles:
- Real-time embedded control loop on MCU (Klipper “microcontroller” role)
- Host–client pattern: Host PC performs path planning & high-level logic; MCU executes motion in real time
- Shared SPI2 bus multiplexing multiple peripherals (drivers, SD, expansion) with separate CS lines
- Modular separation: power (5V, 3.3V), logic (MCU), drivers (MOSFETs, TMC), sensors

d. Key technologies/frameworks:
- Klipper firmware on STM32 (C, Python host)
- TMC stepper drivers (SPI interface, step/dir)
- MOSFET heater/fan circuits with flyback protection
- ADC for thermistor/PT100 readings
- USB-OTG FS for host communication
- FDCAN for networked MCUs or future expansions

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Documentation"
        DocsOverview["Repository Overview & Instructions (README.md)"]:::doc
        MechDocs["Mechanical Models & User Manuals (3D/)"]:::doc
        STEP["STEP CAD Archive"]:::doc
        PDFMech["PDF of Mechanical Assembly"]:::doc
        UM_EN["English User Manual"]:::doc
        UM_CN["Chinese User Manual"]:::doc
    end

    subgraph "Firmware Resources"
        FWImg["Klipper Firmware Image"]:::fw
        FWCfg["Default Klipper Configuration"]:::fw
        FWR_EN["Klipper README (English)"]:::fw
        FWR_CN["Klipper README (Chinese)"]:::fw
    end

    subgraph "Hardware Resources"
        Schematic["Electrical Schematic"]:::hw
        PCB_Bot["PCB Outline – Bottom View"]:::hw
        PCB_Top["PCB Outline – Top View"]:::hw
    end

    DocsOverview --> FWImg
    MechDocs --> STEP
    MechDocs --> PDFMech
    MechDocs --> UM_EN
    MechDocs --> UM_CN

    FWImg --> FWR_EN
    FWImg --> FWR_CN
    Schematic --> PCB_Bot
    Schematic --> PCB_Top

    HostPC["Host PC (Path Planner)"]:::host
    USB["USB-OTG FS"]:::bus
    FDCAN["FDCAN1 Bus"]:::bus
    MCU["STM32 MCU (Klipper)"]:::mcu

    subgraph "Peripherals"
        Steppers["Stepper Drivers (TMC via STEP/DIR/GPIO)"]:::digital
        SPI2["SPI2 Bus (MOSI/MISO/SCK)"]:::bus
        CSDrivers["CS Lines to Drivers"]:::digital
        SD_On["Onboard SD Card"]:::bus
        Exp1["EXP1 (LCD & Encoder)"]:::digital
        Exp2["EXP2 (SD Detect, Buttons, IO)"]:::digital
        MOSFETs["MOSFET Heaters & Fans"]:::digital
        Thermistors["Thermistor/PT100 Sensors (ADC)"]:::analog
        Endstops["Endstops & Probe Triggers"]:::digital
        Neopixel["Neopixel RGB Outputs"]:::digital
    end

    HostPC -->|"G-code over USB"| USB
    HostPC -->|"G-code over FDCAN"| FDCAN
    USB --> MCU
    FDCAN --> MCU

    MCU -->|"STEP/DIR/EN"| Steppers
    MCU -->|"GPIO"| Endstops
    MCU -->|"GPIO"| Exp1
    MCU -->|"GPIO"| Exp2
    MCU -->|"GPIO"| Neopixel
    MCU -->|"MOSFET Gate Control"| MOSFETs
    MCU -->|"ADC"| Thermistors

    MCU --> SPI2
    SPI2 --> CSDrivers
    SPI2 --> Steppers
    SPI2 --> SD_On
    SPI2 --> Exp2

    click MechDocs "https://github.com/bigtreetech/manta-m5p/tree/master/3D/"
    click STEP "https://github.com/bigtreetech/manta-m5p/blob/master/3D/BIGTREETECH MANTA M5P-step.rar"
    click PDFMech "https://github.com/bigtreetech/manta-m5p/blob/master/3D/BIGTREETECH MANTA M5P.pdf"
    click UM_EN "https://github.com/bigtreetech/manta-m5p/blob/master/BIGTREETECH MANTA M5P V1.0 User Manual.pdf"
    click UM_CN "https://github.com/bigtreetech/manta-m5p/blob/master/BIGTREETECH MANTA M5P V1.0 用户手册.pdf"
    click FWImg "https://github.com/bigtreetech/manta-m5p/blob/master/Firmware/Klipper/firmware-USB.bin"
    click FWCfg "https://github.com/bigtreetech/manta-m5p/blob/master/Firmware/Klipper/generic-bigtreetech-manta-m5p.cfg"
    click FWR_EN "https://github.com/bigtreetech/manta-m5p/blob/master/Firmware/Klipper/README.md"
    click FWR_CN "https://github.com/bigtreetech/manta-m5p/blob/master/Firmware/Klipper/README_zh_cn.md"
    click Schematic "https://github.com/bigtreetech/manta-m5p/blob/master/Hardware/BIGTREETECH MANTA M5P V1.0-SCH.pdf"
    click PCB_Bot "https://github.com/bigtreetech/manta-m5p/blob/master/Hardware/BIGTREETECH MANTA M5P V1.0-SIZE-bot.pdf"
    click PCB_Top "https://github.com/bigtreetech/manta-m5p/blob/master/Hardware/BIGTREETECH MANTA M5P V1.0-SIZE-top.pdf"
    click DocsOverview "https://github.com/bigtreetech/manta-m5p/blob/master/README.md"

    classDef host fill:#f9f,stroke:#333,stroke-width:1px
    classDef bus fill:#afa,stroke:#333,stroke-width:1px
    classDef mcu fill:#fc9,stroke:#333,stroke-width:1px
    classDef digital fill:#ccf,stroke:#333,stroke-width:1px
    classDef analog fill:#fcf,stroke:#333,stroke-width:1px
    classDef doc fill:#eee,stroke:#333,stroke-width:1px
    classDef fw fill:#eef,stroke:#333,stroke-width:1px
    classDef hw fill:#efe,stroke:#333,stroke-width:1px
```
