The slow down to zero RPM’s takes a while, I am not sure if there is a parameter that I can change on the firmware or something elsewhere that can be done (maybe braking resistance?).
I am using an Arduino via UART. I know there has to be some ramp down so that it doesn’t overshoot, but it takes something like a 1/2 of a second to slow down which seems pretty slow.
Any input? Thanks!
Arduino code for tuning
for (int motor = 0; motor < 2; ++motor) {
odrive.SetParameter(motor, odrive.PARAM_FLOAT_CURRENT_CONTROL_CURRENT_LIM, 12.0f); // [A]
odrive.SetParameter(motor, odrive.PARAM_FLOAT_VEL_LIMIT, 150000.0f); // [counts/s]
odrive.SetParameter(motor, odrive.PARAM_FLOAT_POS_GAIN, 10.0f); // [(counts/s) / counts]
odrive.SetParameter(motor, odrive.PARAM_FLOAT_VEL_GAIN, 10.0f/10000.0f); // [A/(counts/s)]
odrive.SetParameter(motor, odrive.PARAM_FLOAT_VEL_INTEGRATOR_GAIN, 50.0f/10000.0f); // [A/(counts/s * s)]
}
I take it you are running velocity control?
I think so, but I am not really sure if I am looking in the right spot or for what… Sorry…
void set_pos_setpoint(Motor_t* motor, float pos_setpoint, float vel_feed_forward, float current_feed_forward) {
motor->pos_setpoint = pos_setpoint;
motor->vel_setpoint = vel_feed_forward;
motor->current_setpoint = current_feed_forward;
motor->control_mode = CTRL_MODE_POSITION_CONTROL;
#ifdef DEBUG_PRINT
printf("POSITION_CONTROL %6.0f %3.3f %3.3f\n", motor->pos_setpoint, motor->vel_setpoint, motor->current_setpoint);
#endif
}
void set_vel_setpoint(Motor_t* motor, float vel_setpoint, float current_feed_forward) {
motor->vel_setpoint = vel_setpoint;
motor->current_setpoint = current_feed_forward;
motor->control_mode = CTRL_MODE_VELOCITY_CONTROL;
#ifdef DEBUG_PRINT
printf("VELOCITY_CONTROL %3.3f %3.3f\n", motor->vel_setpoint, motor->current_setpoint);
#endif
}
void set_current_setpoint(Motor_t* motor, float current_setpoint) {
motor->current_setpoint = current_setpoint;
motor->control_mode = CTRL_MODE_CURRENT_CONTROL;
#ifdef DEBUG_PRINT
printf("CURRENT_CONTROL %3.3f\n", motor->current_setpoint);
#endif
}
In your arduino program, do you call set_position, or set_velocity?
set position
if (digitalRead(buttonFpin) == LOW)
{
float pos_m0= (0,3000) ;
odrive.SetPosition(0,pos_m0);
}
Hi @Brandon_Lima
My guess is that this a gain related issue. You have a relatively low pos_gain
and a large vel_integrator_gain
. If you are commanding the odrive to instantaneously move to a far away position then there is a large integrator error at the beginning of the run resulting in a rapid acceleration. However as you approach the target position the integrator error will rapidly fall off resulting in the pos_gain
becoming the dominant term and this will cause it to slowly settle on the final position. I’m not 100% sure that your problem (i’m still learning the PID control theory) since the gains will vary a lot between motors and setups but its my best guess.
Therefor perhaps try increasing your pos_gain
and reducing your vel_integrator_gain
and see if that helps. If you haven’t already then I also suggest you try tuning your gains.
Thanks! Ultimately I was able to get it to do what I was looking for by playing with the different tuning settings.
Thanks for the input!
1 Like