# peng-zhihui/dummy-robot architecture

> Architecture diagram of the GitHub repository peng-zhihui/dummy-robot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/peng-zhihui/dummy-robot
- Repository: https://github.com/peng-zhihui/dummy-robot

## Overview

##### Project Type and Purpose
- This is a full-stack mechatronic system for a super‑compact robotic arm (“Dummy‑Robot”).
- It spans hardware (PCB designs & 3D models), embedded firmware (STM32F4 core controller + STM32F1 motor drivers + teaching pendant), and host‑side software (PC GUI, CLI tool, mobile app).

##### File‐Structure Highlights
- 0.SubModules/Peak ⇒ Teaching pendant (hardware & firmware submodule)
- 1.Hardware ⇒ PCB projects: REF core board, REF base board, stepper‐driver boards (20/42/57), LED ring, wireless locators, gripper modules
- 2.Firmware ⇒
- Core‑STM32F4‑fw (FreeRTOS, HAL/CMSIS, BSP, robot algorithms, user apps)
- Ctrl‑Step‑Driver‑STM32F1‑fw (closed‑loop stepper drivers, CAN/UART protocol)
- submodule Peak firmware
- 4.Model ⇒ 3D CAD parts for arm, enclosure, suitcase
- 5.Docs ⇒ images & documentation
- README.md ⇒ system overview, architecture, communication protocols, command modes, technology stack

##### Main Components
a. Host Layer
- PC App (DummyStudio in Unity3D)
- CLI tool (reftool based on fibre)
- (Future) Mobile App
b. Teaching Pendant (“Peak”)
c. Embedded Core Controller
- STM32F405 MCU running Core‑STM32F4‑fw
- Subsystems: BSP (OLED via software‑I2C, IMU, EEPROM), RabbitMQ(?) – actually fibre RPC, FreeRTOS scheduler, Robot‑kinematics library, UserApp interface
- Interfaces: USB/UART for PC/CLI, wireless/UART for pendant, CAN bus for drivers
d. Motor Drivers
- Multiple STM32F1‑based boards (20/42 stepper drivers)
- ADC & chopped‑MOSFET or discrete FETs, encoder feedback, CAN/UART firmware
e. Mechanical & Power
- Stepper motors with encoders
- CAN bus + 24 V power trunk (4‑wire: V+, GND, CAN‑H, CAN‑L)
- 3D‑printed links and suitcases

##### Relationships & Data Flows
- PC GUI / CLI → (USB/UART) → Core Controller → (CAN bus) → Motor Drivers → Motors
- Pendant → (wireless/UART) → Core Controller
- Core Controller → (software‑I2C) → OLED display / status LEDs
- Motors & encoders ↔ Motor Drivers ↔ Core Controller (feedback for kinematics)

