Public Lab Research note


My experience of building and using a spectrometer based on the Public Lab design

by MrBumper | December 20, 2014 17:37 | 2,353 views | 7 comments | #11488 | 2,353 views | 7 comments | #11488 20 Dec 17:37

Read more: unstable.publiclab.org/n/11488


I originally posted the following to the Sepctrometry thread, which prompted a number of useful comments. Liz Barry, director of community development at PL, asked me to copy post here. Based on the comments I received I have added the odd note, so what was quite a long post .... is now even longer!


I had ordered a Public Lab spectrometer kit, which I received here in the UK a couple of days ago. However I got impatient waiting for it to arrive so I went ahead and built my own using a Logitech C310 HD web cam.

I bought a black plastic box about 8 by 4.5 by 2.5 inches and cut two pieces of 1 by 1 inch aluminium angle as mounts for the camera and the diffraction grating. The two angle pieces are fixed to the box by bolts such that they can be swivelled and I can experiment a little with angles. I used a small office butterfly clip to hold the diffraction grating on to the angle. The reflective surfaces of the aluminium are covered with black card. ...

Note - Using the butterfly clip means I can very easily change the holographic film diffraction grating for, for example a piece with a different line spacing or for a chunk of DVD. The slit on my build is interchangeable / variable. I have two sliding aluminium support plates bolted on either side of a largish rectangular hole in the box. I can use these to clamp either two pieces of black card I can slide back and forth to make an adjustable slit, or I can clamp in one of the printed slits available from PL.

I encountered my first problem with the diffraction grating. I tried splitting several DVD-Rs but tended to wind up with the aluminium silvering stuck to the wrong half. In the small places where the aluminium had stayed with the top half I still had a layer of photo sensitive dye tinting the clear sections purple. Successful separation of the DVD may be brand specific.I recently split the DVD that came with the PL kit and that split a little better. I will try using DVD material in the future, but instead I bought some Edmund Optics 1000 lines per mm holographic film (DVD material gives you 1,351 lpmm). ....

See my research note on removing silvering and dye from a DVD-R: Preparing a DVD-R to act as a diffraction grating

Note - I did find a US school project on the web, where they experimented with CDs and DVDs as diffraction gratings. They apparently were able to remove the aluminium silvering by rubbing down some adhesive packing tape onto the separated surfaces. The silvering would then come away with the tape when they peeled it off. BTW - I don't know if it makes any difference to the perfomance of the spectrometer if the grooved side of the DVD diffraction grating is either facing towards or away from the camera lens. Or for that matter whether the holographic film I used has sides and is best one way round. I suspect the answer is yes, and the 'grooves' should be toward the camera lens.

There is a question here over the transmission efficiency of the diffraction grating. So far as I understand it there is no procedure for calibrating the amplitude response of the spectrometer. Now this isn't so bad if the amplitude response remains relatively flat across the spectrometers range, but looking at the efficiency curves for commercial diffraction gratings it seems that response normally isn't flat and can vary by as much as 40% over their useful range. This has to be corrected for in spectrometer design / software. Now I have no idea how flat the response of a chunk of DVD or a piece of holographic film might be. I have tried asking Edmond Optics about their holographic film but they have not responded. ....

Note - I do have some plots of daylight and fluorescent lighting I captured a fair while ago using a spectrometer that was part of a Microvision Superspot 100, an instrument designed for the measurement and analysis of computer displays. If I compare these with the plots I get from my DIY spectrometer, the DIY plots look remarkably similar. So it would seem that the amplitude response of the DIY spectrometer is at least not horribly distorted.

I tried to understand the optical design of the PL spectrometer to see if I could calculate better angles for my build, but I still haven't worked out if the PL design was carefully thought out, or just thrown together empirically to see what worked reasonably well with the simplest possible construction. I ended up setting my camera and film at 45 degrees like the PL, although now I have the kit I can see that the angle is not as I thought it was because the slit is actually offset a little. The camera of course has to be set at an angle to the slit because otherwise it would view the direct light from the slit and that would tend to wipe out the exposure. ...

