Message Boards Message Boards

6
|
24714 Views
|
4 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Yet another Wolfram/RPi spectrometer - this time with RaspiCam

Recently, I tried making a visible spectrometer using the Raspberry pi, the camera module and Mathematica.  Details are posted here, but here's a brief summary.  The spectrometer is built out of legos and a few components found around my house (and since I'm a Chemistry professor, diffraction gratings and cuvettes are really found around my house).



The light source (in the upper right hand corner) is a white RGB LED.  Immediate to the left is the sample compartment (which unfortunately is just a little too big for a standard sized cuvette).  Next comes a transmission diffraction grating which is a common supply in general physics classes.  I then use a 10x magnifying lens to condense the light onto a business card.  At the bottom right in the picture is the camera module (connected by the white ribbon to my Raspberry Pi and mounted using a hodge-podge of Legos).  The camera is pointed towards the business card.

Unlike my first version of a spectrometer, this version doesn't require any additional GPIO interfacing or MathLink programming; everything can be done within a typical Mathematica notebook without additional packages.  I acquire images using Import and then use ImageTake to grab just the region of interest.  Here are some example images of the empty spectrometer and with three samples: water, green food coloring and red food coloring.

 
In order to get spectra out of these images, I do 3 things:

1. Convert the images into data with ImageData and then average each of the rows
2. Convert the y axis into absorbance.
3. Calibrate the x axis by assuming that the RGB LED emits red, green and blue light at the expected wavelengths.

The code for these steps is fairly straightforward, and demonstrates how easy it is to manipulate Images, process array data rapidly, and perform linear fitting statistics with just a few lines of code.  For the samples above, I ended up with the following spectra:

The results are decent, given the quick and dirty calibration, the limitations of my source and the lack of any robust alignment of my "optical bench".  With some modifications, I suspect I can improve the wavelength resolution, although I will probably be limited by the source, which doesn't have a continuous emission across the visible region of the electromagnetic spectrum.  The system is easy enough to build at home, however, to serve as a spectroscopic tool for science fair experiments or other kitchen chemistry projects.  
POSTED BY: BoB LeSuer
4 Replies
Thank you .. You have light up my options with your well supported statements.   I do have an interterest simitar, but in my case workign with turbid media and radiative transfer functions.  I do have a question. Have you tried your experiements with scattering agents in your medium?  Did you use inorganic or metal base dyes? Have you tried to measure reduce scattering coefficients in your test?
POSTED BY: Jose Calderon
Posted 10 years ago
Well I too may be well out of date on this but I think there are two kinds of CCD sensors around; line scan sensors and area scan sensors. They basicly do what the name says. Line scan sensors just have a single line of pixels where as area scan sensors have an an array in a rectangular grid. The RPi camera and web cams are area scan sensors which take a complete frame at a time. They are limited in resoution by having to cover the whole area. Line scan cameras just collect data from a single line and rely on the picture moving past the camera to cover a large area. Since the amount of data collected each time is roughly the square root of that captured by an area scan camera they can operate much faster and since they are taking repeated images as the picture moves past you can get extreamly high resolution. Consequently they are used in military areal photography, high end scanners and spectrometers etc. In spectrometers you only need a single line of data across the spectrum. That's what I was thinking about when I said overkill. The downside of line scan cameras is that they are relatively expensive and hard to find; preumably due to the limited and specialized market. The RPi camera is of course quite cheap.

Thinking about it, there are some advantages in using the RPi area scan camera since if you align the camera so that it is normal to the slit you get a column of data at each wave length rather than a single data point so you could average the data to improve the SNR. You can also take repeated pictures and stack them.  Over kill can be a good thing! Looking back at your post is that what you have done? I may have been a bit hasty with my overkill coment. I once was shown a photograph of people standing on the Eiffel tower walk ways. It was taken from Charles de Gaulle airport twenty miles away and you couls see the faces well enough to recognise them! I'm told its technology used by the CIA! There is a lot to be gained by picture stacking.

Another obvious point is that at the moment you have a single beam instrument so I think you must be assuming that the intensity of the beam is constant at all wavelengths. This would be corrected for in a dual beam instrument but you could do the same thing by doing repeated runs changing between your sample and a reference and taking the ratio. Although you say this is 'Yet another' spectrometer all the ones I have seen so far are best clssed as classroom demonstrations rather than viable instruments. There is a growing interest out there for open source laboratory instruments that can be used in research. The combination of the RPi and a free version of Mathematica is a very attractive platform for this kind of development.. If you are not familiar with this idea have a look at http://www.openlabtools.org/ which is a project at Cambridge University to develop a regearch grade biological microscope. I am working on a spin off project in collaboration with them to develop an open source polarizing microscope for use in geology. The target users for this are people studying by distance learning, MOOC courses etc. One of the later options (we have only just started) would be to add a visual spectrometer to the microscope so that the absorption spectra of minerals can be measured. This could then be related to crystal field theory. It seems possible that low cost physical apparatus combined with sophisticated software (eg Mathematica) can make a big difference.

I hope this has helpd. So good luck and I hope you develop this instrument further it looks interesting and fun.
POSTED BY: bjs
Please, could you explain why is an over kill?  I thought that the reason CCD is prefered  due to the sensor frame interlacing .  CCD capture signals from all pixels at the same time.  CMOS sensors (web cams) do only one line at a time. (row of pixels ) at the time. 

Has this change in any way with current sensors?
POSTED BY: Jose Calderon
Posted 10 years ago
Congratulations you have a really interesting instrument. One thing you might like to try is to try to improve the signal to noise ratio by using a Fourier or Wavelet transform.  Mathematica has everything you need to do this and there are quite a few  example codes around that will give you a starting point. Many commercial spectrometers now use linear CCD devices as sensors so using the RPi camera is probably overkill.
POSTED BY: bjs
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract