![]() |
Tuning PID Code
Help us, Kevin, you are our only hope! Or someone else...
Our programming guy (robotaddict -- my son as it turns out) has written single-stick code based heavily on Kevin's PID code routines. It's been a long, difficult road for a student who had little C experience at the beginning of the season, but the code seems to work pretty well. The wild oscillations are gone, and the robot is drivable. But there are some problems. I'm hoping some of you with real-world PID experience can give John -- er, I mean robotaddict -- some guidance of final debugging. We also use these routines for aiming and autonomous, so it is important that he fix them. John and the programming mentors have tweaked the P,I, and D settings a LOT, but the perfect blend of settings has been elusive. 1. The controls are pretty sensitive. Turning is especially twitchy. 2. Can someone describe the PID tuning process in even more detail than Kevin does in the comments in his code. Careful descriptions of what the robot is doing in relation to each of the control settings would be especially appreciated. 3. The robot nearly drives in a straight line, but gently drifts to one side in a long (say 30-40 feet) drive. Thank you SO MUCH in advance. |
Re: Tuning PID Code
I am facing this challenge too, except PID code is controlling the position and elevation of our turret, plus its steering and autonomous mode.
There is no one in my area who has responded with any PID experience except those that use it for temperature control. This leaves me with many questions about the best way to do PID control, like how long should the I values stick around? For something like controlling the spin (yaw) of a turret, should I even use I, or switch to PD? Quote:
Eagerly waiting, Robinson |
Re: Tuning PID Code
Quote:
|
Re: Tuning PID Code
Quote:
The actual PID algorithm is not very complex, just the tuning process. I found this on the Wikipedia for PID Controller: Quote:
Robinson |
Re: Tuning PID Code
Also, while I am at it, note this post (and the rest of the thread, really)
Quote:
Send us more luck, Robinson |
Re: Tuning PID Code
Quote:
Unless your robot will sit in the middle of the field for the entire match, I don't think it's really necessary. :) There will be much larger errors induced by motion than the (usually small) steady-state error. |
Re: Tuning PID Code
Quote:
Thanks in advance, Robinson |
Re: Tuning PID Code
I won't go in the method of tuning a PID as others have done, but here are some tips to get you up in running FAST.
1. Use three POTs on a board labeling them P,I,D. Connect them to Analog ports. Say 14,15,16 respectfully. Make a function to read the pots, and then multiply the values out. Like K_P = analog14 * 0.0001. Of course K_P needs to be a float. Your analog will be 0-1024 so you need to make your K_P, K_I, K_D values smaller, normally less than 1 K_P = analog14 * 0.0001 K_I = analog15 * 0.0001 K_D = analog16 * 0.0001 If you need a bigger "tweak" just shrink the multiplier K_P = analog14 * 0.001 K_I = analog15 * 0.001 K_D = analog16 * 0.001 You won't be able to view K_P in your "Print to Screen" so just display your analog value, so you can multiply or divide back to get your "real" K_P,K_I,orK_D value to "hard code" it back into the system so you can REMOVE the PID trimmer pot board. 2. Wow...use LABVIEW to tune your PID system. We tuned our ball velocity PID by connecting the ball motor to PWM1, then mapped our velocity variable to PWM2. Start Labview Dashboard. Both applications, the connections one, and the view application. Of course there ARE NO MOTORS connected to PWM2, we are just transporting the information to Labview because we don't know how to edit Labview. Out of the box, PWM1 and PWM2 was configured in a graph......;-) See these handy video tutorials if you haven't done it yet. http://www.lasarobotics.org/Forum/viewtopic.php?t=366 Now you can view your PWM1 which is your motor OUTPUT, and your pretending that PWM2 is your velocity output so you can just use Labview PWM2 to view, graph and log your PID tuning. You'll see very quickly how effective this tool is. In combination of the two tools, making a PID tuning POT trimmer board, and displaying the tune on Labview, you'll have your PID tuning done in a matter of minutes. Hopfully this helps. - |
Re: Tuning PID Code
Mr. Elston, first off, what an amazing idea. Our team had nightmares tuning last year, we didn't get the values right until Atlanta! (albeit, we didn't have much testing time before hand anyway)
Quote:
|
Re: Tuning PID Code
Quote:
We used the box to set the PID constants for our turret, drivebase position seek, and direction tracking; and for setting the motor speed and timing for the catapult winder mechanism we started with. We will probably be doing the same thing for our PID parameters this year, with the additional feature of using menus and commands through the program port to save the data to EEPROM the way Kevin Watson's camera software works. |
Re: Tuning PID Code
1 Attachment(s)
Yes you can.
You'll need 3 100K pots. See this document: http://www.ifirobotics.com/docs/lega...-2004-2-17.pdf PDF Page #5 Each port provides four analog inputs. These inputs are typically connected to joysticks and potentiometers, providing an analog input ranging from 0 to 254 (in software) that is transmitted to the Robot Controller. In the event that an analog input is less than 0.05V, a value of 127 will be generated. This ensures that when a joystick is unplugged, the corresponding output on the Robot Controller will not go to a full reverse condition. Each port provides +5V Aux, used for wiring to potentiometers or other sensors. The wiring diagram for a potentiometer is shown below. Always use 100kΩ potentiometers. You'll need to "borrow" a joystick port. And then scale your PID to something different like 0-254 instead of 0-1024 like you would see on the analog port of the RC. WARNING....UNPLUG....PID pots when in competition.....LOL.... WARNING #2....Make sure that your values default to 0 when radio drops...because by default they go to 127. I like the pots onboard the robot the best, when robot was up on blocks. Though the below picture looks "kewl" from the OI, RC tuning from the analog was my favorite.... |
Re: Tuning PID Code
Mr. Anderson & Mr. Elston,
Thank you for confirming this. This is going to save so much time for us :), we're hoping on getting this tuning board built today. Thanks again for the help =) |
Re: Tuning PID Code
Ok, so our team looked around the lab for 100 K ohm potentiometers, and we could not find any. So after some thought we decided to slice open the KOP Joystick from last year (it was semi-busted anyway) and extract the 2 potentiometers from there.
To our surpise, these pots are 120K ohms, can we still use them for the PID trimming board? Seems to me that if they were used for the KOP joystick, there is no reason why they would pose a threat. Thanks for your help, I just want to make sure because that OI is mighty expensive to repair/replace if we blew it...:p |
Re: Tuning PID Code
As a side note, I have read that the easiest way to tune a full PID controller is to increase your P constant until there is a constant steady-state error, then increase your I constant until the steady-state error is gone and you have minor oscillation. Finally, increase the D constant to soak up any oscillation.
Hope this helps! We'll have some tuning to do pretty soon ourselves hopefully... |
Re: Tuning PID Code
Quote:
-Kevin |
| All times are GMT -5. The time now is 01:33. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi