User avatar
jbeale
Posts: 3360
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

setting lens focus

Sun Jun 09, 2013 4:39 pm

Interested to compare notes with anyone else who is adjusting lens focus. Before turning the lens I put two white dots, one on lens and one on lens housing, so I could see the rotation angle. Hold lens cell with one set of thin pliers, turn lens with another set. What I find is:

Code: Select all

angle that lens is unscrewed : focal distance
0 degrees: focus at infinity (initial, stock position)
45 degrees: focus at 32 cm
90 degrees: focus at 15 cm
170 degrees: focus at 7 cm
I suspect this is true: to achieve a focal length of "FL", turn the lens CCW by this amount:

Code: Select all

turns = 3.5 cm / FL
For example, if you want FL = 10 cm, unscrew 3.5/10 = 0.35 turns = 126 degrees.
Note: after about one full turn, the lens will be completely unscrewed and fall out, and dust will start accumulating inside the lens housing on the IR filter surface, etc.
Last edited by jbeale on Mon Jun 10, 2013 6:38 am, edited 3 times in total.

dan3008
Posts: 1172
Joined: Wed Aug 15, 2012 1:05 pm

Re: setting lens focus

Sun Jun 09, 2013 6:22 pm

Wow, did it really make that much diffrence? I'm going to have to try this when my camera board arrives lol
dan3008 wrote:Pays your money, takes your choice

smx
Posts: 23
Joined: Sun May 26, 2013 8:59 pm

Re: setting lens focus

Sun Jun 09, 2013 6:56 pm

Hello jbeale,

when you change the focus, does it stop being sharp to infinity?

Cheers

User avatar
jbeale
Posts: 3360
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: setting lens focus

Sun Jun 09, 2013 9:11 pm

smx wrote:when you change the focus, does it stop being sharp to infinity?
The lens is focused at infinity from the factory. Any change you make will change that focus, and it will no longer focus at infinity. The closer you focus it, the more blurry distant objects will be, just like any other camera. There is actually a calculator to tell you exactly what range of things will be "in focus" (for your definition of "acceptably blurry"). Let's say you want to focus at 15 cm, and you'll call it "in focus" with no more than 3 pixels of blur. You also need to know this: R-Pi camera has 1.4 micron wide pixels, f = 3.6 mm and f-stop = 2.9 mm. 3 pixels * 1.4 um = 0.0042 m "Circle of Confusion". Type those numbers into this depth of field calculator.
You will find Near Focus: 13.19cm Far Focus: 17.39cm Depth of Field: 4.21cm

As a specific example, here is an example where I focused the camera at 15 cm. The ruler shows that the horizontal field of view at this distance is also about 15 cm, and items on the far wall (which is about 2 meters away) are blurry.
Image

towolf
Posts: 421
Joined: Fri Jan 18, 2013 2:11 pm

Re: setting lens focus

Sun Jun 09, 2013 10:24 pm

I’m not sure I can answer your question (I made no markings and it is dark now, can’t set infinity properly) but for me the lens slips out of the thread and starts to fall out of the housing when focus is at 4-5cm. That means without further tinkering you can’t use the thread as a focussing helicoid to get closer than about 4cm.

EDIT: actually, make that 3cm.

User avatar
rkinch
Posts: 72
Joined: Sun Jun 02, 2013 7:19 am
Location: Palm Beach County, Florida USA
Contact: Website

Re: setting lens focus

Mon Jun 10, 2013 5:40 am

Since this simple thread fit is not purposed for precision focus adjustment, some understanding and improvisation is needed to make it work well as such.

I measure the stock lens as having a metric thread, namely M6x0.35. So a fraction of a turn is only a few tenths of a mm at most. There is a lot of "allowance" in these threads relative to tenths of a mm, so you need either some preload force against the lens into the rearward direction of the threads, or some gap filler like PTFE tape. Otherwise the lens will rattle back and forth and throw off your focus adjustment.

("Allowance" in threads is the term for the positive gap between the largest allowed male thread and smallest allowed female thread, in the range of sizes permitted for a given thread standard, so that threads do not interfere.) For M6x0.35, the smallest pitch diameter (female) is 5.793mm versus largest (male) at 5.753mm, so there is at least the difference (0.04mm) in "slop" in a thread fit, and typically much more. This amounts to at least 1/10 turn (typically more) in this thread. These are tiny amounts of looseness but they will affect the focus in cameras and lenses this tiny.

User avatar
jbeale
Posts: 3360
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: setting lens focus

Mon Jun 10, 2013 6:43 am

