Making 6-bit codes permanent.
For an index of all Leica-related articles click here.
What are 6-bit codes?
Modern digital cameras with removable lenses communicate with the lens through a set of electrical connectors in the lens and in the camera body. This ensures that EXIF data – focal length, aperture, etc. – are sent to the digital image file, making cataloging and retrieval a simple process. However, lenses for Leica digital M body cameras have no electrical connections between lens and camera. Leica wants to keep things compact so instead concocted an ingenious optical communication system between the lens and the camera. An arc of 6 optical readers resides in the camera’s lens mount between the 4 and 5 o’clock positions, viewed from the front with the lens removed, and these optical sensors are matched with machined pits in the rear mount of the lens when the lens is mounted. Those pits are either filled with black ink (indicating a ‘1’ to the sensor) or filled with white ink (or not filled, remaining bare metal) pits, indicating a ‘0’. With six sensors the number of combinations is 2 to the power of 6, or 64. Hence ‘6-bit’. (There are actually up to 192 combinations as the fine technician Yukosteel explains here). This system permits communication of the lens’s focal length and design (Summicron, Elmar, Noctilux, etc.) to the camera which adjusts the sensor’s response to minimize optical aberrations. Current Leica optics come with the coding pits milled. Older ones and lenses from non-Leica manufacturers do not. But they can be added. Every digital M Leica, from the M8 on, uses this optical lens recognition system.
Why code the lens with 6-bit information?
As I depend on 6-bit coding to record the focal length of the lens used in EXIF data (a frequently searched field given my modus operandi in Lightroom), such coding is important to me. Further, proper coding of the lens results in the best possible optical performance, particularly with wider lenses and those which are prone to vignetting. Simply placing the ink codes on the plain rear flange of the lens is not a permanent solution as the ink will eventually wear away owing to friction between the flange and the camera’s lens mount each time the lens is inserted or removed. Once the ink wears away the lens will not be correctly recognized. So the long term solution is to machine the code pits on the lens’s mount or, if you are using Leica Thread Mount lenses, using an adapter with machined pits. With ‘pitted’ lenses, or LTM lenses with this type of adapter, the ink is protected from frictional wear over time.
Should you do this?
This is not a low risk procedure. I suggest you think carefully if you want to take the risk and rehearse the steps in advance. I found that practicing with a spare LTM-to-M bayonet adapter, illustrated below, made a significant difference to my level of confidence when it came to actually machining two of my lenses.
6-bit code table:
The table for more recent Leica lenses is here. The codes read clockwise looking at the rear flange of the lens. A ‘1’ indicates a black ink filled pit. A ‘0’ means do nothing. The correct ink is that in the Uni-Ball pen. A Sharpie does not work.
By the way, note the question marks against both versions of the Elmarit-M 135/2.8 lenses in the code table. They are there because, at least on my M10, a lens coded ‘001001’ is not correctly recognized, refusing to invoke ‘Auto’ recognition. So if you are coding a 135mm focal length lens, I recommend you use the code for the APO-Telyt-M 135/3.4 (‘110101’) which I can confirm works correctly. For my 135mm f/4 Elmar, a tack sharp lens which can be found inexpensively on the used market, I do not code the lens with ink, simply leaving the camera’s manual code set for the APO-Telyt-M 135/3.4. Thus when this sole uncoded lens in my collection is inserted it will be reported as a 135/3.4.
Which lenses are candidates for milling/machining?
- Recent Leica lenses can be sent to Leica, along with a spare arm and leg, for machining by the factory, thus preserving resale value.
- The two Voigtländer lenses I own (21mm f/3.5 Color-Skopar Aspherical and 75mm f/1.9 Ultron) come with a machined groove on the rear flange which will happily accept your ink codes and ensures these will not wear off from friction. Maybe some smart person at Cosina saw this as a neat way of side-stepping Leica’s 6-bit code patents? It’s likely that many other Cosina Voigtländer lenses come with a like groove, making milling unnecessary.
- There is now a large number of Leica lens clones available from a variety of makers – Light Lens Lab, Mandler, Thypoch, 7Artisans, etc. – and most appear to come with plane rear flanges. It makes sense to machine these as resale value is likely unaffected, most are inexpensive in the first place, and their plane flanges make for an impermanent coding fix if the ink is simply applied to the un-machined flange.
- In my case my two most recent lens acquisitions, the 35mm and 50mm Summicron clones from Light Lens Lab, both came with plane rear flanges, suggesting machining is in order.
DIY:
I got a quote of $350 from a respected Leica technician to engrave the code pits on the LLL lens (which he said he would have to dismantle before milling the coding pits), so I decided to do it myself, no dismantling involved. I procured a 1/16″ (0.0625″) diameter flat bottom mill bit – this is the correct size – and set about cutting the requisite code pits myself. The correct pit depth is a scant 0.01″, just enough to avoid abrasion of the ink fill. It’s not critical – you want it deep enough to hold coding ink below the plane surface of the rear flange.
No need to mill pits for ‘0’ locations:
There’s no need to mill pits for ‘0’ locations and given that each cut is an exercise in intestinal fortitude, the fewer cuts the better.
Oblong or circular pits?
Do the pits have to be oblong, like on Leica lenses? No. This is good news as machining an oblong pit is obviously more work/higher risk than simply machining a circular one. But there is a right and a wrong way to place the ink dot which will be used as the machining location if only a circular pit is being cut. Some experimentation disclosed that, with my M10 body, if the ink is toward the inside of the flange, nearest to the glass in the lens, it will not correctly register the lens automatically. If, on the other hand, the ink is toward the outside edge of the flange, furthest from the glass, it works fine.
I suggest you check on your particular body before doing any machining by placing a single dot of ink (not an oblong), with the coding template in place, toward the outside end of the oblong cut-out in the template, let the ink dry and see if the lens is correctly recognized automatically. You do this by going to Main Menu->Lens Detection on the rear LCD display. You want the LCD to show the word ‘Auto’. See below. If it does not your ink needs to be relocated nearer to the glass. Do this ink dot placement process carefully and you will be assured of cutting the circular pit in the correct location.
Pit placement:
The placement of the ink/milled cut toward the outside rim of the lens’s flange is visually obvious if you take a look at the lens mount on the camera’s body. As is clearly visible in the image below, the sensors below the glass arc are placed well towards the outside of the flange. Examine those through a magnifying glass and you will observe that the sensors reside behind square – not oblong – openings. Quite why Leica decided on oblong pits on the lens’s mount is a mystery when circular ones work just as well. Possibly this is a sample variation/tolerance issue? Given the high level of precision in the machining of both the mount and the lens’s flange that seems unlikely to me, but whatever.

