Precise focus control from PC

Started by EhsanKia, May 14, 2014, 12:29:30 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

EhsanKia

Hello,

I'm doing research on a subject related focus pulling, and to experimentally try my results, I need to be able to very precisely control the focus on my Canon camera.
I have multiple bodies available to me, such as the 70D, the 5D3, etc, and many different lenses.

The Canon SDK is very limited in this reguard. It only provides 3 different speeds, and the fastest, even when sent as fast as possible, is still pretty slow.
Furthermore, the movement with those is not as smooth and precise as I need it to be.

The body itself can clearly move it much faster and smoother, as witnessed when I use autofocus.
Magic Lantern does quite a lot of neat things with focus too, so I'm guessing you guys have access to the same smooth control.
So I was wondering if anyone here who has in-depth knowledge of the inner working could just tell me if what I need is doable
by using a custom firmware, and if so, which direction to look towards. Would communicating with the custom firmware from the PC be possible?

Thanks,
Ehsan

ItsMeLenny

There are 3 different stepping sizes as far as I know. If you install canon eos utility it has <<<, <<, <, >, >>, >>>, for each of the stepping. One is like micro step, 2 is like mini, and 3 is a big jump. The other thing is, they seem to vary between lenses. That is, each lens has its own amount of steps, plus its own step size.
The 3 stepping sizes that eos utility are the same ones that can be controlled by the arrow keys on the camera when ML is installed, you have to turn on pull focus in a menu.

An other alternative could be to build some sort of rig that uses a stepper motor with a wheel that manually turns the lens. Some sort of arduino rig hooked up to the computer.

EhsanKia

So even ML doesn't have better access to the focus motors, and all the features
such as rack focus and follow focus use the same 3 speeds?

It's just a shame, when I use autofocus, the body manages to rotate through the whole focus
field in a fast and smooth motion, but using those 3 speeds, I can't go anywhere as fast or smoothly.
Maybe in a future SDK they'll provide better controls then.

Thanks for the help. I guess there isn't really a way to make it go any faster or give it finer control over the speed.

ItsMeLenny

I think I understand what you're saying. But that's how canon focus.
It jumps big steps, over shoots, backtracks in smaller steps, over shoots tracks forward in even smaller steps to find the sweet spot.

Audionut

Without direct control of the AF chip, that's all she wrote.

EhsanKia

Quote from: Audionut on May 15, 2014, 05:30:28 PM
Without direct control of the AF chip, that's all she wrote.

And is there any way to get access to the AF chip?
Has any reverse engineering ever gone towards getting a lower level access to the focus movements?

And just to give a concrete example:

Video of autofocus
Video of spamming Far3 as fast as possible

Could the limitation be due to the fact that I'm using the SDK through the USB wire in Liveview?
As is, can ML, being loaded as a custom firmware right in the camera, move the lens faster?

dmilligan

Quote from: EhsanKia on May 15, 2014, 06:01:59 PM
And is there any way to get access to the AF chip?
Has any reverse engineering ever gone towards getting a lower level access to the focus movements?
Search for TX19A

Audionut


a1ex

Quote from: EhsanKia on May 15, 2014, 06:01:59 PM
Has any reverse engineering ever gone towards getting a lower level access to the focus movements?

http://www.magiclantern.fm/forum/index.php?topic=4997

and Sztupy's 60D focus code (in ML repo history).

The current solution (same commands as EOS utility) is simple and fairly portable (IIRC there were problems reported with STM lenses), but the new cameras certainly allow finer focus control (but it requires serious reverse engineering). Also, I couldn't get Sztupy's code working without locking up the camera after a few minutes, so consider it only a proof of concept.

ItsMeLenny

I do recall somebody making a wireless rig which hooked up to the lens chip directly of a 50mm 1.8.
The thing is it only worked on that 50mm 1.8, and I'm also not sure what happened to the project.

EhsanKia

Quote from: ItsMeLenny on May 16, 2014, 03:16:20 AM
I do recall somebody making a wireless rig which hooked up to the lens chip directly of a 50mm 1.8.
The thing is it only worked on that 50mm 1.8, and I'm also not sure what happened to the project.

Hmm, that's interesting (sorry for the late reply).
I am actually considering a very custom setup hooking up directly to the lens/chip.
I don't mind adapting code to a specific lens. I've already done quite a lot of lens specific measurement, calibration and fitting for this project so that's not an issue. Either way, I'll report back my findings, might come useful to others or even ML.

ItsMeLenny

I tried searching for that what I spoke of, but it'd be quite a few years ago that I saw it.
However in the process of searching for it I found this:
http://pickandplace.wordpress.com/2011/10/05/canon-ef-s-protocol-and-electronic-follow-focus/

eyeland

Quote from: ItsMeLenny on May 23, 2014, 09:39:02 AM
I tried searching for that what I spoke of, but it'd be quite a few years ago that I saw it.
However in the process of searching for it I found this:
http://pickandplace.wordpress.com/2011/10/05/canon-ef-s-protocol-and-electronic-follow-focus/
Interesting
Daybreak broke me loose and brought me back...

EhsanKia

Hey guys. It's been a while now, and I realize the direction I took is no longer relevant to Magic Lantern, let alone firmware hacking, but I thought I'd make one last post to report what I ended up doing here, for anyone interested. We ended up going the route proposed by ItsMeLenny. My supervisor bought a couple lens extenders and we hacked our way into the lens. Although, after getting the protocol working, we ended up actually modifying the lens itself, since the 28mm lens didn't go too well with the 13mm extender, and we were having a hard time communicating with the other lenses (they use a different faster protocol).

So yeah, we got everything hooked up nicely. The lens is connected to an arduino, and we can get the motor position. We made focus distance vs motor position measurements and fit a function to it. Using our mocap setup, we can now get position data of the camera and target, convert into motor position, and move the lens accordingly. We can also more or less control the speed of the motor by sending a lot of small movements rather than one big one.

I'll attach a few pictures and videos below. Thanks for the suggestions, and hopefully this information will help some other person in the future.

Some pictures of the setup and process
Poorly made video showing focus follow

ItsMeLenny

Very Cool! Thanks for coming back and doing an update, even if it has been a while, better late than never.

Just to make some comments, I think lots of lenses (as you discovered) all have slightly different protocols, and they also all have slightly different stepping sizes, so what may work for one lens will be out of focus for another. (Which I mentioned before with that only working with the 50mm 1.8)(which I still haven't come across that original post.)

And so what you're doing is mo-capping the position of the camera plus the position of the object using a different camera (or IR camera), then doing the calculation and controlling the lens?

Since you have that kind of control over the lens, if you were to build an electronic dolly, you could set up a scene in a 3D program including depth of field and mash the 3D world with the real world quite easily :P (once it's all set up which would be the hard part).

Again, really cool hack, except I don't think I'll be destroying any of my lenses any time soon, it's not the most easily reversed hack :P (But of course there is really no other way to do it, the ring extender would give good macro but take away the infinite focus (although whether that's needed in a small room)).