MagicFocus โ€“ Open-Source Lidar Autofocus

A free, open-source autofocus for any lens with a focus gear, where you choose how focus moves. An M5Stack CoreS3 or Core2 reads a TFmini-S lidar and drives a Tilta Nucleus Nano II motor by radio through a Gateway H2. Nothing connects to the camera, so it works with any camera.

View on GitHub Setup guide
MagicFocus on a camera, labelled: the M5Stack CoreS3 runs MagicFocus, with the Gateway H2 and DIN Base stacked under it; the TFmini-S lidar beside it is aimed where the lens points; the Tilta Nucleus Nano II motor turns the focus ring of a Canon RF 24-70mm F2.8, a focus-by-wire lens
MagicFocus on a camera rig, with a Canon RF 24-70mm F2.8.

Why MagicFocus

๐ŸŽš๏ธ You choose how focus moves

Five autofocus curves, Snap, Overshoot, Creep, Smooth and Linear, each slow or fast, so a focus change looks the way the shot needs.

๐ŸŽฅ Any camera, almost any lens

The lidar measures the distance itself, so nothing connects to the camera. Focus-by-wire lenses work too, with one camera setting.

๐Ÿ“ก The motor you already have

MagicFocus drives a stock Tilta Nucleus Nano II motor by radio, as its own hand wheel does: no modification, and no cable to the motor.

๐Ÿงฉ Off-the-shelf parts

An M5Stack CoreS3 or Core2, a Gateway H2 module and a TFmini-S lidar. A CoreS3 even flashes the H2 stacked on it.

๐ŸŽฏ Calibrated by eye, lens by lens

Focus each lens at a few distances with the camera's focus aids and save; MagicFocus interpolates between the points.

๐Ÿ“ˆ You see what it does

A live graph of the lidar and lens distances, and a radio status that shows whether the motor is answering.

How it works

How MagicFocus works: the lidar measures the distance to the subject, MagicFocus looks it up in the lens's calibration, the Gateway H2 radios the motor position, the Tilta motor turns the focus ring, and the lens focuses on the subject
From the lidar's distance to the lens's focus ring, by radio.

On the screen

The MagicFocus tab on a CoreS3, labelled: the lens slot and name, where holding the name locks the lens; Lidar, the distance to the subject, and Lens, where the lens is focused; Camera, the Blackmagic camera link, Core2 only; and Motor OK, which means the motor answers by radio
The MagicFocus tab: the lens, the lidar and lens distances, autofocus and the motor's radio status.

Focus curves

On the AF Curve tab, choose how autofocus moves to each new distance. The Speed button makes every curve slow or fast.

CurveHow focus moves to the new distance
SnapStraight there in one move
OvershootA little past it, then back
CreepStops just short of it, then makes the last small move
SmoothGlides there, easing in and out
LinearGlides there at a constant speed

Hardware

The TFmini-S lidar on a small mount beside the CoreS3, labelled: aim the lidar where the lens points; its cable is red 5 V, black GND, green TX and white RX; the CoreS3 runs MagicFocus, with the Gateway H2 and DIN Base stacked under it
The lidar beside the CoreS3, aimed where the lens points.

Setting up

Steps 1 to 3 are done once, steps 4 and 5 for each lens. The setup guide has the details.

  1. Flash the Gateway H2
  2. Flash MagicFocus onto the CoreS3 or Core2
  3. Pair the motor with the Knob or the Control Handle
  4. Set up the camera and lens
  5. Calibrate a lens

Frequently asked questions

Does MagicFocus need a connection to the camera?

No. The TFmini-S lidar measures the distance to the subject itself, and MagicFocus drives the focus motor by radio, so it works with any camera.

Which lenses work with MagicFocus?

Any lens that takes a follow-focus gear on its focus ring. Focus-by-wire lenses, such as Canon's RF lenses, work too once one camera setting is changed; see Focus-by-wire lenses.

Which focus motor does MagicFocus drive?

A stock Tilta Nucleus Nano II motor, by radio, the way its own hand wheel does. You need the Nucleus Nano II hand wheel or the Nucleus-N II Control Handle once, to pair the motor, and then switch it off.

What hardware do I need?

An M5Stack CoreS3 (recommended) or Core2, an M5Stack Module Gateway H2, a Benewake TFmini-S lidar, a microSD card, the Tilta Nucleus Nano II motor and a focus gear ring for each lens. The M5Stack DIN Base is optional.

How do I calibrate a lens?

Aim the lidar at a subject, focus it by eye with the camera's focus aids, and save the point on the Calib. tab. With two or more points saved, MagicFocus interpolates between them.

Is MagicFocus free?

Yes. MagicFocus is open-source firmware licensed under the LGPL-3.0.