# weiyx15/pwm_rectifier architecture

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

- Interactive diagram: https://gitdiagram.com/weiyx15/pwm_rectifier
- Repository: https://github.com/weiyx15/pwm_rectifier

## Overview

##### Project type and purpose
- This is an embedded, real-time, bare-metal control application running on the TI TMS320F28335 DSP.
- Purpose: implement and experiment with PWM-based rectifier control (SVPWM, ADC-SOC triggering, EPWM deadband, filtering).

##### File structure
- Top level: example folders (“Example_2833xAdcSoc”, “Example_2833xEPwmDeadBand”, “SVPWM”, etc.) each containing a single .c demo.
- No OS directory—firmware runs directly on the DSP.
- Core modules scattered as separate examples: ADC SOC setup, EPWM deadband, different SVPWM algorithms, filtering, test harness.
- README confirms device (TMS320F28335) and project context (university course work).

##### Main components to highlight
a. Hardware platform
- TMS320F28335 CPU core
- On-chip peripherals: ADC modules, ePWM modules, timers, interrupt controller, GPIO
- External power electronics (rectifier bridge, sensors, filters)
b. Software modules
- ADC_SOC: configures ADC to sample voltages/currents, raises end-of-conversion interrupt
- Control algorithm (SVPWM): reads ADC data, computes duty cycles
- EPWM driver: programs ePWM registers (compare modules, dead-band insertion)
- SVPWM_filter: optional filtering stage on reference or feedback signals
- Test harness (testSVPWM): validation application
c. Interrupt & data flow
- ADC SOC interrupt → Control ISR → EPWM update → output to power stage
d. Configuration & startup
- System init (clock, PLL) → Peripheral init (ADC, ePWM, GPIO) → Main loop or idle

##### Relationships and interactions
- EPWM outputs going to external power-converter stage.
- Real-time ISR context around ADC → Control → PWM chain.
- A debug/UART block if present (not in file tree, but common in this DSP).

##### Architectural patterns & design principles
- Interrupt-driven, data-flow architecture
- Separation of concerns:
- Peripherals configuration (init code)
- Sensor acquisition (ADC driver)
- Control math (SVPWM core)
- Actuator update (ePWM driver)
- Modular code organization: each example folder illustrates one piece of functionality.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "DSP (TMS320F28335)" 
        direction TB
        SysInit["System Init\n(clock, PLL)"]:::init
        PeriphInit["Peripheral Init\n(ADC, ePWM, GPIO)"]:::init
        subgraph "Real-Time ISR Context"
            direction TB
            ADCISR["ADC_SOC ISR"]:::driver
            ControlISR["SVPWM Computation"]:::algorithm
            Filter["Filtering Stage"]:::algorithm
            PWMUpdate["ePWM Update"]:::driver
        end
    end

    External["External Power Electronics\n(rectifier bridge, sensors, filters)"]:::external
    Test["Test Harness\n(testSVPWM)"]:::test
    Docs["Project Documentation\n(README)"]:::test

    SysInit --> PeriphInit
    PeriphInit -.-> ADCISR
    ADCISR -->|"ADC Data"| ControlISR
    ControlISR -->|"Optional Filter"| Filter
    Filter -->|"Filtered Data"| PWMUpdate
    PWMUpdate -->|"PWM Signals"| External
    Test -.->|"Validation Inputs"| ControlISR

    click ADCISR "https://github.com/weiyx15/pwm_rectifier/blob/master/Example_2833xAdcSoc/Example_2833xAdcSoc.c"
    click PWMUpdate "https://github.com/weiyx15/pwm_rectifier/blob/master/Example_2833xEPwmDeadBand/Example_2833xEPwmDeadBand.c"
    click ControlISR "https://github.com/weiyx15/pwm_rectifier/blob/master/SVPWM/SVpwm.c"
    click Filter "https://github.com/weiyx15/pwm_rectifier/blob/master/SVPWM_filter/SVPWM_filt.c"
    click Test "https://github.com/weiyx15/pwm_rectifier/blob/master/testSVPWM/testSVPWM.c"
    click Docs "https://github.com/weiyx15/pwm_rectifier/blob/master/README.md"

    classDef hardware fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef init fill:#e6f7ff,stroke:#333,stroke-width:1px
    classDef driver fill:#d4edda,stroke:#333,stroke-width:1px
    classDef algorithm fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef external fill:#e2e3e5,stroke:#333,stroke-width:1px
    classDef test fill:#f8d7da,stroke:#333,stroke-width:1px
```
