There is a more philosophically focussed companion article over at ArkFab.

At long last, second generation DIY spectro has arrived!

The spectrophotometer. Yes, that is an invisibility cloak. You can't see the stuff that's under it can you? Then that stuff is invisible!

If you recall, when last we left our humble spectrophotometer, it was a shambling mess of stone-age technology. Now, its a shambling mess of information-age technology!

Let’s take a closer look…

what is underneath...?

The upper box contains the Arduino microcontroller, which connects my computer to the motor and the sensor. Servo control  is done with the a modified version of this PySerial-based servo communication software.

arduinoids unite

Lifting the upper box, we can see into the mechanical part of the device. The diffraction grating is turned by a servo motor; it reflects light onto the sensor. As the motor turns the gear it is sitting on, its angle changes, and the spectrum sweeps across the sensor. Or at least that’s how it’s supposed to work.

The moving parts of the spectrophotometer: The light source, gear assembly, diffraction grating, and sensor are highlighted; the motor is hidden underneath the flashlight. Click for another perspective.

By itself the motor is too coarse to properly cover the spectrum; moving from one position to the next, it covers the whole rainbow in about six steps, worse resolution than the graphing calculator setup. So I slowed it down with a gear assembly, pulled out of an old floppy drive. This is much better, but unfortunately there is still some play in the gears, which means that about a third of the motor positions don’t actually move the diffraction grating – it only starts to turn when the motor is at about degree 60 of 180. The at the same time, the motor sweeps the spectrum very slowly (the change in wavelength per change in motor position is small). This is good- it’s why I put in the gears – but now I have the opposite problem. It moves so slowly that 120 degrees aren’t enough to cover the whole spectrum! Clearly, this is an area for optimization.

The diffraction grating is a chip of CD; it stands freely on a gear in the gear assembly. It is manually aimed at the sensor. It’s not really attatched, so instrumental drift is a problem- bump the machine or look at it especially hard and the grating will shift and you will have to start all over. This seems trivial to fix once the gear situation is resolved.

A book burner lit some incense in my house and set off the smoke detector. I guess you could say the alarm came from a censor censer sensor.

So- how do you use this thing?

First, fill a cuvette with water. Run a blank sample. Run several blank samples to check for instrumental drift. Run samples with the light source off to check for light leaks and get an idea of the baseline dark signal. Run blanks with different sample sizes at each frequency (eg, 1sec/degree vs. 0.5 sec/degree) to get a measure of appropriate sample size and other statistical details.

Now, set up the diffraction grating so that the portion of the spectrum you’re interested in is swept across the detector. We’re going to look at the red region so in our case the grating is adjusted so that IR through yellow gets measured.

Run some more blanks, then caaaarefully remove the light cover and caaaaarefully place your sample into the sample slot. We’re using crystal violet, a dark purple dye used in microscopy and as a fungicide. Using a hand-held spectroscope, we can see that its color is due to its transmission of red and blue-green light and absorption of other colors. We’re going to try to measure the red transmission band.

Looking through the spectroscope, we can see the colors which crystal violet transmits (red and blue-green) and which it absorbs (everything else). We're going to measure the red band.

Once you run the sample you have a time series of sensor measurements for each motor position, for the blank and the sample. I found that there is a glitch somewhere in the serial communications which concatenates the data strings: …20, 20, 20, 2020, 20, 20, 20… obviously, this wrecks havoc with simple statistical measurements so the data gets filtered by excluding measurements above a certain limit (the Arduino analog pin doesn’t return values above 1023, for example). After this preprocessing, the time series is averaged, so that each run associates a single number (the mean) with each motor position. That is to say, at each motor position there is a sensor response I0 for the blank run and a response I for the sample being measured. Now, at each motor position, we can calculate the transmission, T, using the formula

T = I/I0

Absorbance, A, is then calculated at each motor position:

A = -log(T)

When we plot the absorbance at each motor position (which corresponds to frequency), here’s what we see:

Measured red transmission band in the spectrum of crystal violet - the horizontal axis is the motor position, which correlates with wavelength.

As expected, we can see a transmission band in the red region (the area where the absorbance dips; when more light is transmitted, less is absorbed) and an absorption band in the orange-yellow (where the absorbance spikes). Since motor position hasn’t been calibrated to frequency yet, we can’t make any quantitative claims, but it’s nice to see our qualitative expectations confirmed. For comparison, here’s someone else’s measured absorbance spectrum. Keep in mind that my horizontal axis is the reverse of theirs (redder colors are bigger wavelengths).

Obviously, this machine is far from finished. Some things to resolve:
* Optimize gear assembly!
* Stabilize diffraction grating
* Calibrate wavelength to motor position
* Amplify detector signal without destroying the precious microcontroller- the signal never gets over 100, although it has a theoretical maximum of 1023. Taking advantage of the full range of the analog input could give more precise measurements.  I think this is what the AnalogReference() function is for?
* Stabilize the light intensity – run the light source off of something other than AAA’s. (USB cord?)

In conclusion,