Public Lab Wiki documentation



Spectrometer Curriculum

This is a revision from August 04, 2013 07:36. View all revisions
5 | 25 | | #8899

Topic: What is a Spectrometer and how does it work ...

[ ..... A Work in Progress ..... ]

Welcome to this introduction about the science behind PublicLab's DIY Spectrometer Project and to the science of spectrometry in general. Since attempting to describe the entire depth and breadth of these topics is far beyond the scope of these pages, this material is organized progressively to allow the reader to enter the text at their individual comfort level. For those with advanced interests, it is hoped that the related reference links at the end will be of benefit. Please keep in mind that this is, hopefully, a "living document", a "work in progress", to which many have, and will, contribute. Many thanks to all.

Energy

We live in a world of mass (our physical environment) and energy (visible light, heat, radio waves, sound and all its other forms). The human body can expend energy (to run, play and get up in the morning) and can detect energy in the form of ultraviolet light (when we tan, or sunburn), visible light (the colors of the rainbow) and infrared (as heat), sound waves (speech, music, etc.) and pressure (sense of touch) but not radio waves, x-rays, cosmic rays and the like. All of these are forms of energy which are transmitted through vibrations. The difference between them is how fast the vibrations cycle; their frequency in number of cycles per second.

Frequency

The span of visible, and near-visible, light energy is of interest because vision is so important to our lives and this range of light frequency, from ultraviolet through infrared is called a spectrum. While ultraviolet light energy has a higher frequency than infrared light, all light travels at the same speed in a vacuum (~300,000,000 meters/sec if you're curious). Yes, the speed of light changes when it enters glass but we'll save that thought for later.

[ Tech Note: Light energy is referenced both as a particle (photon) and a wave (no mass) and both have meaning but in different contexts. For discussions about light colors, wavelengths and spectrometers, we will refer to light as a wave. ]

Wavelength

Since light energy travels at a fixed speed but is also vibrating at some frequency, the distance from one ripple of an energy wave to the next is directly related to the frequency. When you toss a pebble in a pond, you can see the ripples of energy from the pebble and you can see the distance between them which remain roughly the same as they move. For simplicity, if we assume ripples in a pond always travel at the same speed, like the speed of light as a constant, the closer the ripples are together the higher the frequency. This means that we can talk about either the frequency or the wavelength of light energy as they are directly related.

[ Tech Note: Mathematically, they have an inverse relationship where C = 1/Lambda where C is the speed of light in a vacuum and Lambda is the wavelength; both have units of measure in meters. ]

Human Vision

Our eyes detect only the visible light spectrum; from the deep reds just above infrared to the deep violets just below ultraviolet. Most of us can detect red from blue (except for those with some color deficiency) and we can detect various shades of colors and some color intensity. However, we are not very adept at measuring color or color intensities. In fact, our brains are part of our visual system and we can easily be fooled into seeing colors which are not really there. Ah, but what if we could! That could be fun and now you can -- indirectly -- using a spectrometer.

Spectrometers

A spectrometer in its simplest form is just an optical device, like a prism, which separates light into separate wavelengths (by frequency) so the amount of light energy at each frequency can be observed -- the light's spectrum. You have probably seen the rainbow colors (visible spectrum) produced by a prism, a sun-catcher or a diamond ring. All of these are primitive spectrometers. What they lack is control over the direction of the incident light and the means to measure and record the energy across the spectrum they display. So, how do they work?

Refraction

Light travels in straight lines within a medium of constant density. Light from your flashlight shines in a straight "beam" until it hits an object or travels through some material other than the air around you. However, if light shines through air (very low density) and then through water (high density) the direction changes. Refraction is this change in direction of a "ray" of light resulting from the light wave transitioning between different densities at an angle other then 90 degrees (i.e. not shining your flashlight directly towards a window, but at and angle). You've seen this "bending" effect when you look into a pool of water or look at a spoon in a glass of water; objects appear "bent" or even "disjointed". When light enters glass, from air, the density of glass is much higher than air so the light refracts and the change in angle of the path of light. If the light then exits the glass, back into air, and exits at the same angle as it entered, the direction of the light will return to it's original angle.

[ Tech Note: Refraction is a result of a decrease in the phase velocity of the light when it enters glass which is why a lens is able to focus light. ]

What makes the concept of refraction important to the concept of spectrum is that the angle of bending is dependent on the color (frequency or wavelength). Since white light (like light from the sun) contains a wide spectrum of colors, we see light shining through a prism or sun-catcher "split" into a rainbow of colors.

[ Tech Note: The shorter wavelength light (blue, violet and ultraviolet) refracts more than longer wavelength light (yellow, red and infrared) when transitioning from low density (air) to high density (glass). If the "entrance angle" is not the same as the "exit angle" (i.e. a prism shape instead of a flat piece of glass), both the entrance transition and the exit transition bend the light in the same direction and at equal angular change. ]

This also explains why such a rainbow of color appears so brilliant in sunlight but rather "dull" by comparison from a desk lamp; the spectra are not the same and sunlight contains many more colors (a much wider spectrum).

Diffraction

Another method of separating light waves into separate wavelengths for observation is diffraction. Instead of bending light by changing the density through which the light travels, the nature of light as a wave can be exploited. A very thin, flat sheet of material constructed with a set of reflective lines and transparent spaces is called a diffraction grating or phase grating. The result of a ray of white light striking a diffraction grating is similar to the effect of a prism in that they both produce a rainbow spectrum. However, diffraction gratings have the advantage of being physically thin and often inexpensive. In fact, the PublicLab spectrometers use an inner layer of a common DVD disk as a diffraction grating because of the narrow spacing of the DVD "lines" which are imprinted there; designed to store digital data. ( A DVD is not ideal because the lines are not straight; they are designed in an arc. However, such a small area from the "outer rings" of a DVD are used for the PublicLab Spectrometer, that this error can be ignored in this practical, yet inexpensive, measurement device. )

[ Tech Note: To understand this concept, imagine a "narrow beam of light" where the light "ray" is a wave; traveling at the speed of light with the length of each wave directly related to the color of that light. Also imagine that the light wave is like a flat sheet when it hits an object; called a planar wave. Now imagine this "flat wavefront" hitting a flat object like a mirror. What happens? Simple, the light wave bounces off. What happens if there's a tiny hole in the mirror? Some of the light gets through but it changes from a "flat" wavefront to a "spherical" wavefront but there is still no diffraction. So, what if there were two tiny holes very close together? Each would let some light through and each would have a "spherical" wavefront, but the two wavefronts would combine (interfere) depending on the spacing between the two holes. At some angles, relative to the original light ray, the waves would "add" and at other angles the waves would "subtract". This is called an interference pattern. If, instead of holes, narrow slits are constructed so there are many, many wavefronts interacting, the result is called diffraction. ]

Digital Spectrometers

Digital cameras, including computer webcams, contain a silicon imaging sensor chip which converts light energy to electrical voltages and then to digital data which can be recorded and analyzed by computer. By passing light through a diffraction grating, the light can be separated into its spectrum and a digital camera, like a webcam, can convert that spectrum into computer data. This is what the PublicLab Spectrometer devices are designed to do. They let you indirectly "see" the light spectrum from ultraviolet through infrared and measure the energy at each wavelength -- something more than what your eyes are able to do. However, there is one more required element; light from the source must be directed in a narrow, parallel "beam" at the diffraction grating.

The Slit

The PublicLab spectrometer, like many spectrometers, is contained within a black enclosure with light only entering through a narrow slit. The slit is a simple and inexpensive method to simulate collimated light; light traveling in parallel lines from a source. Light from the sun, filtered through the leaves of a tree, produces reasonably parallel "collimated" light because the sun appears quite small in the sky. If a light source for the spectrometer is some distance away and must pass through a very narrow slit, then that light will also be reasonably "collimated". However, it is not perfect, so the lens of the webcam is adjusted to focus on the slit. Keeping the slit very narrow (~0.010 inches) improves the resolution (detail) of the webcam output spectrum but there is also less light -- it is a trade-off, but narrow slits are generally beneficial.

DIY Spectrometer System

Putting all these concepts and physical elements together provides the plan for constructing a practical, yet inexpensive, spectrometer. Let's take a simplistic look at the device from the perspective of a light-ray coming from some source (like a light bulb).

1 - The light source is relatively "small and far away" with light going in all directions 2 - A little bit of the light strikes the slit so just a "thin beam" will reach the camera 3 - The inside surfaces of the spectrometer are non-reflective black to reduce stray light 4 - The light from the slit strikes the chip of DVD, which is mounted at an angle 5 - The DVD diffracts the light into it's spectrum - each color is a different angle 6 - The DVD is mounted to the camera's lens to shine the spectrum into the camera 7 - The DVD/Camera angle is set to provide the rainbow spread across the camera image 8 - The camera image is read by computer software to collect the spectrum data 9 - The camera image data has 3 sets -- Red, Green and Blue 10 - The Red, Green and Blue is converted by software into a final intensity spectrum

[ Tech Note: The "length" of the slit determines how "wide" the spectral band appears in the camera image. Looking at the camera image (UV to the left and IR to the right) the longer the slit the wider (top to bottom in the camera image) the spectral image. Actually, the slit need be only about 1/4-inch long as only the center of the spectral band is measured. ]

[ Tech Note: The "width" of the slit must be very narrow. If the slit width were large, the spectral image would have very low resolution (i.e. "smearing" of spectral peaks). Using sharp edges, slits with only 1/4 mm (0.010-in) are possible and do improve the resolution of spectral lines like from a CFL. ]

[ Tech Note: The light from the slit strikes the diffraction grating at an angle in the PublicLab device. A spectrometer can be built where the light strikes the grating "head on" (at 90-deg) and the spectral colors exit at an angle. However, it is convenient to mount the DVD sliver directly to the camera and let the light stick the DVD at an angle instead. The range of wavelength are then nicely spread across the image chip. ]

Light Spectrum

Every light source has its own spectrum even though the spectrum from separate light sources of the same type can be extremely similar. This similarity is extremely useful as it allows many users to compare and calibrate their own device so the spectral data they collect can be compared.

Remembering that the spectral colors from light are "spread" across the camera image, it is easy to understand that the position of the light from each color is at a unique position within the image. Given the mechanical construction of the PublicLab Spectrometer, the ultraviolet end of the spectrum appears to the "left" and the infrared end of the spectrum appears to the "right" within the image. Also remembering that digital images are formed as a 2-dimensional array of pixels (single points of light; each with a Red, Green and Blue intensity value). It is easy to now understand that each DIY Spectrometer has a fixed association between its image pixels and the spectral colors (wavelengths).

Converting Rainbows to Plots

Now that we know the camera image can capture the rainbow of spectral colors produced by the light source spectrum and the diffraction process, this "rainbow image" must be converted to spectrum data; a plot of light intensity vs wavelength. We also now know that the spectrum colors, with their respective intensities, are spread across the webcam image and there is an association between image pixel number (left to right) and wavelength which results from the diffraction effect.

Webcams are normally used to capture computer user's live images in color so every camera image pixel will have three (3) intensity values; one each for Red, Green and Blue (aka. RGB). Optical RGB filters plus camera electronics send this data, one image frame at a time, to the computer via a USB cable. If the source light contains blue, the Blue filter will easily pass that color and the blue value for that pixel will show a high intensity value. However, the Green filter will pass only a little of the blue light and the Red filter may pass none at all. So, each of the 3 RGB channels from the camera produces an intensity profile which is modified by a color filter.

[ Tech Note: Digital camera imaging chips can only detect grey; they just respond to total, broadband light intensity. The RGB filter provides color detection. The camera contains an RGB optical mask known as the Bayer Filter. It is a repeating set of RGGB filters for repeating groups of 4 (2x2) pixels. A software algorithm (demosaiscing), in the camera, combines this data to estimate the RGB values for each pixel. The response curve for each RGB filter is designed to simulate the color response of the cone cells in the human eye. Since Green is the most sensitive wavelength for the eye, there are 2 Green filtered pixels for every group of 4; the other two are Red and Blue. ]

[ Tech Note: By reading the RGB values from a sequence of pixels (eg. a 'horizontal' row from the middle of the spectral rainbow image) and connecting the dots, a plot of Red, Green or Blue filtered intensity vs pixel (which can be calibrated to wavelength) can be created. For every pixel (wavelength) the RGB values can be combined mathematically to create a new plot of spectral intensity vs wavelength -- the final output data of the spectrometer. Typically the mean value (R+G+B)/3 value is calculated at the spectral intensity although it is only an approximation based on the assumption that the RGB filters are uniform bell-shaped functions symmetrically positioned in center wavelength. The overlap between the filter curves is not ideal so there are 'ripples' in the data but since the DIY spectrometer is not a precision laboratory device, they can be forgiven. There are more significant issues to address. ]

NO Clipping

The spectrometer is easily overloaded; i.e. it is easy to provide too much light and overexpose the camera. Like overexposed photos, the spectral data "washes out" to maximum value which is called "clipping". Clipping is bad because the measured intensity is limited to a maximum value and therefore cannot provide the true intensity.

[ Tech Note: The Syba webcam has 8-bit technology which means each pixel can provide a numeric value (R, G or B) of 0 to 255. In reality, the Syba camera appears to have an internal limit of only 245. ]

When observing the R, G and B channel data, it is necessary to set the light level so that none of the RGB data will clip. Otherwise, the resulting spectral plot data will be incorrect. It is easy to spot clipping because one or all of the RGB plots will "flat-top" on one or more peaks -- the plot line will look like it was "cut off". It is also important that the light level be high enough to ensure the RGB plot data uses the whole intensity range.

[ Tech Note: Dynamic Range is limited for the Syba webcam because it only has 8-bit intensity resolution. The top of the range is limited by a value of 245 and by the user's ability to set the highest RGB peak to just less than clipping. The bottom of the range is limited by background noise -- mostly a result of stray light leaking into the device. If the noise were high, like 25 counts, and the max peak were only 200, the dynamic range can be estimated as 20 x Log10( 200 / 50 ) = 12 dB. The '50' represents a weak signal which is only 2x the noise -- just barely measurable. Compared with laboratory equipment, 12 dB significantly limits the measurement capability of weak signals. ]

Peaks, Hills and Valleys

So, how do we read a spectral plot? A narrow peak represents light with significantly more energy concentrated at, or around, a single color wavelength. A laser is light at only one, single, very stable, repeatable wavelength. A CFL has several narrow "spikes", or "lines" in its spectrum which are also always the same and, since we know which wavelengths are emitted it is useful for calibration.

[ Tech Note: Single spectral lines are a result of the transitions between specific energy levels at an atomic scale. While we think of the solar spectrum as continuous, it actually consists of separate spectral lines; each a result of atomic scale energy properties. This also explains why the solar spectrum has "holes" in it -- wavelengths where no light is emitted. However, most of these "holes" are very narrow and so difficult to detect. ]

Camera RGB vs Spectrum

Light from a CFL contains a number of spectral peaks at a number of different wavelengths (colors) and the diffraction grating spreads those colors across the camera sensor but the camera detects RGB and we just want intensity vs wavelength. So, what is happening?

[....Editing to be continued..... -Dave ]

. .

.

.

Technical References

What are the two different types of spectroscopy, and how does the usage of the spectroscope differ?

http://en.wikipedia.org/wiki/Electromagnetic_spectrum

http://en.wikipedia.org/wiki/Photon

http://en.wikipedia.org/wiki/Fluorescence_spectroscopy

http://en.wikipedia.org/wiki/Absorption_spectroscopy

Rayleigh scattering in the sun and atmosphere.

http://en.wikipedia.org/wiki/Rayleigh_scattering

http://en.wikipedia.org/wiki/Optics

http://en.wikipedia.org/wiki/Lens_(optics))

http://en.wikipedia.org/wiki/Refraction

http://en.wikipedia.org/wiki/Dispersion_(optics))

http://en.wikipedia.org/wiki/Fraunhofer_lines

http://en.wikipedia.org/wiki/Chromism

http://en.wikipedia.org/wiki/Chromaticity_diagram

http://en.wikipedia.org/wiki/Image_sensor

http://en.wikipedia.org/wiki/Bayer_filter

http://en.wikipedia.org/wiki/Exposure_(photography)