What's new

An inexpensive spectrometer for doing acetone testing on kava

verticity

I'm interested in things
I've been working on an amateur science project for acetone testing kava varieties. Here I will describe the apparatus I made (that you could make too!) and show that it works, but there won't be any groundbreaking information about unknown kava samples. (Spoiler alert: Papa Ele Ele is noble; Isa is not)

The instrument is a spectrometer, which is an instrument for measuring the intensity of light that something absorbs as a function of wavelength. This is basically a poor man's version of the spectrophotometer that Deleted User uses for his tests.

Here is a schematic diagram showing how the spectrometer works.

The light source passes through a narrow slit, to create a thin beam of light. It then goes through a diffraction grating, which disperses it by wavelength. This is the same effect that a prism has. The rainbow pattern then is imaged by a detector, and the relative intensity of various wavelengths can be determined.

Here is my spectrometer:


And here is a look inside the black box:


From left to right, there is a regular webcam as the detector, with a fragment of DVD stuck in front of it, which acts as a diffraction grating. The glass thing is the sample cuvette, and then an acetate entrance slit (0.12 mm). Illumination is provided by a halogen lamp. This design is inspired by the work at Public Laboratory, which has instructions for making something like this, and also sells kits. I got the slit from there. Sample cuvettes can be ordered from vendors on Amazon for ~ $10 (for the cheap ones). Data analysis is done by a computer program that checks the intensity at different positions on the webcam images. For these results I averaged 100 images together to smooth out the noise.

And this contraption actually works. First it needs to be calibrated so that the wavelengths that the pixels on the webcam correspond to are known. To do this you can use a compact fluorescent lamp, which emits light at specific, known, wavelengths. Here's a CFL spectrum I took:


FWHM means "Full Width at Half Max", which is a measure of resolution. This instrument has a resolution of ~3 nm, which is not bad, sufficient for our purposes here.

For analyzing kava samples, I want to look at the absorbance spectra. Absorbance is a measure of how much light is absorbed by a sample. Deleted User's results are based on transmittance which indicates how much light passes through a sample, and thus the color that we see. But absorbance has the advantage of being directly proportional to the concentration of substance in your sample. So, theoretically if the "tudei" peak of a particular sample is half the size of the tudei peak of pure tudei, that would mean there is half as much of whatever substance causes the orange tudei peak, and so would be a good indication of adulteration.

So, here's my results. This just compares Papa Ele Ele - a known Hawaiian noble -- with Isa -- a known tudei, both extracted in a 1-to-3 ratio with acetone (by volume). Both samples are from @Gourmet Hawaiian Kava. Chris doesn't sell Isa for human consumption, but generously provided a sample for testing.



Notice that PEE has a peak at 424 nm, but for Isa, the peak looks similar on the blue side, but the max is shifted to 445 and the overall absorbance is higher, so it looks like there is actually a second substance (or substances) in the Isa with a slightly different spectrum than the yellow substance in PEE. If we assume that Isa contains the same amount of yellow substance as PEE, and assume that the orange substance is completely absent from PEE, we can take the difference of the two spectra (just subtract the PEE from the Isa curves), to see what the spectrum of the orange (tudei) stuff by itself would look like:



In the future, when I get some more free time (lol), I hope to measure some spectra of noble kava adulterated by various percentages of tudei, to see if I can prove what I said that absorbance is proportional to concentration, and then do some "unknown" samples.

So, it's actually possible to do "Deleted User style" acetone tests with inexpensive equipment, some of which you probably already have laying around the house.
 

Steve Mariotti

Kavapithecus Krunkarensis
Review Maestro
I'm working on this problem too. Though haven't made much progress. Currently nailing down parts list and building an enclosure in Autodesk Fusion 360. I had a test print done, and it'll be perfect for this purpose.

I need to figure out the parameters of the "light stage" inside the device because I want everything fixed in place and impossible to set up wrong.

The Public Labs device has you set it up with a really large distance between the slit and the diffraction grating. This seems like a bad idea. You're trying to collumnate the light and it seems like distance would offer further dispersion.

