Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ build/
.pio/
firmware/controller/build/
firmware/controller/build-host/
firmware/controller/build-*/
firmware/build-*/
firmware/controller/managed_components/
firmware/controller/sdkconfig
firmware/controller/sdkconfig.old
CMakeFiles/
Expand Down
151 changes: 151 additions & 0 deletions ELECTRICAL-TRUTH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# Radiance3D — electrical truth (quick reference)

**Status:** authoritative · **Version:** 2.2 · **Date:** 2026-08-23

> **Normative source:** [`WIRING-DIAGRAM-HANDOFF.md`](WIRING-DIAGRAM-HANDOFF.md) v2.2.
> This file is the condensed lookup view of the same truth. If the two ever disagree, the
> handoff wins and this file is the one that needs fixing.
> Firmware changes required by these decisions: [`FIRMWARE-WIRING-RECONCILIATION.md`](FIRMWARE-WIRING-RECONCILIATION.md).

## Power tree

```text
12 V BATTERY + ──[ 5 A MAIN FUSE, at the battery ]──► 6-WAY BLADE-FUSE BLOCK
├─ BRANCH A [5 A] ─► PAN TMC2209 `VS` 12 V
├─ BRANCH B [5 A] ─► TILT TMC2209 `VS` 12 V
├─ BRANCH C [5 A] ─► BUCK #1 `VIN+` ─► `VOUT+` 5.00 V ─► ESP32 `VIN`
├─ BRANCH D [5 A] ─► BUCK #2 `VIN+` ─► `VOUT+` 5.00 V ─► AD8317 `+5V`
└─ 2 spare fused ways

ESP32 `3V3` (own AMS1117, fed from `VIN`) ─► PAN `VIO`, TILT `VIO`
```

Both bucks are **5.00 V** and are never joined. The motors never touch the battery — the
TMC2209 regulates winding current from its `VS` supply. Branch letters are logical; the
physical side and slot are assigned at assembly. Detail: handoff §3, §5, §6, §7.

## Ground tree

> **Planned first-build baseline:** `#03` is a cut copper-clad plate staged in the tray between
> the two bucks. `IMG_5544`–`IMG_5550` show loose bare copper wire placed near the plate and
> buck `VIN−` terminals; the wire ends are not soldered to the plate and the terminal clamps
> are empty. No ground-bus edge is currently installed. The staged copper will be insulated
> before soldering; the final build must not leave exposed ground conductors.

```text
12 V BATTERY − ─► COMMON COPPER-CLAD GROUND BUS
├─ PAN TMC2209 `GND` (ONE return — both GND pads are one net)
├─ TILT TMC2209 `GND` (ONE return)
├─ BUCK #1 `VIN−` (non-isolated: `VIN−` = `VOUT−`)
└─ BUCK #2 `VIN−` (non-isolated)

ESP32 `GND` ─► BUCK #1 `VOUT−` AD8317 `GND` ─► BUCK #2 `VOUT−`
AD8317 `J2` pin 2 ─► ESP32 `GND` (analog reference pair, twisted with the ADC line)
PAN / TILT `MS1`+`MS2` ─► each module's own `GND` pad (short local links)
```

Detail: handoff §4.

## ESP32 assignments — `PAD (GPIO)` form

The printed pad names are not GPIO numbers. Always write both.

| Function | Pad (GPIO) | Destination | State |
|---|---|---|---|
| Board supply | `VIN` / `GND` | Buck #1 `VOUT+` / `VOUT−` | build decision |
| Logic supply out | `3V3` | both driver `VIO` pads | build decision |
| PAN STEP / DIR / ENN | `D25` (25) / `D26` (26) / `D27` (27) | PAN `STEP` / `DIR` / `EN` | firmware |
| PAN UART TX / RX | `TX2` (17) / `RX2` (16) | PAN `RX` — TX through 1 kΩ, RX direct | firmware |
| TILT STEP / DIR / ENN | `D18` (18) / `D19` (19) / `D23` (23) | TILT `STEP` / `DIR` / `EN` | firmware |
| TILT UART TX / RX | `D14` (14) / **`D22` (22)** | TILT `RX` — TX through 1 kΩ, RX direct | **build decision · `FR-2`** |
| Detector ADC | `VP` (36), ADC1_0 | AD8317 `J2` pin 1 | firmware |
| E-stop | `D13` (13) | *not installed* | firmware reserves it, no switch exists |

