Investigating tube lenses for infinity optics, RPi HQ camera, and a simple upright microscope

I went a bit off the deep end after building my first OFM, trying to see how I could modify the optics a bit. I wanted to answer these questions:

  1. Does an achromatic doublet make a good tube lens? If not, is there an affordable tube lens that works well?
  2. How do images from the RPi HQ camera compare to the camera module v2 (assuming the same objective and optics)?
  3. The condenser lenses used in OFM are cheap but can be a pain to source. Can we build a nice condenser with a good NA that’s not too expensive?

Anyway, this effort took me pretty far afield of the OFM, but maybe some of it will be useful information.

The setup: I wanted a basic upright brightfield microscope that would use infinite-conjugate objectives to evaluate different tube lenses, sensors, and illumination conditions. I ended up building a simple setup that slides along a vertical “2020” aluminum extrusion. Alignment and vibration are problems with this “minimal viable microscope” consisting of illuminator, condenser, stage, objective, tube lens, and sensor, but it works and makes some nice images when I can get everything lined up and not shaking. I didn’t use OpenSCAD for modeling this but I can share models as STL or STEP if any are interesting.

A “high CRI” white LED and an aspheric collector lens to roughly collimate the beam. I also made a little bayonet mount where I can fit field stops.

Two achromatic doublets (50 mm FL and 19 mm FL) to create a condenser with an approximate NA of .57 - This is hugely overkill for the objective I’m using but I plan to reuse this later since it appears to work well. In the future I think an Abbe style condenser would be a better and cheaper choice but it’s not easy to find large ball lenses like they tend to use. Anyway, using achromats here seems like overkill and I could definitely have gotten away with singlet lenses. There’s also a bayonet mount on the bottom of the condenser that I can mount aperture stops to. I haven’t tested that yet so all these images are with the condenser “wide open”

Just a (reasonably) flat surface that goes up and down. I’m using a bolt and captive nut to raise and lower it, and I built a simple double-paralellogram flexure to hold it in place. I also put some captive nuts in the stage that hold screws to adjust a platform above the stage, if I need a really flat field. This only sort of worked and probably isn’t worth the trouble.

Objective: I tested a used Olympus 10X Plan achromat from Ebay. These have field numbers of 22 with their native tube lens focal length (180 mm) and are pretty easy to find used for cheap. I use similar objectives on commerical scopes and the quality is fine for a low-power objective. Most importantly, the field is quite flat across the whole field of view.

Tube lens configurations:

  • One lens (2 elements) 75 mm achromatic doublet. This produces an image circle of 22*(75/180) = 9.1 mm which more than covers both camera sensors here.
  • Two lenses (5 elements, 64 mm FL) Raynox DCR-150 macro-converter lens combined with the above 75mm achromatic doublet as a focal reducer: The Raynox lens is a relatively inexpensive 3 element lens (60-70 USD new) that is very popular as a tube lens with photographers who strap microscope objectives to their DSLRs. It has a focal length of 208mm so it’s pretty close to most “native” microscope tube lenses, but using it alone would produce a hilariously tiny field of view with the raspberry pi cameras. I placed the Raynox next to the objective and then spaced the doublet at a distance calculated to get a combined focal length of 64.5 mm. This produces an image circle of 7.88mm which covers both v2 and HQ camera sensors.


  • Raspberry Pi HQ Camera Module (C/CS mount)
  • Raspberry Pi Camera module v2.1: I created a small case for this camera that has a C-mount thread and sensor spacing, that way I could just swap it out for the HQ camera 1:1. I also glued the camera down to the camera board since it had a peice of flexible foam backing on it that was causing sensor tilt. I would not do it this way again, instead I would just redesign the case to compress the foam down the same way the OFM does.

Test Slides:

  • Target reticle
  • NPM1 mutant AML blood smear
  • Appendix with a pinworm

Because I was using the HQ camera, I didn’t use the OFM software and couldn’t leverage its automatic exposure, white balance, and flat fielding. I used RaspiCam, which worked quite well otherwise.

Raspberry Pi Camera v2 with two-lens tube lens (I manually flat-fielded these images with varying degrees of success)

Raspberry Pi HQ camera with two-lens tube lens (no postprocessing)