Also, @verticity, do you know what they're software is doing to create the sample reading? It looks like it samples the spectrum along the line you define in the setup and then saves that. And repeats for 100 samples for averages. It's looking for intensity at each point in the image bitmap? I obviously want to replicate that functionality in firmware.

So then you pop 4 AA cells into it, open the door and insert the cuvette, snap it shut and press the button.

Once I have the geometry of the light stage bit, I can start iterating in PLA. Black ABS is way better for this, but I have access to cheap PLA and want to make my mistakes there!
 

verticity

I'm interested in things
Hey, what happened to the Gilligan's Island gif? I can't see it now.
I'm working on this problem too. Though haven't made much progress. Currently nailing down parts list and building an enclosure in Autodesk Fusion 360. I had a test print done, and it'll be perfect for this purpose.

I need to figure out the parameters of the "light stage" inside the device because I want everything fixed in place and impossible to set up wrong.

The Public Labs device has you set it up with a really large distance between the slit and the diffraction grating. This seems like a bad idea. You're trying to collumnate the light and it seems like distance would offer further dispersion.

Also, @verticity, do you know what they're software is doing to create the sample reading? It looks like it samples the spectrum along the line you define in the setup and then saves that. And repeats for 100 samples for averages. It's looking for intensity at each point in the image bitmap? I obviously want to replicate that functionality in firmware.

So then you pop 4 AA cells into it, open the door and insert the cuvette, snap it shut and press the button.

Once I have the geometry of the light stage bit, I can start iterating in PLA. Black ABS is way better for this, but I have access to cheap PLA and want to make my mistakes there!
Steve, a couple points:
- The slit does not collimate the light in the sense that laser light is collimated, it creates a linear "point source" which is imaged by the camera. The camera lens projects an image of the narrow slit on the camera's CCD. If the camera is closer to the slit that is equivalent to having a wider slit, which means worse resolution (but better sensitivity to the light)

- The most difficult part for me to get right was mounting the cuvette. (Using standard 1 cm square cuvettes). Notice that the cuvette is mounted inside a light tight "wall" so that light can only pass through the cuvette. It cannot reach the camera any other way. That is essential to avoid reflections inside the instrument; even if the walls are flat black, like mine are, there can still be enough reflections to mess you up. When the cuvette is removed, the cuvette "wall" acts as a light baffle which was essential for avoiding reflective interference with emissisive sources (i.e. CFL). It would be better to mount the cuvette as close as possible to the slit, I think, but you also have to worry about reflections off the surfaces of the cuvette, which are flat. The cuvette should be aligned exactly so the surface is perpendicular to the slit. I did the best I could to rig something like that with foam board and electrical tape (lol), but with 3-D printing you could get it exactly right.

- It does make sense that the final product should have fixed components, but you will need to do some experimentation to find the best positions of the fixed components: your prototype should have adjustable parts. In mine, the camera is mounted magnetically to a steel plate, so it is easy to move around, and the cuvette mount can be moved back and forth also. The problem is, they move too easily, so it is hard to keep the thing calibrated. Surely you could do better by mounting the camera on a piece of wood or something, with a slot in it and a screw to fix the position, or something like that.

- Public Labs software is picking a single line across the spectrum. I don't know if it does averaging over time, but it is throwing away most of the spectrum that is projected on the camera. Their rationale is that they have to do this because of the curvature of the DVD grating. And the intensity of each point is just a floating point number which is the average of the R, G and B channels. You could equally well just use the integer sum of R, G and B, that might be easier for a microcontroller. I created my own software that can average the whole spectrum between 2 lines you define, and average any number of images together, which is important for S/N of absorption spectra, because the absorption spectrum is actually the difference between the measured spectrum and the "blank" spectrum (the spectrum of an empty cuvette). i.e. it is the difference of things that are pretty similar, hence need for good S/N. I found that the DVD curvature was not actually an obstacle to getting sufficiently high resolution. My software is in WPF (sorry) but if you are interested I would be happy to provide it to you.
 

verticity

I'm interested in things
Correction: you will still need to use floats (preferably doubles) for the averaged spectra.
 

verticity

I'm interested in things
Re collimation: If you wanted to be "fancy" you could actually collimate the light from the slit with a cylindrical lens (or pair of lenses). That would boost the amount of light going through the sample quite a bit, which could be critical if you are using a low powered light source.

Something like this:


Source: http://www.durst-pro-usa.com/world_images/theofcon.htm

The cuvette would be between the two lenses, and the camera's CCD would be where it says "Projected lamp filament" Possibly the built-in camera lens could serve as the second lens.
 
Last edited:

Steve Mariotti

Kavapithecus Krunkarensis
Review Maestro
- The slit does not collimate the light in the sense that laser light is collimated, it creates a linear "point source" which is imaged by the camera. The camera lens projects an image of the narrow slit on the camera's CCD. If the camera is closer to the slit that is equivalent to having a wider slit, which means worse resolution (but better sensitivity to the light)
I'd probably want a narrower slit, though 3d printing isn't precise enough to give me a hard edge for the slit. As you mentioned once before, an air gap is best. Two razorblade edges, if somehow at perfect parallel would work. I can't think of a way to get the precision that the acetate slit provides.
- The most difficult part for me to get right was mounting the cuvette. (Using standard 1 cm square cuvettes). Notice that the cuvette is mounted inside a light tight "wall" so that light can only pass through the cuvette. It cannot reach the camera any other way. That is essential to avoid reflections inside the instrument; even if the walls are flat black, like mine are, there can still be enough reflections to mess you up. When the cuvette is removed, the cuvette "wall" acts as a light baffle which was essential for avoiding reflective interference with emissisive sources (i.e. CFL). It would be better to mount the cuvette as close as possible to the slit, I think, but you also have to worry about reflections off the surfaces of the cuvette, which are flat.
I've seen cuvettes with flat walls, ones that are cylindrical like test tubes, ones that ARE test tubes. Wouldn't a cylinder be better? It seems like it would simply act as a lens, and also filter out the light from the source.
The cuvette should be aligned exactly so the surface is perpendicular to the slit. I did the best I could to rig something like that with foam board and electrical tape (lol), but with 3-D printing you could get it exactly right.
Yes, I think the tolerance is about 1mm on the printer I'm using right now. There are better printers with better resolution. But even at 1mm we might be OK in terms of tolerances provided the light stage isn't too complicated and/or subject to small twists in the housing when printed to final ABS.
- It does make sense that the final product should have fixed components, but you will need to do some experimentation to find the best positions of the fixed components: your prototype should have adjustable parts. In mine, the camera is mounted magnetically to a steel plate, so it is easy to move around, and the cuvette mount can be moved back and forth also. The problem is, they move too easily, so it is hard to keep the thing calibrated. Surely you could do better by mounting the camera on a piece of wood or something, with a slot in it and a screw to fix the position, or something like that.
I have a 3Doodler, which is basically printing head and filament motor in pen form. My plan is to print the enclosure in the cheap PLA and use the 3Doodler to make semi-permanent adjustments. ABS melts at a higher temperature, so should be a good glue for moving pieces around.
- Public Labs software is picking a single line across the spectrum. I don't know if it does averaging over time, but it is throwing away most of the spectrum that is projected on the camera. Their rationale is that they have to do this because of the curvature of the DVD grating. And the intensity of each point is just a floating point number which is the average of the R, G and B channels. You could equally well just use the integer sum of R, G and B, that might be easier for a microcontroller. I created my own software that can average the whole spectrum between 2 lines you define, and average any number of images together, which is important for S/N of absorption spectra, because the absorption spectrum is actually the difference between the measured spectrum and the "blank" spectrum (the spectrum of an empty cuvette). i.e. it is the difference of things that are pretty similar, hence need for good S/N. I found that the DVD curvature was not actually an obstacle to getting sufficiently high resolution. My software is in WPF (sorry) but if you are interested I would be happy to provide it to you.
This is fantastic information. You never cease to amaze, man. I was wondering about the diffraction grating too. Rather than using scavenged DVD grating, I could go with a specific grating cut to precise size and mounted in the housing permanently. Then I would be less concerned about the curvature as it'd be all parallel. Should make things easier to calibrate initially.

Re collimation: If you wanted to be "fancy" you could actually collimate the light from the slit with a cylindrical lens (or pair of lenses). That would boost the amount of light going through the sample quite a bit, which could be critical if you are using a low powered light source.
That's a great idea. A linear lens array would reduce the size of the enclosure and make calibration easier as the lens assemblies could be completely fixed.

Could DVD drive lenses be appropriated for this, do you think? Surely there are bulk consumer optics products circulating in overabundance that can be tapped for the materials for this.
The cuvette would be between the two lenses, and the camera's CCD would be where it says "Projected lamp filament" Possibly the built-in camera lens could serve as the second lens.
Yeah, the webcam has a lens. And I believe is adjustable, though I've never been able to turn the one on the Public Labs device.

I'll read up on optics and research what's available as OEM consumer electronics parts.
 

Steve Mariotti

Kavapithecus Krunkarensis
Review Maestro
So a lot of lenses for use with lasers are mounted in a standard threaded metal ring with threads on the outside. That's pretty handy for prototyping.


Here's a sketch I did of what I think would be the next step for me. This is pretty ugly but gets the point across. I have to go clean it up if I'm actually going to print one.

upload_2016-1-2_15-46-42.png


You should be able to view the model online:

http://a360.co/1PE6GyM

The size of this thing overall is 160mm by 70mm by 20mm or like 6 inches by 3 inches by an inch.

The sample would presumably go in between the light source and the slit holder and of course just now I realize that I left no room for it. I'll go add a slot for a 20mm by 20mm (?) flask.

I'm happy with the adjustable bed and thread idea because the threads keep the lenses axes correctly aligned, and the thread geometry is standard and was a preset in my CAD package. WOOT!
 

verticity

I'm interested in things
I'd probably want a narrower slit, though 3d printing isn't precise enough to give me a hard edge for the slit. As you mentioned once before, an air gap is best. Two razorblade edges, if somehow at perfect parallel would work. I can't think of a way to get the precision that the acetate slit provides.
You might be able to buy air-gap slits somewhere. The acetate ones are serviceable for the visible spectrum, though

I've seen cuvettes with flat walls, ones that are cylindrical like test tubes, ones that ARE test tubes. Wouldn't a cylinder be better? It seems like it would simply act as a lens, and also filter out the light from the source.
No, a square cuvette is preferable. You want the path that the light travels through the sample to be constant. Also you definitely don't want the sample cuvette acting as a lens. It would have a different focal point depending on whether it had air or acetone in it, and would generally confuse things
Yes, I think the tolerance is about 1mm on the printer I'm using right now. There are better printers with better resolution. But even at 1mm we might be OK in terms of tolerances provided the light stage isn't too complicated and/or subject to small twists in the housing when printed to final ABS.
The cuvette is only 1 cm: a 1 mm tolerance would leave a lot of wiggle room. I don't think that would be good enough.

I was wondering about the diffraction grating too. Rather than using scavenged DVD grating, I could go with a specific grating cut to precise size and mounted in the housing permanently. Then I would be less concerned about the curvature as it'd be all parallel. Should make things easier to calibrate initially.
You can get transmissive gratings quite cheaply. The problem is they are not rigid, so you would have to mount them on a glass slide or something. For example:
http://www.carolina.com/catalog/det..._gl_products&gclid=COrdsfatjMoCFQ2HaQodMXwBGA



That's a great idea. A linear lens array would reduce the size of the enclosure and make calibration easier as the lens assemblies could be completely fixed.
You would actually need a cylindrical lens to collimate the slit, and maybe also another lens to focus it on the camera. A cylindrical lens looks like a section of a glass rod, for example:


Could DVD drive lenses be appropriated for this, do you think? Surely there are bulk consumer optics products circulating in overabundance that can be tapped for the materials for this.
I think you would need something larger than a DVD lens to gather all the light from the slit.
 

verticity

