ODESC V4.2 Motor Configuration and Setup

Flashing

Before configuring, ensure the ODESC board is running the official ODrive v0.5.6 firmware:

1. Connect the ODESC to your computer via USB.

2. Perform MASS ERASE to remove current firmware, then flash the standard ODrive v0.5.6 firmware using an ST-Link and STM32CubeProgrammer .

3. Once flashed, launch odrivetool in your terminal to connect.

After confirming that the firmware has been flashed and the controller is recognized by your computer, unplug the controller.

Base Configuration

Next, connect the battery to the controller and connect the USB cable to the controller and your computer. In your terminal, launch odrivetool and run the following blocks to configure the power limits, motor hardware, and anti-shake tuning.

1. Power Limits (25.2V Battery)

dev0.config.dc_bus_undervoltage_trip_level = 18.0

dev0.config.dc_bus_overvoltage_trip_level = 32.0

dev0.config.dc_max_positive_current = 40.0

dev0.config.dc_max_negative_current = -5.0

2. Motor Configuration and Voltage Bump Calibration

dev0.axis0.motor.config.pole_pairs = 5

dev0.axis0.motor.config.current_lim = 10.5

dev0.axis0.motor.config.calibration_current = 5.0

dev0.axis0.motor.config.resistance_calib_max_voltage = 10.0

3. Hall Sensor Configuration and Noise Filter

dev0.axis0.encoder.config.mode = ENCODER_MODE_HALL

dev0.axis0.encoder.config.cpr = 30

dev0.axis0.encoder.config.calib_scan_distance = 150

dev0.axis0.encoder.config.bandwidth = 100

4. Tuning and Limits

dev0.axis0.controller.config.vel_limit = 60

dev0.axis0.controller.config.vel_limit_tolerance = 2.0

dev0.axis0.controller.config.vel_gain = 0.02

dev0.axis0.controller.config.vel_integrator_gain = 0.05

dev0.axis0.controller.config.control_mode = CONTROL_MODE_VELOCITY_CONTROL

5. Save Base Settings and Reboot

dev0.save_configuration()

dev0.reboot()

Calibration Sequence

Wait for the board to reconnect to odrivetool after the reboot. Ensure the motor is free to spin.

# Start calibration

dev0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE

Allow approximately 15 to 20 seconds for the motor to beep and calibrate.

Enable Pre-Calibrated Mode

The next step is to lock the settings into flash memory so calibration process doesn’t need to be repeated.

# Tell the controller not to forget the calibration alignment

dev0.axis0.motor.config.pre_calibrated = True

dev0.axis0.encoder.config.pre_calibrated = True

# (Optional) Automatically enter closed-loop control on boot

dev0.axis0.config.startup_closed_loop_control = True

# Lock it in

dev0.save_configuration()

dev0.reboot()

Testing

Wait for the board to reconnect to odrivetool after the reboot.

# Test movement (2 turns per second)

dev0.axis0.controller.input_vel = 2

# Stop movement

dev0.axis0.controller.input_vel = 0