Note - It would be great if the original designers of the PL kit could comment on this. I would really like to know why they chose the angles and arrangement of camera relative to the diffraction grating that they did. As I understand transmissive diffration gratings, if they are placed at right angles to a beam of light they pass some of the light straight through and some is diffracted to either side into to two spectra. The spectra are diffracted at an angle known as the dispersion angle (I guess that is a mean angle of the visible wavelengths probably for green). The dispersion angle for the Edmonds holographic 1000 lpmm film is apparently 36 degrees from the normal. Angling the film from the normal increases the width of dispersion. There are some equations for grating dispersion and It doesn't look too difficult to calculate the angles but I haven't tried that yet.

The business of focussing the camera is rather confusing. The assembly instructions with the kit don't mention focussing or doing anything to adjust the camera. They don't even say to remove the small sticky protection tab over the lens. Then there are various bits of contradictory advice hidden away on the web site about focussing. I did see the comment about focussing at the slit distance, qualified by the fact that the cameras supplied with the kit cannot focus at the slit distance for the kit. I haven't tried that with the kit yet but it's a bit annoying if true. I seem to be able to focus the Logitech on the slit in my black box build....

Note - see my comment below. The Sanmtch camera will focus perfectly well at the slit distance in the PL kit.

Getting your build light tight and with minimum reflections; can be quite tricky. I noticed I got light leaks through the edges of the lid on the PL kit conduit box. Putting a slight reverse bend in the lid and then being careful tightening the two screws seems to have solved that. I mean to get around to lining the inside of my black box build with black velvet, since if I use a really strong light source and crank the exposure I can see some of the inner details of the box on the camera output.

