Full feature, Instrumentation Grade Linear CCD (TCD1304) includes KiCAD, Firmware and Python


Well-known member
Just now posted to github, a repository with design files, source code and python script for sensor board using a TCD1304 and Teensy 4.0.

Please see Linear CCD with design files, firmware and python

The design features an instrumentation grade front end that matches the CCD output to the ADC input, a full feature sketch for the Teensy 4.0 that provides trigger, gate and clocking functions and an optional "keep clean", and a Python Class library that doubles as a utility program with a command line interface and real time graphics.

The README discusses some of the electrical design issues. I hope to fill in more information on the internals of the sketch and python class library, but the source code is there for those who are interested.

Here is a spectrum of a fluorescent ceiling light in my lab, at a distance of about 8 meters, through a 200um fiber and slit. As you can see the signal performance is okay. It is actually a little better than the more expensive commercial instrument that I usually use. There is a picture of the spectrometer in the github readme.


This is the reverse side of the board, the sensor is mounted and centered on the opposite side. The pins across the top provide trigger in, sync and busy out, and some spare and duplicates of the SH and ICG signals that control the sensor. The pins across the bottom provide analog inputs (should be used with an appropriate front end), and 3.3V for a low power accessory.


Here is a conceptual sketch for how the front end works. The idea is to match the CCD to the ADC. There is an opamp follower that precedes this to take care of the impedance from the sensor, and this has to be followed by a resistor or better yet an RC to take care of the kickback from the ADC. See the github repository for the LTSpice file and for the complete schematics and PCB layout. Layout is vitally important also if you want to have low noise.


Here are the supported shutter and frame scenarios. The first is a short shutter with longer frame interval, the second is back to back shutters and the last is frame interval as multiple of shutter. Besides being clocked, these have to work with reliable timing when started from a trigger or gate input.



Here are scope tracings for a single frame, SH (green), ICG (purple) with a SYNC output (blue) and BUSY signal which remains asserted from the first SH to the last data transfer.


Here is a triggered frame, triggered on the rising edge, with trigger input in blue.


And here is a gated frame, notice the SH signal on the rising and trailing edges of the trigger (gate) input.


And this a movie made by triggering a series of frames in response to the start of a pulse applied to an OLED. This shows the evolution of the spatial distribution of light from the OLED.


In terms of features and signal performance, I think this does a lot and seems quite competitive with the expensive commercial instruments.

BOM is $25 plus sensor, bare PCB and Teensy.
Last edited:
I want to add some notes of appreciation. The sketch rolls up many of the answers and help from questions that I posted to the forum at one time or another while working on this or earlier projects. Some names that come to kind include @PaulStoffregen of course and @KurtE and @defragster. See the code, a lot of the functionality may seem familiar. Couldn't of done it without you! Thanks.
Last edited:
I just noticed that there is a preliminary post for this project at https://forum.pjrc.com/index.php?threads/linear-ccd-with-teensy-4-0-and-hyperspectral-imaging.72761/

I am not sure how to remove the previous, but consider this the definitive post with source files, as referenced at the top, at github

Did I mention BOM $25 plus bare pcb, sensor and T4 (or T3.2), about $80 in total?

For the spectrometer, add around $200 for grating and lenses, or you might get lucky on ebay.

Commercial instruments, upwards of $2K. And here, you get the source code (see the link at the top).