Encoder hall polarity error

Hi all,

I am trying to setup a hoverboard with odrive v3.6-56V by following every steps described below document.
https://docs.odriverobotics.com/v/0.5.5/hoverboard.html#hoverboard-motor-wiring

I found the pole pair as 52 by counting number of detents.
dev0.axis0.requested_state = AXIS_STATE_MOTOR_CALIBRATION was successfully done as
below motor setup shows

In [221]: dev0.axis0.motor
Out[221]:
DC_calib_phA: 1.9492510557174683 (float)
DC_calib_phB: -0.8201689124107361 (float)
DC_calib_phC: -1.12917959690094 (float)
I_bus: 0.0 (float)
config:
  I_bus_hard_max: inf (float)
  I_bus_hard_min: -inf (float)
  I_leak_max: 0.10000000149011612 (float)
  R_wL_FF_enable: False (bool)
  acim_autoflux_attack_gain: 10.0 (float)
  acim_autoflux_decay_gain: 1.0 (float)
  acim_autoflux_enable: False (bool)
  acim_autoflux_min_Id: 10.0 (float)
  acim_gain_min_flux: 10.0 (float)
  bEMF_FF_enable: False (bool)
  calibration_current: 10.0 (float)
  current_control_bandwidth: 100.0 (float)
  current_lim: 10.0 (float)
  current_lim_margin: 8.0 (float)
  dc_calib_tau: 0.20000000298023224 (float)
  inverter_temp_limit_lower: 100.0 (float)
  inverter_temp_limit_upper: 120.0 (float)
  motor_type: 0 (uint8)
  phase_inductance: 0.0002176045236410573 (float)
  phase_resistance: 0.17459237575531006 (float)
  pole_pairs: 52 (int32)
  pre_calibrated: True (bool)
  requested_current_range: 25.0 (float)
  resistance_calib_max_voltage: 4.0 (float)
  torque_constant: 0.515999972820282 (float)
  torque_lim: inf (float)
current_control:
  I_measured_report_filter_k: 1.0 (float)
  Ialpha_measured: 7.879737854003906 (float)
  Ibeta_measured: 6.309068202972412 (float)
  Id_measured: 10.092523574829102 (float)
  Id_setpoint: 10.0 (float)
  Iq_measured: 0.178409144282341 (float)
  Iq_setpoint: 0.0 (float)
  Vd_setpoint: 0.0 (float)
  Vq_setpoint: 0.0 (float)
  final_v_alpha: 0.8792524933815002 (float)
  final_v_beta: 1.6940604448318481 (float)
  i_gain: 17.459238052368164 (float)
  p_gain: 0.021760452538728714 (float)
  phase: 2.700525999069214 (float)
  phase_vel: 40.0 (float)
  power: 26.511167526245117 (float)
  v_current_control_integral_d: 1.7390443086624146 (float)
  v_current_control_integral_q: 0.7940816283226013 (float)
current_meas_phA: -1.9550633430480957 (float)
current_meas_phB: 0.8230656385421753 (float)
current_meas_phC: 1.132250428199768 (float)
effective_current_lim: 10.0 (float)
error: 0 (uint64)
fet_thermistor:
  config: ...
  temperature: 26.775304794311523 (float)
is_armed: False (bool)
is_calibrated: True (bool)
last_error_time: 0.0 (float)
max_allowed_current: 30.375 (float)
max_dc_calib: 3.0375001430511475 (float)
motor_thermistor:
  config: ...
  temperature: 0.0 (float)
n_evt_current_measurement: 2181177 (uint32)
n_evt_pwm_update: 2181179 (uint32)
phase_current_rev_gain: 0.012500000186264515 (float)

Now I tried to calibrate hall sensor polarity by calling

dev0.axis0.requested_state = AxisState.MOTOR_CALIBRATION.ENCODER_HALL_POLARITY_CALIBRATION

Motor turns a little bit and the encoder shows error: 16 as below

In [222]: dev0.axis0.encoder
Out[222]:
calib_scan_response: 0.0 (float)
config:
  abs_spi_cs_gpio_pin: 1 (uint16)
  bandwidth: 300.0 (float)
  calib_range: 0.019999999552965164 (float)
  calib_scan_distance: 520.0 (float)
  calib_scan_omega: 12.566370964050293 (float)
  cpr: 312 (int32)
  direction: 0 (int32)
  enable_phase_interpolation: True (bool)
  find_idx_on_lockin_only: False (bool)
  hall_polarity: 0 (uint8)
  hall_polarity_calibrated: False (bool)
  ignore_illegal_hall_state: False (bool)
  index_offset: 0.0 (float)
  mode: 1 (uint16)
  phase_offset: 0 (int32)
  phase_offset_float: 0.0 (float)
  pre_calibrated: False (bool)
  sincos_gpio_pin_cos: 4 (uint16)
  sincos_gpio_pin_sin: 3 (uint16)
  use_index: False (bool)
  use_index_offset: True (bool)
count_in_cpr: 0 (int32)
delta_pos_cpr_counts: 0.0 (float)
error: 16 (uint16)
hall_state: 4 (uint8)
index_found: False (bool)
interpolation: 0.5 (float)
is_ready: False (bool)
phase: 0.0 (float)
pos_abs: 0 (int32)
pos_circular: 0.0 (float)
pos_cpr_counts: 0.0 (float)
pos_estimate: 0.0 (float)
pos_estimate_counts: 0.0 (float)
set_linear_count(obj: object_ref, count: int32)
shadow_count: 0 (int32)
spi_error_rate: 0.0 (float)
vel_estimate: 0.0 (float)
vel_estimate_counts: 0.0 (float)

I don’t know what is wrong with the above setup.

What is error 16? Can you do dump_errors(odrv0)?

I changed the odrivetool version to v0.5.4 and errors are in string now.
Below dump shows illigal hall state.
Maybe the hall sensors are broken?

In [27]: dump_errors(odrv0)
system: no error
axis0
  axis: Error(s):
    UNKNOWN ERROR: 0x00000100
  motor: no error
  sensorless_estimator: no error
  encoder: Error(s):
    ENCODER_ERROR_ILLEGAL_HALL_STATE
  controller: no error
axis1
  axis: no error
  motor: no error
  sensorless_estimator: no error
  encoder: no error
  controller: no error

You still have a mismatch. Update both firmware and odrivetool:

pip install --upgrade odrive
odrivetool dfu

52 is extremely unlikely. Do you have a link to the motor?

I also thought that way but, I tried to find pole pairs for this motor by a method described in below link.
https://docs.odriverobotics.com/v/0.5.5/getting-started.html#pole-pairs

I checked the detents by applying 24V/0.5A to a pair of wire from the motor and 52 is number I got.

Attached is the 24V/200W motor I am trying to run.

6 inch model from here

Thank you for your assist.
I am currently using firmware as master branch from GitHub - odriverobotics/ODrive: High performance motor control
Which version of firmware do I have to update?

You should have fw 0.5.5 and odrivetool 0.6.3

Hmm, since this motor says it’s geared, you may have to either ask the supplier or take it apart and manually count the magnets.

Oh I see. I didn’t account for the gear ratio of the motor.
I should ask about this to the manufacturer.
Thanks for your comment.