Something else I did not realise until I had played around with the spectrometer for a while is that is important to have the right camera settings and Spectral Workbench does not provide any method of setting the camera, or even mention it. After poking around the PL web site again I found some comments about disabling camera auto exposure using a command line. I tried that and got various error messages (I'm running Ubuntu 14.10 and Firefox version 34). Eventually I managed to install the Gtk UVC Video Viewer.

Gtk UVC Video Viewer has a GUI with a number of useful settings. I have found I can launch Gtk UVC and turn off auto white balance, set exposure to manual and adjust the exposure slider to get a spectral image without saturation (judged by eye). I can then close Gtk UVC and the settings will persist while I open Spectral Workbench. This is crucial to getting good results. SW will saturate quite easily on the red, green of blue while the white average remains almost flat line. Maybe there is a way around that. Perhaps it really needs two displays - one for RGB and one for White. The white can then perhaps be scaled to show a useful peak. ....

Note - As one of the comments to my original post pointed out, specific cameras may have different features and for example, it may not be possible to adjust exposure through the Gtk UVC Video Viewer for some cameras. It seems to me this is almost essential to be able to get good captures without clipping. Adjusting the intensity of a light source to avoid clipping is quite tricky. I have not yet tried the camera that comes with the PL kit to see how it responds to the Gtk UVC Video Viewer.

I have had a great deal of trouble with opening a PL account and then logging in to Spectral Workbench. I have to open the Firefox Advanced settings - network tab and clear my web content and user data every single time before logging in to PL. If I don't do that I just get a 499b error when I try to log in to Spectral Workbench. ....

Note - Jeff Warren at PL is working with me on this. It seems at the moment to be a problem with the local cacheing of my Firefox browser.

The other problem I have is with calibration. I can calibrate my plot from a CFL just fine and the wavelength X axis appears. But when I capture data from other light sources and indicate that I want to use my previous CFL data for calibration nothing happens, the X axis remains as uncalibrated. Is this a current bug or is there a user setting I have missed? I have to work around that by exporting CSV files and creating spreadsheets, where I can just copy the wavelength data across from my CFL plot. ...

Note - This was a bug in SW and Jeff has now fixed it. Yeh! Jeff.


7 Comments

...if the grooved side of the DVD diffraction grating is either facing towards or away from the camera...
I experimented with that once, although I was trying to learn if it made any difference to the best angle for the grating, not the sharpness of the diffraction pattern. But I did not notice any difference in sharpness of the diffraction pattern. It also made little or no difference to the grating angle, although if flipping the grating over also changes the orientation of the curves in the DVD grooves, the height of the diffraction pattern (perpendicular to the wavelength scale) changes. I'm not sure why that is.
.
If you line the inside of the spectrometer with fabric, beware that some dark fabrics reflect quite a lot of NIR. I think I got lucky when I blindly used cheap polyester felt. The photo below is of two purchases of felt taken with a pure NIR camera. I think this is a good result, even though the felt does reflect some of the camera's flash.
.

TwoFelt.jpg
.
Chris

Reply to this comment...


Hi Chris, Thanks for the tip on dark material and your findings on grating orientation. The internet really is killing bricks and mortar retail, I went to one of the biggest fabric shops in central London the other day to buy some black velvet. They had none in stock! This seems to happen to me almost every time I go out to a shop to buy something.

Were you working with holographic film or was this with DVD material? I can see any difference not being apparent with the film since it is quite thin. As I said, there probably is a best way round in theory, but it may not matter too much in practice.

I think I will cotinue to experiment and try to work out how the theory applies to the basic PL design of the spectrometer. I shall get some new batteries for my laser pointer today and then I can more easily measure diffraction angles and see where the light actually goes when you pass it through a grating.

I have now tried the Sanmtech camera that comes with the PL kit and there would appear to be absolutely no problem with focussing. It will easily focus all the way down to 25mm or less. You need 90mm for the PL kit, so no problem there. It does work with the Gucview camera control application, although the camera has no exposure control. A shame really, I have found the exposure control on the Logitech C310 to be very useful in getting good captures. I am aiming on completing the PL Spectrometer kit build today and will then compare it with my 'black box' build.

Is this a question? Click here to post it to the Questions page.

Reply to this comment...


the sanm camera does have exposure control, I haven't had trouble with it using UVC ctrl. work. It should work in GUCView.

Reply to this comment...


Well I have tried the Sanm camera 'popsickle' stick camera with various control utils. There is absolutely no sign of an exposure control Matthew. Perhaps you have a different camera to mine.

Reply to this comment...


we picked the Sanm camera specifically because exposure control was implemented... it would be news to me that it doesn't work. exposure control is rarely, if ever implemented in any USB software packages, so I'm not surprised you can't find it.
GUVCview being an exception. I don't have my linux machine on me right now but I'll check with a newer production unit.

try these utitlities: http://publiclab.org/wiki/spectral-workbench-usage#Webcam+configuration

Reply to this comment...


Matthew I'm a bit baffled by your reply to my previous comment. You picked the Sanm Tech specifically because exposure control was implemented ....... exposure control is rarely, if ever implemented in any USB software packages. So if its not implmented how is it of use?

I'm not trying to be sarcastic I'm genuinely baffled. Guvcview (and various other Linux utils I tried) does show exposure and gain controls for my Logitech cameras but not for the Sanm Tech. I see the FAQ page seems to say something about control via browser, I'll investigate.

Is this a question? Click here to post it to the Questions page.

Reply to this comment...


the poor implementation of the UVC specification is baffling, I agree.
Exposure control isn't really of any use. controlling exposure also doesn't stop the camera's internal process from adding non-linearities either. We picked hardware with the hope of adding features to the software, but haven't yet. GUVCview has no equivalent in windows or on mac. linux is the only platform exposure control seems to matter on. There is a package for exposure control that works on ma (linked to in my comment above) but it is mediocre and often crashes the capture software.

Reply to this comment...


Login to comment.