Placement of the 6-bit sensors is towards the outside of the lens mount.
The width of metal at the inner side (green arrow) is clearly greater than at the outer (red arrow)
In the following image I have conferred circular (best as can be done with a felt tip pen) – not oblong – ink markings on the lens’s rear flange using the coding template and coding ‘100001’ for the 50mm f/2 Summicron lens. The circular ink marks have been placed towards the outside rim of the lens.

Placement of the circular ink markings for machining.
These must be towards the outside rim of the lens’s flange.
Confirmation of correct placement before milling:
Thus marked the lens is mounted and the LCD confirms that ‘Auto’ lens recognition is functioning, the lens being recorded as a 50mm f/2. This setting is visible at the bottom of the LCD display when the central button in the directional keypad is depressed.

Auto lens recognition is functioning.
Tools needed:
- A drill press – I use an inexpensive bench top one. $104.
- The milling bit described above. $8.
- A 4″ X-Y vise. Don’t even think of undertaking this project without one. The vise permits extremely accurate placement of the lens’s flange under the milling bit. As with most Chinese tools this needed rework – dismantling, deburring, proper lubrication and rubbing things down with 600 grit sandpaper to make everything work smoothly. After this process it becomes a superb and inexpensive tool. Once the slides are locked in position prior to machining (two bolts) the whole assembly, made of heavy cast iron, is exceptionally stable and robust. $61 plus some sweat equity. I got free shipping on eBay.
- Soft jaws to grasp the lens in the vise without marring. $8.
- Some stout Scotch 3M packing tape to mask the rear of the lens, preventing any swarf entering the focus helicoid
- A flashlight to aid in aligning the lens under the milling bit.
- The 6-bit lens coding template. $8.
- A Uni-Ball pen for both preliminary marking and subsequent filling of the milled recesses.
- Isopropyl alcohol and Q Tips for wiping off excess ink after milling.
Total outlay? $190 and you will have a very handy drill press with a two axis vise when all is said and done. As the quote I received was for $700 for two lenses I can’t complain about the outlay for the DIY option.
Dry run:
I did several machining dry runs to get a feel for the milling cutter and for correct placement. I practiced on an old Leica LTM to M adapter. I found that placing the mill bit a thumbnail’s thickness from the edge of the flange was ideal – at first I milled too deep and too close to the edge leaving an ugly opening at the periphery of the flange.

