Sciencemadness Discussion Board

DIY spectrometer resolution

aa1881 - 7-3-2024 at 08:19

I made a diy spectrometer using this tutorial:
https://www.gaudi.ch/GaudiLabs/?page_id=1124

It works, but the resolution isn't great and I'd like to improve it, but the theory isn't very clear to me.

Apart from changing the grating and narrowing the entrance slit, are there any other ways to increase the resolution? I read stuff about angles and distances, but I couldn't get it to improve experimentally. Could i change the camera or add other optics to increase the resolution?

Thanks in advance,
aa1881

DIY spectrometer resolution

aa1881 - 7-3-2024 at 08:20

Here is an image of a neon bulb and the spectral "lines" are pretty broad and not all are visible.

0_09.bmp - 2.5MB

RU_KLO - 7-3-2024 at 09:22

sorry, I do not own or constructed a spectometer,- its in my wish list, so take this with a grain of salt.
I think that the most important part is the light source. it should have a broad spectrum.

for example, you cannot meassure in a band (ex: 400 - 500nm) if you light does not produce light in that spectrum.
also, if the light has a high energy in a band, it could overwhelm the sensor, thus blurring the others.
Getting the right amount of light on the camera is important. Too much light, and the lines are blurred.

The same is in accoustics and microphony, thats why, for meassuring microphones, there are calibration charts that adjust the sensor to get the most flat response possible.