My lens seems absolutely tight without any slop, but that may be because I did not remove the three blobs of glue around the edge which (I assume) are supposed to keep it from moving after adjustment to infinity focus at the factory. It does turn anyway using my two-plier technique. On the other hand, I'm not sure if I could detect 40 microns of motion.

User avatar
rkinch
Posts: 72
Joined: Sun Jun 02, 2013 7:19 am
Location: Palm Beach County, Florida USA
Contact: Website

Re: setting lens focus

Mon Jun 10, 2013 6:53 am

jbeale wrote:I'm not sure if I could detect 40 microns of motion.
That's a minimum. You'll see it go in and out of focus if you touch the lens. Elastomeric glue blobs might be acting as a preload spring.

towolf
Posts: 421
Joined: Fri Jan 18, 2013 2:11 pm

Re: setting lens focus

Mon Jun 10, 2013 2:28 pm

rkinch wrote:You'll see it go in and out of focus if you touch the lens.
That’s not my experience. It’s a pretty good fit. And the deep DOF works to our advantage.

I’ve found it easiest to pull focus using a rubber bung. Much easier than grabbing the lens using pliers every time. And no chance of scratching it.

Image

IBalic
Posts: 3
Joined: Thu Feb 06, 2014 8:20 pm

Re: setting lens focus

Tue Mar 11, 2014 1:13 pm

This is really cool. However, I don't know if it's just me, but I am not able to turn the lense around. Seems like it is too tight, and I don't want to destroy it. Anyone who would care to explain the procedure a little more in detail?

User avatar
RaTTuS
Posts: 10061
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: setting lens focus

Tue Mar 11, 2014 1:39 pm

it's gled with a blob of glue - you can *fix* this by
either
1) using an eraser to unscrew
or
2) a small pair of pliers
or
3) any other way of brute force that comes to mind ....

I had success with all three...
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

IBalic
Posts: 3
Joined: Thu Feb 06, 2014 8:20 pm

Re: setting lens focus

Tue Mar 11, 2014 1:44 pm

RaTTuS wrote:it's gled with a blob of glue - you can *fix* this by
either
1) using an eraser to unscrew
or
2) a small pair of pliers
or
3) any other way of brute force that comes to mind ....

I had success with all three...
Thanks!

thegnnu
Posts: 157
Joined: Thu Oct 18, 2012 7:07 pm
Location: Bristol

Re: setting lens focus

Tue Mar 11, 2014 7:35 pm

I can say the camera is sharp I just moved the lens anti-clockwise until the subject came into focus
If you want proof I made this timelapse last week
Close Up 3 Day Orchid

Close Up 3 Day Orchid
http://vimeo.com/user10370362/previe...

this may be a better link
it is now in vimeo channels raspi
https://vimeo.com/channels/raspi/88431356
thegnnu

About this video
"I have adjusted the Raspberry Pi Camera lens to give close up approx 100mm focal point. The Orchid filmed over 3 days, frames taken every 30 seconds. A jump in the size after first day is due to the orchid opening during darkness hours."

src123
Posts: 9
Joined: Wed Mar 19, 2014 11:07 am

Re: setting lens focus

Mon Sep 22, 2014 11:41 am

