First a couple tips
First of all I would look at Kevin's
2005 navigation code . It has files in it (pid.c & pid.h) that can serve as a good base (I moded it significantly) for generic PID control, plus the structs make it easy to reuse for multiple loops.
Second if you are going to try to install this in Atlanta I recommend using pots or the EEPROM (if you already have that working) to set the P, I & D constants since time is a major factor and it take too long to redownload to change constants.
Third if you are using the Camera as your main sensor, realize that the camera doesn't give you data every loop (about every 3 loops) so set the last error and error only when you get new data from the camera so it calculates the D error correctly.
Fouth, the on the Victor 884s the deadzone center point is 132 or 133 (PWM_ZERO is 132 in Kevin's code) not 127. Keep this in mind so your robot doesn't favor forward or backward. Also be careful reversing direction of motors in code (for simplicity I just swap wires)
Quote:
Originally Posted by sparksandtabs
Is that what majority of code does for the Intergral part, just reset it once the target is reached? This is one of the only parts I have always been consfused about, because you you have a huge buildup (even if it is capped) your always going to overshoot. Becuase I would still like to have it in there incase lets say i get stuck on a piece of string (just an example) then it will increase the motors until the string breaks.
|
I personally set the I error to 0 when it is on target and when it overshoots (error changes direction since it may never be "on target" when it goes past).
You may want to use I only when your close to target as has been suggested (I prefer not to).
Quote:
Originally Posted by sparksandtabs
The other thing I need more help with is the derivative constant, should I make the constant negative? because if it it positive then when you have a big change your just gonna add even more to the output.
thanks,
John
|
The derivative term works in the oppose direction as the other 2 term. It damps oscillation and effectively sets a speed limit on your motion (it will also resist external impulse but that was more important last year). Be careful not to "overdamp" the system to where you need to set P and I very high to overcome D.
Good luck I'll be in Atlanta if you need any help,
-Brian