projects/ janelia/ Mouse Joystick/ Sources/ mouse-joystick-pcb/ .agents/ AGENTS.md/

Archived page

Mouse Joystick PCB Agent Guidance

.agents/AGENTS.md of mouse-joystick-pcb, rendered; the Markdown is beside it.

This file is the canonical project guidance for agent sessions in this repository.

Session Start

Read this file first.

If AGENT_MEMORY_REPO is set and points at a directory, read $AGENT_MEMORY_REPO/AGENTS.md before planning or editing.

If sibling checkouts exist, read:

If .agents/handoff.local.md exists, read it before planning or editing.

If the task is multi-step, risky, or likely to span more than one session, read .agents/PLANS.md and keep it updated as work progresses.

Current State — 2026-10-15

v1.0 is fabricated, tagged v1.0 and in service: four boards built from fab/mouse-joystick-pcb/ (the v1.0 order, regenerated only for a new revision), two in Rig 1 and two on the verification rig. The copper is the fabricated copper; since the tag the block sheets were regenerated from the library with the copper kept, and the PCB changed in footprint fields, paths and group ids only. Its documentation is complete: the generated set under docs/generated/ (block pages, subsystem pages, the MCU pin allocation, the dimensioned outline drawing, the BOM with its sourcing, the recorded netlist checks), the README block and the Pages site (https://peterpolidoro.github.io/mouse-joystick-pcb/, built by .github/workflows/pages.yml from the committed pages; make site builds it strictly here). Bring-up findings and open items are in .agents/PLANS.md and docs/bringup-log.md.

The routing record of September 2026 (the routing session handoff, the autoroute log, the routing completion and the connector access correction) is history, kept for how the board came to be; it is not an instruction to route again. The next revision's changes are the PLANS items (the brake overshoot, the inert torque calibration switch, the USB 1200 baud touch), each decided with measurements first.

Repository Purpose

This repository owns the KiCad implementation and board-specific notes for mouse-joystick-pcb: a single-axis mouse joystick controller integrated as a native pyControl peripheral. Two of these boards serve the rig's two joysticks.

There is a second, live design for the same rig. ../mouse-joysticks-pcb is the twin-axis board. The form-factor question is deliberately open. See docs/relationship-to-twin-axis-board.md.

The predecessor motor-control validation board is ../tmc51x0-driver-dev-pcb. The previous-generation joystick board is ~/Repositories/kicad/mouse-joystick-pcb — same name, different design, prior art to mine rather than a dependency.

Board Rules

Keeping Two Repositories In Sync

Shared facts live in both this repository and ../mouse-joysticks-pcb:

When one of these changes, change it in both. A silent divergence in a shared fact is the failure mode of running two repositories.

Safety Rules

The board must reach a safe state without pyControl's cooperation:

Development Environment

Prefer Makefile targets:

docs/generated/ and the block between the <!-- BEGIN/END GENERATED BOARD DOCUMENTATION --> markers in README.md are written by make docs. Never hand-edit either. make docs is a no-op unless a .kicad_sch, .kicad_pcb, .kicad_pro or .kicad_dru hash changed, so run it freely; make docs-check is the pre-tag gate and names what moved. Mechanical coordinates there are centre-of-board origin, X right and Y up, which is not KiCad's frame — see kicad-libs/docs/board-documentation.md.

Local KiCad Overlay

The pinned Guix channel (dd8c1c5) carries KiCad 10.0.6, verified with guix time-machine -C .guix/channels.scm -- show kicad, so plain make kicad-edits gives 10.0.6. The opt-in overlay in .guix/manifest-kicad-local.scm and .guix/local-modules/orb-weaver/kicad-local.scm (make kicad-version-local, kicad-shell-local, kicad-edits-local, fab-local) stays as the hook for the interval between a KiCad release and its Guix package; the user uses it whenever KiCad is ahead of Guix. Since 2026-10-08 it overrides KiCad 10.0.7 (released that day; the Guix update is submitted upstream), so the -local targets give 10.0.7 and the default ones 10.0.6. The module is byte-identical in kicad-libs, mouse-joysticks-pcb and tmc51x0-driver-dev-pcb; bump all four together (the procedure is in kicad-libs/docs/guix-packaging.md), and reset it to plain aliases once the pin catches up.

Routing Helpers

make export-dsn, make freeroute, make import-ses, make clearance-baseline and make clearance-check call the shared kicad-libs commands (orb-weaver-kicad-export-dsn, -import-ses, -clearance-check); the scripts moved out of this repository's scripts/ on 2026-09-25 and the channel pin 768a00b ships them. kicad/clearance-baseline.json is still this board's baseline. Workflow: kicad-libs docs/freerouting-autorouting.md.

KiCad Project State

Layout and routing are complete as of 2026-09-21. The four-layer PCB has 364 footprints, with all 1,204 numbered pad identities matching the schematic. The configured fabrication build reports ERC 0 errors/0 warnings and DRC 0 errors/0 unconnected pads. Its remaining warnings are 499 advisory clearances and 20 dangling vias; clearance regression passes with no voltage-bearing findings. These checks do not establish firmware or bench behavior.

ERC alone did not catch the earlier electrical findings. After schematic or layout edits, compare the exported schematic netlist to the PCB as well as running ERC/DRC. Use .agents/PLANS.md and the tracked handoff above for current status; older dated planning entries are history where completion supersedes them. The project now has 24 netclasses and 166 netclass patterns, the four-layer stackup, plot/fabrication setup and JLCPCB design rules.

The netclasses were doing nothing until 2026-09-17. The .kicad_dru carried an unconditional (constraint clearance (min 0.10mm)) rule, and an unconditional custom clearance constraint replaces the netclass value rather than flooring it — so the effective clearance was 0.10 mm board-wide and all 21 classes' 0.15–0.5 mm settings were dead letters. Fixed in ff081ff: the fab floors moved to Board Setup → Constraints (min_clearance and min_track_width, 0.0 → 0.1 mm) and both unconditional rules were deleted. Never re-add a fab floor as an unconditional rule — the file carries a comment saying so. All conditional rules were kept.

rule_severities.clearance is error here and must stay that way. The existing scoped Legacy low-voltage block clearance is advisory rule demotes non-voltage-bearing pairs to warnings; HV, motor and other voltage-bearing classes remain errors. Preserve that distinction and run make clearance-check after routing. Never suppress the clearance category globally to hide failures.

The inherited patterns were generic names (+24V, VM, PGND, +3V3, USB_HS) that matched almost nothing here — 146 of 156 nets fell to Default at 0.2 mm, including the 36 V rail and all four motor phases, and */HV_IN was silently matching PWR_HV_LOCAL at 0.25 mm. Fixed 2026-08-17. Two things to know before touching them again: this board's rails are spelled +3.3V_*, not +3V3_*; and BRA/BRB are not Kelvin sense nets on a TMC5130A — they carry full coil current into the sense resistor, so they are sized with the motor phases. SENSE_KELVIN exists for the TMC5160's SRA/SRB. If you add patterns, re-check that no net matches more than one netclass.

Validation

For documentation-only changes, review against docs/validation-plan.md gates.

For schematic/layout work, use KiCad ERC/DRC once the design is mature enough for those checks to be meaningful.

ORB_WEAVER_KICAD_LIBS must resolve for KiCad to find the database and footprint libraries.

When editing kicad-libs design blocks, run scrub-private-vendor-fields then validate. Validate inspects .kicad_sch only, so a passing validate does not prove the .kicad_pcb side is clean.

Publication Layers

This repository is mirrored to GitHub for the rig's researchers, so it has two layers (decided 2026-10-12):

A new document goes into exactly one of the two lists. LICENSES/NOTICE.md keeps its kicad-libs URL: it is the CC-BY-SA attribution for the embedded symbols, footprints and blocks.