Just a question from a programmer having trouble with his PID loop- we are experimenting with our robot from last year since we don’t the new one completely fabricated, and we’re running into some problems.
The problem the other programmers and I have right now is that we can get our robot to turn 90 degrees (very reliably) but it does so in little spurts of motion. Our values are currently 120 of P, 1 of I, and 80 of D. We would prefer not to raise the Integral value too much because of the unpredictability.
Anybody know how we’d get it so we can turn 90 degrees in one smooth motion?
Thanks, Joe Sanders, FRC Team #294
If the turn stops way too soon, it sounds like your P constant is too low, and/or your D constant is much too high.
It sounds like your D is too high, the robot starts accelerating and the D kicks in and slows it down too much, once it slows down, the D term decreases and it accelerates again.
One way to help debug your PID loop is to have the robot print all the appropriate data with commas delimiting the values. You can then use hyperterminal to capture the data to a file, and import it into excel to graph.
We are using a PID routine for our steering. We connect a pot to the steering gear motor for feedback.
We are calling our routine in Default_Routines and the behavior is somewhat erratic (we are working on the K values).
Should I call this in teleop_spin() and use the Get_ADC_Result_Count() value to determine if something has changed on the pot?
I’m afraid the 22.6 ms loop is too slow. Our steering system moves fairly fast.
We use PD of PID for the turn. We might add I later but it turns well now.
We use wheel encoders.
P = (left wheel count)*turnratio - right wheel encoder count
Turnratio = the ratio of the radius of the inside and outside turns. Smaller the ratio the larger the turns.
Then practice doing that with just P before you do move onto ID.
BTW to know when a turn is done, if you subtract one wheel count from the other it will give you the difference and that will give you the number of degrees no matter how large or small the turn is. For instance an 180 turn on our bot is about 600 encoder clicks diference between wheels or about 3.3 clicks per degree difference.
Keep in mind the fact that you can’t change motor outputs any faster than the 26.2 millisecond loop anyway.
Not strictly true.
With proper code you can use PWMs 13-16 at the maximum 8ms update rate that the Victor’s are designed to accomodate.
Good point, thanks for mentioning it. And, fortunately for those teams whose programmers aren’t experts on the guts of the PIC’s CCP hardware, Kevin Watson has made most of that proper code available on his web site. With a little bit of custom code to set up a repeating timer, the deluxe PWM support functions can do great things.