The question says it all -- does the camera "know" how far the subject is from the lens, i.e. what is the current exact focus distance set at the lens?


4 Answers 4


Many (possibly most) modern SLR lens systems return focus setting data to the camera.

It's useful to note that while the absolute focus position of the lens is reported to the camera, this information is not essential in determining that the lens is "in focus". Modern focusing systems usually use either phase or contrast detection in the camera proper with mirrorless cameras using focus sensors in the main optical sensor. The lens physical focus-system position will usually be useful in determining how best to drive the lens to a desired focus point but are not used in the actual "in focus" decision.

Potentially the precision of data returned could be high - something better than 1% of range would be possible and meaningful with modern systems.

However, it appears that most if not all systems use a simple gray-coded* system with perhaps 16 steps. Number of steps varies with manufacturer and even with lens model.

A Gray code is a (usually but not essentially) binary code in which only one bit changes at each position change. This means that if the position oscillates to and fro at the boundary that erroneous codes cannot be sent. In a normal binary code, where 2 or more bits may change at once, if one changing bit alters before another due to mechanical tolerances or contact bounce then completely erroneous codes may be sent in error.

Std binary code At the 3 to 4 boundary 3 bits change at once. If any of these were early or late in occurring many illegal codes could result

0 0000
1 0001
2 0010
3 0011
4 0100

Out of my head Gray-code I have purposefully NOT followed what may be a most logical sequence.
What is important is that at each step only 1 position changes state - erroneous codes can not be caused by bounce or tolerance errors:


A few brand specific samples - more anon:

Claim here that the Canon EF 50mm f/1.4 USM only uses a 2 bit = 4 position code. - interesting discussion with some relevance.

Minolta / Sony A mount system lenses that I have inspected use a simple grey-coded mechanical distance encoder with 4 bit / 16 position precision.

Nikon: Here is a nice Nikon discussion with specific 16 stage gray coding information for one lens, plus some circuitry and a lot of associated material.

TC16A teleconverter modification - with much related material - excellent.

Gray codes for an example lens:

Here a4 digit code is returned wit 1 = open circuit and 0 = contact shorted to ground. 0000 70mm
0001 75mm (Approx)
0011 81mm (Approx)
0010 85mm (Approx)
0110 94mm (Approx)
0111 101mm (Approx)
0101 109mm (Approx)
0100 117mm (Approx)
1100 126mm (Approx)
1101 135mm (Approx)
1111 145mm
1110 155mm
1010 169mm (Approx)
1011 181mm (Approx)
1001 195mm (Approx)
1000 210mm

Adding gray-coded sensors to manual Nikon lenses to allow operation with more modern bodies.
He discusses adding coding for focal length and focus position.
The Electric Accordion - his aim is mainly "fooling" purposefully crippled low end bodies but the principles apply.

Example rotary gray code pattern. This is to gray code a knob or dial but lens focus rotation uses the same style of pattern. There are numerous different possible gray codes.

enter image description here

Excellent gray-code discussion with specific reference to lens focusing.
Position encoders and the Gray code
From the above:

enter image description here


DIY Nikon lens protocol converter - upgrade old or incompatible lenses.](http://photo.net/nikon-camera-forum/00956N)

Canon gray-code patent February 2012 !!!](http://www.freepatentsonline.com/y2012/0032068.html) and PDF here - may or may not be lens related.

  • 1
    \$\begingroup\$ Surely the code is used to communicate focus adjustments, not to store absolute focus group positions - I'd be amazed if a lens could only focus to 16 predetermined depths (I know the 50 f/1.4 can focus to more than 4!) Also the Nikon code you posted looks like the focal length sensor code (for a 70-200mm lens), focal length reporting is definitely less accurate so I'd be willing to believe 16 values are enough. \$\endgroup\$
    – Matt Grum
    Commented Mar 26, 2012 at 11:02
  • \$\begingroup\$ @MattGrum - My understanding is that focusing adjustment can be achieved without any position feedback from the lens - it is entirely an optical effect achieved with sensors in the body. My understanding is that the encoders return rough versions of absolute focus distance as an aid to systems which need to "know" subject distance. One such is the Flash system. Illuminating correctly based on the location that the user is focusing on is liable to be a good choice in most cases :-) - but not all, of course. An encoder I have has absolute focus rotation angle sensor with 4 bits/16 steps. \$\endgroup\$ Commented Mar 26, 2012 at 13:33
  • \$\begingroup\$ Thanks, that makes sense now. Lots of great info in your answer, by the way! \$\endgroup\$
    – Matt Grum
    Commented Mar 26, 2012 at 14:00

Yes for most camera systems:

  • For Canon EOS, select EF and EF-S lenses transmit distance information through the EF mount.
  • For Nikon, D- and G-type Nikkor lenses transmit distance information through the F mount; this is what the D designation means. G lenses are the same, only without an aperture ring.
  • For Sony, all current lenses transmit distance information through the A mount; this information, among other things, is used in flash exposure calculation (Advanced Distance Integration - ADI).
  • For Pentax, F, FA, D FA, and DA lenses transmit distance information through the KAF mount.
  • I'm not sure about legacy Four Thirds, but Micro Four Thirds lenses do transmit focus distance information to the camera. Some Olympus OM-D cameras (E-M1X, E-M1 Mark II and Mark III, E-M5 Mark III) even have a focus limiter feature that uses this distance information. This is like the focus limiter switch on some telephoto and macro lenses, only that it is controlled by the camera body and not the lens and allows an arbitrary range of distances to be selected.
  • \$\begingroup\$ Only some EF/EF-S lenses transmit distance information according to Canon lens spec sheet. \$\endgroup\$
    – Imre
    Commented Mar 25, 2012 at 23:18

This depends on both the camera and lens, both must support communication of such information.

Nikon introduced the feature with their "D" lenses (later "G" lenses can do it as well). According to Nikon's glossary, the following bodies can use that information: F6, F5, F100, F90X, F80, F75, F70, F65, F60, F55, F50, PRONEA S, PRONEA 600i, D2 series, D1 series, D100 and D70s/D70. I suspect this list is outdated and should include more recent models.

Canon E-TTL II capable bodies and some EF lenses also communicate focusing distance; there is no indication of this feature in lens model name.

All Pentax auto-focus lenses and SLRs since early 1990s can communicate distance information, according to Roland Mabo.

  • \$\begingroup\$ Do you know with what precision the distance is communicated? Pentax DSLRs seem to include metadata for close, middle, or distant focus — with no indication what that means exactly. \$\endgroup\$
    – mattdm
    Commented Mar 25, 2012 at 22:39
  • \$\begingroup\$ @mattdm No, but I guess that shows which end the focusing scale is close to; and for intended purpose (fine-tuning matrix metering) that precision should be enough. \$\endgroup\$
    – Imre
    Commented Mar 25, 2012 at 23:10

Here are a few of Nikon NEF EXIF excerpts:

Make                            : NIKON CORPORATION
Camera Model Name               : NIKON D7200
Focus Distance                  : 29.85 m
Subject Distance Range          : Unknown
Hyperfocal Distance             : 499.23 m

Make                            : NIKON CORPORATION
Camera Model Name               : NIKON D7200
Focus Distance                  : 3.35 m
Subject Distance Range          : Unknown
Hyperfocal Distance             : 18.76 m

Make                            : NIKON CORPORATION
Camera Model Name               : NIKON D80
Focus Distance                  : 3.16 m
Subject Distance Range          : Unknown
Hyperfocal Distance             : 2.02 m

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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