Designing, 3D-Printing, and Calibrating a Custom Linear CCD Spectrophotometer
Why our first 3D-printed optical housing suffered from zero-order and ceiling glare, how we engineered an asymmetrical sawtooth baffle and 45-degree V-trap in SolidWorks, and calibrating 3,648 Toshiba TCD1304 CCD pixels with three lasers.
Ahmed Ahmed
MEng Molecular Bioengineering, Imperial College London
Why Build a Spectrophotometer From Scratch?
Every molecular bioengineering lab has a benchtop UV-Vis spectrophotometer tucked into the corner. You pipette into a plastic cuvette, close the lid, click "Measure," and a clean absorbance curve pops up on the screen. Until you have to design and align the optical path yourself, it is easy to forget that inside that grey box is a game of geometric ray-tracing where a few percent of stray scattered photons can completely ruin your dynamic range.
Our goal in this project was to design, 3D-print in black PLA, wire, and calibrate a combined transmission absorbance and fluorescence spectrophotometer from scratch. We had a 900 lines/mm transmission diffraction grating, a few ThorLabs and Newport optical post mounts, an STM32 Nucleo-F401RE microcontroller board, and a Toshiba TCD1304 linear CCD array ( silicon photodiodes spaced at an pixel pitch across a sensor window).
The Geometry Puzzle: Getting 400 to 700 nm onto a 29 mm Chip
The first challenge I hit in SolidWorks was purely geometric. A linear CCD chip is only wide. If you mount the diffraction grating at the wrong angle by even two or three degrees, the violet end of the spectrum misses the left edge of the silicon die entirely, or the red end spills off the right edge onto the PCB solder mask.
To anchor the middle of the visible spectrum (, corresponding to our green calibration laser) squarely onto the centre of the TCD1304 detector window, I started from the first-order () diffraction grating equation for a grating pitch of :
Tracing the folded beam path from the cuvette exit slit (TransmissionCuvetteHolder.SLDPRT) off the internal steering mirror and through the grating plane onto CCD_Board.SLDASM yielded a target grating mount incidence angle of . Building that exact angle directly into the SolidWorks locating ribs meant that when we dropped the physical grating into the 3D-printed slot, the dispersed rainbow landed across the central active pixels on the first try without needing finicky thumbscrew adjustments in the dark.
The Stray-Light Surprise (and How We Engineered Around It in CAD)
Here is where theory met the messy reality of 3D printing. Even when you print an optical enclosure in matte black PLA, fused deposition modelling leaves microscopic cylindrical layer lines along every wall. At shallow grazing angles, black PLA behaves almost like a shiny specular mirror.
When we ran our first dark-room tests with a bright broadband source, two major stray-light artefacts showed up as an elevated baseline floor across the CCD:
- The Zero-Order () Beam: A transmission diffraction grating does not deflect 100% of incoming light into the rainbow orders. Over half of the optical power passes straight through undiffracted at , slams into the back wall of the box, and scatters back onto the CCD sensor.
- Ceiling Grazing Reflections: Divergent rays exiting the cuvette holder skimmed along the flat top lid of the housing and bounced straight down onto the detector pixels.
To fix both problems mechanically without adding bulky external optics, I redesigned the internal walls of the SolidWorks assembly around two passive optical traps:
- A Concave Specular Zero-Order V-Trap: Right where the undiffracted beam hits the rear wall, I extruded a deep, narrow V-shaped cavity angled at . Instead of scattering back into the main chamber, parallel zero-order rays are forced to bounce inward deeper and deeper toward the apex of the V-trap, losing roughly 90%+ of their intensity on each successive black PLA reflection.
- An Asymmetrical Sawtooth Ceiling Baffle: Across the inside of the upper lid, I modelled a series of angled sawtooth teeth. Any shallow ray flying upward from the cuvette slit hits the steep vertical face of a sawtooth ridge and is reflected backward toward the source compartment rather than forward onto the CCD.
Turning 3,648 Raw Pixel Numbers into Nanometres
When the STM32 Nucleo-F401RE reads out a frame from the TCD1304 CCD, it outputs an array of 12-bit ADC integers indexed from pixel to . Out of the box, the microcontroller has no idea which pixel corresponds to blue or orange.
To calibrate the dispersion axis, we shone three monochromatic diode lasers into the sample chamber: violet (), green (), and red (). In Python, I wrote a peak-centroid script (scipy.signal.find_peaks and scipy.stats.linregress) across replicate captures to fit the linear pixel-to-wavelength transformation:
Seeing the three laser centroids snap onto a straight line () was a great moment in the lab because it confirmed two things at once: our SolidWorks grating slot was mechanically square to the CCD plane, and small-angle diffraction across the sensor introduced almost zero non-linear tangent distortion.
Testing Unknown Dyes, Chlorophyll Fluorescence, and Honest Instrument Limits
Once calibrated, we switched between two optical configurations:
- Collinear () Transmission Absorbance: Computing Beer-Lambert logarithmic absorbance from dark-subtracted blank and sample intensities:
- Orthogonal () Fluorescence Emission: Exciting the cuvette from the perpendicular port so only Stokes-shifted isotropic fluorescence photons entered the slit toward the grating.
When given blind chemical unknowns, overlaying our Python-calibrated spectra against reference library profiles allowed us to identify every unknown dye and fluorophore unambiguously:
Where Our Prototype Hit Its Physical Limits (and How I Would Upgrade v2)
Building the instrument from scratch also made its physical trade-offs crystal clear:
- The Slit-Width vs Signal-to-Noise Trade-off: In transmission absorbance you have plenty of photons, so a narrow entrance slit () gives sharp spectral resolution (). In fluorescence, however, isotropic emission means less than 1% of emitted photons enter the solid angle of the slit. Widening the slit boosts fluorescence SNR but broadens the image of the slit across multiple CCD pixels, convolving sharp peaks with a rectangular boxcar kernel.
- Uncollimated Beam Divergence & Plano-Convex Lenses: Without a collimating lens before the grating and a focusing cylindrical lens before the
TCD1304detector, beam divergence across the free-space path limits spectral sharpness. Adding an achromatic doublet collimator and a cylindrical focusing lens (as used in commercial Ocean Insight miniature spectrometers) would boost photon collection by an order of magnitude while tightening the point-spread function. - CCD Electronic Shutter Integration Time & Dark Current: Because the
TCD1304is an uncooled silicon CCD, increasing the STM32 integration time (SHandICGtimer pulses) to capture dim fluorophores also integrates thermal dark-current electrons. Implementing automated real-time dark-pixel subtraction using the optically shielded dummy pixels (pixels 0 to 31) of theTCD1304frame would stabilise the baseline during long fluorescence exposures.