Two lens or not two lens? That is the question

Hi all,

!! Please note this is a shameless cross post from I just want more input if possible!!

As I prototype the field dissection microscope I am facing some lens related questions, and more importantly lens related design decisions.

I have started off with things I had around the workshop from previous Openflexure prototyping:

In the first version I simply unscrewed the PiCamera2 lens until it almost fell out. Then took an image.

I think the magnification is about 0.25 between the woodlouse, and the image on the camera sensor. Now there are a few of problems here:

  1. Very hard to repeatable set the lens in the same position
  2. May need a bit more magnification in some systems
  3. Working distance is super short (~1cm or so), which is really annoying

One thought is to make a system with a second lens. For this I make a modified super short lens spacer for the picamera lens, and a separate holder for another lens, these can be held apart by a little frame

The plan was to make a system with two lenses. As the camera sensor is smaller than the bug, we need to demaginfy the bug somewhat, to make a virtual image, that we then image with the picamera lens:

The eventual plan was to get “pancratic magnification” or adjustable zoom, my eventually modifying the system so that the picamera lens can be moved a few mm. I decided to start with the picamera lens about 6mm from the sensor giving it about a magnification of 1

Starting with the 50mm tube lens from the OpenFlexure microscope I ended making a tube that spaced this lens about 75mm away from the pi lens. This gives a magnification of about 0.33, and a working distance of about 180mm. This working distance is huge, making the microscope super unwieldly (which we can’t have, we must be able to wield with ease!). I was able to see my woodlouse (well an new woodlouse, Woody the Second we shall call them). Though it was awkward enough I didn’t save a snapshot.

In desperation I also tried the 6mm focal length plastic lens from the OFM illumination. The lens to lens distance here needed to be really accurate, and without an adjusting mechanism I couldn’t really get a focus, but the lens is clearly awful so I didn’t proceed.

Where next?

Well this is the question!

First of all, I think the next stage for me should be to design a stand, tweak the mechanics some more, and write some docs. This way others can build something an have a play.

As for what is next for the optics, I would love some feedback. I am much more of an mechanics person than I am an optics person. So I am just assuming everything is a perfect thin lens. Which will only get me so far. I have some ideas, but there is a trade off on cost/openness/quality/availability. I am not sure which is most interesting for the community.

What do people think of these options:

  1. Find a plain lens with about 20mm focal length and try again. Both as a 1-lens and 2-lens system. My back of the envelope calculations tell me should give me a more sensible size and working distance.
  2. Get M12 lenses perhaps this kit. These are easier to adjust. However there is lots to think about here:
    1. The kit above seem to be six lens groups. If they are optimised for imaging long distance, will this make a rubbish microscope. How easy are these lenses to get, and can we get identical ones in a few years?
    2. I think single lenses are available in an M12 housing, but they are fairly expensive, and might perform even worse!?
    3. M12 mounts are available for lots of cameras. Allowing experimentation with PiCamera2, PiCameraHQ, and lots of other cameras
  3. Just get a cheap C-mount adjustable microscope lens and put in on a picamera HQ. The downside is the lens is now a black box, and this lens might be hard to buy in some locations. The up side is it should give me time to concentrate on nice mechanics.

All comments welcome!

Any thoughts @WilliamW @r.w.bowman @biodotpe

This does all depend on the quality of the lenses, as well as the configuration. Which is where I get a bit lost. The Pi camera lens is an excellent lens for its design use: object a long way away, image close to the focal distance. Unscrewing the lens so that it is further from the image plane and the object is closer moves you away from the design, but the image you get is still good as it is not so far from the design. In addition to the issue with the working distance, this is also not really that robust against future availability - many channels have stopped stocking Pi Camera v2.1 since Pi Camera Module 3 came out, even though Pi Camera V2.1 is not discontinued.

The second version is even further from the design spec of the Pi camera lens, although not so far that it makes sense to reverse the lens (as for the main microscope). The other apparent issue with the second version is the position and size of the entrance pupil of the Pi camera lens. The virtual bug image is not a real object reflecting light in all directions from each point, it is formed from light going through the first lens, so light forming the top of the image is mainly heading upwards and will not go into the Pi camera lens. I think I expect strong vignetting, but you did see something reasonable? I am not exactly clear on what you have written, but did you mean a magnification of 1:1 rather than 1mm? In that case why not just use the 50mm lens to image the bug directly sensor? Then you can only get changes in magnification by changes in working distance: leaving the camera-bug distance about fixed and moving the lens. This seems to be what is done in many hand-held USB-microscopes. As for the 50mm lens, a simple achromatic lens is not that great in imaging terms, but it is being used at a small aperture so will probably be fine. A shorter focal length to get an acceptable working distance should be OK, as long as the aperture remains small and there is enough light to cope with a small aperture.