`VN` (GPIO39) is **unused** — moved off to avoid the SAR-ADC glitch erratum (handoff §8.5).
`D21` is free; there is no rear OLED (`FR-1`). No strapping pin is used.

**USB rule:** do not power `VIN` from Buck #1 while USB is also connected, unless
`VIN`↔USB isolation has been verified.

## TMC2209 V1.3 — printed silkscreen, both drivers

```text
EN MS1 MS2 RX TX CLK STEP DIR
VS GND A2 A1 B1 B2 VIO GND
```

Never print `VM`, `VDD`, `VCC_IO`, or `PDN` — those are seller-graphic names.
`TX` is a dead pad on a factory board; leave it open.
**Both drivers are UART address 0**: bridge `MS1`+`MS2` and link to that module's own `GND`
pad. Safe because each driver has its own dedicated UART peripheral (`FR-3`).
A **100 µF / 25 V** bulk capacitor across `VS`–`GND` at each driver is datasheet-required and
must be bought. Detail: handoff §9, §10.

## Motors — YEJMKJ 42HDB0014NC 24B ×2

2 phase · 1.8° · 200 steps/rev · 1.0 A/phase · 3.5 Ω · 3.4 mH · 0.13 N·m · 42 × 42 × 20.5 mm.

**Authoritative colour map, from the exact product listing and the motor nameplate:**

```text
BLACK (A+) -> driver `A1` GREEN (A-) -> driver `A2`
RED (B+) -> driver `B1` BLUE (B-) -> driver `B2`
```

No re-pinning is ever required. If direction comes out reversed, fix it in firmware
(`direction_inverted`, `FR-5`), never by rewiring a coil. Detail: handoff §11, §12.

## AD8317 EVAL BD / NWDZ V1.0 — schematic-proven

Pads and connectors: `+5V`, `GND`, `Tadj`, `Valt`, `Vset`, `J2` (2-pin), SMA `RF_IN`,
SMA `Vout`. **There is no `VCC` pad.** Supply is **5.00 V** from Buck #2.

From the exact module schematic:

- **`R2 = 0 Ω` is fitted and ties `VOUT` to `VSET` — the board is hard-wired in MEASUREMENT
MODE.** The controller-mode hazard is closed.
- **No onboard regulator.** `+5V` → series diode `D2` → 10 µH LC filter → `VPOS`, so
`VPOS ≈ 4.3–4.7 V` from a 5.00 V rail. At 3.3 V in, `VPOS` would fall to ~2.6–3.0 V, at or
below the IC's minimum — which is why 5.00 V is correct.
- **`J2` is a 2-pin output header:** pin 1 = `Vout` (after the module's own `R6 = 1 kΩ`),
pin 2 = `GND`. **Take the analog output here.**
- **`Valt` is a dead pad** (`R4` not fitted). **`Tadj`** reaches `TADJ` through a fitted 200 Ω
with the to-ground `R7` unfitted; adding ~300 Ω to GND gives the 5.8 GHz optimum of 500 Ω.
- **Expected `Vout`: 0.35–1.9 V.** `Vout` FALLS as RF power RISES, −22 mV/dB at 5.8 GHz. The
seller listing claims the opposite and is wrong.
- **No external ADC series resistor** — `R6` is already on the module. Add only the 100 nF at
the ESP32 end.

Detail: handoff §13.

## RF path

`AUT ──(direct threaded SMA)──► AD8317 RF1n`. `IMG_5552`–`IMG_5555` confirm the black whip
antenna is screwed directly onto the detector SMA; there is no intermediate coax jumper,
panel bulkhead, or unknown termination in the baseline path. The remote 5.8 GHz VTX at
8–10 ft is **separately powered** and is not on this power tree. Detail: handoff §14.

## Moving / flex conductors

Eight, plus the rigid RF coupling: tilt motor `W36`–`W39` (BLACK/GREEN/RED/BLUE) and the
detector group `W13`, `W14`, `W29`, `W31`. `IMG_5553`–`IMG_5554` show loose factory motor
leads gathered around the tilt stage; they do **not** prove the final flex-loop routing.
Leave slack for full motion and set final lengths after physical assembly. Detail: handoff §17.

## Parts to buy before first power

100 µF/25 V ×2 (`#13`, `#14`) · 100 nF ×1 (`#15`) · 5 A fuse + insulated in-line holder
(`#16`) · 1 kΩ ×2 (`#17`).

## Pre-power checks

Five, all quick, none blocking the drawing: **buck commissioning · AD8317 measurement-mode
confirmation · motor coil resistance · driver VREF · USB/VIN rule.** Full text in handoff
§19.2.

## Firmware reconciliation

Firmware was read, not modified. Seven items are queued in
[`FIRMWARE-WIRING-RECONCILIATION.md`](FIRMWARE-WIRING-RECONCILIATION.md). Three must land
before commissioning: **`FR-2`** (tilt UART RX 39 → 22), **`FR-3`** (tilt UART address 1 → 0),
and **`FR-6`** (make the `I_scale_analog` current path explicit).
143 changes: 143 additions & 0 deletions FIRMWARE-WIRING-RECONCILIATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# Radiance3D — firmware / wiring reconciliation

**Status:** execution list for a later controlled task · **Date:** 2026-08-23
**Wiring authority:** [`WIRING-DIAGRAM-HANDOFF.md`](WIRING-DIAGRAM-HANDOFF.md) v2.2

> **No firmware was modified in the documentation task that produced this file.**
> Per the project's firmware-reconciliation rule, the verified physical pinout and the final
> wiring design are authoritative. Where firmware disagrees, the mismatch is **recorded here**
> and executed later as its own controlled task — never fixed by rewiring the machine to match
> an older firmware assumption.

## Execution sequence

```text
FINAL WIRING TRUTH <- WIRING-DIAGRAM-HANDOFF.md v2.2 (done)
|
PRINTABLE BLUEPRINT <- produced from that handoff
|
PHYSICAL ASSEMBLY <- direct-soldered, five pre-power checks
|
FIRMWARE RECONCILIATION <- THIS FILE, executed as one controlled task
|
BUILD / HOST TESTS <- cmake host build + ctest, no hardware
|
FLASH WITH MOTORS DISABLED
|
VERIFY CONTROL / UART / ADC
|
COMMISSION ONE AXIS AT A TIME
```

---

## FR-1 — Remove the phantom rear-OLED pin reservation

| Field | Value |
|---|---|
| **Function** | Reserved display pins |
| **Old firmware assignment** | `controller.reserved_oled_pins = [21, 22]`; docs describe an "ESP32 DevKit-style USB-C board with rear OLED" |
| **Final wiring assignment** | **No OLED exists.** `D21` (GPIO21) and `D22` (GPIO22) are free general-purpose pins |
| **Source files affected** | `firmware/config/radiance3d-owned-hardware.json` · `HARDWARE.md` · `docs/hardware/gpio-map.md` |
| **Required change** | Set `reserved_oled_pins` to `[]`. Remove "rear OLED" from the board description and delete the OLED row and the GPIO21/22 reservation sentence from the GPIO map. |
| **Safe to apply immediately** | **Yes.** Nothing reads these pins; the field is descriptive. |
| **Bench verification** | None required. Visual confirmation only: rear silkscreen reads `ESP32 DEVKITV1` and the rear PCB is bare (`02-esp32/listing-elegoo-esp32-bottom-view-ESP32-DEVKITV1.jpeg`). |
| **Why** | The reservation blocks two usable pins for a component that does not exist, and `FR-2` depends on GPIO22 being free. |

## FR-2 — Move TILT UART RX from GPIO39 to GPIO22

| Field | Value |
|---|---|
| **Function** | Tilt (elevation) driver PDN_UART receive |
| **Old firmware assignment** | `axes.elevation.uart_rx_pin = 39` — board pad `VN`, `SENSOR_VN`, input-only |
| **Final wiring assignment** | **GPIO22 — board pad `D22`.** Connection `W26`. `VN`/GPIO39 becomes unused. |
| **Source files affected** | `firmware/config/radiance3d-owned-hardware.json` (`axes.elevation.uart_rx_pin`) → regenerates `hardware_profile_generated.hpp` · `docs/hardware/gpio-map.md` · `docs/hardware/wire-standard.md` (`SIG-002` row) |
| **Required change** | `uart_rx_pin: 39 → 22`. Update the `SIG-002` harness row from `39 RX` to `22 RX`. |
| **Safe to apply immediately** | **Yes**, and it must be applied **before** the tilt UART link is trusted. GPIO22 is not a strapping pin and passes `validate_esp32_gpio()`. |
| **Bench verification** | With motors disabled: read a TMC2209 register over the tilt UART (`IOIN` or `GCONF`) and confirm a valid reply. Then sample the detector ADC repeatedly while the tilt UART is active and confirm no framing errors accumulate. |
| **Why** | Espressif documents that powering an RTC peripheral (SAR ADC1/ADC2/AMP) pulls GPIO36 (`SENSOR_VP`) and GPIO39 (`SENSOR_VN`) low for ~80 ns. Radiance3D samples the detector on GPIO36, so every ADC power-up would glitch GPIO39 — read by a UART receiver as a spurious start bit. Moving the pin removes the erratum from the design instead of working around it with `adc_power_acquire()`. GPIO22 is also bidirectional, unlike input-only GPIO39, and sits beside `D23` for tidy soldering. Handoff §8.5. |

## FR-3 — Set the tilt driver's UART address to 0

| Field | Value |
|---|---|
| **Function** | Tilt driver TMC2209 UART device address |
| **Old firmware assignment** | `axes.elevation.uart_address = 1` (pan is 0) |
| **Final wiring assignment** | **Address 0 on both drivers.** `MS1` and `MS2` are bridged together and linked to each module's own `GND` pad — connections `W27` (pan) and `W28` (tilt). |
| **Source files affected** | `firmware/config/radiance3d-owned-hardware.json` (`axes.elevation.uart_address`) · `docs/hardware/tmc2209-v1.3.md` ("Pan is PDN/UART address 0; tilt is address 1") |
| **Required change** | `uart_address: 1 → 0`. Update the tmc2209 doc sentence. |
| **Safe to apply immediately** | **Yes**, provided it is applied together with the `MS1`/`MS2` wiring. A mismatch in either direction simply means the tilt driver never answers — no damage. |
| **Bench verification** | With motors disabled, read a register from each driver over its own UART and confirm both reply at address 0. |
| **Why** | Each driver sits alone on its own dedicated UART peripheral (pan on UART2, tilt on UART1), so there is no shared bus and therefore no electrical need for distinct addresses. Address 0 on both lets the two modules be wired **identically** — the highest-value property in a direct-solder build — makes the address deterministic rather than relying on the TMC2209's internal pull-downs in a chopper-noise environment, and halves the address wiring. Handoff §10.2. |

## FR-4 — Correct the TMC2209 pinout in the measurements file

| Field | Value |
|---|---|
| **Function** | Documentation of the driver's physical pad names |
| **Old firmware assignment** | *(documentation only, no code)* `Measurements/tmc2209-v1.3.md` records `top row VM GND A2 A1 B2 VDD GND`, `bottom row EN MS1 MS2 PDN CLK STEP DIR` |
| **Final wiring assignment** | The photographed board silkscreen: `EN MS1 MS2 RX TX CLK STEP DIR` / `VS GND A2 A1 B1 B2 VIO GND` |
| **Source files affected** | `Measurements/tmc2209-v1.3.md` |
| **Required change** | Replace the pinout paragraph with the photographed silkscreen. Note that `IMG_5240` shows the **seller's graphic**, not the board, and that the earlier transcription also **dropped `B1`**. |
| **Safe to apply immediately** | **Yes.** Documentation only. |
| **Bench verification** | None. Confirmed by `03-tmc2209/single-driver-pin-labels.jpg`. |
| **Why** | A wrong pad table in a measurements file can propagate into later work. `VM`/`VDD`/`PDN` are seller-graphic net names; the board reads `VS`/`VIO`/`RX`/`TX`. |

## FR-5 — Confirm and set axis rotation direction

| Field | Value |
|---|---|
| **Function** | Pan and tilt rotation direction |
| **Old firmware assignment** | `axes.azimuth.direction_inverted = false`, `axes.elevation.direction_inverted = false` |
| **Final wiring assignment** | Motor leads by colour: `BLACK→A1, GREEN→A2, RED→B1, BLUE→B2` (`W32`–`W39`). **Direction is not predictable from wiring alone** — it also depends on how each motor is mounted. |
| **Source files affected** | `firmware/config/radiance3d-owned-hardware.json` (`direction_inverted`, both axes) |
| **Required change** | **None until commissioning.** Then set `direction_inverted` per axis to match the observed sense. |
| **Safe to apply immediately** | No — this is determined by observation, not by the wiring. |
| **Bench verification** | With the axis unloaded and the driver current set, command a small positive move and observe. If the platform turns the wrong way, flip that axis's `direction_inverted`. **Never correct direction by rewiring a coil.** |
| **Why** | Direction is a firmware property here by design, so no re-pinning is ever needed. Handoff §11.3. |

## FR-6 — Settle which driver-current path is in force

| Field | Value |
|---|---|
| **Function** | TMC2209 run/hold current control |
| **Old firmware assignment** | `commissioning_current_ma = 650`, `maximum_rms_current_ma = 800`, `hold_current_percent = 30`, `sense_resistor_milliohms = 110`; written over UART to `IRUN`/`IHOLD` |
| **Final wiring assignment** | The module's `VREF` trimpot is physically present and adjustable; `VREF` is left as a wired test point |
| **Source files affected** | `firmware/controller/src/` — wherever `GCONF` is written |
| **Required change** | Decide and make explicit: either **clear `GCONF.I_scale_analog`** so current is purely digital and the trimpot is irrelevant, or **keep the default `I_scale_analog = 1`** and document that `VREF` must be set to ~0.92 V for 650 mA RMS. Whichever is chosen, assert it in firmware rather than inheriting the power-on default implicitly. |
| **Safe to apply immediately** | Yes as a code change, but **verify before any powered motion.** |
| **Bench verification** | With `VS` powered and the ESP32 held in reset, measure `VREF` on each driver. Then, after flashing, confirm the actual winding current matches the requested 650 mA RMS (measure motor-supply current at a known holding position, or use a current probe). |
| **Why** | With `I_scale_analog = 1` — the chip's power-on default — `VREF` scales whatever `IRUN` requests, so a mis-set trimpot silently scales both axes even though firmware writes the current digitally. Handoff §9.4. |

## FR-7 — Bring the hardware docs in line with the final wiring

| Field | Value |
|---|---|
| **Function** | Project hardware documentation |
| **Old firmware assignment** | `docs/hardware/gpio-map.md` lists `Tilt PDN UART TX/RX 14 / 39`, an `OLED 21 / 22` row, and `AD8317 analog output 36` without the board pad names. `docs/hardware/wire-standard.md` `SIG-002` lists `39 RX`; its `MTR-001/002` rows mandate `A1/A+ → Black, A2/A− → Yellow extension (motor Green), B1/B+ → Red, B2/B− → Blue` |
| **Final wiring assignment** | Tilt UART RX is `D22` (GPIO22); no OLED row; ADC is `VP` (GPIO36); motor mapping is `BLACK→A1, GREEN→A2, RED→B1, BLUE→B2` |
| **Source files affected** | `docs/hardware/gpio-map.md` · `docs/hardware/wire-standard.md` · `docs/hardware/tmc2209-v1.3.md` |
| **Required change** | Update the tilt UART RX pin, delete the OLED row and its reservation sentence, add the printed pad name beside every GPIO number (`VP (GPIO36)`, `RX2 (GPIO16)`, `TX2 (GPIO17)`), and align the motor colour mapping. |
| **Safe to apply immediately** | **Yes.** Documentation only. |
| **Bench verification** | None. |
| **Why** | These files are still authoritative for harness IDs and gauges, so leaving stale pin data in them invites a future contradiction. |

---

## Summary

| ID | Change | Type | Blocking for first power? |
|---|---|---|---|
| **FR-1** | `reserved_oled_pins → []`, remove OLED from docs | config + docs | No |
| **FR-2** | `elevation.uart_rx_pin: 39 → 22` | **config — required** | **Yes**, before the tilt UART is trusted |
| **FR-3** | `elevation.uart_address: 1 → 0` | **config — required** | **Yes**, must match the `MS1`/`MS2` wiring |
| **FR-4** | Fix the TMC2209 pinout in `Measurements/` | docs | No |
| **FR-5** | Set `direction_inverted` per axis | config, at commissioning | No — determined by observation |
| **FR-6** | Make the `I_scale_analog` current path explicit | code | **Yes**, before powered motion |
| **FR-7** | Align `docs/hardware/*` with the final wiring | docs | No |

**Two config changes (`FR-2`, `FR-3`) and one code decision (`FR-6`) must land before the
machine is commissioned.** The rest are documentation hygiene.

After applying: build for host, run `ctest`, then flash with motors disabled and verify
control, UART, and ADC before commissioning one axis at a time.
Loading
Loading