Expose the Koheron CTL200 thermistor setpoint (rtset) as a settable HA number in ohms, clamped to SEED_RT_SETPOINT_MIN/MAX_OHM. The former read-only setpoint sensor is replaced by this control. Add a read-only seed temperature in °C, computed in firmware from the actual thermistor resistance via an NTC β-model (constants in config.h; update once the DFB1550LP thermistor R25/β are confirmed). Verified end-to-end over MQTT: set/clamp/restore of rtset and the °C conversion (10 kΩ → 25.00 °C). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
84 lines
4.3 KiB
C
84 lines
4.3 KiB
C
// Compile-time configuration for the Butterfly EDFA Rack bridge.
|
|
#pragma once
|
|
#include "secrets.h"
|
|
|
|
// ── MQTT topics ─────────────────────────────────────────────────────
|
|
// One HA device, one topic base. Sub-units namespaced under it:
|
|
// <base>/availability online | offline (LWT)
|
|
// <base>/diag/<key> ESP/network diagnostics
|
|
// <base>/seed/<key> Koheron CTL200 (increment 3)
|
|
// <base>/amp/<key> Agiltron M511 EYDFA (increment 4)
|
|
// <base>/set/<...> command topics (increment 5)
|
|
#define TOPIC_BASE "lab/laser/" DEVICE_NAME
|
|
#define TOPIC_AVAIL TOPIC_BASE "/availability"
|
|
#define DISCOVERY_PREFIX "homeassistant"
|
|
|
|
#define AVAIL_ONLINE "online"
|
|
#define AVAIL_OFFLINE "offline"
|
|
|
|
#define TOPIC_CMD TOPIC_BASE "/set" // subscribe <base>/set/#
|
|
|
|
// ── Agiltron M511 identity & safety limits ──────────────────────────
|
|
// SN Y4022708 / PN EDFA-1C51113331111 -> device ID 0x0000006F (edfa.py).
|
|
// Startup reads SN/PN and logs them so the ID is confirmed before control.
|
|
#define AGILTRON_DEV_ID 0x00, 0x00, 0x00, 0x6F
|
|
|
|
// HA number sliders are capped here. The hardware allows 8000 mA pump, but
|
|
// the lab notes report ~2500 mA pump-1 -> ~27 dBm (~515 mW). Keep a margin.
|
|
#define SEED_CURRENT_MAX_MA 300 // CTL200 ilmax default is 1000; seed DFB is low-power
|
|
// Pump-1 clamp = the 1 W rated operating point (~4000 mA, measured 2026-06-17).
|
|
// Raise deliberately only for supervised over-rating characterisation; it is a
|
|
// guardrail against accidental over-drive, not a safety interlock.
|
|
#define PUMP_CURRENT_MAX_MA 4000
|
|
|
|
// Seed thermistor setpoint (CTL200 `rtset`) clamp, in ohms. The CTL200 has no
|
|
// native °C setpoint; it regulates the seed TEC to hold the thermistor at this
|
|
// resistance. The default operating point is 10 kΩ. The range below spans
|
|
// roughly 39…13 °C on the β-model (a guardrail, not a diode-safe interlock —
|
|
// narrow it if the DFB1550LP datasheet gives a tighter window).
|
|
#define SEED_RT_SETPOINT_MIN_OHM 6000
|
|
#define SEED_RT_SETPOINT_MAX_OHM 16000
|
|
|
|
// NTC β-model for the read-only resistance→°C conversion (display only; the
|
|
// CTL200 does its own regulation in ohms). Assumes a 10 kΩ @ 25 °C NTC with
|
|
// β = 3435 K. Update if the seed thermistor's R25/β are known to differ.
|
|
#define SEED_THERMISTOR_R25_OHM 10000.0f
|
|
#define SEED_THERMISTOR_BETA_K 3435.0f
|
|
#define SEED_THERMISTOR_T25_K 298.15f
|
|
|
|
// ── Serial links to the instruments (wired in later increments) ─────
|
|
// UART0 stays the USB console. The classic ESP32 has 3 hardware UARTs.
|
|
//
|
|
// Koheron CTL200 (ASCII, 115200 8N1, "\r\n", ">>" prompt) -> UART2
|
|
// ESP32 GPIO17 (TX2) -> CTL200 RX, GPIO16 (RX2) <- CTL200 TX, GND
|
|
//
|
|
// Agiltron M511 (binary 0x55AA packets, 115200 8N1) -> UART1
|
|
// ESP32 GPIO26 (TX1) -> M511 RX(pin3), GPIO25 (RX1) <- M511 TX(pin7), GND
|
|
// (UART1 default pins clash with SPI flash on WROOM, so remap to 26/25.)
|
|
#define KOHERON_UART_NUM 2
|
|
#define KOHERON_TX_PIN 17
|
|
#define KOHERON_RX_PIN 16
|
|
#define KOHERON_BAUD 115200
|
|
|
|
#define AGILTRON_UART_NUM 1
|
|
#define AGILTRON_TX_PIN 26
|
|
#define AGILTRON_RX_PIN 25
|
|
#define AGILTRON_BAUD 115200
|
|
|
|
// ── Static IP ───────────────────────────────────────────────────────
|
|
// Pinned to .150 (free as of 2026-06-17) to avoid the DHCP clash with the
|
|
// BKtel EDFA Pi on .101. Comment out USE_STATIC_IP to fall back to DHCP.
|
|
#define USE_STATIC_IP
|
|
#define STATIC_IP_OCTETS 192, 168, 0, 150
|
|
#define GATEWAY_OCTETS 192, 168, 0, 1
|
|
#define SUBNET_OCTETS 255, 255, 255, 0
|
|
#define DNS_OCTETS 192, 168, 0, 1
|
|
|
|
// ── Timing ──────────────────────────────────────────────────────────
|
|
#define PUBLISH_INTERVAL_MS 2000 // telemetry cadence
|
|
#define MQTT_RECONNECT_MS 5000
|
|
|
|
// PubSubClient's default 256-byte buffer is too small for discovery
|
|
// payloads that embed the device block; bump it.
|
|
#define MQTT_BUFFER_SIZE 1024
|