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

A / transmit

Hello world

B / receive

—

To send
After TIAvoltage
Received

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

Loading model…
STEP ↓
U1 · STM32F723

Buffers data between the Raspberry Pi, transmitter, and receiver.

Drag to rotate · Pinch to zoom. Arrow keys rotate; + / − zoom.

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.

Loading model…
STEP ↓
U4 · Laser current control

The OPA356 compares the current-sense signal with the setpoint and drives the current-control stage.

Drag to rotate · Pinch to zoom. Arrow keys rotate; + / − zoom.

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.

Loading model…
STEP ↓
D1 · S5972 photodiode

Converts incoming laser light into a small electrical current.

Drag to rotate · Pinch to zoom. Arrow keys rotate; + / − zoom.

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.

Three-quarter Fusion CAD view of the laser sled, showing the Raspberry Pi, custom boards, laser holder, and black receiver shroud on a shared baseplate above an aluminum rail.
Laser sled — the electronics and optical hardware on a common rail-mounted baseplate.

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.

Loading assembly…
STEP ↓
Drag to rotate · Pinch to zoom. Arrow keys rotate; + / − zoom. Home resets the sled view.

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.

The custom USB interface board on a sunlit desk beside a laptop, with a USB-C cable and programming leads connected to the STM32F723 board.
USB interface during initial programming. Select the photo for the full-resolution image.

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.

macOS terminal showing STM32 Virtual ComPort and STM32 STLink as separate USB devices, followed by three serial-port listings in which the STM32 usbmodem port is present, absent, and present again.
First USB enumeration on the Mac. The serial-port listings show the STM32 port disappearing and reappearing.

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.

Mac terminal running screen on the STM32 USB serial port and displaying Hello PHY-A!, with the CDC receive handler and its echo buffer visible behind the terminal.
First USB echo — “Hello PHY-A!” returned in the Mac's serial terminal, with the firmware echo handler visible behind it.

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.

Mac terminal running screen on the STM32 USB serial port and displaying Hello PHY-A!, with the CDC receive handler and its echo buffer visible behind the terminal.
First USB echo — “Hello PHY-A!” returned in the Mac's serial terminal, with the firmware echo handler visible behind it.

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.

USB echo throughput by chunk size200 verified round trips per chunk size

Payload throughput (Mbit/s)

USB echo throughput by chunk sizeThroughput rises from 2.670 Mbit/s at 64 bytes to 8.881 Mbit/s at 512 bytes. Exact values and average round-trip times are in the table below.024681064128256512Chunk size (bytes)
Measured USB echo performance, October 29, 2026. All rows passed byte-for-byte verification.
Chunk sizeAvg. round tripThroughput
64 B192 µs2.670 Mbit/s
128 B209 µs4.910 Mbit/s
256 B251 µs8.175 Mbit/s
512 B461 µs8.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.

STM32CubeMX clock tree for PHY-A, showing a 25 MHz HSE divided by 25, multiplied by 336, and divided by 2 to produce 168 MHz SYSCLK and HCLK. PLLQ divides by 7 to supply the 48 MHz USB peripheral clock. APB1 runs at 42 MHz and APB2 at 84 MHz.
PHY-A clock configuration in CubeMX — 168 MHz core/AHB clock and a 48 MHz USB peripheral clock, derived from the 25 MHz HSE. Select the image to read the full clock tree.

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.

USB throughput by CPU clockTX-only and bidirectional echo · 96–216 MHz
USB clock sweep results transcribed from the supplied benchmark image.
CPU clockTX-onlyBidirectional echo
96 MHz27.59 Mbit/s15.50 Mbit/s
144 MHz84.05 Mbit/s21.68 Mbit/s
168 MHz87.36 Mbit/s22.83 Mbit/s
192 MHz39.03 Mbit/s22.94 Mbit/s
216 MHz40.31 Mbit/s23.01 Mbit/s

Reported throughput (Mbit/s)

USB throughput by CPU clockTX-only throughput peaks at 87.36 Mbit/s at 168 MHz, then drops to 39.03 at 192 MHz and 40.31 at 216 MHz. Bidirectional echo increases from 15.50 to 23.01 Mbit/s across the clock sweep. All five readings for both series are listed in the table above. The horizontal axis uses a linear MHz scale.025507510096144168192216CPU clock (MHz)
  • 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)

