September 2026–present
Work in progress
Sending Data Through Lasers
Building a 638 nm optical link between two Raspberry Pis with six custom PCBs, from USB interfaces and laser drivers to mixed-signal, FPGA-based receivers.
- optics
- FPGA
- analog circuits
- PCBs
Link simulation
Hello world
—
Bit-aligned traces. TIA voltage is illustrative, on a relative scale.
Each node has a Raspberry Pi, USB interface, transmitter, and receiver. Two independent beams carry data in opposite directions.
Transmission is slowed for visibility. The simulation sends raw payload bits; the planned link uses 8b/10b coding and CRC-based retries, with a 50 Mbit/s line-rate target.
Overall architecture
The link is designed around two matching nodes. Each has a Raspberry Pi, a physical USB interface (PHY-A), a transmitter (TX-A), and an receiver (RX-A). Two separate beams carry data in opposite directions, allowing each node to transmit and receive simultaneously.
The Raspberry Pis run the host CLI software; the custom boards handle the optical link. An STM32F723-based USB interface buffers data between the Pi and the transmitter and receiver boards via USB 2.0 to the Pis. TX-A drives an HL63603TG laser diode from a serial input from the STM32. At the other end, RX-A converts the incoming light into a differential signal, with an iCE40UP5K FPGA intended to recover timing and decode the data before passing it back to the Pi through the STM32.
PCBs
Each node uses three boards: PHY-A, the USB interface; TX-A, the transmitter; and RX-A, the receiver.
PHY-A / USB interface
This board connects the Raspberry Pi to the optical hardware. It buffers outgoing data for TX-A and accepts recovered data from RX-A.
STM32F723 Handles USB communication and data between the host and the two TX/RX boards.
Board connections A serial data line feeds TX-A. A separate connection (the large 14 pin) brings decoded bytes and control signals back from RX-A.
Power and debug Local power handling, a programming header, and status indicators support bring up independently of the host software
Buffers data between the Raspberry Pi, transmitter, and receiver.
TX-A / transmitter
TX-A converts the incoming bit stream into changes in laser current. The laser is mounted separately from this board via screw terminal.
Current driver The analog driver sets the diode current, while the modulation path switches the optical output with the data.
Power and enable A TPS61085 boost converter supplies the driver, taking 5V (sourced upstream from Pi 5V peripheral line via USB) to 8V. Arming this rail requires both the physical jumper and the digital arm signal from the PHY board (PHY-A).
HL63603TG · 638 nm The external laser diode which creates the 638 nm light for carrying data between hosts.
The OPA356 compares the current-sense signal with the setpoint and drives the current-control stage.
RX-A / receiver
RX-A contains the optical front end and the FPGA. It turns incoming light into a differential signal that can be decoded and passed to the USB interface.
S5972 The photodiode produces a current in response to received light, chosen specifically for its response to 638 nm wavelength and balance of capacitance to surface area.
AD8015 → SY88803V The transimpedance amplifier converts that current to a voltage. The limiting amplifier conditions the signal for the digital stage.
iCE40UP5K The FPGA is intended to recover timing, decode the stream, and deliver recovered bytes to the USB interface. Programming done via SPI to external flash.
Converts incoming laser light into a small electrical current.
Mechanical layout
The mechanical assembly brings the Raspberry Pi, USB interface, transmitter, and receiver onto a shared sled. A common baseplate carries the board mounts, laser holder, and receiver optics above the 2040 rail.
These images were captured directly from the Fusion assembly on October 14, 2026. The close-ups show the receiver shroud and the laser mounting hardware. This is the current CAD layout; physical fit and optical alignment still need to be checked during assembly.
Explore the assembly
Rotate the sled to inspect the board carriers, receiver shroud, and laser mount. Select Full rail to see the complete assembly, or Reset to return to the sled. The STEP download contains the full assembly exported from Fusion.
Bring-up
Notes on initial power-up, board testing, and the first optical link.
Boards as received
The USB interface, TX-A, and RX-A boards before manual population of the remaining components. The paired views show each board alongside an unpopulated PCB. Select a photo for a closer look.
Power and first firmware
All power rails check out, and a simple test program has been flashed to the STM32F723. The clock and GPIO/control signals have also been verified.
USB enumeration on macOS
October 28, 2026. The STM32F723 on PHY-A now enumerates over USB on the Mac as STM32 Virtual ComPort. macOS creates a CDC serial port at /dev/cu.usbmodem3784356930311. The board appears as its own USB device alongside the ST-Link programmer.
A separate live check of the Mac's USB and serial registries confirmed the device was active and configured:
| Check | Observed result |
|---|---|
| USB product | STM32 Virtual ComPort |
| Manufacturer | STMicroelectronics |
| Vendor / product ID | 0483:5740 |
| USB configuration | 1 (configured) |
| Serial port | /dev/cu.usbmodem3784356930311 |
| Reported USB link speed | 480 Mb/s (high speed) |
The captured USB and serial registry output records the independent enumeration check. The 480 Mb/s figure is the reported bus speed, not measured application throughput.
First USB echo
October 28, 2026. With a CDC echo handler added to the firmware, the first text exchange works: Hello PHY-A! is sent from the Mac and echoed back by the STM32 over USB. The terminal session uses screen /dev/cu.usbmodem3784356930311 115200.
The receive callback copies incoming bytes into a 512-byte buffer and sends them back with CDC_Transmit_HS, then rearms reception. This demonstrates a short host-to-board-to-host text exchange. The chunk-size benchmark below measures repeated binary exchanges on the Mac; Raspberry Pi host testing is still to come.
256 byte send-receive test
October 29, 2026. With test/usb-speed/main.py. bytes(range(256)) is sent to the MCU over USB, which is then sent back to the host to verify integrity.
USB echo throughput
October 29, 2026. Running test/usb-speed/benchmark.py against PHY-A on the Mac verified 800 binary round trips with no mismatches. The script sends a fresh random payload, waits for the complete echo, and compares every byte before sending the next payload: 200 exchanges each at 64, 128, 256, and 512 bytes.
Payload throughput (Mbit/s)
| Chunk size | Avg. round trip | Throughput |
|---|---|---|
| 64 B | 192 µs | 2.670 Mbit/s |
| 128 B | 209 µs | 4.910 Mbit/s |
| 256 B | 251 µs | 8.175 Mbit/s |
| 512 B | 461 µs | 8.881 Mbit/s |
Measured payload throughput rises from 2.670 Mbit/s at 64 bytes to 8.881 Mbit/s at 512 bytes. Larger chunks carry more data per exchange, although the average round trip also increases. These are single-run measurements on macOS over USB CDC, with the serial port configured at 115200 baud.
Throughput is calculated as outgoing payload bits divided by the elapsed time for the complete send-and-echo loop; returned echo bytes are not added to that numerator. Average round trip is the total elapsed time divided by 200, including Python payload generation, serial I/O, and byte verification. This measures the host and firmware echo loop, rather than the USB bus rate or the optical link's throughput.
Download the benchmark output or the full-precision timings and run metadata.
87.37 Mbit/s USB transmit at 168 MHz
October 29, 2026. A major step forward for PHY-A: with the STM32F723 core clock set to 168 MHz and trace disabled, the board streamed 10 MiB to the Mac at 87.37 Mbit/s over USB CDC. The captured run received all 10,485,760 bytes in 0.960 seconds, then verified every byte successfully.
The TX benchmark, test/usb-speed/tx-benchmark.py is now published alongside the matching firmware and clock configuration. Run it with:
python3 tx-benchmark.py --trace off
| Measurement | Captured result |
|---|---|
| MCU core clock | 168 MHz |
| Trace | Disabled (--trace off) |
| Direction | PHY-A → Mac |
| Payload received | 10,485,760 bytes (10 MiB) |
| Transfer time | 0.960 s |
| Payload throughput | 87.37 Mbit/s |
| Data integrity | PASS — all bytes verified |
The host sends a start command, and the firmware generates a deterministic XOR byte pattern and transmits it in 4,096-byte chunks. The script times the transfer from the start request until the full payload arrives; the byte-by-byte integrity check runs afterward. This is continuous MCU-to-host USB throughput. The earlier graph records sequential host-to-MCU-to-host echo exchanges, so the two tests measure different workloads.
The captured terminal output can be viewed here.
Some weird behaviour: most of this jump from previous echo tests to ~87mbit/s is attributable to increasing clock speed SYSCLK to 168 MHz and compiling to optimize for speed rather than binary size, with build flag in CubeIDE set to 03 (Optimize most / Aggressive optimization) as opposed to defaults -0g or 0s which optimize for debugging and binary size respectively. However, when SYSCLK is increased beyond 168 MHz to, say, 192 or 216, the throughput actually decreases. I'm looking into that now.
| CPU clock | TX-only | Bidirectional echo |
|---|---|---|
| 96 MHz | 27.59 Mbit/s | 15.50 Mbit/s |
| 144 MHz | 84.05 Mbit/s | 21.68 Mbit/s |
| 168 MHz | 87.36 Mbit/s | 22.83 Mbit/s |
| 192 MHz | 39.03 Mbit/s | 22.94 Mbit/s |
| 216 MHz | 40.31 Mbit/s | 23.01 Mbit/s |
Reported throughput (Mbit/s)
- TX-only
- Bidirectional echo
162 Mbit/s USB transmit at 216 MHz
October 30, 2026. As mentioned above, increasing clock speed to 216 MHz from 168 Mhz (which previously yielded the best result of ~87 Mbit/s) resulted in worse USB throughput. Today, I investigated whether this limitation was in the firmware’s execution path rather than the USB link itself.
The clearest change came from enabling the M7's instruction cache, with SCB_EnableICache(); in main(). While keeping SYSCLK at 168 MHz, four fully logged 10-mebibyte transfers from MCU to Mac averaged 137.90 Mbit/s. With instruction cache enabled, throughput increased by ~58% against the prior-day measurement with the same clock speed.
With instruction cache still enabled, increasing SYSCLK to 216 MHz now produced the expected throughput increase. Four fully logged transfers from MCU to Mac averaged 157.13 Mbit/s. The earlier regression associated with higher clock speeds no longer appeared in this configuration. While instruction caching did mitigate the regression, it does not necessarily isolate the cause of the original slow down at 216 MHz.
I then tested transfer sizes and buffering. Increasing the transmit chunk from 4 KiB to 16 KiB moved two verified runs from about 157.1 Mbit/s to 159.8–160.4 Mbit/s. This was a much smaller improvement than enabling I-cache. Longer, 100 MiB streaming echo tests measured approximately 76.9 Mbit/s with successful verification.
Further experiments with data caching, FIFO allocation, and USB DMA produced results around 161 Mbit/s transmit and 78 Mbit/s echo, without a clear additional throughput improvement. One configuration with D-cache enabled also timed out before receiving the full payload. Later tests completed, but the cause of that failure has not yet been isolated, so I’m keeping it in the test record rather than treating the highest result as a reliability claim.
The main outcome is a substantially faster, measured USB transport on the custom PHY-A board. This is still a USB subsystem benchmark; the greater throughput of the laser system will probably not be bottlenecked by USB transfer speeds.
Instruction cache and CPU clock
Mean TX throughput at 168 MHz: 87.36 Mbit/s without I-cache and 137.90 Mbit/s with I-cache (57.9% difference). At 216 MHz with I-cache: 157.13 Mbit/s.
TX throughput (Mbit/s)
- I-cache on · logged means
- I-cache off · reported sweep
10 MiB TX payloads, 4 KiB submissions. I-cache-on groups: n=4 at 168 MHz and n=4 at 216 MHz.
Run values
| Configuration | Payload | Runs (Mbit/s) | Mean | n |
|---|---|---|---|---|
| 168 MHz · I-cache off · 4 KiB TX setting | 10 MiB | 87.36 | 87.36 | 1 |
| 168 MHz · I-cache on · 4 KiB TX setting | 10 MiB | 137.89, 137.89, 137.91, 137.91 | 137.90 | 4 |
| 216 MHz · I-cache on · 4 KiB TX setting | 10 MiB | 157.14, 157.13, 157.04, 157.22 | 157.13 | 4 |
Uncached clock sweep
| CPU clock | Rates (Mbit/s) | Mean | n |
|---|---|---|---|
| 96 MHz | 27.59, 27.59 | 27.59 | 2 |
| 144 MHz | 84.05 | 84.05 | 1 |
| 168 MHz | 87.36 | 87.36 | 1 |
| 192 MHz | 39.03 | 39.03 | 1 |
| 216 MHz | 40.32, 40.31, 40.31 | 40.31 | 3 |
TX submission size
At 216 MHz with I-cache, the 4 and 16 KiB groups differ by 1.92%. The highest trial is 160.40 Mbit/s.
Mean throughput (Mbit/s); dots show individual trials
Run values
| Configuration | Payload | Runs (Mbit/s) | Mean | n |
|---|---|---|---|---|
| 216 MHz · I-cache on · 4 KiB TX setting | 10 MiB | 157.07, 157.08 | 157.08 | 2 |
| 216 MHz · I-cache on · 16 KiB TX setting | 10 MiB | 160.40, 159.78 | 160.09 | 2 |
Streaming echo
The 100 MiB groups average 76.91 and 76.92 Mbit/s. Throughput counts the payload once over the complete round trip.
Mean throughput (Mbit/s); dots show individual trials
The 4/16 KiB labels record the TX-only setting; echo queue batching is independent of this value.
Run values
| Configuration | Payload | Runs (Mbit/s) | Mean | n |
|---|---|---|---|---|
| 216 MHz · I-cache on · 4 KiB TX setting | 10 MiB | 80.30 | 80.30 | 1 |
| 216 MHz · I-cache on · 4 KiB TX setting | 100 MiB | 76.92, 76.91 | 76.91 | 2 |
| 216 MHz · I-cache on · 16 KiB TX setting | 100 MiB | 76.87, 76.97 | 76.92 | 2 |
D-cache, FIFO and DMA
Later reported rates stayed around 161 Mbit/s TX. These results have no complete transfer log or explicit full-payload PASS.
| Experiment | TX (Mbit/s) | Echo (Mbit/s) |
|---|---|---|
| D-cache enabled | ≈161 | 78.83 |
| FIFO reallocation | Reported unchanged; no numerical sample | |
| USB DMA enabled | ≈161 | ≈78 |
One D-cache TX transfer timed out 75,993 bytes short of 10 MiB. Its cause remains unresolved.
TX-A / 8 V rail
The TPS61085 boosts the incoming 5 V supply to the nominal 8 V laser-driver rail on TX-A. This rail requires two arming conditions: the physical jumper must be fitted, and the PHY board (PHY-A) must assert its digital arm signal.
The first oscilloscope check shows a beautifully flat trace: 7.969 V average, with 32 mV peak-to-peak variation in this capture—about 0.40% of the measured rail voltage. The photo below records the steady-state rail, with the measurements transcribed underneath.
| Measurement | Scope display | Rail voltage (x10) |
|---|---|---|
| Average voltage | 796.9 mV | 7.969 V |
| Minimum voltage | 795.2 mV | 7.952 V |
| Maximum voltage | 798.4 mV | 7.984 V |
| Peak-to-peak variation | 3.2 mV | 32 mV |
| RMS voltage, including DC | 796.9 mV | 7.969 V |
| Mid-level voltage | 796.8 mV | 7.968 V |
Probe scaling: the probe was set to 10× while the scope channel was set to 1x, so voltage readouts are multiplied by ten in the rail-voltage column. Channel 1 is DC-coupled at a displayed 20 mV/div (200 mV/div at the rail), with a 1 us/div timebase and 250 MSa/s acquisition over a 4K-point record. The RMS reading includes the DC level; it is not an RMS ripple measurement.
The TPS61085 documentation from Texas Instruments is the boost convert used (5V to 8V). But arming is not done with the 61085's en pin, but rather, an upstream TPS22919DCKR that modulates the clean incoming 5V rail from a digital signal from PHY. (The armed 5V line is also controlled by this same digital signal for many peripherals)