Encoder to distance

Distance travelled from encoder counts, plus the conversion factors to put in code.

Inputs

Counts, or rotations if your API reports rotations (then set counts per rotation to 1).

Phoenix 6 (Talon FX) and REVLib (SPARK) report rotations: use 1. Phoenix 5 Talon FX: 2048. A quadrature encoder read as raw 4× counts: cycles per revolution × 4.

:1

Encoder rotations per wheel rotation. An encoder on the motor uses the gearbox reduction; one on the wheel uses 1.

Result

Distance

0.4729
Wheel rotations
1.481
Distance per encoder rotation
0.04729
Distance per count
0.02309
CTRE SensorToMechanismRatio for metres (1 ÷ k_rot)Per metre of travel
21.15

How it’s calculated

Formula

nwheel=countsCPR×R,x=nwheel πdn_\text{wheel} = \frac{\text{counts}}{\text{CPR} \times R}, \qquad x = n_\text{wheel} \, \pi d
krot=πdR,kcount=πdCPR×Rk_\text{rot} = \frac{\pi d}{R}, \qquad k_\text{count} = \frac{\pi d}{\text{CPR} \times R}

With your numbers (converted to SI units)

nwheel=204802048×6.75=1.481n_\text{wheel} = \frac{20480}{2048 \times 6.75} = 1.481
x=1.481×π×0.1016 m=0.4729 mx = 1.481 \times \pi \times 0.1016\,\text{m} = 0.4729\,\text{m}
krot=π×0.1016 m6.75=0.04729 mk_\text{rot} = \frac{\pi \times 0.1016\,\text{m}}{6.75} = 0.04729\,\text{m}

What it means

k_rot is the distance per encoder rotation. For REV, it is the position conversion factor; REV reports velocity in RPM, so use k_rot ÷ 60 as the velocity conversion factor for m/s. For CTRE Phoenix 6, set SensorToMechanismRatio to R to read wheel rotations and multiply by πd, or set it to 1 ÷ k_rot to read metres directly. k_count is the distance per encoder count, for APIs that report raw counts.

Assumptions

  • No wheel slip; the measured distance drifts from the real one when the wheel slips or the tread wears.

Learn the concepts behind this on resources.simbotics.org · All formulas