Raspberry Pi HQ camera with 75 mm achromatic doublet tube lens (no postprocessing)


  1. The Thor labs achromatic doublets don’t seem to have flat fields and the lens I used produced a pretty noticable field curvature when used alone. I think this is actual field curvature and not a tilted slide based on focusing up and down and seeing a pronouced circumferential difference in focus. It’s probably not an aberration, per se, since I could focus the edges of the image nicely, just not the center and the edges at the same time. I guess this is expected as these lenses aren’t really meant for imaging. Interestingly, when combined with the Raynox (which is intended for photography) the issue was not really noticable. I think this is due to the distance between the achromatic doublet and the detector. Longer distance = more noticeable curvature.

    • In the combined 208mm/75mm system where the doublet mostly works like a focal reducer, the back focal length from the achromatic doublet to the detector is relatively short (about 30 mm) and the field curvature is minor.
    • the back focal length is more than double the distance (~70 mm) when the achromatic doublet is used by itself, and the field curvature is more perceptible.
    • If this is true then I expect that in the standard OFM high resolution optics with finite conjugate objectives (I think BFL 45-50 mm?), the effect of the added field curvature might be somewhere in between these extremes. I also wonder if this issue Support for HQ Pi camera - #7 by Ryan is actually a field curvature problem, rather than coma aberration
  2. The HQ cam is a very substantial increase in quality. The issue isn’t the detector size, resolution, or the mounting hardware (which is nice to have), but the CRA mismatch between the bayer filter/microlens array designed for webcam/cellphone lenses and the lenses used in microscopy really compromises the quality achievable from the standard camera. Some of this can be post-processed out, but the images I took today were saturated in one or more channels in part of the image, which makes correction not worth it.

  3. As for the condenser, it looks good but with such a low-NA objective it’s hard to tell if it’s actually doing a good job. Once I get a higher NA objective to test it with, we’ll see how it performs.

The OFM software is really doing a tremendous job improving the camera’s output as I found it nearly impossible to work with the unprocessed output from the standard raspberry pi camera. That said, the photos from the HQ camera looked really good without post processing beyond a simple white balance.


As you say, the filter/microlens array of the PiCamera 2 gives problems that are hard to correct completely (discussed in other threads about colour saturation) the High-Q camera does not have that issue and so should be a lot better. Unfortunately until now the Pi Camera V2 has been the only one that could be integrated into the software to give the live illumination and flat field correction and fast autofocus, which are necessary for scanning and tiling. The upcoming Openflexure server V3 should allow us to use the other Pi cameras.

For the tube lenses, I would have expected the Thorlabs achromats to be best when operated in their design configuration with the image at the focal distance from the lens - which you get with an infinity corrected objective. But that is moving in the opposite direction from your observation - a larger distance of 75mm for your lens.

Very nice work and thanks for sharing. This explains the reason of the out of focus areas in all of my builds. I noticed the same artifact mostly in the upper left corner of the field. I was under the impression that could be a problem with an uneven stage due to a problem with my printer, or something with the doublet lens position inside the tube. However, neither tilting the slide, sanding the stage, nor repositioning the lens improved the image.

In my digital photography classes I learned that optical magnification is always superior to digital magnification. But the former is way more expensive than the latter. Adding $70 USD is a significant amount when you look at the total cost of the current microscope. Could this image aberration be programmatically fixed? Can z stacking be used to obtain a sharper image? If money was not an issue, what would it take to build the OFM optics “Rolls Royce” ?

Also, why is the first image showing at higher magnification?

Once again, thanks for sharing this amazing work.

I guess the “rolls Royce” of optics would be a purpose-built microscope tube lens like the Thor labs ttl200, but they are real expensive (much more than the raynox). You can also use any “long” camera lens like a telephoto lens. I’m not suggesting any of this would be appropriate for the OFM since these optics are big and chunky too.

Field curvature is definitely something that can be compensated for by focus stacking. It’s actually an ideal use-case for it! You mentioned that you’ve experienced this; are you using infinite conjugate objectives? I am curious if the current tube lenses works better with finite conjugate objectives.

As to your question about magnification, the first set of 3 images use the Raspberry Pi v2 Camera, which has a smaller sensor than the HQ camera. The smaller sensor produces larger apparent magnification (crop factor).

I bought a beat up Olympus 40x Plan N 0.65 NA on eBay and the results are really nice with this setup.

1 Like

Just wanted to chime in here to say that people in the macro photography world swear by the raynox DCR 150. Not sure the 200mm focal length is what you want for a rpi camera though.

1 Like

