Step/Direction
This is the simplest possible way of controlling the ODrive. It is also the most primitive and fragile one. So don’t use it unless you must interoperate with other hardware that you don’t control.
Pinout
While any GPIOs can be used, we suggest using the Isolated IO pins STEP and DIR, please refer to the datasheet (Pro, S1) to locate these pins on your ODrive.
Important
ISO_VDD and ISO_GND must be provided by the microcontroller to use these Isolated IO pins.
To use alternative GPIO pins for this interface, set <axis>.config.step_gpio_pin
and <axis>.config.dir_gpio_pin
to their desired GPIO number and save_configuration()
.
How to Configure
Set the STEP GPIO (S) mode
<odrv>.config.gpio(S)_mode
toDIGITAL_PULL_DOWN
Set the DIR GPIO (D) mode
<odrv>.config.gpio(D)_mode
toDIGITAL
Enable the interface by setting
<axis>.config.enable_step_dir
to TrueEnable circular setpoints
set
<axis>.controller.config.circular_setpoints
to Trueset
<axis>.pos_vel_mapper.config.circular_setpoints
to True
After this, step and direction will be enabled when you put the axis into closed loop control.
Note that to change out of step/dir, you need to set <axis>.config.enable_step_dir
to False, go to AxisState.IDLE
, and then back into closed loop control.
Circular setpoints are used to keep floating point error at a manageable error for systems where the motor can rotate large amounts.
If the motor is commanded out of the circular range, the position setpoint automatically wraps around to stay in the range.
Two parameters are used to control this behavior: <odrv>.<axis>.controller.config.circular_setpoint_range
and <odrv>.<axis>.controller.config.steps_per_circular_range
.
The circular setpoint range sets the operating range of input_pos, starting at 0.0. The steps per circular range
setting controls how many steps are needed to traverse the entire range.
For example, to use 1024 steps per 1 motor turn, in a space that wraps every 128 turns:
set
<axis>.controller.config.circular_setpoint_range
to 128.0 (turns)set
<axis>.pos_vel_mapper.config.circular_output_range
to 128.0 (turns)set
<axis>.controller.config.steps_per_circular_range
to 1024*128 (steps)
The circular range is a floating point value and the steps per circular range parameter is an integer. For best results, set both parameters to powers of 2.
The maximum advisable step rate is 50kHz.
Please be aware that there is no enable line right now, and the step/direction interface is enabled by default, and remains active as long as the ODrive is in position control mode. To get the ODrive to go into position control mode at boot, see how to configure the startup procedure.