# nradulovic/hw_compact architecture

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

- Interactive diagram: https://gitdiagram.com/nradulovic/hw_compact
- Repository: https://github.com/nradulovic/hw_compact

## Overview

##### What this project is (type + purpose)

From the README + tree:
- Two physical PCBs:
1) **Amplifier board (mono channel)** with short-circuit protection + input/output filtering.
2) **Power supply board** with speaker protection, mute, and LED indication; feeds the amplifier(s).
- Design artifacts in:
- **KiCad**: PCB layout + schematic for the amplifier board.
- **LTspice**: simulation schematics/models for amplifier variants/blocks.

##### How the file structure maps to architecture (what to represent)
Top-level directories:
- `kicad/pamp/…`
- `compact.sch` (schematic) → your authoritative source of component-level design intent.
- `compact.kicad_pcb` (PCB layout) → placement/routing + connectors and nets.
- `compact.pro`, caches → project metadata.
- `ltspice/pamp/…`
- Multiple `.asc` schematics: likely subcircuits/variants (ops, vbe, compact module, protection slope, etc.).
- `.asy` symbol(s) for modules.
- `.plt` plot settings (expected waveforms/measurements).
- `ltspice/spice_root` suggests a library root or shared simulation dependencies.

Implication for diagramming:
- **KiCad side** = “what will be built” (boards, connectors, power domains).
- **LTspice side** = “how it was validated” (simulation models/variants), useful for documenting design rationale but not part of runtime system.

##### What the README adds that must appear
Key architectural commitments:
- **Single-ended input**.
- **No volume control** (so input path goes straight to amplifier input conditioning).
- **Short-circuit protection** (explicit block).
- **Input/output filtering** (explicit blocks).
- Two-board system:
- Amplifier board = mono channel.
- Power supply board = mains → DC rails + speaker protection/mute + LED status.

##### Primary pass-through/output (Live/Neutral/Earth) (if used in chassis wiring)
4. **Transformer / Secondary AC input** (AC1/GND/AC2) (even if transformer is off-board, represent it as an external component feeding the board)
##### DC Rails Output: Vcc, GND, Vee
7. **Speaker protection / relay / fault detection** (the README implies speaker protection & failure/overload indication)
##### LED indicator driver (Anode/Cathode; states POWER/FAILURE/OVERLOAD)

**Amplifier Board (Mono)**
##### Power input: Vcc, GND, Vee

**External / System-level**
- **Audio Source** (line-level single-ended)
- **Speakers**
- **Chassis Earth** bonding (Earth wire, safety ground)
- Optionally: **Transformer** as an external block between mains and secondary AC input, depending on whether it’s on the PSU board (README implies secondary comes in, so transformer is likely external).

- **Energy flow**: Mains → transformer → PSU rectification → DC rails → amplifier → speaker.
- **Signal flow**: Audio in → input filter → amplifier core → output filter → speaker protection → speaker.
- **Control/fault flow**:
- Short-circuit detection in amplifier influences output limiting (local loop).
- PSU board fault/overload detection influences:
- Speaker relay open (disconnect)
- LED state (POWER/FAILURE/OVERLOAD)
- Mute (if mute drives relay or amplifier mute)
- Mute key (K1/K2) → speaker protection/mute control logic.

Critically, label inter-board wiring using the README connector names:
- PSU DC out: **Vcc/GND/Vee** → Amplifier power in **Vcc/GND/Vee**
- Amp output: **Out/GND** (Amp board) → PSU “Amplifier input/Amplifier output” terminals (README lists both; represent as “from amp” and “to speaker terminal block” through protection relay).

If the PSU board takes both left and right:
- Amp L Out/GND → PSU OutL/GND path
- Amp R Out/GND → PSU OutR/GND path

##### Architectural patterns / design principles
For this project, the main “architecture patterns” are hardware-centric:
- **Separation of concerns by PCB**:
- PSU board handles hazardous mains domain + protection/UX (LED/mute).
- Amplifier board handles low-level audio + power amplification.
- **Protection layers**:
- Local fast protection: amplifier short-circuit protection.
- System-level protection: speaker relay/protection on PSU board.
- **Grounding domains**:

