Hey,
this got me a bit further as I am now able to calibrate the motor without any errors. I get the beep and also a somewhat off measurement for the phase resistance (ODrive measures 2.3 Ohms. In reality it’s around 3.6 Ohms)
odrv0.axis0.motor after doing AXIS_STATE_MOTOR_CALIBRATION
In [84]: odrv0.axis0.motor
Out[84]:
DC_calib_phA: 1.1101914644241333 (float)
DC_calib_phB: -1.0377676486968994 (float)
DC_calib_phC: -0.07235477864742279 (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: 1.0 (float)
current_control_bandwidth: 1500.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.002006554277613759 (float)
phase_resistance: 2.2909862995147705 (float)
pole_pairs: 5 (int32)
pre_calibrated: False (bool)
requested_current_range: 5.0 (float)
resistance_calib_max_voltage: 20.0 (float)
torque_constant: 0.20600000023841858 (float)
torque_lim: inf (float)
current_control:
I_measured_report_filter_k: 1.0 (float)
Ialpha_measured: 0.0 (float)
Ibeta_measured: 0.0 (float)
Id_measured: 0.0 (float)
Id_setpoint: 0.0 (float)
Iq_measured: 0.0 (float)
Iq_setpoint: 0.0 (float)
Vd_setpoint: 0.0 (float)
Vq_setpoint: 0.0 (float)
final_v_alpha: 0.0 (float)
final_v_beta: 0.0 (float)
i_gain: 3436.4794921875 (float)
p_gain: 3.009831428527832 (float)
phase: 0.0 (float)
phase_vel: 0.0 (float)
power: 0.0 (float)
v_current_control_integral_d: 0.0 (float)
v_current_control_integral_q: 0.0 (float)
current_meas_phA: -1.1066875457763672 (float)
current_meas_phB: 1.0355292558670044 (float)
current_meas_phC: 0.07121540606021881 (float)
effective_current_lim: 10.0 (float)
error: 0 (uint64)
fet_thermistor:
config: ...
temperature: 32.445682525634766 (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: 415629 (uint32)
n_evt_pwm_update: 415634 (uint32)
phase_current_rev_gain: 0.012500000186264515 (float)
Calibrating the hall polarity also works without an error. While doing that, the motor spins quietly - kind of fast.
In [93]: odrv0.axis0.requested_state = AXIS_STATE_ENCODER_HALL_POLARITY_CALIBRATION
In [94]: odrv0.axis0.encoder
Out[94]:
calib_scan_response: 0.0 (float)
config:
abs_spi_cs_gpio_pin: 1 (uint16)
bandwidth: 100.0 (float)
calib_range: 0.019999999552965164 (float)
calib_scan_distance: 150.0 (float)
calib_scan_omega: 12.566370964050293 (float)
cpr: 30 (int32)
direction: 1 (int32)
enable_phase_interpolation: True (bool)
find_idx_on_lockin_only: False (bool)
hall_polarity: 0 (uint8)
hall_polarity_calibrated: True (bool)
ignore_illegal_hall_state: False (bool)
index_offset: 0.0 (float)
mode: 1 (uint16)
phase_offset: 85 (int32)
phase_offset_float: 1.4640014171600342 (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: 3 (int32)
delta_pos_cpr_counts: -5.605193857299268e-45 (float)
error: 0 (uint16)
hall_state: 6 (uint8)
index_found: False (bool)
interpolation: 0.5 (float)
is_ready: False (bool)
phase: 0.0 (float)
pos_abs: 0 (int32)
pos_circular: 0.13250578939914703 (float)
pos_cpr_counts: 3.9750475883483887 (float)
pos_estimate: 0.13250158727169037 (float)
pos_estimate_counts: 3.9750475883483887 (float)
set_linear_count(obj: object_ref, count: int32)
shadow_count: 3 (int32)
spi_error_rate: 0.0 (float)
vel_estimate: 0.0 (float)
vel_estimate_counts: 0.0 (float)
When I get to the hall sensor offset calibration, the motor spins a few times in each direction. After this I get an error: 16 in the encoder config.
In dump_errors(), there is a ENCODER_ERROR_ILLEGAL_HALL_STATE.
In [95]: odrv0.axis0.requested_state = AXIS_STATE_ENCODER_OFFSET_CALIBRATION
In [96]: odrv0.axis0.encoder
Out[96]:
calib_scan_response: 144.0 (float)
config:
abs_spi_cs_gpio_pin: 1 (uint16)
bandwidth: 100.0 (float)
calib_range: 0.019999999552965164 (float)
calib_scan_distance: 150.0 (float)
calib_scan_omega: 12.566370964050293 (float)
cpr: 30 (int32)
direction: 1 (int32)
enable_phase_interpolation: True (bool)
find_idx_on_lockin_only: False (bool)
hall_polarity: 0 (uint8)
hall_polarity_calibrated: True (bool)
ignore_illegal_hall_state: False (bool)
index_offset: 0.0 (float)
mode: 1 (uint16)
phase_offset: 73 (int32)
phase_offset_float: 1.4663901329040527 (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: 3 (int32)
delta_pos_cpr_counts: -5.605193857299268e-45 (float)
error: 16 (uint16)
hall_state: 6 (uint8)
index_found: False (bool)
interpolation: 0.5 (float)
is_ready: True (bool)
phase: 1.0823841094970703 (float)
pos_abs: 0 (int32)
pos_circular: 0.13269804418087006 (float)
pos_cpr_counts: 3.97507381439209 (float)
pos_estimate: 0.13250036537647247 (float)
pos_estimate_counts: 3.975010871887207 (float)
set_linear_count(obj: object_ref, count: int32)
shadow_count: 3 (int32)
spi_error_rate: 0.0 (float)
vel_estimate: 0.0 (float)
vel_estimate_counts: 0.0 (float)
I checked my hall sensors with an oscilloscope and they seem to be working. Manually rotating the shaft while observing the shadow_count comes out to be 30 per rotation, which matches my cpr.
After a while I tried what happens if I just keep going and tried:
odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
Sometimes the motor spins for a second, sometimes for 10 or more while vibrating quite a bit. But it seems powerful.
In [99]: odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
In [100]: dump_errors(odrv0)
system: no error
axis0
axis: no error
motor: Error(s):
MOTOR_ERROR_UNKNOWN_TORQUE
MOTOR_ERROR_UNKNOWN_VOLTAGE_COMMAND
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
I read about adding 22nF capacitors to the hall inputs. I’ll pick up a few tomorrow and give that a try.
I also tried around with the motor types - no difference.
- Start with HIGH_CURRENT until after the motor calibration, then switch to GIMBAL.
- Do the whole procedure as HIGH_CURRENT
I am currently running from a benchtop supply that can provide 36V 2.3A max. Should I rather switch over to a 42V e-bike battery?
When giving a quick look to my configs, can you see anything that’s “just off” and wrongly configured?