Encoders

Overview

All encoders supported by ODrive require that you do some sort of encoder calibration. This requires the following:

  1. Selecting an encoder and mounting it to your motor, refer to Known and Supported Encoders to make sure your hardware is compatible.

  2. Connecting the pins to the ODrive

    1. Each encoder types will require different connections, please refer to the relevent section below for instructions specific to your encoder type.

    2. Information about the ODrive’s GPIO can be found on the pinout page.

  3. Configure the ODrive

    1. Set <axis>.config.load_encoder and <axis>.config.commutation_encoder to the appropriate EncoderId.

    2. Additional configuration may be necessary, please refer to the relevent section below.

  4. Encoder calibration

    1. The calibration procedure may vary depending on the type of encoder, please refer to the relevent section below.

    2. During calibration the rotor must be allowed to rotate without any biased load during startup. That means mass and weak friction loads are fine, but gravity or spring loads are not okay.

    3. The current limit during encoder calibration is set with <axis>.config.calibration_lockin.current. The default value is enough for most applications, but can be increased for larger motors or loads.

    4. Verify calibration.

  5. Save the settings in the odrive for correct bootup by running <odrv>.save_configuration().

Verify Calibration

After the calibration procedure has completed, verify that procedure_result is equal to ProcedureResult.SUCCESS. This can be done easily from odrivetool by running dump_errors(odrv), or from the GUI by inspecting the ODrive icon in the bottom left corner. If instead, you see ProcedureResult.BUSY then the calibration has not yet completed, check again after a couple more seconds.

Onboard Encoder

ODrive Pro and ODrive S1 both come with an integrated magnetic encoder. To use this encoder, a diametric neodymium magnet must be mounted to the end of the motor shaft. For general purpose use we recommend the 8996 by Radial Magnets, if there is a chance that the magnet could get hot we suggest using the 9049 variant. If neither of these are suitable, any diametric neodymium magnet with a diameter ≥ 4mm and thickness ≥ 2.5mm will work.

When mounting, a 1mm gap between the onboard encoder and the magnet is ideal.

Incremental Encoders

Note

If the index (Z) signal is not used, ENCODER_OFFSET_CALIBRATION must be run after every reboot before CLOSED_LOOP_CONTROL can be used. If you would like to automate this process at startup, set <axis>.config.startup_encoder_offset_calibration to True.

RS-485 Encoders

  • RS-485 encoder signals use a differential pair A, B and will require power and ground from the ODrive.

    Encoder

    ODrive

    Vcc

    5V

    A

    RS485_A

    B

    RS485_B

    GND

    GND

Important

At this time, only the CUI AMT21 series of encoders is support by the RS-485 interface

Hall Effect Encoders

Important

Due to the relatively low resolution of hall effect encoders, ODrive Robotics recommends a different encoder type for position control or applications requiring high performance at low speeds.

SPI Encoders

SPI encoders usually measure an absolute angle, which means you don’t need to repeat the encoder calibration after every ODrive reboot.

Some of these chips come with evaluation boards that can simplify mounting the chips to your motor. For our purposes if you are using an evaluation board you should select the settings for 3.3v.

Note

The AMT23x family has a hardware bug that causes them to not properly tristate the MISO line. To use them with ODrive, there are two workarounds. One is to sequence power to the encoder a second or two after the ODrive recieves power. This allows 1 encoder to be used without issue. Another solution is to add a tristate buffer, such as the 74AHC1G125SE, on the MISO line between the ODrive and each AMT23x encoder. Tie the enable pin on the buffer to the CS line for the respective encoder. This allows for more than one AMT23x encoder, or one AMT23x and another SPI encoder, to be used at the same time.

  • The SPI interface has three required and one optonal signal connections: clock (SCK), data (MISO), chip select (nCS), and optionally data out (MOSI). Additionally the encoder will require power and ground from the ODrive.

    Encoder

    ODrive

    Vcc

    3.3V

    SCK

    SPI_SCK

    MISO/DATA

    SPI_MISO

    MOSI (optional)

    SPI_MOSI

    nCS

    SPI_nCS

    GND

    GND

Note

If you want to save a wire with AMS encoders, you can also connect the encoder’s MOSI to the encoder’s Vcc instead.

Important

Only the following modes are supported at this time:

  • CUI protocol: Compatible with the AMT23xx family (AMT232A, AMT232B, AMT233A, AMT233B).

  • AMS protocol: Compatible with AS5047P and AS5048A.

Note

If you are having calibration problems, make sure that your magnet is centered on the axis of rotation on the motor. Also make sure that your magnet height is within range of the spec sheet.

Known and Supported Encoders

Key

  • ✓: Supported

  • E: Experimental

  • S: Coming Soon

  • X: Not Supported

Encoder

Interface

Pro

S1

Onboard Magnetic

internal

Incremental

A,B,(Z)

Incremental

Sin,Cos

X

X

Hall Effect Sensor

A,B,C

CUI AMT21

RS485

CUI AMT23

SPI

AMS (AS5047p, AS5048A)

SPI

MA732, MA702

SPI

E

E

Broadcom-AEAT-9922

SPI

E

E

RLS (Orbis 14-bit only)

SPI

E

E

EnData/Tamagawa/RLS-AksIM

~

X

X

Be sure to check the ODrive Encoder Spreadsheet.

Encoder Noise

Noise is found in all circuits, life is just about figuring out if it is preventing your system from working. Lots of users have no problems with noise interfering with their ODrive operation, others will tell you “I’ve been using the same encoder as you with no problems”. Power to ‘em, that may be true, but it doesn’t mean it will work for you. If you are concerned about noise, there are several possible sources:

  • Importantly, encoder wires may be too close to motor wires, avoid overlap as much as possible

  • Long wires between encoder and ODrive

  • Use of ribbon cable

The following might mitigate noise problems. Use shielded cable, or use twisted pairs, where one side of each twisted pair is tied to ground and the other side is tied to your signal. If you are using SPI, use a 20-50 ohm resistor in series on CLK, which is more susceptible noise.