I found this article on hacking macro lenses. The author used a lens extension tube to allow closer focusing. IE The lens's Minimum Object Distance (MOD) was significantly reduced.

I cannot find an affordable lens that suits my requirements, so I would also like to extend or shorten an existing lens to achieve my goals. Basically I am trying to hack a close-focus machine vision industrial camera from an S-Mount Raspberry Pi camera. The problem I'm running into is that compatible lenses have too high MODs. Given the constraints below, how do I solve the variables?

The Constants:

  • Object Size: 4" x 5"
  • Object Distance: 4.5" (Object to Lens)
  • Camera Sensor: 0.25"
  • The Object should be in focus and snug to the edges of the captured image
  • Avoid fish-eye or wide angle lenses, if possible

The Variables:

  • Focal Length (Lens to principal focus)
  • Image Distance / Back Focal Length (Lens to sensor)

I found this article which discusses Optics and the Lens Equation. I could simply solve the lens equation as follows: 1/115 mm + 1/x = 1/6 mm. In this case, the image distance would be 6.3303 mm. Is it really that simple though?

I can use any standard lens (3 mm, 4 mm, 6 mm, 8 mm, etc). My concern is that extension rings result in image magnificaion which would cut-off the image. I could plug my numbers into the magnification equation. and then extend my object size to include a 20% buffer, for example. But making that adjustment changes the figures for the lens equation. The two equations are intrinsically linked and I'm not sure how to solve them inclusively.


I think you are misinterpreting what your variables are. The focal length is fixed for a given lens and cannot be changed. What you can change is the image to lens distance. Combined these will determine what point is in focus using the lens equation.

The data sheet for the camera you give, gives the focal distance as 6.68 mm.

plugging this into $$\frac{1}{u}+\frac{1}{v} = \frac{1}{f} $$ we get

$$\frac{1}{6.68} - \frac{1}{114.3} = \frac{1}{u} $$

$$ u = 7.1 mm $$

The problem is that this is not a simple thin lens, so the lens formula will not be exact, and you to not know what the current lens to image distance is, you might be able to get a rough estimate by finding where the image is currently in focus. In general, as the focus distance moves further away the image to lens distance will approach the focal plane.

Your best bet is probably a bit of trial and error you want to try and raise the lens by just under 1 mm from the image plane. I'm not sure how easy this is to do accurately and would probably just play with it until you get close to what you want.

  • $\begingroup$ I was considering focal length a variable because I'm not married to the default lens. S-Mount lenses are cheap and easy to swap out. I could solve the equation any old way. My major concern was in italics, I should have bolded it: "The Object should be in focus and snug to the edges of the captured image". Since extension rings result in image magnificaion, I expect that the image would become cut-off, which I don't want to do. $\endgroup$
    – skibulk
    Dec 4 '15 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.