Analog Input

Analog inputs can be used to measure voltages between 0 and 3.3V. 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 Gxx pins support analog inputs. This Gxx pin (numbered X) be configured be setting <odrv>.config.gpioX_mode to GpioMode.ANALOG_IN before it can be used as an analog input. Once configured, the voltage on Gxx can be read using <odrv>.get_adc_voltage(X).

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(X)_analog_mapping. Additionally, the scale of this voltage input can be mapped linearly from [0, 3.3] -> [<...mapping>.min, <...mapping>.max].

For example, <controller>.input_pos can be fed by the analog voltage input by setting <odrv>.config.gpio(X)_analog_mapping to <controller>._input_pos_property. This mapping can be disabled by setting <odrv>.config.gpio(X)_analog_mapping to None.

Note

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