Position hold with torque limit

All I am using a Odrive to power a electric fishing reel. I am looking for a way to have a position hold but if the fish pulls harder then the current limit allow the position to “slip”.

I am controlling the Odrive using Arduino and currently use a simple if statement to make it work. basically if the motor turns more than 0.1 of a turn then reset the the new position as the SetPosition. code below:

if((POS_setpoint+.1)<(activePOS) || (POS_setpoint-.1)>(activePOS)) {
POS_setpoint = activePOS;
odrive.SetPosition(0, POS_setpoint);

This works very well at low current settings but at high current setting you can really feel the new setpoint being updated. Almost feels like motor cogging. Is there a better way to do this?

Have you tried reducing that .1 to a lower value?
Also, perhaps don’t change the setpoint to the activePOS, but instead change it to the midpoint between POS_setpoint and activePOS. That should be a bit smoother.

Moving it to a lower value does smooth it out but also kind of artificially lowers the holding toque. I kind of like you second idea of using a midpoint setpoint, I will try that soon.

It a tricky problem to figure out with out upsetting the PID controller, I don’t know of a better way to do it.

Maybe you can try to switch to velocity mode with set_vel = 0, once the slip is detected?

1 Like

I’m not sure that would work as the OP intended though (unless vel_integrator_gain is also 0)

@towen yup you are correct the vel_integrator_gain must be set to 0 for it to work. that being said I upped my vel_gain to .9 and it feels really awesome. What’s the negative to leaving vel_integrator_gain at zero?

Thanks in advance.

1 Like

The only real disadvantage there is that you lose precision in position control, which is probably not an issue in your application, but would be an issue in others (robotics, CNC machining etc.)

@towen that kind of what I figured but as you said I don’t need super accurate Position. I am going to try this moving forward and see how it works.

@towen the negative to setting the velocity to 0 and the vel_integrator_gain =0 is that the driver is not applying any torque to try to resist the motors. is there a way I can up the Vel_gain to try to but force the motor to hold 0 velocity? when the vel_gain is high I start to get a vibration in the motor.

If not I need to go back to try a hack for position control mode.

Hmm no, as I originally suspected, velocity control on its own is not enough for what you want.
Maybe you could implement a state machine and switch between position and velocity modes, or maybe just stick with your fast position mode implementation that worked earlier.

What happens if you use velocity mode (with both vel_gain and vel_integrator_gain to some nicely tuned non-zero values), and set a torque limit? I think it should slip at that torque limit.