# Gantry — Wiring, Homing & Firmware

Pairs with BILL_OF_MATERIALS.md. Board = BTT SKR-class running Marlin or Klipper. XYZ = NEMA17 via TMC2209;
the 4 wrist joints = STS3215 on their own serial bus.

## Stepper wiring
- Each NEMA17 has 4 wires = 2 coils (A+/A-, B+/B-). Find pairs with a multimeter (continuity = same coil).
- Plug each motor into a **TMC2209** in the board's X / Y / Z driver slots. If an axis runs backwards, flip
  the connector or invert the axis in firmware.
- **X, Z = belt (GT2 20T)** → steps/mm = 200·(microsteps 16)/(20 teeth·2 mm) = **80 steps/mm**.
- **Y = T8 leadscrew (8 mm lead)** → steps/mm = 200·16/8 = **400 steps/mm**.

## Endstops + homing
- One switch per axis at its home. **Home Y to the TOP** (max) so the arm lifts away from the floor on home;
  X and Z to a convenient min. 2–3 wires each → board endstop pins (X-min, Y-max, Z-min).
- Home order: **Z → X → Y-up**. Then set soft limits = the joint travel in gantry_arm.urdf
  (X ±220, Z ±220, Y 0..-420 mm).
- The Y leadscrew is **self-locking** → the arm holds position on power loss; still keep the Y-top endstop so
  homing never crashes the carriage into the top rail.

## Driver current (TMC2209 Vref)
- NEMA17 ~1.2–1.5 A rated → set run current ~1.0–1.2 A (Vref per your driver: I ≈ Vref/1.41 for TMC2209
  in some firmwares — follow your board's calc). Y can run a touch higher for reliable lifts; it does not need
  holding current (screw self-locks) → enable a low hold current to save heat.

## Wrist servos (STS3215)
- Daisy-chain the 4 servos on the serial bus; one servo cable to a bus adapter (FE-URT / TTL) → a spare board
  UART or a separate MCU. IDs 1–4. These are position servos, controlled independently of the stepper motion.

## Power
- One 24 V PSU: steppers + board logic. STS3215 want 6–12.6 V → a buck converter (24→12 V) for the servo bus.

## Safety / gotchas
- Set soft limits BEFORE first full-speed move.
- Add the drag chain before wiring the moving axes (the hanging wrist bundle must not snag over travel).
- Square the frame; a racked gantry loses steps under acceleration.
