Many modern SLR lens systems (maybe most) return the focus adjustment data to the camera.
Potentially the accuracy of the data returned could be high – something better than 1% of the range would be possible and meaningful with modern systems.
However, it seems that most if not all systems use a simple gray coded system * with perhaps 16 steps. The number of steps varies by manufacturer and even with the lens model.
A Gray code is a binary code (generally but not essentially) in which a single bit changes with each change of position. This means that if the position swings back and forth to the limit, erroneous codes cannot be sent. In a normal binary code, where 2 or more bits can change at a time, if one changing bit changes before another due to mechanical tolerances or contact bounces, completely erroneous codes may be sent in error.
Standard binary code
At 3 to 4 limits, 3 bits change at the same time. If any of these things happen sooner or later, many illegal codes could result
From my head Gray-code
I have NOT deliberately followed what may be the most logical sequence.
What is important is that at each step only 1 position changes state – erroneous codes cannot be caused by bounce or tolerance errors:
Some brand-specific samples – plus anon:
State here that the Cannon EF 50mm f / 1.4 USM only uses a 2-bit code = 4 positions. – interesting discussion with some relevance.
Minolta / Sony A mounting system the objectives i have inspected use a simple mechanical distance coder coded in gray with a precision of 4 bits / 16 positions.
Nikon: Here's a nice Nikon discussion with gray coding information at 16 specific levels for a lens, more circuits and lots of related hardware.
Modification of TC16A teleconvector – with a lot of related material – excellent.
Gray codes for an example goal:
Here, a 4-digit code is returned with 1 = open circuit and 0 = short-circuited to ground contact.
0001 75 mm (approx.)
0011 81 mm (approx.)
0010 85 mm (approx.)
0110 94 mm (approx.)
0111 101 mm (approx.)
0101 109 mm (approx.)
0100 117 mm (approx.)
1100 126 mm (approx.)
1101135 mm (approx.)
1010 169 mm (approx.)
1011181 mm (approx.)
1001 195 mm (approx.)
Adding gray code sensors to the manual Nikon lenses to allow operation with more modern bodies.
He discusses adding coding for the fcal length and focus position.
The electric accordion – its main purpose is to "deceive" the deliberately crippled low-end bodies, but the principles apply.
Example of a rotating gray code template. It is for coding in gray a button or a dial but the rotation of the focusing of the lens uses the same style of pattern. There are many different gray codes.
Excellent discussion in gray code with a specific reference to len focusing.
Position encoders and Gray code
From the above:
Nikon DIY 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 linked to the lens.