Skip to main content

Down The VelocityTorqueCurrentFOC Road

How to tune for Velocity

We like to use MotionMagic because it makes speed changes smoother! We use MotionMagic for basically all of our motion profiles.

When using a velocity profile, you are trying to get the motor to a specific velocity instead of a specific amount of rotations.

The Plot

In Phoenix Tuner, plot Velocity (rotations/sec) and Acceleration (rotations/sec2).

You might want to turn off Acceleration because it is a very noisy signal

Then also plot Reference (rotations/sec) and ReferenceSlope (rotations/sec2).

Make sure the Reference and ReferenceSlope are from PID_VELOCITY (not PID_POSITION)

 

Configurations

Motion Magic

  • Start with the MotionMagic configs

    • We don't use the cruise velocity gain because we are trying to get to our target velocity, not this velocity we are setting

    • Make cruise acceleration 4, and double from there if needed after more tuning

FeedForward and FeedBack

Try to minimize the amount of feedback gains while tuning, but use them if necessary

  • kS
    • Set to 1 and start doubling (use binary searching to get the optimum value)
    • We are trying to get the smallest kS possible before the motor starts turning
  • kA
    • Change it based on the Reference and our current Velocity signals
    • The steeper the slope of the Reference, the more we have to increase kA in order to get the Velocity to match it
    • A steeper slope means a higher kA and vice versa
  • kV
    • After getting the Velocity to peak along with Reference, it's time to raise kV
    • Increase kV until the Velocity line stays straight and is closely matching the Reference

These should get you pretty close to the Reference line - change kP and kD a little bit to get to your desired accuracy!