@r.w.bowman will probably spot the misconceptions here.

option 3 in your final list is actually not so bad for reproducibility, and is similar to ‘get an M12 lens’. You cannot get exactly the same lens everywhere maybe and there will be variable quality. However if you specify the mount type and focal length then the basic optical performance is specified, in the same way that you could specify a microscope objective x40 infinity corrected.

Thanks William, this is really helpful

100% correct. It was pretty awful, very dark and vignetted. I was tempted to turn the lens around as it was equidistant from the virtual image and the sensor so there isn’t much need for something different. Everything was made worse because I have ran out of black filament, and the spacer didn’t completely obscure excess light. It was very much a “is this worth further work test.”

Ooops, yes

I was thinking that by moving the pi-lens I had less distance to move it. But yes, you are right that leaving the camera-bug distance fixed is more important.

I plan to get some neopixel or other LED rings so light should be pretty bright. I can always add an aperture.

This is true. I suppose the M12 lenses I have found are a bit better at giving me specs than the very cheap c-mount microscope lens. But then this can be worked out on post. I’ll have to talk to Andy about what he can get in panama.

This bit is wrong, oops. The overall camera-object distance has to change as well as the lens object distance. Both move over quite a large range for a useful range of magnification.

Did seem too good to be true. Yeah. I think it is likely that you need to do two adjustments to zoom.

1 Like

Hi @j.stirling, we did the same for our microscopy stage. As I mentioned before, we wanted to improve the FOV and working distance, so we tried with other cheap lenses. However, the lens from the PiCam is much better, as @WilliamW pointed out. It is worth to keep it in the final design.

So, I would go for a 2-lens system including the original lens and Pi cam v2. I remembered this design from Fernan.

On the other hand, moving to the Pi cam HQ seems a trend for this kind of application such as the Enderscope or this new design called “Entomoscope”:

In terms of reproducibility, any optical component is always an issue in South America. Unfortunately, an extra lens, a lens that doesn’t come with the hardware, is not cost-effective for prototyping. Shipping costs can be more than the product. I’m not sure if it’s the same in Panama. That is why a USB microscope is so attractive as a solution for some applications (?)


I think a non-zero part of the difficulty of making a nice continuous zoom lens is getting several lens group distances to adjust simultaneously. Zooming nicely at constant focus is probably quite tricky - but maybe figuring out how you could make it work for a few key zoom levels would already be very useful.

I did play with a very basic “optics rail” for exactly this sort of experimentation, which ended up dumped in a disused branch of a not-very-visible repo (GitHub - rwb27/openflexure_dissection_microscope at optics_rail). May or may not be helpful to you, but I thought it was worth mentioning. There should be bits in there that hold a pi lens, camera, and larger lenses, and are marginally less horrible to use than balancing everything on cardboard and blu tac…

I would need to think carefully to figure out whether your two-lens version is useful compared to a single lens - but I’d second William’s thought that you’re likely to have bad vignetting in that system and I’m not totally sure how you fix it.

The plastic condenser lens is pretty bad for imaging - but if you use it as one half of an afocal telescope (i.e. keep the pi lens in place, focused on infinity) it’s better than I expected: I think the saving grace is that you’re only ever using a small portion of the aperture, so the aberrations are much less. The downside of that approach is that it’s fixed-magnification, so you’d need to swap lenses to change your FoV. I know you can readily get suitable f=40mm lenses (made for Google Cardboard) that I’d expect would work OK - so the question is what range of magnifications you’d need.

It may be hard to beat the c-mount macro lens option, but there’s definitely a question there as to how easy it is to get hold of them (and whether they cover the right magnification range). I know there are also stands for that, e.g. Microscope stand with 0.12-1.8x lens, but again the question is availability/repairability if you’re not in pimoroni’s region.

Lastly I will mention this paper that I saw in a tweet - it uses an off the shelf telecentric lens (probably £1k or more IIRC) though, so doesn’t tell us anything very useful about low cost optics.

Oops, I see @biodotpe has mentioned this already!


The images in the recent post on the other thread are superb Crowdfunding a new OpenFlexure-family Microscope - Announcements - OpenFlexure Forum and the working distance looks long in the posts on the project on What is the lens solution that you arrived at?

The working distance is about 110mm which is long enough to not be in the way but short enough that the microscope is not massive.

The lens is the M2016ZH01 M12 lens from Aducam

The lens sits in a fairly long M12 lens holder and is screwed a fair way out.

1 Like