Trial mill – too close to the edge and too deep.

Soft jaws at work. The red arrow points to one of the two X-Y motion locking 10mm bolts. I replaced the stock screws with bolts to allow easy locking of the vise when milling. All the screw threads on the vise are metric.
The order of events:
Here is the order of events after a trial run:
- Using the coding template place ink dots to the outside of the template slots according to the coding table. If your lens does not appear in the table experiment using manual settings in the camera noting and applying the code which delivers the best results.
- Apply a piece of Scotch tape to the rear lens mount and trim it with a sharp knife to prevent the tape interfering with the machining bit.
- Mount the lens in the X-Y vise using the soft jaws, with the front surface – I leave the protective UV filter in place – mating with one of the two slides. This ensures the lens’s rear mount is perpendicular to the milling bit.
- Align the milling bit with the first ink dot on the rear flange. This is the most time consuming part. I raise the drill press table to where it is maybe 1/2″ from the milling bit then, with the power off, lower the bit until it just contacts the lens’s rear mount. Noting the positional error use the X and Y axis handles to adjust the position until the bit is centered on the ink dot. Yes, there is backlash in the X/Y motion. This is after all a $61 mass manufactured tool, not a costly Bridgeport vise. With the bit in contact with the lens mount feel with a thumbnail that its edge is one thumbnail distant from the edge of the mount. This will result in the right offset for the pit from the edge of the lens.
- Now to get the position dead right insert the coding template on the rear lens mount and carefully lowering the milling bit confirm that it enters the cut-out in the template with no binding. This will make sure you have the bit exactly positioned, given that the ink dot is more of an irregular blob than a pinpoint with a poorly defined center (see the above step). Sweat this until it’s perfect. You only get one chance to get this right.
- Remove the coding template, turn the drill press on and machine the pit until you just see brass filings replacing the chrome ones, assuming your mount is chrome plated brass. If the mount is aluminum just machine enough that you can discern the pit. I use a medium speed setting on the drill press – high speeds are not required.
- Repeat for any additional pits required.
- Fill the machined pit(s) with black ink using the Uni-Ball pen, let the ink dry, then with a Q tip barely moistened with isopropyl alcohol, wipe across the ink filled pits to remove any ink overspill – it’s almost impossible to avoid overspill as the Uni-Ball’s tip is not fine enough.
- Insert the lens in the camera, turn the camera on and confirm that the correct lens is reported.
The above steps are illustrated below.

The Light Lens Lab 50mm f/2 S-P II lens in the soft jaws,
ready for milling. Note the Scotch 3M tape attached
to the rear of the lens, protecting the focus helicoid.

Final positioning check using the 6-bit coding template.
You want the milling bit to enter and exit the appropriate openings
in the template without interfering with, or lifting,
the template from the lens. You also want to check
that the milling bit is entering the template toward
the outside of the slot in the template – see above.
Once you are happy with the alignment lock both the
X and Y axes vise motions using the arrowed bolt(s)
illustrated above. Recheck that nothing has
shifted after locking the slides.
How deep to drill? Forget the depth stops on the drill press – they are an exercise in frustration. Just machine enough that you see brass showing through the chrome plating on the flange. You need only a very fine cut. If the lens’s mount is aluminum mill just enough that you can discern the pit.

Two milled recesses on the 50mm lens,
filled with black ink from the Uni-Ball pen.
For the 50mm f/2 LLL Summicron clone the code is ‘100001’.

Confirmation that the lens is recognized as a 50mm f/2.

Here are the milled recesses on the 35mm f/2 8-element LLL Summicron clone
lens before filling with ink. The code is ‘000110’.

Confirmation that the lens is recognized as a 35mm f/2
Do the above and you will never have to worry about your ink codings wearing with use.
How to confer proper lens names in EXIF data:
As coded the two LLL lenses are reported as “35mm f/2 Summicron” and “50mm f/2 Summicron” in EXIF metadata on import to Lightroom Classic. To properly name these as “LLL 8-element 1:2/35” and “LLL Speed Panchro 1:2/50” lenses in EXIF metadata I use the application described here. It takes mere seconds to do after each import of new images into Lightroom Classic. If I used multiple lenses for the latest import I filter metadata by focal length in LR Classic and apply the EXIF renaming tool for each batch of images with a common focal length. No reliance on memory is required.

Proper lens names in LR Classic metadata for my M10 images.