The weather for today

Today I finished the PSU for the peltier element and connected the stm32f103 to the thermistor (the stm32f103 is still not measuring the voltage over the TEC). And here are the readings (sorry for the blurry photographs):

First, before the TEC was turned on:


It’s fairly hot in DK at the moment. The ambient temperature is 25-26°C.

Then after 5min with the TEC on. The voltage drop over the TEC is app. 8V, I have no idea what current draws, but the transformator is rated at 4A:


So it reaches a temperature difference of around 10°C. Not as much as I had hoped.. With some heatsink paste between the peltier element and the aluminium plates the temperature dropped another 1.5°C, still not anywhere the expected ΔT of 30°C.

So good animals are uncooked, as we say here in Denmark. I had a second look at the audine project to see if I had missed something. Most likely I have, but I didn’t find anything suspicious about my setup except that the TEC 12706 protrudes slightly on the cold side. I had some smaller TEC’s from another shopping spree, most notably the TEC 03506. You see the difference in size here:


And with the little one, it’s an entirely different story. The voltage drop across the smaller TEC was around 5.6V and the temperature difference was much greater. The CCD started to collect condensation, which is around the time I stopped the test:


The temperature at this point was -0.6°C 🙂


New spectrograph geometry calculations

Here’s a quick walk-through to calculate the geometry of the spectrograph. I guarantee nothing concerning the correctness of what follows (but please do correct me if you find errors).

At the heart of everything is the diffraction equation:

The relevant wavelengths are given by the Raman shifts:

If we’re interested in wavenumbers from 150-4000cm⁻¹ and λ₀ = 532nm, the range for λ₁ becomes 536.3-675.8 nm. The edge filter’s cut-on wavelength is 540 nm, so the range is in fact 540-675.8 nm – this also means that the spectrometer’s lower limit is 278 cm⁻¹.

d is given by the grating in the case of 1200 lp/mm it becomes

Because the CCD is 29.1 mm wide and the focal length of the focusing off-axis parabolic mirror is 152.4 mm we can calculate what angles of the diffracted light we would like. For 540 nm to fall on the edge of the CCD, the angle should be:

The angle for 675.8nm is of course identical except for the sign. It gives us an angular range of ±5.45° around the center angle. The angle of incidence can now be found by solving this set of equations:

Of course not any solution will fit the spectrograph’s geometry. The angle of dispersion (γ) for the central ray must match the angle between the off-axis parabolic mirrors as seen from the diffraction grating (2α):

2α is determined by the position of the mirrors and is:

Where lm is the distance between the mirrors. Their diameter is 25.4mm, so lm cannot be shorter than this.

I’m don’t think there’s a (practical) solution to the equations, but setting lm to 27mm, 2α becomes 10.16° and then these values more or less cover the spectral range:

The CCD then covers the spectrum from 538-680 nm.

For better explanations go here:

Sneak peak at the new spectrograph

My original choice for the spectrograph’s geometry turned out to be much worse than I had even dared expect. The difference between the angle of incidence and the angle of the diffracted light was far too great.

I (obviously) didn’t know at the time, that there’s something called the anamorphic factor.¹ The definition is as follows:

r = cos θi / cos θm

If the anamorphic factor is significantly different from 1, the image of the slit on the CCD will be deformed. I don’t fully understand the implications, but I could see that a “line” supposed to take up maybe 100µm was spread out over almost 1 mm. Ok, I might be exaggerating slightly, but it was very obvious that it was never going to work.

I spent some time not thinking about it(!?), and eventually came across T.J. Nelson’s page about a High resolution compact spectrograph, and decided that this was juuust exactly what I wanted to do.

Continue reading

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.