I'm interested in things
So a lot of lenses for use with lasers are mounted in a standard threaded metal ring with threads on the outside. That's pretty handy for prototyping.


Here's a sketch I did of what I think would be the next step for me. This is pretty ugly but gets the point across. I have to go clean it up if I'm actually going to print one.

View attachment 4871

You should be able to view the model online:

http://a360.co/1PE6GyM

The size of this thing overall is 160mm by 70mm by 20mm or like 6 inches by 3 inches by an inch.

The sample would presumably go in between the light source and the slit holder and of course just now I realize that I left no room for it. I'll go add a slot for a 20mm by 20mm (?) flask.

I'm happy with the adjustable bed and thread idea because the threads keep the lenses axes correctly aligned, and the thread geometry is standard and was a preset in my CAD package. WOOT!
Looks cool!.
Note the diffraction grating must be held at an angle to the incoming light, not perpendicular to it, as in the drawing; it will then project a spectrum at an angle, so the camera needs to be offest as well. You can find formulae to calculate the angle online (probably somewhere on the Public Lab site) You also might want the ability to have optics mounted between the grating and the camera.
 

verticity

I'm interested in things
Also, you might want to be able to adjust the distance between the light source and the slit for prototyping, as well as the distance from the slit to the grating. Maybe the slit, grating and camera could all be mounted on the threaded optics bed.
 

Steve Mariotti

Kavapithecus Krunkarensis
Review Maestro
Questions!

What are the tangible advantages of using optics to collimate and then focus the light? Higher precision? And I would have thought to put the collimating lens just after the slit rather than between the diffraction grating and the camera. Carrying completely parallel light from the slit to the diffraction grating for a clean projection onto the grating for the webcam to look at the back of. No?

I left 12cm square for the cuvette. Can you link me the ones you use?

I have something nearly ready to print which will let me move pieces around and play with distances a bit. I just need to find a set of parameters that all work well together and start nailing the details down.

I found this thing:

Amazon product
Which appears to be basically a slit a diffraction grating and then a light isolated tube on the inside that you can peer down and see the spectrum overlaid on a scale printed in the tube's window. Or near as I can gather.

I still haven't given up on the idea of using a diode array if I can find one of the right size and shape to put in the case. That would be a great power saver.
 

verticity

I'm interested in things
Questions!

What are the tangible advantages of using optics to collimate and then focus the light?
The benefit is that you will be using a low power light source. You will not be able to plug a halogen lamp into a wall socket. So you need to use the light efficiently. The non-benefit is that if you start putting lenses after the slit, then the slit is no longer a good point source, so you lose resolution unless you basically construct a complete optical system to focus the slit on the grating. You are basically constructing a telescope, which happens to have a sample cuvette in the middle of it. You are forming an image of the slit on the grating, which should be as narrow as possible at that point for maximum resolution.
And I would have thought to put the collimating lens just after the slit rather than between the diffraction grating and the camera.
Correct, you probably don't want anything between the grating and the camera. But you will need more than one lens, like I described. Actually, just brainstorming here, sorry if I am not being consistent, I guess you could use a system of 3 round lenses to do this: 1. A plano-convex after the slit to collimate the light to a width that can pass through the cuvette. 2. On the other side of the cuvette, a bi-convex lens to focus the light down to a smaller size suitable for projecting on the camera, and 3. Another collimating lens near the focal point of the second lens, this one concave because the light is being focused, not dispersed at this point, to give you a nice collimated beam of the correct size to project on the camera..
Or something like that lol

Or you could just try it without the lenses (except the one built into the camera) at first, and see if you actually need all the extra lenses.
I left 12cm square for the cuvette. Can you link me the ones you use?
These are the cuvettes I used:
Amazon product
You can also get disposable plastic ones for much cheaper. In general plastic does not play well with acetone, but they might be OK for single use & dispose, for example:
Amazon product
I found this thing:
I can't see the thing, but it sounds like a spectroscope. Those are useful for looking at emissive sources and identifying spectral lines, but they lack some important parts for your purposes: a light detector that can interface with a computer, a sample holder, and a light source. But it might be instructive to get one to play with/tear apart.
 
Top