This Custom Circular Circuit Board Gives USB Control to Your Canon EOS Electronic Focus Optics!
In this first of two articles, we take a look at a clever custom Cannon lens controller circuit from Jana Marie Hemsing.
There's a recurring theme with engineers — why buy something, when I can design and make it myself?
It's a question I find myself asking time and time again, often when I'm deep into an attempt to design my own version of something. Also, all to often when my project budget has far exceeded what it would have cost to buy this thing off the shelf.
But, it's not about the cost when it comes to designing our own implementation of a given device or thing — the journey will surely reveal many a lesson we'd never have the chance to learn otherwise, and offer insights and bragging rights that don't come with a pre-made item, delivered in a UPS box.
Back again with another finely executed project, the ever productive and proficient pair that are Jana Marie Hemsing and Niklas Fauth return with a view set to creating a completely custom camera, capable of meeting their requirements!
There's more than meets the eye with this project, and where as this is only half of the package — we'll cover the Image sensor, being handled by Fauth in a complementary article to this one shortly — the optics being handled here are critically important to the operation of any camera!
DSLR cameras, and even high-end mirrorless cameras, will often feature interchangeable lenses to allow for the myriad different levels of zoom or field of view that can be required by a photographer.
While I struggle to think of a camera lens I've seen that isn't adjustable, in terms of focus or f-stop (aperture), the lenses used by these higher end cameras are typically also able to be controlled automatically, with the camera able to dictate commands to the lens, which can then drive it's internal motors, adjusting the optics until the camera thinks it has a clear shot.
While nearly every camera manufacturer will have its own specific implementation of the electrical and mechanical interface between the lens and the camera body, they all seem to take the form of a series of pogo-pin contacts that sit around the mounting ring system used.
Hemsing and Fauth are targeting the Canon EOS-EF range of optics, the mounting system of which we can see above, on the body of a Canon EOS R series body.
Already, this looks like a tricky bit of kit to interface a PCB to — it's not exactly a 0.1" pitch header that you can just plug into!
With very little information publicly documenting either the hardware, or signaling interface used by the EOS-EF series of electronic, auto-focus lenses, Hemsing was fortunate enough to come across a significant document that lays out the basics needed to get the lens responding to your beck and call!
Give me a signal...
This document is a treasure trove and surely has saved Hemsing a huge amount of reverse engineering. There's no need for an oscilloscope or logic probe to debug the lens communication here, thankfully it's all been documented previously.
As Hemsing notes, the communication protocol the lens interface uses behaves somewhat like a hybrid of SPI and I2C, with a two lines for data, to and from the lens/camera body (similar to the CIPO, COPI found in SPI), but also a tri-state clock, with clock stretching implemented, as can be found implemented within the I2C specification.
There is even a simplified schematic of the connections between the camera body and the lens, as we can see below. No need to rip apart a camera body here to find the circuit, and therefore no risk of potentially damaging several thousand dollars worth of equipment in doing so!
With the core communication protocol, and associated interface circuity specified, Hemsing turns to KiCad, and puts together a circuit schematic that is allows his choice of MCU, an STM32 F042, to talk to the lens electronics.
Top right, we've got a USB-C socket, and although these symmetrical, reversible connectors are intended to pass super-speed USB3.0 signals, it's nice to see the continued adoption of the new connector, even for USB 2.0 speed applications.
While this circular board has a bandwidth requirement of bytes / second, there's no reason it can't still make use of the nice new connection system! As always, nice to see some ESD protection on external interfaces, with a USBLC6-4 covering the D+/D- lines from potential static discharge, etc. — that's not a bad idea for something which is often going to be handled by human hands!
Making sure it's not lost in translation...
A selection of 2N7002 transistors and P-channel MOSFET devices are used to interface the different supply voltages present in the controller PCB w.r.t the lens electronics (3V3 vs 5V0, respectively).
The P-FET trick is one we often see used when designers need a simple, bi-directional level translation, often with I2C devices and busses with mixed voltages.
AN10441 from NXP breaks down the theory behind this idea, it's an app note worth sticking in the box of tricks — it can save you buying a specific IC, when looking to do what can be done with a few FETs and some pull-up resistors!
As far as the schematic goes, that's about it. The STM32 sits with two spare I/O, and even includes a UART header for debugging, or lower level embedded control, rather than relying purely on the USB-CDC interface alone.
Let's get physical...
This simplicity in design clearly shows through in the layout of the lens controller board. As we can see below, it's a clean layout, with less than half of the annular ring being occupied by the circuit.
With what looks like the remnants of an imported DXF used to work out the positions of the components and various contacts needed to talk to the lens, it's worth noting that functionality when working in KiCad.
With manufacturers often offering mechanical drawings for things like enclosures, a huge amount of time can be saved by pulling that data into KiCad directly, rather than manually translating the information from other documents, or worse yet, relying upon manual measurements of the real world objects.
With this board, there's a very specific reason to do this, and you can just see them peeking at you from the bottom of the board, along inner edge of the ring...
Even if you aren't designing board with such a unique form factor, that's a handy thing to keep in mind if you ever have to design a board that needs to fit into an existing space. Here, it's almost essential, in order to make sure that the spring contacts — seen in the 3D view below — align properly with the lens body!
Picture perfect...
With boards fabricated, components placed, and solder finally reflowed, the finished controller looks pretty as a picture! The attention to detail sometimes is easy to overlook in a design, but here, even springing for black solder mask to match the lens body is a lovely touch.
A custom machined locking ring takes care of the appropriate spacing, and mechanical retention of the ring to the lens optics.
We can see the finished controller capably controlling the configuration of the lens optics and aperture iris mechanism in the video below, and it looks like it's very much a successful design — we're sure Hemsing must be happy with the results of this project!
So we can hear you asking, why go to all this bother? A lens on its own, even under computer control, doesn't — at first glance — appear to be that useful, right? Where's the sensor needed to digitize the focused image?!
Well, despite this being a partner project, produced in conjunction with Niklas Fauth, as we mentioned at the start of the article, so far, we've only touched on the contributions of Hemsing...
In part two of this mini-series, we're going to take a look at what Fauth has been working on, and the missing half of this project — the custom CCD image sensor board that will be paired with the lens and the controller board! Catch up with the 2nd article here!