Sudden and loud movements during calibration

Hi all,

During calibration, my motor ( D5065 270KV) snaps really fast and loud to some positions… (It sometimes also results in me having to reset the odrive)
Please see this video:

video of motor during calibration

Is this normal behaviour during calibration? I am currently using the following:

//motor_calibration
void Calibrate0() {
  
      char c = '0';
      int motornum = c-'0';
      int requested_state;

      requested_state = ODriveArduino::AXIS_STATE_MOTOR_CALIBRATION;
      Serial << "Axis" << c << ": Requesting state " << requested_state << '\n';
      odrive.run_state(motornum, requested_state, true);

      requested_state = ODriveArduino::AXIS_STATE_ENCODER_INDEX_SEARCH;
      Serial << "Axis" << c << ": Requesting state " << requested_state << '\n';
      odrive.run_state(motornum, requested_state, true);

      requested_state = ODriveArduino::AXIS_STATE_ENCODER_OFFSET_CALIBRATION;
      Serial << "Axis" << c << ": Requesting state " << requested_state << '\n';
      odrive.run_state(motornum, requested_state, true);

      requested_state = ODriveArduino::AXIS_STATE_CLOSED_LOOP_CONTROL;
      Serial << "Axis" << c << ": Requesting state " << requested_state << '\n';
      odrive.run_state(motornum, requested_state, false); // don't wait

      //odrive.TrapezoidalMove(0, 0.0f);
   }

I am also using the following parameters

// Setting parameters
  odrive_serial << "w axis0.encoder.config.cpr " << 8192 << '\n'; //amount of counts of encoder
  
  odrive_serial << "w axis0.controller.config.vel_limit " << 10000.0f << '\n'; //this is counts/s
  odrive_serial << "w axis0.controller.config.control_mode " << 3.0f << '\n'; //control mode
  odrive_serial << "w axis0.controller.config.input_mode " << 5.0f << '\n'; // input mode trap trajectory
  
  odrive_serial << "w axis0.motor.config.current_lim " << 20.0f << '\n'; //max is 60A
  odrive_serial << "w axis0.motor.config.calibration_current " << 10.0f << '\n'; //to increase torque during calibration? //see https://docs.odriverobotics.com/api/odrive.motor.error
  odrive_serial << "w axis0.motor.config.pole_pairs " << 7 << '\n';
  odrive_serial << "w axis0.motor.config.torque_constant " << 0.0306f << '\n';
  
  odrive_serial << "w axis0.trap_traj.config.vel_limit " << 4000.0f << '\n'; // some values chosen after some trail and error
  odrive_serial << "w axis0.trap_traj.config.accel_limit " << 200.0f << '\n';// some values chosen after some trail and error
  odrive_serial << "w axis0.trap_traj.config.decel_limit " << 200.0f << '\n';// some values chosen after some trail and error

my next plan was to try and do the tuning as described here but I currently don’t know if I’m on the right track anymore…

The sudden & loud movement occurs when you enter closed loop control. This is “normal” if you haven’t done any tuning yet.
The default gains are set for the most common motor types, but with low inertia motors they could be too high.

I’d recommend setting pos_gain and vel_gain to near zero and vel_integrator_gain to zero before you start the tuning.

It could also be that your encoder mounting is loose. Please make sure there is no movement between the encoder and the motor.

Hi Towen, thank you for the advice and I will try you suggestions soon.

Hello,

I just upgraded the firmware and tried to do the calibration sequence with the odrivetool. It runs a lot smoother now. I did not change pos_gain and vel_gain yet (I will try that in the future).

To be honest I dont know exactly what has changed, but I do think that my arduino code wasnt working that well (even though I think the code is correct). I think that when I write to the odrive through software serial, It sometimes doesnt register well (maybe I write to fast etc…) Anyway I will rewrite the hole program thats for sure.

Just one more question. In the documentation it says:

AXIS_STATE_FULL_CALIBRATION_SEQUENCE — 3

Run motor calibration and then encoder offset calibration (or encoder index search if <axis>.encoder.config.use_index is True).

So, does this mean I don’t need to perform the encoder offset calibration if I plan to use the index search? Because now in my arduino code I do motor calibration, index search, offset calibration and close loop control (in this order)…

The hole calibration sequence still confuses me a bit from time to time. I dont really know what is needed and what not…

The default gains have probably changed in the new firmware. That or perhaps you had saved some gains earlier and these have been reset.

Regarding FULL_CALIBRATION_SEQUENCE - as the documentation says, this is a shortcut, and is equivalent to running MOTOR_CALIBRATION followed by either ENCODER_OFFSET_CALIBRATION or INDEX_SEARCH depending if use_index is set.

If you have set up the index properly then you can set use_index=True so that the startup sequence can use INDEX_SEARCH instead of encoder offset calibration - index search is slightly more robust when there is a load on the motor, but still not as good as having an absolute encoder.