SparkMAX not properly using kF? (PID problems)

Hello all,

We are trying to use a PID closed loop on our flywheel shooter (driven by 2 NEOs) to run it at a constant RPM. While tuning the PID loop, we found that the actual RPM was consistently about 80% of the desired RPM at steady state. This should not happen if our feedforward is correctly set (right?).

To check our feedforward value, we set the P, I, D gains to 0 and tried to run the flywheel. Unfortunately, it didn’t move. We tried to use the Spark MAX Client to check what the SparkMAX thought the feedforward value was, but it (erroneously?) said that our kF was negative eight billion or so. We tried to change it to a more reasonable value, but the client prevented us from doing so by changing the kF value before the configuration was saved.

How can I make sure that my feedforward value is being properly set? Is our code setting it correctly? Should I expect the flywheel to be able to run using only kF (with other gains set to 0)?

Language: Java
Relevant Code: github link

From a theoretical standpoint, using on F is enough to make a motor spin if F is implemented as proportional to the setpoint, which is the most common way for velocity in FRC.

Last year when we were testing sparks and neos we had many issues with firmware and the Spark MAX Client, so make sure you are running the latest firmware and client versions.

A proper kF value would only work perfectly at a single setpoint. Essentially it is the output required to maintain velocity at the setpoint. If you can change your setpoint, you will either have to set your kF for a low setpoint and let PID try to correct with a high kP. You really should use the arbitrary feedforward feature based on the setpoint.

We have exactly the same setup, two NEOs driven by SPARK MAX controllers for our shooter. We used the Robot Characterization tool to get feedforward values to plug into SimpleMotorFeedForward and it worked great. We can set our PID values to 0 and we hit the setpoint. We only need PID to get up to speed quicker and recover after shooting.

Here’s a link to our characterization project, if that helps at all.

Here’s a link you our code. There are a couple equations you can ignore that we use to calculate the RPM for the target distance.

We have found that the CANSparkMAX PIDController hasn’t been accurate compared to our own PID Controller so at this point we have made our own position and velocity PID Controllers.

We have got the opposite results. We have received very good results using sparkmax PID controller on our shooter.

You can set the PIDF gains in the code. I would recommend setting the gains in your code then in the client.

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