My team has been working to build a turreted shooter. We have all of the physical components set up. We also have working camera code. The issue is that our PID loop on the turntable doesn’t work properly. For some reason, the loop stops moving as soon as it is within 30 degrees of where it should be, regardless of what we put in setAbsoluteTolerance(). Does anyone have a tip for what we are doing wrong? Thanks.

What are your P, I, and D values? Tuning these should help your PID loop run correctly.

We started just adjusting P, and tried a wide range of values from .00001 to .05. I seemed to do nothing, no matter what it was. D made a difference, but it still won’t stop near the setpoint.

If you are using Talon’s closed-looping features , check out…

“section 16.31. My Closed-Loop is not working? Now what?”

…in the Talon SRX Software Reference Manual.

Right now we aren’t using a Talon for it. We have one spare SRX though, would it be worth it to use it instead of a spark? I know it can do the PID loop on its own, so it might be useful.

Try going higher on P. Set it to 1.0 and see what happens.

the way I start with P is to look at how it is used. First you need to know the units of your feedback. Is it degrees? encoder counts? if it is not in “engineering” units like degrees, I would convert that first. the encoder can be set to how many ticks per unit.

next set I and D to 0.

what is the biggest error you expect to see? 20 degrees? the largest output for the motor is -1 or 1, so set P such that the biggest error times P equal to max motor output. so if 20 degrees error is 1.0 motor output, then P is 1/20 or 0.05.

you should be able to get 95% of the way there by just using P. if you are oscillating, then P is too high. if it takes forever to get there, then P is too low.

If you can not get close with just P alone, then you have a mechanical or logical error. D and I just make you faster and more accurate, but should be small contributions.

can you tell if your PID is still active? when/how do you enable it and disable it? are you able to monitor the encoder input, the motor output and such on smartdashboard? use the graphing functions in smart dashboard to watch what is happening.