Back to All Work
Motor Keyframer - Homemade Motion Control for Film

I built this in 2017-2018 to use on set for my work as a photographer and videographer. My goal was to create smooth and repeatable camera motion. This was my first coding project, and my first robotics project. I learned a great deal about CAD, C, Java, and a lot more. I credit my work on this project with my successes in software, robotics, and in university.

Motion control for cameras with ESP32 based wireless control. Implemented a follow focus (wireless device to allow manual focus on a camera stabilizer), motorized crane, motorized pan tilt head. Uses a custom serial protocol over bluetooth allowing dual mode operation with either real-time or keyframe based pre-programmed moves.

XL Motion Control System - Pan Axis Gear + Encoder Mechanism
XL Motion Control System - Pan Axis Gear + Encoder Mechanism

Prototype 1 - Wirelessly Controlled Pan + Tilt + Focus
Prototype 1 - Wirelessly Controlled Pan + Tilt + Focus

Original Article from 2018

Cover image
Keyframes in Adobe After Effects
Cover image
CAD Rendering of the XL rig

In animation and visual effects, an artist uses “keyframes” to specify the position of a given element in a scene at a particular time, and using multiple of these keyframes, the animation software calculates the positions and times in between the keyframes to create a smooth animation. This project applies the sample principle to real-life cameras, and enables accurate and repeatable motion control.

Cover image

Motor Movement

Cover image

We already know that a digital animation is just a collection of keyframes, and that a keyframe is just a time value with a corresponding position value, so to design a keyframe system, all we need is an array of data with a time and position axis. To simplify the code, this system treats all motor positions as one “keyframeable” value – each time coordinate corresponds to 4 motor positions values. This reduces the size of the packet and makes accessing the data far simpler, and asynchronous control can be achieved by interpolating position values for motors whose movement is to be unaffected by a given keyframe.

The system receives a keyframe as a string, with commas separating integers. It knows that the data follows a standard format – time, positions, time – where the number of positions is defined in the software based on the number of motors in the system.

Based on this string, the data is parsed into an array which enables easier math operations looking forward and backwards in time to calculate the ideal velocities (and perhaps in future acceleration curves and PID Parameters) in order to make the motors move to their positions efficiently.

The system accurately times the moves and ensures their accuracy by referencing a millisecond (in future, microsecond) timer and position feedback.

Data Acquisition

Cover image

The goal of the system software is to acquire a parcel of move data, and move the motors accordingly when given the signal. Data can be acquired in any way so long as the data is returned as a correctly formatted string. In the current version, there are 2 data acquisition modes.

Bluetooth Mode

Cover image

Creating an good user interface on the hardware of the Motor Keyframer is possible, but it is both more difficult and less elegant than using an existing device to send data over bluetooth. This is why the primary interface with the keyframer is bluetooth (or any other serial port). Since bluetooth is used for various purposes – control, debugging, mode switching – one cannot directly send the move data without context. Because of this, the data is encoded in a packet which includes a type identifier, the data, and an end marker.

Recorder Mode

Normally, backlash from gearing, position loss upon restart, and missed steps would reduce the accuracy of a motion control system. In order to prevent this, each motor, or more accurately degree of freedom in this system must have position feedback. Since we have access to the positions of each axis regardless of the motors, if the motors are disengaged, the system can be used in order to encode a manmade move which the motors can subsequently replicate.

Cover image

To start recording, the system is given the sample rate and optionally a recording time, and when the recording is finished it returns a string of the manmade move, of the same sort as it could receive over bluetooth or otherwise.

Hardware

Expandable, Standard Chassis Design

The hardware of the motion control rig follows the same philosophy as the software – complete modularity.

Cover image
Encoder assembly for yaw axis
Cover image
Encoder for pitch axis

Using encoders placed after all the gearing of the motors, directly on the point of rotation, the most accurate possible position data can be gathered. Because of this encoder placement, any motor can be used to drive the joints with positioning being maintained.

Standard, Adjustable Components

Cover image
Cover image

Throughout the motion keyframer’s hardware, considerations are made for expandability and compatibility. All of the stepper mounts are a standard NEMA 23, the servo control is standard Dynamixel TTL, and the encoders are connected in a motor-independent manner.

Cover image
Using aluminium X beams, the NEMA23 stepper mount and bevel gear have adjustable spacing in order to ensure gear meshing regardless of shaft length.

Cover image
Power & Control Bay at the base of the pan tilt head