Where to set F to start on a pidf control?

We have used PID control successfully for the last 2 years. I have seen several threads that suggest using F and P to set velocity control for a flywheel. Wondering where a good place to start with our F value if want our NEO to run at 4200 rpm and how is that determined?

The impact F has on your system is kF*setpoint, meaning it doesn’t use a sensor.

Although you can technically calculate it, I’d start small and work your way up. Plot desired velocity vs actual velocity, and increase F until they’re close together. Then add P, I, and D as you need. I believe the robot characterization tool has an option for
a generic sensored system (@Oblarg?)


The CTRE Phoenix docs say the same thing. Start increasing F until the system is responding close to how you want, and then start adding P, I, D terms.


(while these docs are specific to CTRE devices, the theory is the same)


Flywheels are pretty easy to control, you can get a good starting point just thinking about units.

If the formula for feedforward control is K_f * setpoint = output, and given the assumptions…

a. The speed of a DC motor is governed by the equation \omega = K_v * V, where \omega is angular velocity, V is voltage, and K_v is the speed constant of your motor

b. Your setpoint is measured in RPM

c. Your output is in volts

…then we can take the feedforward formula, transform it into K_f = output / setpoint, which basically means that K_f is the amount of volts per RPM that we want to add to the motor. This is equal to 1/K_v

REV helpfully lists the K_v value of the NEO at 473, so assuming that your units are the same as this example, 1/473 = ~.002 might be a good starting value.

1 Like

Correct me if I’m wrong, but I believe you put Kv on the wrong side of that equation.

Wikipedia lists it as K_v = \omega_{no-load} / V_{peak}, which is the same thing (a little more specific).

1 Like

Whoops, total brain blip.

How would you plot?

If you pass your calculated velocity from your encoder to your shuffleboard, you can simply right click on it to plot. Also, if you are using Talon SRX there is a plot option in the ctre phoenix tuner. I am pretty sure Spark MAX has a similar way of plotting velocity.

1 Like

Assuming you don’t have a sparkmax/talonSRX/talonFX:
Look into plotting a variable with shuffleboard or smartdashboard.
You’ll need a sensor to collect the velocity data.

“Graph widgets for numerical data”

You can also use shuffleboard to dynamically adjust a variable, so if you expose the kF/kP/kD values as variables then you can tweak them without having to re-deploy code. Just make sure to capture your work when you’re done!

Yes, Phoenix Tuner and the REV SparkMax Client have similar features.


this whitepaper has some good information that my team has used to great effect


1 Like

I like to think of my F value as “What would I set my motor to if I didn’t have a PID”. That’s a decent layman way to explain it.


I read or watched somewhere – possibly here? - it explained this way:

Imagine that you’re riding a bicycle, and you’re trying to match the speed of a car driving slowly at a constant rate. The PID is you pedalling and adjusting to keep your bike in sync with the car. Wouldn’t it be nice if your bike had an electric assist that would give it a little fixed speed boost? That’s the kF.


This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.