Analog Input


Analog inputs can be used to measure voltages between 0 and 3.3V, and optionally map to position, velocity, or torque setpoints (or any other ODrive endpoint).

ODrive uses a 12 bit ADC (4096 steps) and so has a maximum resolution of 0.8 mV.

Look for analog input in the pinout (Pro, S1) to see which GPIO pins support analog inputs.

Given a analog-capable GPIO pin Gxx (here, N will be used to notate the GPIO pin number), the pin can be configured in analog mode with <odrv>.config.gpioN_mode = GpioMode.ANALOG_IN.

All GPIO mode changes require a <odrv>.save_configuration() before taking effect.

Once configured, the voltage on Gxx can be read using <odrv>.get_adc_voltage(N).

Endpoint Mapping

Analog inputs can also be used to feed any of the numerical properties that are visible in odrivetool or the Web GUI .

This is done by configuring the endpoint mapping for the analog Gxx pin in question: <odrv>.config.gpio(N)_analog_mapping.

Every time the analog value is read, the voltage width will be remapped from 0 - 3.3V to a range defined by <odrv>.config.gpio(N)_analog_mapping.min to <odrv>.config.gpio(N)_analog_mapping.max.

The mapped value will then be written to the endpoint defined by <odrv>.config.gpio(N)_analog_mapping.endpoint. This can be any writable value on the ODrive, not just pos/vel/torque setpoints.

Typically, the name of this endpoint will be the property name with a leading underscore, and followed by _property.

For instance, if you want to map to <odrv>.axis0.controller.input_torque, the property name will be <odrv>.axis0.controller._input_torque_property.

As another example, the name of <odrv>.axis0.config.motor.current_soft_max would be <odrv>.axis0.config.motor._current_soft_max_property.

This mapping can be disabled by setting <odrv>.config.gpio(N)_analog_mapping to None.


Changes to the endpoint mapping will be ignored after a reboot unless you run <odrv>.save_configuration().

Velocity Control Example

As an example, we’ll configure the axis with a velocity setpoint from 0 to 5 turn/s, controlled by the analog input voltage. This assumes your ODrive is connected to ODrivetool as odrv0. In the GUI, this can be set up graphically in the configurator, so this guide is only relevant for when using ODrivetool.

  1. Make sure you’re able to control the axis0 velocity by writing to odrv0.axis0.controller.input_vel, and that the velocity controller is properly tund. If you need help with this follow the getting started guide.

  2. If you want to control your ODrive with the analog input without using anything else to activate the ODrive, you can configure the ODrive such that it automatically enters closed loop at startup. See here for more information.

  3. Select an analog-capable pin (see the Pro, S1 pinout pages for details).

  4. In odrivetool, configure the analog input mapping, where N is the GPIO pin number selected (e.g. if pin G15 on ODrive Pro is used for analog input, gpio(N) would be replaced with gpio15)

    odrv0.config.gpio(N)_mode = GpioMode.ANALOG_IN
    odrv0.config.gpio(N)_analog_mapping.min = 0
    odrv0.config.gpio(N)_analog_mapping.max = 5
    odrv0.config.gpio(N)_analog_mapping.endpoint = odrv0.axis0.controller._input_vel_property


    you can disable the input by setting odrv0.config.gpio(N)_analog_mapping.endpoint = None

  5. Save the configuration and reboot

  6. Now, once the ODrive is powered and running in closed loop control (whether manually commanded in the GUI/ODrivetool or set to enter closed loop control on startup), the velocity setpoint will be set by the analog input.