Blue pill blues

Every once in a while I get the question if the STM32F103 “blue pill” will be able to drive the TCD1304, and while the chip has enough peripherals to do all the driving and reading, it lacks a 2nd DMA-controller to handle communication.

Of course that doesn’t mean the mcu can’t be used in this application, it just means that my firmware can’t be ported to the F103 without rewriting at least parts of it.

But that isn’t what this post is about anyway, it’s actually about using a thermoelectric element to cool the TCD1304, to keep dark current down thereby enabling long(er) integration times.

Here is the CCD on top of the cold tip. The TEC-12706 is sandwhiched between the two aluminium plates. The lower plate will be secured to the chassis of the spectrograph, which in turn has a larger heatsink:

Continue reading


Broken promises

I promised I would test the new circuit after june 16th, and as I’ve promised my girlfriend to act more like a grown-up, I immediately broke this promise.

Having finished correcting exam papers ahead of time, I did a few tests this afternoon. It went terrible at first. The first 30min was spent without realising I had swapped the SH- and ICG-wires. Then ..okay I’m getting frustrated all over again just writing about it.

The long story short was that the particular nucleo board I was using had a an old and/or corrupted firmware. 2 hours later, once I figured that out, I resoldered all the resistors I had frantically been swapping, to get something resembling what ltspice said I should be getting and then:


An aspirin blister pack covering roughly half the CCD.


The TCD1304 at full saturation. The ADC delivers close to it’s maximum value (4095).


“Total” darkness. (The CCD was placed upside down on the table, light is leaking in from the sides.) The pixel values are close to the dummy pixels.


20µs integration


80µs integration. notice the pixel values are roughly 4x higher than for 20µs.

The values for R1, R2, R3 and R4 are:

  • R1 = 1200 Ω
  • R2 = 2200 Ω
  • R3 = 1200 Ω
  • R4 = 560 Ω

in the opamp section of the circuit:


Approximately 300mV of the ADC’s range remain unused, however at this point I ran out of time and patience.

Suddenly you’ll like bipolarity

As it turns out, bipolar is not just a useful label to put on your ex-girlfriend/boyfriend. It’s also something a power supply can be, and in the PCB presented here, you’ll need one of those.

The new PCB for the TCD1304 arrived some weeks ago, I’ve just been too busy with my actual job to do anything with it (exam-periods are stressful for teachers too). But here it is:


The circuit requires a ±7.5V PSU (±9V is fine too, it just has to be higher than the drop-out voltage for the 7×05 regulators, but not too high – you know, like Goldilock).

The circuit looks like this:


R1, R2, R4 and R5 should be chosen according to output voltages of the TCD1304 as explained here:, and pad1 and pad3 should read +7.5V and -7.5V

The PCB depicted above was intended to have a variable voltage divider between Vref and V-, but I’ve later learned this is not a good design, hence the wire-mess on the left side. It’s since been corrected and the voltage divider is now between Vref and AGND. Here are the eagle files (corrections included).

Mind you that it’s still not fully tested, so don’t go off and send it to the board house just yet. It’ll be june 17th before I have time to fully confirm if it’s working.

If I were to redo it, I would substitute the 78L05 and 79L05 voltage regulators (U3-4 and U2) with LDOs LT1761 and with LT1964.

TCD1304 on macOS


Image from

One of the spin-offs of the raman spectrometer is a small, entirely 3D-printed VIS-spectrometer, that I thought could compete with the relatively expensive commercial USB-spectrometers at my school.

The spectrometer costs less than 80$ in parts and has a resolution of around 2nm. The project page on hackaday is here: Ottervis-lgl-spectrophotometer  but as always, the hackaday layout/interface is not really very easy to navigate and/or maintain, so I’ve created a separate page for the project here: OtterVIS.wordpress

One of the biggest problems of bringing the spectrometer into the classroom is that the students all use either macOS/OSX or Windows[1] – and the interface software is made for linux. I will probably never get around to making a Windows-version was already difficult to learn serial programming for linux.

But as most people know, there’s a UNIX under the apple’s skin, so porting from linux to macOS can be very straightforward. In the case of the Otterly CCD CLI, it’s as simple as installing xcode, glib and pkg-config and changing the makefile slightly.

Of course not everyone needs to compile the CLI for themselves, and installing glib will be the only step required before running a precompiled binary. So with that, it should be possible to get the students to be able to use the spectrometer.

Goto for slightly more details and a download of the sourcecode, new makefile and precompiled binary, all in one zip.

[1] In my six years of teaching, I’ve taught around 400 students. Only one of them used linux. The remaining 399 used macOS and Windows – roughly 50/50 with a slight lead to Apple.

Just a close-up

I received an old Olympus CHB microscope and immediately took a close-up of the TCD1304. I don’t have a camera adapter for the microscope, so I borrowed my girlfriends smartphone to take the picture.

I have no I idea what is what, except that the black area in between the two silvery things contains the pixels. The magnification is 100x.


First steps towards a new PCB

This entire time I’ve been content with the very simple drive circuit from the TCD1304’s datasheet:

tcd1304 typical drive circuitIt has a low parts count, it’s easy to understand and it performs reasonably well.

However, after reading through the Audine project, I’ve realized how elegant TEC can be done, and how inelegant I had planned to do it. So I decided to make a new PCB with a cut-out for a cold tip, and while I was at it I also wanted to try David Allmon’s solution for conditioning the output to the ADC.

And here it is:

Of course it doesn’t work.

Continue reading

Line camera command line

Command line line camera! Line camera line commander? DIY command line camera!? I thought I would be able to make a cool combination with these four words, but obviously not..

I’ve been looking more and more at how Hr. Fröhlich has continued to improve the interface for the linear CCD firmware, and I’ve come to the conclusion that I cannot possibly write a very good GUI.

What the world really needs is something that will make the linear CCD module more modular on the software side, making it much easier to tailor the hardware to your software.

So here it is: A command line interface for the linear CCD module.

There’s also a new SPI-firmware revision, to make the SPI-firmware “pin-compatible” with the UART-firmware and give it all the bells and whistles of the UART-version.

It will be followed up with a similar CLI for the UART, hopefully tomorrow (march 19).


The UART-CLI telling you how to push its buttons.