# Getting Started

## Wire up the ODrive

### Hardware Requirements

• An encoder, unless using sensorless mode.

• A >12V power supply or battery. Make sure you are within the voltage rating of your ODrive (58V for Pro, 50V for S1). Some advice on choosing a power supply can be found here.

### Connections

Warning

Make sure to avoid a ground loop! See the ground loop page for details.

1. Solder the motor phases onto the solder pads that are labelled A/B/C.

2. If the motor has a thermistor, connect it to THERMISTOR+ and THERMISTOR-.

3. Solder the power supply cables onto the solder pads that are labelled +/-.

4. If using an encoder, connect it to the corresponding I/O connector.

Note

Please see the full pinout page for important information about pin functionality and specifications.

### Safety & Power Up

Warning

Always think safety before powering up the ODrive if a motor is attached. Consider what might happen if the motor spins as soon as power is applied.

If possible, connect the power source first and then turn it on to avoid inrush current. If this can’t be avoided then a small spark is normal when plugging in the power connector, this is caused by the capacitors charging up. To avoid this issue we recommend using these anti spark connectors.

## Connecting to the ODrive

There are two methods for connecting your ODrive to a computer, a command line utility called odrivetool or our new web GUI. If you are using the GUI, select Connect new device in the top right corner and continue to Configure Power Supply, otherwise you will need to install odrivetool.

Note

You cannot use odrivetool and the GUI at the same time, if either say Could not claim interface make sure the other is closed and try again.

## Configure Power Supply

Use this configuration if you’re powering the ODrive from a power supply that plugs into the grid.

ODrive is a four-quadrant drive, so it regenerates braking energy into electrical energy when deccelerating. Most AC/DC power supplies do not accept reverse current, so there needs to be a method to dissipate the regenerated power. This can be done with a brake resistor on ODrives that have support for that, or otherwise with a regen clamp module.

Please adapt the ??? placeholders below. dc_bus_overvoltage_trip_level is the overvoltage fault level and should be set to a value that will protect it from overvoltage damage. For instance if your power supply outputs 24V a reasonable value is 30. dc_max_positive_current is the overcurrent fault level and should be set to a value that will protect your power source from overcurrent damage. dc_max_negative_current is the regenerated current fault level, it is a negative value.

odrv0.config.dc_bus_overvoltage_trip_level = ???
odrv0.config.dc_max_positive_current = ???
odrv0.config.dc_max_negative_current = -1

Additionally, on ODrive S1 if you have a brake resistor connected:

odrv0.config.brake_resistor0.resistance = ??? # resistance in Ohms
odrv0.config.brake_resistor0.enable = True
odrv0.save_configuration()

## Motor Configuration

We only list configurations for the most commonly used motors here. If you’re using a different motor, you can use these scenarios as reference and read up on the documentation of the settings to adapt them for your motor.

odrv0.axis0.config.motor.motor_type = MotorType.HIGH_CURRENT
odrv0.axis0.config.motor.pole_pairs = 7
odrv0.axis0.config.motor.torque_constant = 8.27 / 270
odrv0.axis0.requested_state = AxisState.MOTOR_CALIBRATION
# [wait for end of motor beep]
odrv0.save_configuration()

odrv0.axis0.motor.motor_thermistor.config.r_ref = 10000
odrv0.axis0.motor.motor_thermistor.config.beta = 3435
# thermistor must be connected
odrv0.axis0.motor.motor_thermistor.config.enabled = True
odrv0.save_configuration()

Warning

If you change the motor, make sure to re-run the motor calibration.

### Setting the Limits

#### Current limit

odrv0.axis0.config.motor.current_soft_max = 10 # [A] (adapt this to your motor)
odrv0.axis0.config.motor.current_hard_max = 18 # [A] (should be more than soft max)

It is recommended to set the soft max to something quite weak to start with, but strong enough to overcome friction in your system with a decent margin. Once you have built confidence in the stability of the control and strength of your mechanical setup, you can increase these. For high current motors you need to turn this up to get high performance, and for low current motors such as the BotWheel you need to use something that’s lower than the examples shown above.

The recommended maximum for current_soft_max is the continuous current rating of your motor if you are not using motor thermistor temperature feedback, and the peak current rating of your motor if you are using it. The hard max is a fault trip level and should be set to a level above the soft max. The appropriate level is a tradeoff between getting nuisance faults especially during high accelerations, and ability to catch unstable current control situations. The recommended maximum is the current your motor can handle for 50ms.

Note

The motor current and the current drawn from the power supply is not the same in general. You should not look at the power supply current to see what is going on with the motor current.

#### Velocity limit

odrv0.axis0.controller.config.vel_limit = 2 # [turn/s]


The motor will be limited to this speed. Again the default value is quite slow.

#### Temperature limits

odrv0.axis0.motor.motor_thermistor.config.temp_limit_lower = 100 # °C (adapt this to your motor)
odrv0.axis0.motor.motor_thermistor.config.temp_limit_upper = 120 # °C (adapt this to your motor)

## Encoder Configuration

Note

The rotor must be allowed to rotate without any biased load during encoder calibration. That means mass and weak friction loads are fine, but gravity or spring loads are not okay. Heavier loads are not advised, it is recommended that you lift any wheeled robot off the ground.

The following commands assume you have the encoder connected to the Motor I/O connector.

Connecting the A,B phases is mandatory, the Z (index pulse) is optional.

odrv0.inc_encoder0.config.cpr = 8192
odrv0.inc_encoder0.config.enabled = True
odrv0.axis0.config.commutation_encoder = EncoderId.INC_ENCODER0
odrv0.save_configuration()
# [wait for ODrive to reboot]
odrv0.axis0.requested_state = AxisState.ENCODER_OFFSET_CALIBRATION
# [wait for motor to stop]


After each subsequent reboot you need to re-run odrv0.axis0.requested_state = AxisState.ENCODER_OFFSET_CALIBRATION before you can activate position/velocity control.

Warning

If the encoder setup changes at all, make sure to re-run the encoder offset calibration.

### Viewing Encoder Feedback

Position and velocity feedback from the load_encoder can be found in the Mapper pos_vel_mapper by entering

odrv0.axis0.pos_vel_mapper.pos_rel
# or
odrv0.axis0.pos_vel_mapper.vel


Similarly, feedback from the commutation_encoder can be found in the Mapper commutation_mapper.

What is a Mapper?

A Mapper converts from one rotational/linear space to another rotational/linear space. For example, from an encoder’s circular output onto the user’s axis linear space, or the motor’s electrical phase circular space.

## Status LED

The current status of the ODrive can be observed by the color the LED:

• blue/teal: The ODrive is idle. It will not move, and has no errors.

• green: The ODrive is active and running.

• red: An error has occured and the ODrive is disabled. Please refer to the troublshooting page for more information.

## Position Control

Warning

Make sure you have a good mechanical connection between the encoder and the motor, slip can cause disastrous oscillations or runaway.

1. Enter closed loop control mode by setting odrv0.axis0.requested_state to AxisState.CLOSED_LOOP_CONTROL.

From now on the ODrive will try to hold the motor’s position. If you try to turn it by hand, it will fight you gently. That is unless you bump up odrv0.axis0.config.motor.current_soft_max, in which case it will fight you more fiercely. If the motor begins to vibrate either immediately or after being disturbed you will need to lower the controller gains.

2. Send the motor a new position setpoint by setting odrv0.axis0.controller.input_pos to 1.

The units are in turns.

3. At this point you will probably want to properly tune the motor controller in order to maximize system performance.

## Other Control Modes

The default control mode is unfiltered position control relative to the startup position of the axis. You may wish to use a controlled trajectory instead. Or you may wish to control position in a circular frame to allow continuous rotation forever without growing the numeric value of the setpoint too large.

You may also wish to control velocity (directly or with a ramping filter). You can also directly control the torque of the motor.

For this and more, refer to Control Modes.

## Watchdog Timer

Each axis has a configurable watchdog timer that can stop the motors if the control connection to the ODrive is interrupted.

Each axis has a configurable watchdog timeout: <axis>.config.watchdog_timeout, measured in seconds. Set

<axis>.config.enable_watchdog = True

to turn on this feature.

The watchdog is fed using the <axis>.watchdog_feed() method of each axis. Some ascii commands and most CANSimple commands feed the watchdog automatically.

## What’s Next?

You can now:

• Properly tune the motor controller to unlock the full potential of the ODrive.

• See what other commands and parameters are available, in order to better control the ODrive.

• Control the ODrive from your own program or hook it up to an existing system through one of it’s interfaces.

• See how you can improve the behavior during the startup procedure.

If you have any issues or any questions please get in touch. The ODrive Community warmly welcomes you.