I’ve been having issues with closed loop control on the SparkMAX’s.
I have ensured that both sides of the drive train have encoders in phase.
positive output yields a positive encoder position/velocity on both.
Using any ControlType, the motors run at either 100% forward or 100% reverse. Changing the PID gains does nothing (unless they are 0).
I am using the latest beta firmware.
Here is a link to my code
Have you looked at our closed-loop examples? Our gains won’t be perfect for your system, but it should get you close. For example, in our Velocity example, our gains are:
kP = 5e-5;
kI = 1e-6;
It looks like some of yours are as high as 2 in some places.
Also, please update to the latest full firmware release, 1.1.31, and the APIs 1.1.9. They must be updated in simultaneously.
I should have updated my Gains class, sorry.
with a P of 0.01, and the rest of the terms at 0, it still goes straight to 100% and oscillates back to -100% almost immediately
It sounds like your PID loop may be underdamped (gains are too high). If you look at our examples the gains are very small as David had mentioned.
For velocity control the example has a kP value of
Another thing to try is to make sure you start from factory defaults before configuring the controller using the
I think Coast mode makes it harder for PID and less precise since the motor will keep spinning without power. Maybe try Brake mode. I don’t know if that is related but it wouldn’t hurt
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.