Hi, I tried to set up my Odrive 3.5 48V with my motor, but I can’t get the internal ABI encoder’s offset calibration to work (`encoder.is_ready=False`

)

Motor calibration and index search works (`motor.is_calibrated=true`

, `use_index=True, index_found=True`

), but I always get `encoder.error = ERROR_CPR_OUT_OF_RANGE`

. I understand this means that given the motor and encoder configurations, encoder counts don’t match with electrical motor rotation.

Counts per rotation are 2500 ppr *4 => `cpr = 10000`

. I verified this from the motor’s datasheet and from manually turning the motor and watching the pulse count reported with odrivetool.

I verified the number of motor pole pairs to be 8 via this method.

I also unmounted the attached 1:25 worm gearbox, but it didn’t help.

The encoder is built-in, so I cannot re-align if that was really the cause (which I doubt since manual turning shows correct counts).

I tried `calib_range = 0.05`

and `calibration_current = 30`

as suggested in Encoder error 0x0002 questions

I even built and flashed new firmware from the Connect Hall and incremental encoder topic where hall sensor is used as index pulse. But is has the same `ERROR_CPR_OUT_OF_RANGE`

problem.

Is there anything else I can set or try to make this work?

## odrivetool log

```
In [6]: odrv0.axis0.motor
Out[6]:
error = 0x0000 (int)
armed_state = 0 (int)
is_calibrated = True (bool)
current_meas_phB = -0.015051960945129395 (float)
current_meas_phC = 0.015044689178466797 (float)
DC_calib_phB = -1.6362192630767822 (float)
DC_calib_phC = -2.1500930786132812 (float)
phase_current_rev_gain = 0.02500000037252903 (float)
thermal_current_lim = 45.87586212158203 (float)
get_inverter_temp()
current_control:
p_gain = 0.025488227605819702 (float)
i_gain = 33.564842224121094 (float)
v_current_control_integral_d = -0.7992188930511475 (float)
v_current_control_integral_q = 0.44919270277023315 (float)
Ibus = 0.1462455838918686 (float)
final_v_alpha = 0.8796867728233337 (float)
final_v_beta = 0.2399977147579193 (float)
Iq_setpoint = 10.0 (float)
Iq_measured = 10.19466781616211 (float)
Id_measured = -0.15742921829223633 (float)
I_measured_report_filter_k = 1.0 (float)
max_allowed_current = 60.75 (float)
overcurrent_trip_level = 67.5 (float)
gate_driver:
drv_fault = 0 (int)
timing_log:
TIMING_LOG_GENERAL = 0 (int)
TIMING_LOG_ADC_CB_I = 2770 (int)
TIMING_LOG_ADC_CB_DC = 12854 (int)
TIMING_LOG_MEAS_R = 7594 (int)
TIMING_LOG_MEAS_L = 7618 (int)
TIMING_LOG_ENC_CALIB = 7914 (int)
TIMING_LOG_IDX_SEARCH = 0 (int)
TIMING_LOG_FOC_VOLTAGE = 7858 (int)
TIMING_LOG_FOC_CURRENT = 8186 (int)
config:
pre_calibrated = False (bool)
pole_pairs = 8 (int)
calibration_current = 10.0 (float)
resistance_calib_max_voltage = 4.0 (float)
phase_inductance = 2.5488227038295008e-05 (float)
phase_resistance = 0.033564843237400055 (float)
direction = -1 (int)
motor_type = 0 (int)
current_lim = 10.0 (float)
inverter_temp_limit_lower = 100.0 (float)
inverter_temp_limit_upper = 120.0 (float)
requested_current_range = 25.0 (float)
current_control_bandwidth = 1000.0 (float)
In [12]: odrv0.axis0.error = 0; odrv0.axis0.encoder.error = 0; odrv0.axis0.motor.error = 0 [30/1236]
In [13]: odrv0.axis0.requested_state = AXIS_STATE_ENCODER_INDEX_SEARCH
In [14]: odrv0.axis0.encoder
Out[14]:
error = 0x0000 (int)
is_ready = False (bool)
index_found = True (bool)
shadow_count = 314 (int)
count_in_cpr = 314 (int)
interpolation = 0.5 (float)
phase = 1.5808494091033936 (float)
pos_estimate = 314.9997253417969 (float)
pos_cpr = 314.7500305175781 (float)
hall_state = 5 (int)
vel_estimate = 0.0 (float)
config:
mode = 0 (int)
use_index = True (bool)
find_idx_on_lockin_only = True (bool)
pre_calibrated = False (bool)
zero_count_on_find_idx = True (bool)
cpr = 10000 (int)
offset = 0 (int)
offset_float = 0.0 (float)
enable_phase_interpolation = True (bool)
bandwidth = 1000.0 (float)
calib_range = 0.019999999552965164 (float)
idx_search_unidirectional = True (bool)
ignore_illegal_hall_state = False (bool)
In [15]: odrv0.axis0.requested_state = AXIS_STATE_ENCODER_OFFSET_CALIBRATION
In [16]: odrv0.axis0.encoder
Out[16]:
error = 0x0002 (int)
is_ready = False (bool)
index_found = True (bool)
shadow_count = -98847 (int)
count_in_cpr = 1153 (int)
interpolation = 0.5 (float)
phase = -0.4850621223449707 (float)
pos_estimate = -98846.25 (float)
pos_cpr = 1153.75 (float)
hall_state = 4 (int)
vel_estimate = 0.0 (float)
config:
mode = 0 (int)
use_index = True (bool)
find_idx_on_lockin_only = True (bool)
pre_calibrated = False (bool)
zero_count_on_find_idx = True (bool)
cpr = 10000 (int)
offset = 0 (int)
offset_float = 0.0 (float)
enable_phase_interpolation = True (bool)
bandwidth = 1000.0 (float)
calib_range = 0.019999999552965164 (float)
idx_search_unidirectional = True (bool)
ignore_illegal_hall_state = False (bool)
```