Ryan Malloy c07284a7d6 ESP32 antenna positioner: dual-axis stepper control + automated 3D pattern measurement
PlatformIO firmware for ESP32 + 2x TMC2209 (UART, StallGuard sensorless homing)
driving NEMA 17 steppers. HTTP API with mDNS discovery (positioner.local).

Python side: async httpx client, PositionerMixin with 6 MCP tools including
measure_pattern_3d which orchestrates the full theta/phi sweep — serpentine
scan path, per-point S21 capture, progress reporting, WebSocket broadcast.

Web UI gains positioner REST endpoints (status, move, home).
New measure_antenna_range prompt for guided workflow.
2026-02-01 22:34:10 -07:00

50 lines
2.6 KiB
C

#pragma once
// ── WiFi credentials (set via build flags or edit here) ──────────
#ifndef WIFI_SSID
#define WIFI_SSID "YOUR_SSID"
#endif
#ifndef WIFI_PASS
#define WIFI_PASS "YOUR_PASS"
#endif
// ── Pin assignments ──────────────────────────────────────────────
#define THETA_STEP_PIN 25
#define THETA_DIR_PIN 26
#define THETA_EN_PIN 27
#define PHI_STEP_PIN 32
#define PHI_DIR_PIN 33
#define PHI_EN_PIN 14
// ── TMC2209 UART ─────────────────────────────────────────────────
#define TMC_RX_PIN 16
#define TMC_TX_PIN 17
#define THETA_TMC_ADDR 0
#define PHI_TMC_ADDR 1
#define TMC_R_SENSE 0.11f // sense resistor value (ohms)
#define TMC_RMS_CURRENT 800 // motor current in mA
// ── Motor constants ──────────────────────────────────────────────
#define STEPS_PER_REV 200
#define DEFAULT_MICROSTEPS 16 // 0.1125 deg per microstep
// Steps per degree = STEPS_PER_REV * MICROSTEPS / 360.0
// At 16 microsteps: 200 * 16 / 360 = 8.888...
// ── Motion defaults ──────────────────────────────────────────────
#define DEFAULT_MAX_SPEED 2000.0f // steps/sec (~225 deg/sec)
#define DEFAULT_ACCEL 1000.0f // steps/sec^2 (~112 deg/sec^2)
#define SETTLE_MS 200 // ms after move before measurement
// ── Homing ───────────────────────────────────────────────────────
#define HOME_SPEED 500.0f // steps/sec (slower for stall detect)
#define STALL_THRESHOLD 50 // TMC2209 StallGuard threshold (tune per setup)
#define HOME_BACKOFF_STEPS 100 // steps to back off after stall detection
// ── Safety ───────────────────────────────────────────────────────
#define IDLE_DISABLE_MS 30000 // disable motors after 30s idle
#define WATCHDOG_TIMEOUT_S 60 // WDT reset if no command while moving
// ── mDNS ─────────────────────────────────────────────────────────
#define MDNS_HOSTNAME "positioner"