In audio/radio, for better precision, filters are used. Try to use optical filters to remove whats unwanted. (it is used in old book chemistry as "use cobalt blue glass, for checking the spectrum of potassium to filter the sodium spectrum)

Also better sensors, give better results. -in this case, a better camera.

I dont think that optics (in case of lenses) will help. In audio if the signal is distorted, amplifying in will get the distortion amplified. (Crap in; Crap out)


try to meassure sun light (pointing with a mirror) to see the spectrum you have and confirm this with internet spectrum meassures.

attached a picture of light spectrums dowloaded from:
https://ledworx.co.za/services/spectrometer/

I did made DIY electronic "equipements" for meassuring -mostly audio-electronics, because it was may last hobby, currently is chemsitry, and have understand that there are a lot of limitations (Y call them tolerances) and you have to be tolerant....
You cannot match a DIY USD 100 to a 2000 usd equipemnt, in accuracy and presicion.

hope it helps

found this, maybe it could help you https://publiclab.org/notes/cfastie/2-5-2013/grating-angle



Wavelenghts_of_light.png - 71kB


[Edited on 7-3-2024 by RU_KLO]

Stokes - 8-3-2024 at 01:04

It might help to add a collimating lens between the fiber optic input and the slit, which is basically just a convex lens with one of its focal points at the point where light enters the spectrometer.

Twospoons - 8-3-2024 at 13:19

Quote: Originally posted by aa1881  
Could i change the camera or add other optics to increase the resolution?
aa1881

That image looks a little out of focus to me.

If you are prepared to buy a camera with a bigger sensor and a better lens, then yes. Those little web cams are not really optimal for making a high resolution spectrometer.
A bigger lens will capture more light, and a sensor with bigger pixels should have a lower noise floor. The focal length of the lens also matters: you want to use as much of the sensor width as possible, so the setup of the lens should spread the spectrum across the entire sensor.
Lens quality also matters, in terms of resolving power, contrast, and optical distortions.

aa1881 - 8-3-2024 at 16:40

The distance from the grating to the camera is 2.8 mm, which should be the focal point for the camera, and if I understand correctly, these camera's have a pretty wide focal range.
Other than the source listed bij RU-KLO with experimental data, I found a reasonably userfriendly guide to designing a spectroscope with a theoretical approach (https://ibsen.com/resources/spectrometer-resources/spectrome...). I'll start by designing a somewhat modular spectroscope to play with these paramaters and find an optimum and also to find a way to fully stretch the spectrum across the sensor, as Twospoons suggested, but if it still doesn't provide satisfactory results, I'll look into getting a better resolution camera with an adjustable focus lens and might add a collimation lens to it as well. I won't get to this anytime soon, but once/if I'll make it work, I'll post an update for those googling the same question and struggling as I am.

Thanks everyone for your input so far, you've been very helpful.

Rainwater - 8-3-2024 at 18:20

You should ditch the gradient and use a prism. That should bring the resolution to the maxium your camera has.
Edit: Preview/post conflict
Using a long bolt, you could rig up a way to accurately move the optics(camera or lens) to find that sweet spot where everything is in focus.
This is on my todo list

[Edited on 9-3-2024 by Rainwater]

Sulaiman - 9-3-2024 at 02:20

Try watching the video from the camera using a monochromatic light source,
adjust your optics for the thinnest line image.

If no monochromatic light source is available
you could just adjust your optics for the most focussed/sharp image.

I have a diy spectroscope that one day (?) I hope to add a camera to,
just like my remote (in a comfy place) controlled telescope project... someday, maybe. :(

Ubya - 10-3-2024 at 06:03

cheap webcams have cheap sensors and even cheaper lenses.
Mine isn't the worst webcam on the market, but I still managed to shoot myself in the foot by removing the IR filter, because now it is permanently out of focus for the visible spectrum.

Large sensor, focusable, those are my tips.

0_02.jpg - 1MB

this is the janky spectrophotometer I've been playing with for 4 years, nothing fancy

spectrophotometer.jpeg - 135kB

aa1881 - 10-3-2024 at 09:41

So I've been messing around with distances and angles, and although it can get sharper or fuzzier when looking at monochromatic light, the apparant length of the spectrum across the sensor always seems to be about 300 pixels for a white ligth source, and I'd like to use the entire 1280 horizontal pixels.
Here is a video to illustrate what I mean, notice the horizontal length of the spectrum not changing despite moving all variables:

https://youtu.be/sPG8lB17gxE

I also think this camera can't get me the resolution I desire, ideally about 1 nm of separation. Does anyone have any recommendations for sensors and or lenses to get me to that kind of resolution? Does anyone know how to make the desired range of the spectrum fit across the entire sensor? Does that require lenses?

Sulaiman - 10-3-2024 at 11:22

A longer focal length lens will project a larger image.

All lenses introduce multiple non-ideal behaviours,
A big one is chromatic abberation (eg can focus blue or red but not both)
and each type has a usable transmission spectrum.
'good' lenses aren't cheap.

Ubya - 10-3-2024 at 13:44

Quote: Originally posted by aa1881  
So I've been messing around with distances and angles, and although it can get sharper or fuzzier when looking at monochromatic light, the apparant length of the spectrum across the sensor always seems to be about 300 pixels for a white ligth source, and I'd like to use the entire 1280 horizontal pixels.
Here is a video to illustrate what I mean, notice the horizontal length of the spectrum not changing despite moving all variables:

https://youtu.be/sPG8lB17gxE

I also think this camera can't get me the resolution I desire, ideally about 1 nm of separation. Does anyone have any recommendations for sensors and or lenses to get me to that kind of resolution? Does anyone know how to make the desired range of the spectrum fit across the entire sensor? Does that require lenses?


The width of the spectrum you see doesn't change if you vary the distance of the camera or the light source from the diffraction grating, it only depends on the grating itself.

https://ibsen.com/resources/calculators/grating-order-calcul...

you can play with this tool to see the angles of the various wavelengths (so that you can capture only what you want, and check if any higher diffraction orders are mixing with your order of interest).

if you want to fill the camera field with the spectrum, you need the appropriate lense to do that.

let's make an example with the tool I linked above.
1000 lines/mm diffraction grating
45° angle of incidence so that the webcam isn't looking directly at the source light (0 order) flooding thesensor with light.
360nm 1° Diffraction Order 20.3°
1000nm 1° Diffraction Order -17°

The delta is 37.3°, so I think you'd need a lense with a 46° field of view to fill most of the image with your spectrum.

(I haven't checked the numbers thoroughly so please make your own calculations!)

Sulaiman - 11-3-2024 at 00:05

Quote: Originally posted by Ubya  
... this is the janky spectrophotometer I've been playing with for 4 years, nothing fancy
Janky or not, it's served you well. Nice!

How much learning is required to make use of the spectra?
And where do you get reference spectra from?
And is there any free or cheap easy to use software to do the analysis?

aa1881 - 11-3-2024 at 00:40

The software I showed in the first image is Theremino Spectrometer. It's free and user-friendly, and comes with a manual with common reference spectra. You can calibrate it with a CFL bulb or with custom spectral lines like a neon bulb.

Ubya - 11-3-2024 at 04:31

Quote: Originally posted by Sulaiman  
Quote: Originally posted by Ubya  
... this is the janky spectrophotometer I've been playing with for 4 years, nothing fancy
Janky or not, it's served you well. Nice!

How much learning is required to make use of the spectra?
And where do you get reference spectra from?
And is there any free or cheap easy to use software to do the analysis?


UV-VIS spectra are the ones I know the least xD

I ugually just compare existing specctras I find on the web. I'm not too picky about the source for these references since my spectra aren't at all accurate, more like ball parks.


This is an example of how I used my spectrophotometer. I extracted some beta catorene, or so i thought, so I checked the spectra to get confirmation.

as aa1881 said, we are using Theremino Spectrometer (https://www.theremino.com/en/downloads/automation), it's designed for this kind of webcam based spectrophotometer.

On and off (you can see how active I've been on this forum lately...) i'm researching to build an open source spectrophotometer based on a linear CCD. There are already progects like this on the web, but i want to give my spin to it. I need something like this anyway lol, might as well share what I do

beta carotene extract.jpg - 104kB

Twospoons - 11-3-2024 at 15:57

Quote: Originally posted by Sulaiman  

A big one is chromatic abberation (eg can focus blue or red but not both)
and each type has a usable transmission spectrum.


This is really quite an important point to note if you want to cover a wide spectrum from near IR to near UV. Chromatic correction is always something of a compromise, and the wider the spectral coverage the worse the compromise will be. Unless you want a very complex and expensive lens set.

This is where a first-surface parabolic mirror might be a better option as a focusing optic. Still looking at a fair bit of coin for a good one, but no spherical or chromatic aberrations, and wide wavelength coverage.

[Edited on 12-3-2024 by Twospoons]

aa1881 - 13-3-2024 at 20:03

I've ordered a 1080p camera with an adhustable lens and without an IR-filter, like most seem to have. It'll get here in a weem or two, when I hope I can continue experimenting with my setup.

Just popped into my head

Sulaiman - 14-3-2024 at 06:42

Chromatic abberation may be significantly compensated for
using a simple lens
if the lens and sensor are NOT parallel.
(blue-end of sensor nearer to the lens than the red-end)

This will introduce some coma, so there is probably a little trade-off.

PS this would not work well with 'achromatic' lenses.
and as above, a first-surface parabolic mirror would be better.

[Edited on 14-3-2024 by Sulaiman]

aa1881 - 21-3-2024 at 06:11

The camera has arrived today. I hope to experiment some more this weekend. I'll post an update on here for anyone who might be building something similar in the future.

Sulaiman - 21-3-2024 at 07:30

One more thought... Diffraction grating quality.

One of the features of the grating that I bought is
"precision ruled grating" on a PET film.
There are better but more costly options.

aa1881 - 22-3-2024 at 11:46

I've made a first prototype but it doesn't look promosing. Attatched is an image of my current setup.
This is my current camera:
https://vi.aliexpress.com/item/1005006594287109.html?spm=a2g...

The grating is 1000 lines/mm

I am a bit at wits end here. In short, how can I get to an image I can make with this (see attached) to something more like this example (other attachment)?
I'll experiment with a broken CD in the meantime, since that's what I see a lot of other people using, but I don't think it should matter that much.

20240322_203810.jpg - 2.6MB0.jpg - 545kBCapture.PNG - 418kB

Stokes - 22-3-2024 at 12:08

You might try seeing whether it improves the resolution to move the light input further away from the slit. Just to test, I would place the setup in a dark room, clamp the fibre-optic cable in line with the input window at about two or three times the current distance from the slit, and see whether that improves the resolution. At a greater distance, the incoming light should be more collimated and diffuse less.

aa1881 - 22-3-2024 at 12:18

Thanks Stokes, that makes a lot of sense, I'll give it a go right away.

aa1881 - 22-3-2024 at 12:30

Adjusting the distance of the light source doesn't seem to change collimation that much, mostly just the brightness, so I don't think lack of collimation is my current Issue

Twospoons - 22-3-2024 at 13:03

What sort of image do you get with a monochromatic source, like a small diode laser?

aa1881 - 23-3-2024 at 03:28

This is a 450 nm laser (having trouble callibrating so ignore the wavelength values)

0_01.jpg - 535kB

Sulaiman - 23-3-2024 at 08:13

The top image shows some of your challenges,
. not a clear/sharp/focused image of the slit
. haze/bloom around the image (often caused by surface contamination, eg condensation.vs.telescopes)
. strange artefact that I do not recognise down to right of the main image.
(could be lens internal reflections, and is the grating flat?)
Hopefully someone with optics experience can diagnose better?

Twospoons - 23-3-2024 at 12:48

I would not expect to see that little secondary peak coming from a laser. If you change the angle of the grating does the spacing of those two peaks change?

Sulaiman - 23-3-2024 at 14:35

The second peak seems to be due to the optical abberation artefact down and right of the main image,
not from the laser.

aa1881 - 29-3-2024 at 06:27

The abberations might be from imperfections in the grating, I cleaned it with some isopropyl alcohol to make sure it wasn't dirty but it didn't seem to help. The focus seems good when remove the lid and focus in the slit. I am now designing a new box for a setup with a reflective grating (a broken CD). I'll post it when I get it all set up.

aa1881 - 6-4-2024 at 12:41

After much trial and error I finally have a setup with clear spectal lines. My only problem now is that the first and second diffraction order are overlapping. Is this something I can resolve?

Once I'm fully satisfied with the setup I'l post a link to the CAD files for my spectrometer for those interested.

Attached is an image of the spectrum of a CFL for reference.

0_02.jpg - 567kB

aa1881 - 10-4-2024 at 10:49

I increased the angle between the light entrance and camera a bit and it has helped somewhat. I am now waiting on a new lens to be able too zoom more onto the spectrum, so that I can use the primary diffraction instead of the secondary, which overlaps with the tertiary.

I uploaded the files to Thingiverse for those interested:
https://www.thingiverse.com/thing:6573462

Twospoons - 10-4-2024 at 17:10

Quote: Originally posted by aa1881  
My only problem now is that the first and second diffraction order are overlapping. Is this something I can resolve?


Pretty sure this is a fundamental limitation of diffraction gratings, and a good reason to use a prism instead if you want a really wide-band spectrometer.

The only way around this is to add wavelength filters to the camera sensor eg if the 2nd order red/IR is overlapping the first order UV/blue you could add a short pass filter over that part of the sensor (blocking red and passing blue)

[Edited on 11-4-2024 by Twospoons]

Ubya - 13-4-2024 at 06:11

Quote: Originally posted by aa1881  
After much trial and error I finally have a setup with clear spectal lines. My only problem now is that the first and second diffraction order are overlapping. Is this something I can resolve?

Once I'm fully satisfied with the setup I'l post a link to the CAD files for my spectrometer for those interested.

Attached is an image of the spectrum of a CFL for reference.

are you using here the CD?

you can get more angular distance between diffraction orders by increasing the line density of the diffraction grating.

a CD has about 625 lines/mm, if you use instead a diffraction grating with 1000 lines/mm you shouldn't have any issues.

I use a diffraction grating with 1000 lines/mm and I see an overlap only in the first order near IR

https://ibsen.com/resources/calculators/grating-order-calcul...
use this to play around

[Edited on 13-4-2024 by Ubya]

[Edited on 13-4-2024 by Ubya]

Twospoons - 13-4-2024 at 16:22

A better explanation (Pictures!), and the solution to order overlap
https://deltaopticalthinfilm.com/products/continuously-varia...

Ubya - 14-4-2024 at 02:53

Quote: Originally posted by Twospoons  
A better explanation (Pictures!), and the solution to order overlap
https://deltaopticalthinfilm.com/products/continuously-varia...


ohh i had no clue something like that actually existed. pretty dope!

Twospoons - 14-4-2024 at 21:26

It occurs to me that a second grating oriented 90 degrees to the first grating could be used as an order sorting filter. Imagine the first grating spreads horizontally: 1st order IR at 900nm would overlap 2nd order 450nm. The second grating would then vertically separate the 900nm 1st order light from the 450nm 2nd order light. Not sure how the optics would be set up for this - maybe like running two spectrometers in series, with the second grating where the image plane would be in the first spectrometer, with another lens following to focus onto the sensor. hard to describe in words and I dont have a good drawing tool handy. In essence: slit - grating - lens - grating - lens - sensor.

There's probably some reason why this doesn't work though.


[Edited on 15-4-2024 by Twospoons]

Sulaiman - 12-5-2024 at 09:30

Just watched a relevant YT video
https://www.youtube.com/watch?v=LxQmaJYMOAk