2702 Recipes

Homing and Zeroing

How a robot finds where its mechanisms are when it turns on. Hard stops, relative and absolute encoders, limit switches and hall effect sensors, and two-encoder turrets solved with the Chinese Remainder Theorem.

A motor's encoder tells the robot how far a mechanism has moved, but not where it started. Before an arm, an elevator, or a turret can go to a position, the robot needs a zero: a known position that every other position is measured from. Finding it is called homing or zeroing. If the zero is wrong, every setpoint, soft limit, and gravity feedforward is wrong with it.

This section covers the ways to find the zero. It starts with the simplest, starting the robot with each mechanism against a hard stop, and ends with solving a turret's angle from two geared encoders. The last page picks a strategy for each kind of mechanism.

What you need

Algebra. The page on two encoders uses remainders (clock arithmetic) and explains them first. Two pages have interactive widgets. It helps to know the mechanism types from Robot Mechanisms.

Where to start

Read the pages in order. Each one builds on the one before.

Key ideas at a glance

IdeaOne-line summaryPage
The zeroThe known position every other position is measured from. Setpoints, soft limits, and gravity feedforward all depend on it.Why Mechanisms Need a Zero
Know you're homedTrack whether each mechanism has its zero. Show it, and don't let the mechanism move on its own until it does.Why Mechanisms Need a Zero
Hard stopsSolid stops at the ends of travel protect the mechanism when the code is wrong, and give a free zero.Hard Stops
Known startA mechanism that starts every match resting on its hard stop needs no sensor. Set its position at the start.Hard Stops
Stall homingDrive slowly into the stop with a low stator current limit. Zero when the speed stays near zero while the stator current is high.Hard Stops
Relative vs. absoluteThe motor's encoder counts from wherever it powered up. An absolute encoder on the mechanism knows the angle right away.Relative and Absolute Encoders
The wrap pointAn absolute encoder's reading jumps by a full turn at one point. Keep the travel inside one turn, and the jump outside the travel.Relative and Absolute Encoders
Index sensorsA limit switch or hall effect sensor marks one position. Zero when it triggers, slowly and from the same side.Limit Switches and Hall Effect Sensors
Sensor plus rotor angleA hall effect sensor finds the turret to within a few degrees, and the motor's rotor angle finds the exact angle inside that window.Limit Switches and Hall Effect Sensors
Two encoders (CRT)Encoders on 19- and 21-tooth pinions repeat at different places, so together they read a turret over almost two turns.Two Encoders and the CRT
A quarter toothAccept a solve only when the two encoders agree within a quarter tooth of the turret gear. A wrong answer is off by about a full turn.Two Encoders and the CRT

On this page