Spinning after enabling closed loop control


#1

I’m having an issue where the motor on one axis starts spinning uncontrollably after enabling closed loop control. The steps I take in odrivetool right after bootup are as follows:

In [1]: odrv0.axis0.requested_state=AXIS_STATE_ENCODER_INDEX_SEARCH

In [2]: odrv0.axis0.requested_state=AXIS_STATE_CLOSED_LOOP_CONTROL 

starts spinning

I got a printout of axis0, and interestingly pos_setpoint seems to take a very large (absolute) value (-1.0744717534594085e+24):

In [5]: odrv0.axis0                                                                                                 
Out[5]: 
controller:
  start_anticogging_calibration()
  current_setpoint = -0.0 (float)
  vel_setpoint = -2.943871909072946e+21 (float)
  vel_ramp_enable = False (bool)
  error = 0x0000 (int)
  set_pos_setpoint(pos_setpoint: float, vel_feed_forward: float, current_feed_forward: float)
  set_vel_setpoint(vel_setpoint: float, current_feed_forward: float)
  vel_integrator_current = 0.0 (float)
  vel_ramp_target = 0.0 (float)
  set_current_setpoint(current_setpoint: float)
  pos_setpoint = -1.0744717534594085e+24 (float)
  config: ...
  move_to_pos(goal_point: float)
requested_state = 0 (int)
motor:
  timing_log: ...
  current_meas_phC = -0.036374807357788086 (float)
  gate_driver: ...
  config: ...
  phase_current_rev_gain = 0.05000000074505806 (float)
  DC_calib_phB = -2.629551649093628 (float)
  error = 0x0000 (int)
  is_calibrated = True (bool)
  armed_state = 0 (int)
  current_meas_phB = -0.19068455696105957 (float)
  DC_calib_phC = -2.703293561935425 (float)
  current_control: ...
encoder:
  is_ready = True (bool)
  vel_estimate = 0.0 (float)
  count_in_cpr = 3234 (int)
  pos_estimate = -54109.76953125 (float)
  pos_cpr = 3234.234375 (float)
  config: ...
  shadow_count = -54110 (int)
  interpolation = 0.5 (float)
  error = 0x0000 (int)
  phase = -1.6917487382888794 (float)
  hall_state = 3 (int)
  index_found = True (bool)
config:
  startup_closed_loop_control = False (bool)
  counts_per_step = 2.0 (float)
  spin_up_current = 10.0 (float)
  enable_step_dir = False (bool)
  ramp_up_distance = 12.566370964050293 (float)
  startup_motor_calibration = False (bool)
  ramp_up_time = 0.4000000059604645 (float)
  step_gpio_pin = 1 (int)
  startup_sensorless_control = False (bool)
  spin_up_acceleration = 400.0 (float)
  startup_encoder_offset_calibration = False (bool)
  dir_gpio_pin = 2 (int)
  startup_encoder_index_search = False (bool)
  spin_up_target_vel = 400.0 (float)
current_state = 1 (int)
error = 0x0000 (int)
get_temp()
step_dir_active = False (bool)
trap_traj:
  config: ...
sensorless_estimator:
  pll_pos = 2.9749515056610107 (float)
  config: ...
  vel_estimate = -0.20460842549800873 (float)
  error = 0x0000 (int)
  phase = 2.9748737812042236 (float)
loop_counter = 2993403 (int)

resetting this value manually seems to have no effect and on a next printout it still remains unusually large.

I’m on 0.4.7. This occurred once in the past and I ignored it, but now it seems to become a repeating pattern.

Any help/ideas would be greatly appreciated.


#2

What is your mechanical setup? I had a similar issue and it had to do with calibration where there was not a consistent load while it calibrated.

Although looking at the motor during calibration it looked as if it was moving at a consistent speeding, looking at the size of the pulses from the encoder on a scope showed they were different. We removed the load during calibration and it has worked fine since.

-Brandon


#3

@Brandon_Lima thanks for the reply (and apologies for the delay, holidays got in between!).

I indeed have an imbalanced/variable load on the motor, but I always remove it when doing motor calibration (but not when encoder is searching for index pulse).

If it’s any help, I solved the issue (for now at least) by restoring an older configuration and reflashing the same firmware (4.7)