Reading a TCD1304 CCD with an RP2040 cover
Research notebook

Reading a TCD1304 CCD with an RP2040

RP2040_CCD_TCD1304 is a work-in-progress driver for Toshiba's 3,648-pixel TCD1304 linear CCD using the Raspberry Pi Pico. The RP2040 generates the sensor clocks with PIO, captures the analog output through its ADC and DMA, and sends binary frames to desktop viewers over serial.

The lightweight Matplotlib viewer validates CRC-32, resynchronizes after partial frames, supports pixel cropping, inversion, baseline subtraction, and CSV export:

python -m pip install matplotlib numpy pyserial
python plot_spectrum.py --port COM14 --invert --first-pixel 32 --last-pixel 3680

The Qt-based Spectrum Studio adds serial discovery, error counters, averaging, dark subtraction, smoothing, normalization, polynomial wavelength calibration, peak tracking, persistent settings, CSV output, and PNG screenshots. A locked environment starts with uv sync and uv run python spectrum_gui.py.

On the device, separate PIO blocks generate the master clock and the datasheet-aligned gate sequence. A DMA-triggered ADC start fixes acquisition to a hardware clock phase rather than CPU scheduling, and preflush pulses clear charge before each captured line.

Physical timing remains a calibration boundary. Exposure, preflush, PIO delays, ADC lead-in, and wavelength calibration must be adjusted together and verified against the actual sensor and analog circuit.

Visit the RP2040 TCD1304 repository for the firmware, circuit, timing diagram, and viewers.