These last images look amazing!. No out of focus areas and the colors are perfect. Please tell me your secret!
I am use finite conjugate objectives: 160/0.17
1) Parco Scientific 58A-0445 20X and 40x Semi-Plan Achromatic DIN Objective Lens

2) AmScope A20X 20X Achromatic Microscope Objective

3) # 185 Objective Lens 60X



Well, the colors looking better has nothing to do with the optics; that’s down to the camera sensor and its bayer filter/microlens array. Using the HQ camera alleviates this but it’s not compatible with the OFM software yet.

As for the focus, I’m not 100% sure what the source is - but it could be the objectives themselves. Your 20X doesn’t purport to be a plan objective which could account for the very soft edges.

Your 40x has less severe softness but it’s still noticeable. It’s supposed to be a semi-plan objective which means that 80% of the field of view is supposed to be in focus at the same time. This doesn’t look like it’s performing as designed but where the issue is isn’t clear to me.

The softness is worse to one side (you say it’s consistently the left) which does suggest either sensor tilt, objective tilt, or another other misalignment somewhere between objective and sensor. I had a similar problem before and the problem was that the objective was not seated exactly straight on it’s mount.

I’m not sure what the best way to ensure alignment is, but one way I spotted the issue was removing the camera from the optics module and pointing the objective directly at a bright, small light source like a surface mount LED. I put a peice of paper on the back of the optics module so I could see the projected image when the room lights were dimmed. This showed me that despite centering the LED relative to the objective the image was not centered where the sensor should be. That clued me in that the objective was misaligned.


I will check like you suggested and get back. I have plenty to try


I just discovered the openflexure forum, it’s a great resource.

May I ask if you have tried imaging at low light, to get an idea for pixel-to-pixel heterogeneity, “hot pixels” etc? I wonder if these artefacts, if present, can be handled by libcamera which Raspi comes with. My application is 3D real-time tracking of microparticles, with each particle image occupying 10-20 pixels. I’ve done it with high-end cameras, NA1.40+ objectives and nano-stages on “proper” microscopes, and I wonder if the setup can be miniaturized w/o losing too much performance.

In terms of stage Z adjustment etc: for a limited budget one can find used spring-loaded translation stages on ebay (Standa, Thorlans, Newport etc). Also, ebay has “aliexpress-grade” stages which cost 5x+ less than Thorlabs ones. I ordered a few and I used them for laser alignment; they seemed OK, but I haven’t characterized drift systematically. Rack-and-pinion stages are very drifty.

In term of alignment, I used a reasonably stable laser and the two-pinhole “alignment” tool from Thorlabs. Lens tubes from Thorlabs were OK, to make sure the obj and the tube lens were “mostly OK”.

My application is transmitted light for which those issues wouldn’t crop up. You might want to check out people disussing the pi cameras for astrophotography as they have detailed knowledge of how the processing affects low light and long exposure captures. I know they disable some of the dead pixel correction as it interferes with some captures.

These aren’t high sensitivity monochrome cameras though. I don’t know how the Bayer filter affects resolution especially with regard to repeatability of a stage

1 Like

I tested a new Plan 40x/0.65 objective. It looks better and the out of focus area on the left is less evident but still there. Besides the color problems, it looks overall better, sharper, and more magnified .

If you acquire a Z-stack, does that area on the left eventually come into focus?

Yes, between 50-100 steps will make it in focus compared to >500 using the S-Plan objective

It is really interesting to see in this and other threads people really looking into the detail of the performance of their microscopes. The overall system works well enough that the optical quality of different objective lenses becomes apparent.
With the motorized focus and scanning the microscope has access to all of the information that is necessary to characterise its own performance. A self-check routine is a goal of current developments of the software. I don’t think that evaluation of field curvature is planned initially, but it should be possible to quantify field curvature and tilt, and even identify the presence of aberration at the edges that is not just a different focus but blurring at any focus.

This thread also brings up the quality of the tube lens as a weak point when using the best objectives. Working out the best price/performance for doing something about that is a substantial investigation.

Absolutely. I think I might explore C-mount photo/video lenses with 50-60mm focal lengths eventually - they might work well, are often inexpensive, and would be a lot more compact than my current system

I wouldn’t discourage this type of exercise. In fact, I learned a lot by exploring how different objectives affect the quality of the image. I realized that I was mistakenly using a semi-plan when I should have been using a plan objective.

I was not intending to discourage it at all. It is very useful to understand all the things that affect overall performance and I have learnt a lot from what you and others are doing.