Quote:
Originally Posted by Mr. Lim
The problem is that our wheel speeds never reach our desired SetPoints. When our SetPoint is 10000 counts per second for instance, our wheels only reach about 5000 counts per second.
Right off the bat, many of you will suggest we up our P constant, however increasing it any more results in our wheels oscillating very badly, especially at low speeds.
Can anyone else share some of their experience in getting velocity-based PID to work with the supplied WPILib?
At this point, I'm not sure if I can simply tune the PID constants to get it working the way we want it to, or if we need to tweak the PID Controller class itself - i.e. getting the Proportional response to be non-linear. Should we only be using the I term?
|
Mr. Lim
As other have stated, you
need integral control in order to have zero tracking error in steady state in a velocity control scheme. That's because in order to track a step reference change, you need an integrator in the compensator (which you don't get with a proportional controller) or in the plant (which you don't get when dealing with velocity). If you were controlling position, then you would probably be OK with a proportional controller (except if you had a considerable deadzone), because then the integrator would be present in the plant.
It might be easier to think of it in these terms: you need a voltage to keep the motor spinning. If you were to reach the desired setpoint speed with a proportional controller, then the error would be zero, and your control effort K*error would also be zero, so your motor would no longer be at your setpoint. In position control that's not a problem, because if you're at the desired setpoint you shouldn't be applying any voltage for it to move.
If you want to understand this deeper, look up
internal model principle in a good book or even Google. I can try to explain it if you can work in the frequency domain.
Regarding the use of the I term alone, it will work, BUT, if your system can be represented by a second order model (and it is very likely that this is a good approximation), then your response will be at best two times slower than in open loop (as in, it will take twice the time to reach the setpoint than if you did not have any control at all). Sure, you will be driving at the precise velocity you want, but you'll be accelerating slower than your opponents, which is never a good thing in a competitive FIRST field.
The best thing would be to use the full PID controller, but it can be tricky to tune without a reasonably good model. I recommend you stick with PI.
You can even predict what your error will be with a proportional controller. Here's what you do: in open loop, apply a voltage step to the motor and determine its steady state velocity. Divide this velocity by the amplitude of the step you applied and call this number the
plant static gain G(0).
Now close the loop with a proportional controller with gain K. The steady state error (that is, your desired setpoint - let's call it A - minus the actual velocity you're reaching) should be equal to A/(1+ K*G(0)).
You should try this simple test to see that there IS logic behind control systems...
If you are using a Victor, then your results will not be correct, because changing the Victor input from 0.5 to 1.0 does not mean the output voltage doubles. The Jaguars are
a lot linear-er in this aspect, and that's why I strongly recommend them for control loop applications, EVEN if their failure rates were much worse than the Victors - in our experience, they are similar, even though we had been using the Victors for a longer time.
Sorry for the long post, but I hope someone learns something from it!