##### Relevant technologies/tools as part of the “architecture documentation”
This repo’s “tech stack” is:
- **KiCad** (schematic + PCB)
- **LTspice** (simulation)

- LTspice `.asc` blocks → validate amplifier topology / protection behavior / operating points
- KiCad schematic (`compact.sch`) → captures final circuit
- KiCad PCB (`compact.kicad_pcb`) → physical realization
This helps explain why both directories exist and how they relate.

- External: Mains, transformer, audio source, speakers, chassis earth, user mute key.
- Boards: PSU board, two mono amplifier boards.
- Connectors and cable harnesses.

- PSU board internal blocks (rectifier, smoothing, relay, detection, LED driver).
- Amplifier board internal blocks (input filter, amplifier, current limit, output network).

- SGND vs GND vs Earth and where they connect.
- Very useful for audio products (hum/noise issues).

##### (Optional) Design Toolcha
- LTspice ↔ KiCad relationship (simulation informs schematic choices).

Because the goal is “as many components as possible,” split at these natural boundaries:
- On PSU board:
- EMI/line filtering (if present) vs rectification vs bulk caps vs regulation vs relay driver vs fault detector vs LED driver.
- On amplifier board:
- Input RF filter vs input coupling/bias network vs voltage gain stage vs driver stage vs output stage vs current sense/protection vs output Zobel/inductor network.

##### Open `kicad/pamp/compact.sch` and list
- Power domains, net labels, connector reference designators.
- Protection circuits and where they sense (output current, emitter resistors, etc.).
##### Open `kicad/pamp/compact.kicad_pcb` to confirm
- Grounding/earth tie points (if any).
##### Skim LTspice `ltspice/pamp/*.asc` to confirm
- Which protection mechanisms are modeled and should be called out (e.g., “2slope” suggests a two-slope limiter).

## Diagram (Mermaid)

