SharpAI
/

how do encoders work on an ftc robot

An encoder is a sensor that tracks the rotational angle or displacement of a mechanism around an axis . FTC robots primarily use two types of encoders:

  • Relative (incremental) encoders track how far a shaft has rotated since it started tracking (such as at robot power-on), meaning they lose position information when powered off .
  • Absolute encoders report the exact angle of the shaft relative to a fixed "zero" position .

Relative encoders in FTC use a two-wire "quadrature" protocol to transmit position data . This format uses two signal wires, A and B, which generate square waves 90 degrees apart as the shaft rotates . The direction of rotation determines whether wire A leads wire B or vice versa . The Control or Expansion Hub combines these waves using an XOR operation to produce an output wave, where each rising and falling action represents one "tick" or "count" .

Most FTC-legal motors have built-in relative quadrature encoders, though external encoders (like the REV Through Bore Encoder) can also be plugged into the JST-PH encoder ports on a REV Hub . Ports 0 and 3 on the Expansion Hub use hardware-based Quadrature Encoder Interfaces (QEI) and are highly accurate at high speeds . Ports 1 and 2 are decoded in software using General-Purpose Timers (GPTs) and can lose counts or "lose steps" when paired with high Counts Per Revolution (CPR) encoders spinning quickly . If using a 5V Modern Robotics-compatible encoder, a REV Logic Level Converter is required to connect it to the Hub .

In the FTC SDK, encoders are accessed through the DcMotor object associated with the physical port . Programmers call the getCurrentPosition() method to retrieve the current position as an integer of "counts" or "ticks" . Because relative encoders do not automatically reset to zero when an OpMode starts, programmers must use STOP_AND_RESET_ENCODER to reset the count to zero .

Was this right?

Generated from indexed documentation and can be wrong — check the source beside each claim. Follow-ups are not saved. Unofficial, not affiliated with FIRST. Quotes Game Manual 0 (CC BY-NC 4.0) and FTC Docs (BSD 3-Clause). Built by Sharp Face Robotics.