The SpectraCam Project
Welcome to the SpectraCam project page hosted by Walla Walla University. This project was developed and is maintained by Dr. Tom Ekkens. If you have comments or suggestions please send email to Tom.Ekkens@wallawalla.edu. This page was last updated on November 19, 2017.
Spectrometers are available in a variety of types and costs. A simple one can be made with a cardboard box and a piece of DVD. Commercial ones use a computer to acquire data and cost hundreds or thousands of dollars. Public Lab (publiclab.org/wiki/spectrometry) has an excellent version that can be purchased and built.
This project uses the camera section of the Public Lab spectrometer but changes the housing and software. The goal was to make the housing strong enough that it could be used for general use. The housing was also extended to improve resolution. New software was written that can be used without an internet connection.
Bill of Materials
|2x 1½ ABS cap||012871529771||$2.56||Home Depot|
|11¼” of 1½" pvc conduit||722669||$4.77||Home Depot|
|2" ABS right-angle||611942029051||$2.85||Home Depot|
|1½ to 1½ Flexible Coupling||018578000032||$3.90||Home Depot|
|Flexible Cap||018578000483||$2.97||Home Depot|
|USB 2MP webcam||JDEPC-OV05||$30.00||Public Labs|
|Flat Black paint||020066197674||$3.63||Home Depot|
|Plastic Diffraction Grating||1000 lines/mm||$5.00||Ebay|
|Black Card Stock||759598993705||$8.26||Walmart|
Set up the Camera
- Remove the lens from the camera.
- Turn the lens housing over and remove the reddish glass.
- Spray with compressed air to clean and reassemble the lens to the camera.
- Plug in the usb camera to a computer running Windows 10 - 64 bit.
- Copy “SpectraCam.exe” and “opencv_world330.dll” to the computer. The file “opencv_world330.dll” is part of the OpenCV 3.30 package. The file “SpectraCam.exe” can be obtained by emailing the author of this page at the address above.
- Start SpectraCam, check “Full Image” and “Camera On”. You should see the live image from the camera. If not change the USB Port from 0 to 1.
- Once you have a good image, set the focus to about 11 inches. Work slowly, the image is averaged over a few seconds.
- Prepare the diffraction grating.
- Cut a 5 mm x 5 mm piece of diffraction grating to fit over the camera.
- Orient the diffraction grating so that light is bent along the long axis of the camera board.
- Put a tiny bit of black paint on the camera housing and glue the diffraction grating down to the top of the camera. Do not get so much paint on that the camera hole is covered.
Machine the PVC
- Drill a hole in the center of one of the ABS caps. This will now be referred to as the front cap.
- Use a 0.0217” drill bit and try to put the hole as close to vertical at the exact center as possible. Be aware that the drill bit is very fragile.
- Use a 0.0276” drill bit by hand to make the hole a bit bigger.
- The completed part is shown in the picture below at left with the location of the hole indicated by the red arrow.
- Drill a hole at the end of the other ABS cap. This will now be referred to as the back cap.
- Use a 3/8” end mill bit to drill a hole 0.75” deep moved in 0.10” from the outside wall the cap.
- The completed part is shown in the picture below at right.
- Prepare the PVC tube.
- Use a saw to cut a piece of 1½ inch PVC conduit to a length of 11¼”. (This lets one sheet of paper sit in the tube without bumping.) Smooth the ends of the cut if desired.
- Clamp the tube into an end mill, load the 1/8” end mill bit and follow this recipe:
- Move to the left end and zero the y-axis.
- Move in 1.3”, find the center by just touching the top. Zero x and z at that point.
- Drill all the way through and then go 0.15” in each direction in x.
- Move up to -0.07” in z, and right to 1.33” in y.
- Repeat the 0.15” in each direction in x.
- Obtain an 8.5 x 11 piece of cardstock. On the short side, measure in 100 mm and cut a slot 8 mm x 32 mm. Cut 19 mm of the tab off. The slot and most of the short side of the paper are shown in the picture at right.
- Roll the cardstock up and slide it into the tube from the front end (opposite the milled hole). Make sure the slot in the paper goes around the milled hole.
- Remove the hose clamps from the flexible coupling and slide it over the tube into the approximate center of the tube to that the milled slot is still visible.
- Slide the front cap unto the tube and lightly push it down.
- Slide the camera into the slot so the circuit board is just even with the surface of the tube. Align the white usb plug to the center of the tube.
- Plug in the camera to the computer.
- Start the software, check “Full Image” and turn on the camera.
- Aim the tube a fluorescent light. You should see a picture similar to the one at the right.
- If the colored dots are not close to a horizontal line, you will need to rotate the camera focus knob slightly to get them as close to horizontal as possible. If the dots slope down, rotate the camera lens slightly clockwise. If the dots slope up, rotate the camera lens slightly counter-clockwise.
- Once the dots are horizontal, hot glue both ends of the camera to the tube if desired.
- Slide the back cap over the white usb plug and push it on until it touches the white plug.
- Attach the usb cable to the camera.
- Slide the 90 degree elbow over the end cap with the opening opposite to the usb cable.
- Hot glue the elbow to the end cap and the end cap to the tube with four spots of hot glue each.
- Glue the usb cable at two locations to the right-angle pipe.
- Insert the flexible end cap into the elbow to keep the cable from moving and seal out the light.
- Slide the coupling over the milled slot to keep out the light. The finished assembly should look about like the picture at the top of this page.
- Start the SpectraCam program and point the spectrometer at a fluorescent light.
- Click the “Start” button to begin capturing data and once again to end capturing data and hold the last data. You also can use CTRL + Space Bar to toggle the camera. You should see a picture similar to the one below. If a warning message about the camera not being found appears, change the “Camera #” from 0 to 1.
- With the camera stopped, press the “Auto” button. The two numbers in the “Blue” and “Red” boxes should change slightly.
- Check the quality of the calibration by selecting “Fluorescent Light” from the dropdown box titled “Fit”. This will add colored bars indicating the expected peak location to the line scan. Many of your peaks should line up with the bars. (This calibration data is adapted from https://www.nist.gov/pml/handbook-basic-atomic-spectroscopic-data ).
- The first order lines are shown in red and the second order lines are shown in green.
- You can adjust the “Blue” or “Red” numbers slightly to try to make the peaks line up better.
- The camera doesn’t show all the lines since it only has a range of 380 nm to 900 nm.
- Once the camera is calibrated, these two numbers should be entered for each set of data.
- The calibration data scan be saved to the local computer by using the the “Save Calibration” entry from the menu accessed by left-clicking on the upper-left icon.
- Moving the camera to another computer will require the numbers to be entered by hand but will not require another spectra of the overhead lines to be taken.
- The “Brightness” dropdown box can be used for dim samples.
- Data Saving.
- The data can be saved using the “Save As” entry from the menu accessed by left-clicking on the upper-left icon. This data can be loaded back into the SpectraCam software and modified.
- The data can also be exported as columns of numbers from that same menu. Once it is in that format, it cannot be loaded back into SpectraCam.
- Also from that menu, the view on the screen can be saved to a PNG file. The resulting file cannot be loaded back into the program.
Using the SpectraCam
Once the SpectraCam is completed, it is time to use it and measure things. The most obvious sample is the fluorescent light that was used for calibration. In the picture below, the red and green lines are the expected values for the first and second order lines.
In the picture below, a sodium street light bulb has been measured. The strong yellow line is actually two lines so close together that they appear as a single line.
In the picture below, a neon sign has been measured. This section of the sign was mostly orange. The expected values have been added again.
Finally, we have data from a blue LED shown below. From this picture we conclude that the transitions that the electrons make in a semiconductor must be less restrictive than those in a gas but that is another story.