hispec-fib
An embedded control project for the fiber subsystem of HISPEC, a high-resolution spectrograph for the Keck Telescope
HISPEC-FIB
Fiber Subsystem Control Project for the HISPEC Astronomical Instrument

Caltech Optical Observatories (COO) is an astronomical research organization at the California Institute of Technology (Caltech), managing the Palomar Observatory and Caltech's participation at Keck Observatory, while developing advanced instrumentation for both facilities.
| Item | Details |
|---|---|
| Organization | Caltech Optical Observatories (COO) |
| Target Instrument | HISPEC — W. M. Keck Observatory (Keck II Telescope) |
| Subsystem | FIB (Fiber Injection Bench / Fiber Subsystem) |
| Embedded Board | W5500-EVB-PICO2 (RP2350 + WIZnet W5500) |
| Tech Stack | Python (lightpath/throughput model), C++ FreeRTOS (embedded), Zyre-like TCP/UDP, mKTL |
| Controlled Components | 7 components: TIB, CAL B/R Fiberswitches, Achromatic Splitter, Blue/Red Main Switches |
| Document Reference | Jeb Bailey, August 2025 (internal technical documents + source code) |
1. Background
HISPEC (High-resolution Infrared Spectrograph) is a high-resolution infrared spectrograph being developed by Caltech Optical Observatories for the W. M. Keck Observatory in Hawaii.
hispec-fib is the software project that controls FIB (Fiber Subsystem), which manages the routing of light through the instrument.
- Configures optical paths in real time across tens of meters — from the Nasmyth platform down to the spectrograph room
- Controls switches and fiber connections to direct science light (for observation) and calibration light (for instrument calibration) along the correct paths
- Reconfigures the full optical path flexibly depending on the science objective, such as exoplanet atmosphere characterization or precision radial velocity measurements
2. Controlled Components: 7 in Total
FIB consists of 7 components distributed across physically separate locations.
| Component | Location & Role |
|---|---|
| TIB (Trunk Interface Box) | Below the Nasmyth platform in the Keck dome. Central control box managing 6 laser sources, variable attenuators, and photodiodes |
| CAL B Fiberswitch | B Calibration rack. Switches calibration light paths for the blue channel |
| CAL R Fiberswitch | R Calibration rack. Switches calibration light paths for the red channel |
| Achromatic Splitter (AS) | Main Switch rack. Handles both B/R channels simultaneously. Splitting ratio software-controlled |
| Blue Main Switch | Main Switch rack. Mechanical XY-stage fiber switcher + USB fiber tip inspection camera |
| Red Main Switch | Main Switch rack. Identical design to Blue Main Switch |
| RaspberryPi | Main Switch rack. Dedicated host for Blue/Red Main Switch USB cameras |
Note: The first four components (TIB, CAL B/R, AS) share a common PCB design and all use the W5500-EVB-PICO2 board. The two main switches are a separate design based on a vendor-supplied PLC and fiber imaging cameras.
3. Hardware Configuration
The actual hardware configuration of the embedded controllers is clearly documented in embedded/docs/breadboard.md and embedded/docs/status.md.
Main Controller Board
The W5500-EVB-PICO2 is the core board used across the embedded controllers including the TIB. It integrates an RP2350 (dual Cortex-M33, 264KB SRAM, 2MB flash) and a WIZnet W5500 Ethernet controller (SPI-based TCP/IP offload, integrated PHY + RJ45) on a single board, with the W5500 connected via SPI0 (GP16–21).
Peripheral Device Configuration
| Device | Role | Interface |
|---|---|---|
| ADS1115 (16-bit ADC) | 2-channel photodiode measurement | I2C0 (GP4/GP5), addr 0x48/0x49 |
| DAC7578SPW (8ch DAC) + OPA2991 OpAmp | Controls 6 variable optical attenuators | I2C1 (GP2/GP3), addr 0x4C |
| PCAL6416A (I2C 16-GPIO expander) | Controls 8 MEMS optical switches | I2C1 (GP2/GP3), addr 0x20 |
| Maiman SF8250-ZIF14 | 6 laser diode drivers | UART1 (GP8/GP9), RS-485 |
| Level Shifter (Phillips 4-bit bidirectional) | 3.3V ↔ 5V level translation | — |
| Power Switch | Power control for photodiodes and laser drivers | GP6 |
embedded/docs/notes.mddocuments the W5500 driver selection process. Both the WIZnet-PICO-LWIP-C and WIZnet-PICO-C examples were evaluated. After identifying a build bug in the latter's W5500 Pico2 support (related to#if 1), the team opted to integrate the ioLibrary_driver directly.
4. Software Architecture
4-1. Embedded Firmware (C++ / FreeRTOS)
The embedded codebase is a multi-task C++ structure built on FreeRTOS, with three core design principles: "no runtime exceptions", "static memory layout", and "single ownership". Network communication (coms_task), command dispatch (executor_task), and asynchronous photodiode polling (photodiode_task) run as separate tasks, and each hardware device — MEMS switches, lasers, and attenuators — is abstracted into an independent device object.
Communication Protocol: Zyre-like
The design documents describe an MQTT-based interface, while embedded/docs/status.md describes the actual embedded implementation using a Zyre-like TCP/UDP messaging layer. The two are inconsistent within the same repository, and the final implementation has not been fully verified at the source code level.
- ENTER: UDP broadcast for dynamic network self-discovery
- WHISPER: TCP-based 1:1 command reception (mKTL command path)
- PUB: Asynchronous data publishing (photodiode telemetry, etc.)
Networking is DHCP-based and designed to automatically restart DHCP after a link loss.
4-2. AIT Modbus Tool (modbus_communication.py)
The Modbus code under ait/photonic_testing/maiman_modbus/ is not operational control code. As the path implies, it is a tool used during AIT (Assembly, Integration and Test) to directly test the Maiman laser drivers over RS-485/Modbus RTU.
Built on minimalmodbus + pyserial, it provides register-level read/write and multi-register access. In production, lasers are controlled via UART RS-485 from the embedded firmware — the Modbus tool serves a separate role for hardware validation during integration testing.
4-3. LightPath Manager (lightpath.py) — A Working Optical Simulator
lightpath.py is not a design sketch — it is executable Python code. It represents HISPEC's entire optical system as a graph and computes spectrum propagation through it.
Each optical component (fibers, switches, WDMs, attenuators, lasers, photodiodes, spectrographs) is modeled as a Python class, and LightpathManager owns the full connectivity graph.
Path Traversal
When switch states change, the active optical paths change with them. LightpathManager performs a DFS over the graph reflecting the current switch states, accumulates the TransmissionCurve product along each path, and sums the spectra arriving at each detector.
5. Role of WIZnet W5500
Confirmed roles based on embedded/docs/status.md and breadboard.md.
| Role | Details |
|---|---|
| Network connectivity layer for embedded controllers | W5500 connected to RP2350 via SPI. WIZnet ioLibrary Driver integrated directly to provide hardware TCP/IP stack. DHCP-based network participation with automatic reconnection after link loss |
| mKTL-based command delivery channel | Receives mKTL JSON commands from upper-level control software over TCP and delivers them to the embedded controller |
| Telemetry collection and upper-level software integration | Asynchronously sends photodiode polling results to the upper-level system. SNTP time synchronization is not yet implemented |
6. Technical Notes
Hardware control and physical model in the same context: Hardware command execution and optical path simulation coexist in the same operational context. When a laser setting changes, the effect on the spectrum reaching the spectrograph can be reasoned about directly within the software.
Clear separation between AIT and operational code: The Modbus code under ait/ and the FreeRTOS code under embedded/ are clearly separated. The same hardware (Maiman laser drivers) is accessed via Python Modbus during AIT and via embedded UART in production — a structure that prevents code confusion during the handoff from integration testing to operation.
7. Current Development Status
This project is actively under development. It is not a finished product — it is in an integration validation stage where some components are functional and the architecture is finalized, but work remains.
FAQ
Q. Why is the WIZnet W5500 specifically necessary for this project?
The FIB embedded controllers need to handle TCP command reception and telemetry transmission simultaneously in a DHCP-based Ethernet environment. The W5500 provides a hardware TCP/IP stack over SPI, reducing the software burden on the RP2350 while maintaining stable network connectivity. This is particularly valuable in a FreeRTOS environment where network tasks must not interfere with real-time hardware control tasks.
Q. Can the W5500-EVB-PICO2 be replaced with a different board?
This board is explicitly specified in the design documents, and the WIZnet ioLibrary Driver is directly integrated into the codebase. Substitution with another W5500-based board may be possible, but the current code is written around the RP2350 + W5500 pin layout and SPI configuration.
Q. Can this project's architecture be applied to other instrument control or industrial environments?
The component-graph structure of the LightPath Manager and the task-separated embedded firmware design are both worth referencing for other multi-device optical control systems, beyond HISPEC-specific parts. That said, since the project is still under active development, APIs and interfaces are subject to change.
Q. How can I run the code locally?
The Python side (lightpath.py) can be run without hardware by installing dependencies such as synphot, astropy, and scipy — enough to explore the optical path simulation. The embedded firmware requires a W5500-EVB-PICO2 board, the Pico SDK, and a FreeRTOS build environment.