CPU clock and instruction cacheCPU clock comparison. I-cache-on means are 137.90 Mbit/s at 168 MHz (n=4) and 157.13 Mbit/s at 216 MHz (n=4). The table lists every trial.030609012015018096 MHz, I-cache off: 27.59 Mbit/s mean; n=2.96144 MHz, I-cache off: 84.05 Mbit/s mean; n=1.144168 MHz, I-cache off: 87.36 Mbit/s mean; n=1.168192 MHz, I-cache off: 39.03 Mbit/s mean; n=1.192216 MHz, I-cache off: 40.31 Mbit/s mean; n=3.216168 MHz, I-cache on: 137.90 Mbit/s mean; n=4; range 137.89–137.91.137.90216 MHz, I-cache on: 157.13 Mbit/s mean; n=4; range 157.04–157.22.157.13CPU clock (MHz)
  • 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
Throughput per trial, group means and sample counts.
ConfigurationPayloadRuns (Mbit/s)Meann
168 MHz · I-cache off · 4 KiB TX setting10 MiB87.3687.361
168 MHz · I-cache on · 4 KiB TX setting10 MiB137.89, 137.89, 137.91, 137.91137.904
216 MHz · I-cache on · 4 KiB TX setting10 MiB157.14, 157.13, 157.04, 157.22157.134
Uncached clock sweep
Original user-reported rates; complete terminal logs are unavailable for this sweep.
CPU clockRates (Mbit/s)Meann
96 MHz27.59, 27.5927.592
144 MHz84.0584.051
168 MHz87.3687.361
192 MHz39.0339.031
216 MHz40.32, 40.31, 40.3140.313

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

4 KiB TX submission10 MiB payload · n=2
157.08mean
16 KiB TX submission10 MiB payload · n=2
160.09mean
Run values
Throughput per trial, group means and sample counts.
ConfigurationPayloadRuns (Mbit/s)Meann
216 MHz · I-cache on · 4 KiB TX setting10 MiB157.07, 157.08157.082
216 MHz · I-cache on · 16 KiB TX setting10 MiB160.40, 159.78160.092

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

10 MiB echo4 KiB TX setting · n=1
80.30mean
100 MiB echo4 KiB TX setting · n=2
76.91mean
100 MiB echo16 KiB TX setting · n=2
76.92mean

The 4/16 KiB labels record the TX-only setting; echo queue batching is independent of this value.

Run values
Throughput per trial, group means and sample counts.
ConfigurationPayloadRuns (Mbit/s)Meann
216 MHz · I-cache on · 4 KiB TX setting10 MiB80.3080.301
216 MHz · I-cache on · 4 KiB TX setting100 MiB76.92, 76.9176.912
216 MHz · I-cache on · 16 KiB TX setting100 MiB76.87, 76.9776.922

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.

Reported-only results, shown separately from logged PASS measurements.
ExperimentTX (Mbit/s)Echo (Mbit/s)
D-cache enabled≈16178.83
FIFO reallocationReported 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.

Measurement notes

Bars start at zero. Dots show individual trials, stacked vertically when close; short range marks show minimum–maximum values, not confidence intervals. TX submissions of 4/16 KiB do not change the 512-byte USB bulk packet size or the independent echo queue’s batching.

The record contains 18 successful transfers with complete logs, measured October 29–30, 2026. Sample counts include only those logs; plots use printed rates rather than rates recomputed from rounded times.

The uncached control is from the prior day. The dedicated chunk comparison uses its own 4 KiB control. Configuration labels follow documented settings; flashed images were not independently identified.

The D-cache timeout received 10,409,767 of 10,485,760 bytes before verification. A later short echo was reported to pass. A separate, earlier trace-on test stopped 27,669 bytes short. The record does not establish a failure rate or identify the cause of either timeout or the original clock regression.

Chart data (JSON)

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.

Hantek DSO2D15 oscilloscope measuring the TX-A TPS61085 supply rail, with a flat yellow trace and a displayed average of 796.9 mV and peak-to-peak variation of 3.2 mV.
TX-A power bring-up — TPS61085 rail on channel 1
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)

Documentation checklist

18 / 88 complete