Flag odrv0.misconfigured after configuration (v0.5.3)

Hi. I’m wondering if I have an issue in my configuration scripts because I’m seeing the flag odrv0.misconfigured is true.

If I set

odrv0.config.gpio9_mode = GPIO_MODE_DIGITAL
odrv0.config.gpio10_mode = GPIO_MODE_DIGITAL
odrv0.config.gpio11_mode = GPIO_MODE_DIGITAL

and

axis.encoder.config.use_index = False

…then the flag is false but my encoder doesn’t work - shadow_count always zero, and ERROR_NO_RESPONSE during calibration. (Same with pull_up and pull_down.)

The following two scripts give me more or less the behaviour I’m after, except the flag is true. Do I worry about it or am I safe?

This bench has an AMT 102-V on an Aerodrive 1250 kv on M0, nothing on M1, and it’s a 24V v3.6 with 0.5.3, and I’m using Canbus.

Thanks!

Step 1: configure.py

import odrive
from odrive.enums import *

# ODrive 0.5.3

odrv0 = odrive.find_any()
odrv0.clear_errors()

odrv0.config.enable_can_a = True
odrv0.config.brake_resistance = 0.47
odrv0.config.enable_brake_resistor = True
odrv0.can.config.baud_rate = 500000
odrv0.axis0.config.can.node_id = 0
odrv0.axis1.config.can.node_id = 1

odrv0.config.gpio9_mode = GPIO_MODE_ENC0
odrv0.config.gpio10_mode = GPIO_MODE_ENC0
odrv0.config.gpio11_mode = GPIO_MODE_ENC0

odrv0.axis0.config.startup_motor_calibration = False
odrv0.axis0.config.startup_encoder_index_search = True
odrv0.axis0.config.startup_encoder_offset_calibration = False
odrv0.axis0.config.startup_closed_loop_control = False

odrv0.axis1.config.startup_motor_calibration = False
odrv0.axis1.config.startup_encoder_index_search = False
odrv0.axis1.config.startup_encoder_offset_calibration = False
odrv0.axis1.config.startup_closed_loop_control = False

for axis in [odrv0.axis0, odrv0.axis1]:
    axis.config.can.is_extended = False
    axis.config.can.heartbeat_rate_ms = 200

    axis.motor.config.pole_pairs = 7
    axis.motor.config.calibration_current = 10
    axis.motor.config.resistance_calib_max_voltage = 1 # < 0.5 * vbus_voltage and  > calibration_current * phase_resistance
    axis.motor.config.torque_constant = 8.27 / 1250
    axis.motor.config.motor_type = MOTOR_TYPE_HIGH_CURRENT
    axis.motor.config.current_lim = 40
    axis.motor.config.current_lim_margin = 8
    axis.motor.config.current_control_bandwidth = 1000
    # axis.motor.config.requested_current_range = 60

    axis.encoder.config.mode = ENCODER_MODE_INCREMENTAL
    axis.encoder.config.use_index = True
    axis.encoder.config.cpr = 8192
    axis.encoder.config.calib_range = 0.05
    axis.encoder.config.pre_calibrated = True
    axis.encoder.config.bandwidth = 1000
    axis.encoder.config.calib_scan_distance = 60
    axis.controller.config.anticogging.anticogging_enabled = False
    axis.controller.config.enable_vel_limit = True
    axis.controller.config.enable_gain_scheduling = False
    axis.controller.config.enable_overspeed_error = True
    axis.controller.config.control_mode = CONTROL_MODE_VELOCITY_CONTROL
    axis.controller.config.input_mode = INPUT_MODE_PASSTHROUGH

    axis.controller.config.pos_gain = 20
    axis.controller.config.vel_gain = 0.1
    axis.controller.config.vel_integrator_gain = 0.16
    axis.controller.config.vel_limit = 10

odrv0.save_configuration()

Step 2: calibrate.py

import odrive
from odrive.enums import *
import time

# ODrive 0.5.3

odrv0 = odrive.find_any()
odrv0.clear_errors()

# for axis in [odrv0.axis0, odrv0.axis1]:
for axis in [odrv0.axis0]:
    print("Starting motor calibration...")
    axis.requested_state = AXIS_STATE_MOTOR_CALIBRATION
    while axis.current_state != AXIS_STATE_IDLE:
        time.sleep(0.5)

    if axis.motor.is_calibrated:
        axis.motor.config.pre_calibrated = True
        print("...done!\n  Phase inductance: {}".format(axis.motor.config.phase_inductance))
        print("  Phase resistance: {}".format(axis.motor.config.phase_resistance))
    else:
        print("Motor calibration failed")

    print("Starting encoder calibration...")
    axis.requested_state = AXIS_STATE_ENCODER_INDEX_SEARCH
    while axis.current_state != AXIS_STATE_IDLE:
        time.sleep(0.1)

    axis.requested_state = AXIS_STATE_ENCODER_OFFSET_CALIBRATION
    while axis.current_state != AXIS_STATE_IDLE:
        time.sleep(0.1)

    if axis.encoder.is_ready:
        axis.encoder.config.pre_calibrated = True

        if axis.encoder.config.pre_calibrated:
            print("...done!\n  Encoder offset  : {}".format(axis.encoder.config.phase_offset_float))
            print("  Encoder direction  : {}".format(axis.encoder.config.direction))
            odrv0.save_configuration()
        else:
            print("Encoder pre-calibration rejected by ODrive")
    else:
        print("Encoder calibration failed")

I have no idea what you’re trying to do.

odrv0.config.gpio9_mode = GPIO_MODE_DIGITAL
odrv0.config.gpio10_mode = GPIO_MODE_DIGITAL
odrv0.config.gpio11_mode = GPIO_MODE_DIGITAL

I didn’t even know you could set anything beyond GPIO 8.

Lol sorry. With that code, I was only trying to get rid of ‘misconfigured.’ The actual code is

odrv0.config.gpio9_mode = GPIO_MODE_ENC0
odrv0.config.gpio10_mode = GPIO_MODE_ENC0
odrv0.config.gpio11_mode = GPIO_MODE_ENC0