```mermaid
flowchart TD

%% =========================
%% System Context / Wiring
%% =========================
subgraph SC["System Context / Wiring (2-board amplifier system)"]
direction TB

subgraph EXT["External / Chassis"]
direction TB
Mains["AC Mains Input\nLive / Neutral / Earth"]:::external
ChassisEarth["Chassis / Safety Earth Bond"]:::earth
Transformer["Transformer (off-board)\nPrimary: Live/Neutral/Earth\nSecondary: AC1/GND/AC2"]:::external
AudioSource["Audio Source (single-ended line-level)\nSignal + SGND"]:::external
Speakers["Speakers\nLeft + Right"]:::external
MuteKey["Mute Key / Switch\nK1 / K2"]:::external
end

subgraph PSU["Power Supply Board (PCB)\nMains → DC rails + speaker protection + mute + LED"]
direction TB
PSU_MainsIn["Mains Input Terminal\nLive / Neutral / Earth"]:::mains
PSU_SwitchIF["Switch Interface\nCN1 / CN2"]:::control
PSU_PassThru["Primary Pass-through\nLive / Neutral / Earth"]:::mains
PSU_SecIn["Secondary AC Input\nAC1 / GND / AC2"]:::ac
PSU_Rect["Rectification + Reservoir Caps"]:::power
PSU_Reg["Regulation / Filtering\nDC rail conditioning"]:::power
PSU_RailsOut["DC Rails Output\nVcc / GND / Vee"]:::power
PSU_SpkProt["Speaker Protection\nRelay + Fault Detect"]:::protection
PSU_MuteIn["Mute Control Input\nK1 / K2"]:::control
PSU_LEDDrv["LED Indicator Driver\nAnode / Cathode\nPOWER / FAILURE / OVERLOAD"]:::control
PSU_AmpInL["Amplifier Input (Left)\nOutL / GND"]:::audio
PSU_AmpInR["Amplifier Input (Right)\nOutR / GND"]:::audio
PSU_SpkOut["Speaker Output Terminals\nOutL / OutR / GND"]:::audio
PSU_Earth["Safety Earth Node\n(Earth)"]:::earth
end

subgraph AMPS["Amplifier Boards (Mono channel) x2"]
direction TB

subgraph AMP_L["Amplifier Board - Left (Mono)"]
direction TB
AL_In["Input Connector\nIn / SGND"]:::audio
AL_InFilt["Input Filter / Conditioning"]:::audio
AL_AmpCore["Amplifier Core\n(VAS + driver + output stage)"]:::amp
AL_SCProt["Short-Circuit Protection\nSense + Limiter"]:::protection
AL_OutNet["Output Filter / Network\n(Zobel / snubber / inductor)"]:::audio
AL_Out["Output Connector\nOut / GND"]:::audio
AL_Pwr["Power Input\nVcc / GND / Vee"]:::power
end

subgraph AMP_R["Amplifier Board - Right (Mono)"]
direction TB
AR_In["Input Connector\nIn / SGND"]:::audio
AR_InFilt["Input Filter / Conditioning"]:::audio
AR_AmpCore["Amplifier Core\n(VAS + driver + output stage)"]:::amp
AR_SCProt["Short-Circuit Protection\nSense + Limiter"]:::protection
AR_OutNet["Output Filter / Network\n(Zobel / snubber / inductor)"]:::audio
AR_Out["Output Connector\nOut / GND"]:::audio
AR_Pwr["Power Input\nVcc / GND / Vee"]:::power
end

end

%% External wiring / interconnects
Mains -->|"power(AC)"| PSU_MainsIn
Mains ---|"earth"| ChassisEarth
ChassisEarth ---|"earth"| PSU_Earth

PSU_MainsIn -->|"power(AC)"| PSU_SwitchIF
PSU_SwitchIF -->|"power(AC)"| PSU_PassThru
PSU_PassThru -->|"power(AC)"| Transformer
Transformer -->|"power(AC)"| PSU_SecIn

PSU_SecIn -->|"power(AC)"| PSU_Rect
PSU_Rect -->|"power(DC)"| PSU_Reg
PSU_Reg -->|"power(DC)"| PSU_RailsOut

PSU_RailsOut -->|"power(Vcc/GND/Vee)"| AL_Pwr
PSU_RailsOut -->|"power(Vcc/GND/Vee)"| AR_Pwr

AudioSource -->|"audio(In/SGND)"| AL_In
AudioSource -->|"audio(In/SGND)"| AR_In

AL_In -->|"audio"| AL_InFilt -->|"audio"| AL_AmpCore -->|"audio"| AL_OutNet -->|"audio"| AL_Out
AR_In -->|"audio"| AR_InFilt -->|"audio"| AR_AmpCore -->|"audio"| AR_OutNet -->|"audio"| AR_Out

AL_SCProt -.->|"control(limit)"| AL_AmpCore
AR_SCProt -.->|"control(limit)"| AR_AmpCore
AL_AmpCore -.->|"sense"| AL_SCProt
AR_AmpCore -.->|"sense"| AR_SCProt

AL_Out -->|"audio(Out/GND)"| PSU_AmpInL -->|"audio"| PSU_SpkProt -->|"audio"| PSU_SpkOut -->|"audio"| Speakers
AR_Out -->|"audio(Out/GND)"| PSU_AmpInR -->|"audio"| PSU_SpkProt

MuteKey -.->|"control(K1/K2)"| PSU_MuteIn
PSU_MuteIn -.->|"control(mute/gate)"| PSU_SpkProt
PSU_SpkProt -.->|"fault/status"| PSU_LEDDrv
PSU_LEDDrv -.->|"control(LED)"| PSU_SpkOut

end

%% =========================
%% Board-Level Block Diagrams
%% =========================
subgraph BBD["Board-Level Block Diagrams (internal functional partitions)"]
direction TB

subgraph PSU_INT["PSU Board Internals"]
direction TB
PSU_EMI["EMI / Line Filtering (if present)"]:::mains
PSU_PrimaryDom["Hazardous Primary Domain"]:::mains
PSU_SecondaryDom["Low-Voltage Secondary Domain"]:::ac
PSU_Bulk["Bulk Storage (Reservoir Caps)"]:::power
PSU_RailSense["Rail Sense / Fault Comparator"]:::protection
PSU_RelayDrv["Relay Driver"]:::control
PSU_StarGnd["Grounding / Star Point (if used)\nPower GND / Signal GND tie"]:::ground

PSU_PrimaryDom -->|"power(AC)"| PSU_SecondaryDom
PSU_SecondaryDom -->|"power(AC)"| PSU_Rect
PSU_Rect -->|"power(DC)"| PSU_Bulk -->|"power(DC)"| PSU_Reg -->|"power(DC)"| PSU_RailsOut
PSU_RailsOut -.->|"sense"| PSU_RailSense -.->|"control"| PSU_RelayDrv -.->|"control"| PSU_SpkProt
PSU_RailSense -.->|"status"| PSU_LEDDrv
PSU_StarGnd ---|"ground"| PSU_Rect
PSU_StarGnd ---|"ground"| PSU_RailsOut
end

subgraph AMP_INT["Amplifier Board Internals (Mono channel)"]
direction TB
AMP_RF["Input RF / RFI Filter"]:::audio
AMP_Couple["Input Coupling / Bias Network"]:::audio
AMP_VAS["Voltage Gain Stage (VAS)"]:::amp
AMP_Driver["Driver Stage"]:::amp
AMP_Output["Output Power Stage"]:::amp
AMP_I_Sense["Current Sense"]:::protection
AMP_Limit["Current Limit / SOA / Short-Circuit Limiter"]:::protection
AMP_Zobel["Output Zobel / Snubber"]:::audio
AMP_LNet["Output Inductor / Series Network (if present)"]:::audio
AMP_SGND["Signal Ground (SGND)"]:::audio
AMP_PGND["Power Ground (GND)"]:::ground

AMP_RF -->|"audio"| AMP_Couple -->|"audio"| AMP_VAS -->|"audio"| AMP_Driver -->|"audio"| AMP_Output -->|"audio"| AMP_Zobel -->|"audio"| AMP_LNet
AMP_Output -.->|"sense"| AMP_I_Sense -->|"control"| AMP_Limit -.->|"control"| AMP_Output

AMP_SGND ---|"ground"| AMP_Couple
AMP_PGND ---|"ground"| AMP_Output
end

end

%% =========================
%% Design / Verification Flow
%% =========================
subgraph DVF["Design / Verification Flow (repository toolchain)"]
direction TB

subgraph LT["LTspice (Simulation / Validation)"]
direction TB
LT_Workspace["LTspice Workspace\nAmplifier validation"]:::tool
LT_Top["Top-level compact amplifier sim\n(pab3bbb-compact.asc)"]:::tool
LT_Module["Compact module / hierarchy\n(pab3bbb-compact-module.asc)"]:::tool
LT_Symbol["Module symbol\n(pab3bbb-compact-module.asy)"]:::tool
LT_Prot["Protection model\n2-slope limiter\n(pab3bbb-arguo-prot-2slope.asc)"]:::tool
LT_Ops["Op-stage / small-signal exploration\n(pab3bbb-compact-ops.asc)"]:::tool
LT_Vbe["Bias / Vbe exploration\n(pab3bbb-compact-vbe.asc)"]:::tool
LT_Plots["Plots / measurements\n(pab3bbb-compact.plt)"]:::tool
LT_Lib["Shared SPICE library root\nDependencies"]:::tool

LT_Workspace -->|"contains"| LT_Top
LT_Top -->|"uses"| LT_Module
LT_Module -->|"symbol"| LT_Symbol
LT_Top -->|"models"| LT_Prot
LT_Top -->|"references"| LT_Ops
LT_Top -->|"references"| LT_Vbe
LT_Top -->|"plots"| LT_Plots
LT_Workspace -->|"depends_on"| LT_Lib
end

subgraph KC["KiCad (Implementation / Build Artifacts)"]
direction TB
KC_Project["KiCad Amplifier Board Project\n(schematic + PCB)"]:::tool
KC_Sch["Schematic\n(compact.sch)"]:::tool
KC_Pcb["PCB Layout\n(compact.kicad_pcb)"]:::tool
KC_Pro["Project Metadata\n(compact.pro)"]:::tool
KC_Cache["Cached Symbols / Lib\n(compact-cache.lib)"]:::tool

KC_Project -->|"authoritative_design_intent"| KC_Sch
KC_Project -->|"physical_realization"| KC_Pcb
KC_Project -->|"metadata"| KC_Pro
KC_Project -->|"cached_lib"| KC_Cache
end

LT_Top -.->|"informs/design_choices"| KC_Sch
KC_Sch -->|"drives"| KC_Pcb

end

%% =========================
%% Click events (paths only)
%% =========================
click KC_Project "https://github.com/nradulovic/hw_compact/tree/master/kicad/pamp/"
click KC_Sch "https://github.com/nradulovic/hw_compact/blob/master/kicad/pamp/compact.sch"
click KC_Pcb "https://github.com/nradulovic/hw_compact/blob/master/kicad/pamp/compact.kicad_pcb"
click KC_Pro "https://github.com/nradulovic/hw_compact/blob/master/kicad/pamp/compact.pro"
click KC_Cache "https://github.com/nradulovic/hw_compact/blob/master/kicad/pamp/compact-cache.lib"

click LT_Workspace "https://github.com/nradulovic/hw_compact/tree/master/ltspice/pamp/"
click LT_Top "https://github.com/nradulovic/hw_compact/blob/master/ltspice/pamp/pab3bbb-compact.asc"
click LT_Module "https://github.com/nradulovic/hw_compact/blob/master/ltspice/pamp/pab3bbb-compact-module.asc"
click LT_Symbol "https://github.com/nradulovic/hw_compact/blob/master/ltspice/pamp/pab3bbb-compact-module.asy"
click LT_Prot "https://github.com/nradulovic/hw_compact/blob/master/ltspice/pamp/pab3bbb-arguo-prot-2slope.asc"
click LT_Ops "https://github.com/nradulovic/hw_compact/blob/master/ltspice/pamp/pab3bbb-compact-ops.asc"
click LT_Vbe "https://github.com/nradulovic/hw_compact/blob/master/ltspice/pamp/pab3bbb-compact-vbe.asc"
click LT_Plots "https://github.com/nradulovic/hw_compact/blob/master/ltspice/pamp/pab3bbb-compact.plt"
click LT_Lib "https://github.com/nradulovic/hw_compact/tree/master/ltspice/spice_root"

%% =========================
%% Styles (color domains)
%% =========================
classDef external fill:#F3F4F6,stroke:#6B7280,color:#111827,stroke-width:1px
classDef mains fill:#FEE2E2,stroke:#B91C1C,color:#111827,stroke-width:2px
classDef ac fill:#FFE4CC,stroke:#C2410C,color:#111827,stroke-width:1.5px
classDef power fill:#FCA5A5,stroke:#991B1B,color:#111827,stroke-width:1.5px
classDef ground fill:#E5E7EB,stroke:#111827,color:#111827,stroke-width:1.5px
classDef earth fill:#DCFCE7,stroke:#15803D,color:#111827,stroke-width:1.5px
classDef audio fill:#DBEAFE,stroke:#1D4ED8,color:#111827,stroke-width:1.5px
classDef control fill:#FFEDD5,stroke:#9A3412,color:#111827,stroke-width:1.5px
classDef protection fill:#FDE68A,stroke:#92400E,color:#111827,stroke-width:1.5px
classDef amp fill:#E9D5FF,stroke:#6B21A8,color:#111827,stroke-width:1.5px
classDef tool fill:#D1FAE5,stroke:#065F46,color:#111827,stroke-width:1.5px
```
