Setting Encoder Position

You can reset the encoder on the Thrifty Nova to be at some specific value. The current position of the encoder will real as the set value, and all the other readings will be adjusted accordingly. The position needs to be passed in encoder units, so it can be wise to use conversions.

Encoder Types

The Thrifty Nova supports three types of encoders, each with different capabilities:

Encoder TypeResolutionPositionVelocityNotes

INTERNAL

42 counts/rev

Built into NEO motors

QUAD

4096 counts/rev

External quadrature encoder

ABS

4096 counts/rev

X

External absolute encoder

Setting Up Encoders

First, tell the motor which encoder type you're using:

javaCopy// Select which encoder to use for feedback
motor.useEncoderType(EncoderType.INTERNAL);  // Built-in NEO encoder
motor.useEncoderType(EncoderType.QUAD);      // External quadrature encoder
motor.useEncoderType(EncoderType.ABS);       // External absolute encoder

Usage Examples

The following example sets the encoder to be currently at the zero position.

myEncoder.setEncoderPosition(0);

And this example sets the current position to read as 21 encoder units.

myEncoder.setEncoderPosition(21);

API Details for setEncoderPosition

Sets the encoder position.

setEncoderPosition(double position)

Parameters:

  • position The position to set the encoder to.

Last updated