Thread: PID Control
View Single Post
  #9   Spotlight this post!  
Unread 07-04-2007, 23:41
John Gutmann John Gutmann is offline
I'm right here
AKA: sparksandtabs
FRC #0340 (GRR)
Team Role: Mechanical
 
Join Date: Feb 2005
Rookie Year: 2004
Location: rochester
Posts: 804
John Gutmann has a brilliant futureJohn Gutmann has a brilliant futureJohn Gutmann has a brilliant futureJohn Gutmann has a brilliant futureJohn Gutmann has a brilliant futureJohn Gutmann has a brilliant futureJohn Gutmann has a brilliant futureJohn Gutmann has a brilliant futureJohn Gutmann has a brilliant futureJohn Gutmann has a brilliant futureJohn Gutmann has a brilliant future
Send a message via AIM to John Gutmann Send a message via MSN to John Gutmann Send a message via Yahoo to John Gutmann
Re: PID Control

Quote:
Originally Posted by The Lucas View Post
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)


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).

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

I won't be in Atlanta and I am not doing this for my team, I am inquiring for my own project. I have a robot that I am working on being GPS controlled, and I may or may not use PID Loops for that ( I don't believe it is entirely neccessary for some parts). The robot that I am (it is at home I get to start again after college lets out) building has 14 inch wheels, good for off road driving, and they stick out past the ends of the frame, so anyway it falls it will beable to drive. I was thinking one cool thing to add is to make it balance, since the wheels stick out past the frame it is very possible. And I have a pnuematic compressor and solenoid and cyclinder I would like to put on so I can hit a balance button and it pushed it self up and starts to balance. I think it is unneeded in the project but it will be pretty cool. Like if I bring it to a team demo, you just see a robot driving around, but then it goes from 4 wheels flat to a 2 wheel tall!? I just think it would look cool and help me learn how to program some more complicated stuff. I will probally be posting more threads and posting pictures of the progress once I get started up again, so look for it around the end of may. Should be pretty cool.