may any body please help me with how to scrape away the epoxy and loosen the thread?? I am having a lot of trouble with this and have already damaged one of my camera module.. :(

User avatar
RaTTuS
Posts: 10061
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: setting lens focus

Mon Sep 22, 2014 2:24 pm

src123 wrote:may any body please help me with how to scrape away the epoxy and loosen the thread?? I am having a lot of trouble with this and have already damaged one of my camera module.. :(
http://www.raspberrypi.org/forums/viewt ... 37#p518476
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

MrMitch
Posts: 2
Joined: Sat Jan 26, 2013 12:38 pm

Re: setting lens focus

Mon Sep 22, 2014 6:15 pm

Focusing the lens closer than Infinity can increase the Depth of Focus.

If any lens is set to Focus at its Hyperfocal Distance then everything from Infinity to Half of the Hyperfocal Distance will be in focus.

Have Fun

Jon Mitchell

( Professional Focus Puller, amateur Pi tinkerer )

src123
Posts: 9
Joined: Wed Mar 19, 2014 11:07 am

Re: setting lens focus

Tue Sep 23, 2014 6:31 am

RaTTuS wrote:
src123 wrote:may any body please help me with how to scrape away the epoxy and loosen the thread?? I am having a lot of trouble with this and have already damaged one of my camera module.. :(
http://www.raspberrypi.org/forums/viewt ... 37#p518476
thanks alot... eraser worked :)

User avatar
ab1jx
Posts: 660
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: setting lens focus

Tue Oct 10, 2017 10:23 pm

MrMitch wrote:
Mon Sep 22, 2014 6:15 pm
Focusing the lens closer than Infinity can increase the Depth of Focus.

If any lens is set to Focus at its Hyperfocal Distance then everything from Infinity to Half of the Hyperfocal Distance will be in focus.
It's called depth of field, not focus. The hyperfocal distance is a good thing https://en.wikipedia.org/wiki/Hyperfocal_distance with some caveats.

I have this Hyperfocal Pro app on my phone:
hyperfocal_pro.jpg
hyperfocal_pro.jpg (41.53 KiB) Viewed 15226 times
The effect depends on the f stop (aperture opening) and the focal length of the lens. Both of which are unknown in this case. A good approximation is probably to focus on the closest end of the range you want to cover. That's what many auto-focus setups do. If you know the f stop and focal length you can calculate a hyperfocal distance which will put everything from a certain distance to infinity in focus. You set up something at that distance, focus on that, and you're all set. The lens focal length is probably fixed in this case but the f stop may vary since an aperture could be done with an LCD darkening in a ring pattern.

Something else worth playing with if you tinker in a machine shop is to take the lens entirely off the camera and mount the camera behind a lens from a 35 mm (or larger) film camera. The ratio between the size of the sensor in the Pi's camera and the size of 35 mm film will give a telephoto effect, with the ratio determining the magnification. The sensor is probably about 5 mm so a 50 mm lens that's "normal" on a 35 mm camera will be like zooming in 7 times to a 350mm lens. I've done that a little with a webcam 20 years or so ago. A zoom (adjustable focal length) lens for a 35 mm camera would be even more interesting. Yes, with work you could even do astrophotography directly into your computer. Used lenses are perfectly acceptable and only diehard nuts use film anymore, so pick something up at a tag or garage sale. Try photocopier lenses too. If you're going to a significant amount of work figure on keeping at least most stray light out while you're at it.

User avatar
ab1jx
Posts: 660
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: setting lens focus

Wed Oct 11, 2017 2:03 pm

jbeale wrote:
Sun Jun 09, 2013 4:39 pm
For example, if you want FL = 10 cm, unscrew 3.5/10 = 0.35 turns = 126 degrees.
Note: after about one full turn, the lens will be completely unscrewed and fall out, and dust will start accumulating inside the lens housing on the IR filter surface, etc.
I think you'll find it's very non-linear. If you attach something round to the lens, figure the circumference of that, make a label that size and mark it off into degrees. Record some focus distances in feet and degrees and plot them with something like Gnuplot. Or just look at the distance markings on the focus ring of an SLR lens. You'll see something like 1-1.5-3-5-10-30-infinity. I don't know enough about optical physics to say what function that is. Also longer focal length lenses have longer distances, like you might jump from 100 feet to infinity. Focusing a camera with a short focal length lens is tricky There ceases to be much difference in focus at different degree positions.

Horsepower
Posts: 1
Joined: Sat Oct 21, 2017 11:41 am

Re: setting lens focus

Mon Oct 23, 2017 5:37 am

Hello,

You thread is very informative. Could you please tell me exactly which Camera Module (the adjustable focal length type) have you used.

Thanks in advance.

-Kamran

User avatar
ab1jx
Posts: 660
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: setting lens focus

Mon Oct 23, 2017 12:02 pm

Horsepower wrote:
Mon Oct 23, 2017 5:37 am
Hello,

You thread is very informative. Could you please tell me exactly which Camera Module (the adjustable focal length type) have you used.

Thanks in advance.

-Kamran
Who?

I just have a 1.3 camera https://www.gearbest.com/raspberry-pi/pp_692849.html which I'm not sure wasn't in a bad batch or something. I'm not totally happy with it but I may be expecting too much. Gearbest seems to have 2 different ones, they also have https://www.gearbest.com/raspberry-pi/pp_612249.html. I bought the cheaper one. Shipping isn't fast, especially if you pick the free option. Figure a couple weeks at least. OK company though, I've bought from them several times. They also have an aluminum case for the Pi.

Focus wrench https://www.shapeways.com/product/X8W5F ... ench-steel

I think the focus adjustment was only meant for initial calibration then a drop of something similar to nail polish was put on to keep it from turning. Once you break it loose vibration will keep moving it around. A drop of something non-permanent like rubber cement or Loktite would probably be good. It's a plastic thread in a plastic housing, not meant for frequent use.

I think the version 2 camera can be adjusted because the wrench page says: "The Raspbery Pi Cam V2 seems to have some issues with the focus."

User avatar
ab1jx
Posts: 660
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: setting lens focus

Thu Nov 09, 2017 4:29 pm

Not to provide competition to the Raspberry Pi foundation or anything but I ran across this Waveshare zooming camera. In concept it's like you have an SLR with a prime (fixed focus) lens and you swap to a zoom lens. http://www.dx.com/p/waveshare-zooming-c ... gRy20Jo-V4 or what seems like the manufacturer's site https://www.waveshare.com/rpi-camera-f.htm Because of the Chinese-English language it's not clear to me exactly what this includes.

By zoom I mean not adjustable focus but changing from wide angle to telephoto. I'd really like to have 1 or a few remote cameras which were weatherproof and could pan, zoom and focus controlled over WiFi. Where I live there are many wildlife photo opportunities on a practically daily basis. But zooming and panning are mechanical processes so that means motors. I guess if people are doing robotics this isn't infeasible.

This is a Nikon zoom I picked up used for $50 (not particularly good glass), it goes from 70-300 mm focal length. And I just realized I have most of what's needed to adapt it to a Pi camera, hadn't thought about it. I got it for my D5200 DSLR.
DSCN8252_lev_cur_shp_800.jpg
DSCN8252_lev_cur_shp_800.jpg (93.25 KiB) Viewed 13605 times

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5557
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: setting lens focus

Thu Nov 09, 2017 5:13 pm

The Waveshare is nothing special - there are many clones that add an M12 mount and therefore allow you to change the lens. And those lights are a pest as the 3V3 rail up to the camera isn't designed to support that sort of current!

Tempting to try your lens with https://www.ebay.co.uk/itm/C-mount-body ... 3268619651, on https://www.ebay.co.uk/itm/5-Pcs-Black- ... 1812892302, on http://www.ebay.co.uk/itm/5MP-OV5647-Se ... 1089063199 (with the M12 lens mount removed) :D
(I'm guessing that your Nikon lens is F mount - there are a couple of options it seems for Nikon. And I have absolutely no idea whether the focal planes will sit sensibly. As the lens adapter says it is C, whilst the camera board adapter says CS, you may be too close by 5mm and so very near-sighted).
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
ab1jx
Posts: 660
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: setting lens focus

Thu Nov 09, 2017 5:59 pm

I wasn't thinking of investing in anything like that. I have a cheap set of macro rings/barrels that aren't very useful as-is. With the F mount there's an aperture mechanism that isn't supported by the cheap set, so the aperture is permanently all the way closed. Not bad if you're looking for depth of field but it takes a lot of light.

I'm new to Nikon DSLRs, I used to have 35mm Yashicas with Pentax screw mounts and there was a spring-loaded pin sticking out of the lens. That hit on a lever in the camera which the camera moved to control to aperture. Not sure how this works just yet.

I was thinking more like a way to mount the lens to something and the camera to the other side. I haven't even tried just holding the zoom up to the camera yet. My focus hasn't been broken loose yet. And I only have the original short flex cable connecting to a Pi. In principle I suppose I could turn it into an astronomical telescope, but then I get into needing az-el mounts for it and all that. And motor drive to counteract the earth's rotation. I have a few used stepper motors around but that sounds too ambitious and I have other projects in worse need of tending to.

The appeal is that it could be outdoors looking at a winter night sky and I could be indoors running it remotely.

User avatar
ab1jx
Posts: 660
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: setting lens focus

Fri Nov 10, 2017 1:51 am

Well, that was quick to figure out, when you slide the lever I circled to the right the aperture opens.
DSCN8264_cr_lev_circ_800.jpg
DSCN8264_cr_lev_circ_800.jpg (106.09 KiB) Viewed 13525 times
So I just need some non-destructive way to hold it over, like a piece of plastic jammed in the slot. I think I'll try a little piece cut from a milk jug.

When you take a lens made to use with a film or sensor area like 35 mm and use it with a small camera, like this has 1/4 inch sensor, it becomes a telephoto. The ratio of the sensor areas gives the magnification. So that's upping it by about a factor of 6. That would be if I mounted a 50mm lens, this is 70 - 300 so it should approach an equivalent 1800 mm or 36 power magnification. That could make a telescope of sorts. If I take my macro barrel set apart there's a place to put in some 2-56 or 4-40 machine screws and mount it to a flat surface Just mount the Pi camera to the other side with a couple screws. Not sure how the distances work out until I try it.

People also use spotting scopes meant for rifles with digital cameras mounted to them, I don't have one of those. Oops, no spotting scopes for use with serious astronomical telescopes. Called digiscoping or something like that.

Oh, and see viewtopic.php?f=43&t=46637&p=1240661#p1240661
Last edited by ab1jx on Thu Nov 30, 2017 4:24 am, edited 2 times in total.

Return to “Camera board”

Who is online

Users browsing this forum: No registered users and 8 guests