##### Architectural Patterns & Technologies
- Layered Firmware:
- Drivers (STM32 HAL, CMSIS)
- BSP modules (GPIO, UART, CAN, I2C)
- Middleware (FreeRTOS, u8g2 graphics, fibre RPC)
- Robot library (kinematics, trajectory planners)
- UserApp (protocol handlers, command modes)
- Bus Topology: CAN trunk for all motor drivers, star‑like connections for USB/UART interfaces
- Modular Hardware: interchangeable PCBs for different functions
- Protocol abstraction: ASCII, CAN, USB CDC classes

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Host Layer (Blue)
    subgraph "Host Layer"
        style HostLayer fill:#e0f3ff,stroke:#0288d1,stroke-width:2px
        PCApp["PC App<br/>(DummyStudio)"]:::host
        CLI["CLI Tool<br/>(reftool)"]:::host
        Mobile["Mobile App<br/>(Future)"]:::host
    end

    %% Teaching Pendant (Blue)
    Peak["Teaching Pendant<br/>(Peak)"]:::host

    %% Embedded Core Controller (Green)
    subgraph "Core Controller<br/>(STM32F405, REF Core PCB)" 
        style CoreController fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px
        FW_HAL["HAL/CMSIS"]:::emb
        FW_BSP["BSP Modules<br/>(GPIO, UART, CAN, I2C)"]:::emb
        FW_RTOS["FreeRTOS Scheduler"]:::emb
        FW_RPC["fibre RPC"]:::emb
        FW_GFX["u8g2 Graphics"]:::emb
        FW_LIB["Robot Kinematics Lib"]:::emb
        FW_APP["UserApp Interface"]:::emb
        EEPROM["EEPROM"]:::storage
        FW_HAL --> FW_BSP --> FW_RTOS --> FW_RPC --> FW_GFX --> FW_LIB --> FW_APP
        FW_BSP --> EEPROM
    end

    %% Motor Drivers (Green)
    subgraph "Motor Drivers (STM32F1)" 
        style Drivers fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px
        MD20["Driver 20 Series"]:::emb
        MD42["Driver 42 Series"]:::emb
        MD57["Driver 57 Series<br/>(Unused)"]:::emb
    end

    %% Mechanical & Power (Light Gray)
    subgraph "Mechanical & Power"
        style Mech fill:#f5f5f5,stroke:#9e9e9e,stroke-width:2px
        Motors["Stepper Motors<br/>+ Encoders"]:::mech
        Model3D["3D CAD Models"]:::mech
    end

    %% Docs and README (Gray)
    Docs["Documentation & Images"]:::docs
    Readme["System Overview & README"]:::docs

    %% Buses (orange)
    PCApp -->|USB‑CDC| CoreController
    CLI -->|USB‑CDC| CoreController
    Mobile -->|USB‑CDC| CoreController
    Peak -->|Wireless/UART| CoreController
    CoreController -->|CAN‑H/L| MD20
    CoreController -->|CAN‑H/L| MD42
    CoreController -->|CAN‑H/L| MD57
    MD20 -->|Feedback| Motors
    MD42 -->|Feedback| Motors
    MD57 -->|Feedback| Motors

    CoreController -->|SW‑I2C| FW_GFX

    %% Additional connections
    CoreController --> Model3D

    %% Click Events
    click Peak "https://github.com/peng-zhihui/dummy-robot/tree/main/0.SubModules/Peak"
    click CoreController "https://github.com/peng-zhihui/dummy-robot/tree/main/1.Hardware/Controller"
    click FW_HAL "https://github.com/peng-zhihui/dummy-robot/tree/main/2.Firmware/Core-STM32F4-fw"
    click MD20 "https://github.com/peng-zhihui/dummy-robot/tree/main/1.Hardware/MotorDriver-20"
    click MD42 "https://github.com/peng-zhihui/dummy-robot/tree/main/1.Hardware/MotorDriver-42"
    click MD57 "https://github.com/peng-zhihui/dummy-robot/tree/main/1.Hardware/MotorDriver-57-unused"
    click Docs "https://github.com/peng-zhihui/dummy-robot/blob/main/5.Docs"
    click Readme "https://github.com/peng-zhihui/dummy-robot/blob/main/README.md"
    click FW_HAL "https://github.com/peng-zhihui/dummy-robot/tree/main/2.Firmware/Core-STM32F4-fw"
    click FW_BSP "https://github.com/peng-zhihui/dummy-robot/tree/main/2.Firmware/Core-STM32F4-fw"
    click FW_RTOS "https://github.com/peng-zhihui/dummy-robot/tree/main/2.Firmware/Core-STM32F4-fw"
    click FW_RPC "https://github.com/peng-zhihui/dummy-robot/tree/main/2.Firmware/Core-STM32F4-fw"
    click FW_GFX "https://github.com/peng-zhihui/dummy-robot/tree/main/2.Firmware/Core-STM32F4-fw"
    click FW_LIB "https://github.com/peng-zhihui/dummy-robot/tree/main/2.Firmware/Core-STM32F4-fw"
    click FW_APP "https://github.com/peng-zhihui/dummy-robot/tree/main/2.Firmware/Core-STM32F4-fw"
    click MD20 "https://github.com/peng-zhihui/dummy-robot/tree/main/2.Firmware/Ctrl-Step-Driver-STM32F1-fw"
    click MD42 "https://github.com/peng-zhihui/dummy-robot/tree/main/2.Firmware/Ctrl-Step-Driver-STM32F1-fw"
    click MD57 "https://github.com/peng-zhihui/dummy-robot/tree/main/2.Firmware/Ctrl-Step-Driver-STM32F1-fw"
    click Readme "https://github.com/peng-zhihui/dummy-robot/blob/main/README.md"
    click Model3D "https://github.com/peng-zhihui/dummy-robot/blob/main/4.Model"

    %% Styles
    classDef host fill:#bbdefb,stroke:#1976d2,color:#0d47a1
    classDef emb fill:#c8e6c9,stroke:#388e3c,color:#1b5e20
    classDef storage fill:#eeeeee,stroke:#616161,color:#424242
    classDef mech fill:#f5f5f5,stroke:#757575,color:#424242
    classDef docs fill:#eeeeee,stroke:#424242,color:#212121
```
