Hey all, we’re attempting to use a PID loop for our intake arm, and seem to be running into some issues.
First one being I can get it mostly working, though once it gets to it’s position to takes too long to realize it needs to stop pushing it in that direction, and has almost caused our intake to snap itself.
I was told to look at doing the PID loop through the Spark Max controller that we are using for that motor, but I don’t think we’d be able to as we’re using an absolute encoder (REV through bore) but don’t have the part to connect it directly to the Spark Max.
The actual code is located here. I need to push up the changes that were made at yesterday’s event still.
Any help would be greatly appreciated, I’m super confused and would really like to be able to get this to work for the team.
Even if you don’t have the absolute encoder adapter, you can set soft limits in your code, so that once the motor gets at or past a certain value, it will stop.
So you can zero your intake arm in it’s retracted position on code startup. And then command it to go from there to whatever value corresponds to the deployed position.
Also note that since your I gain is nonzero, you may see windup and overshoot behavior where the mechanism does not stop at target. The link oblarg posted should help show the effects so you get a sense of what each knob should be doing.