Go to Post Do not interrupt, do not defend yourself - just listen. After they are done, be sure to thank them for their honest feedback, and close the books. Arguing or defending is not how to accept feedback. - DonRotolo [more]
Home
Go Back   Chief Delphi > CD-Media > White Papers
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

photos

papers

everything



PID Control Theory for FRC Programming

Matt Krass

By: Matt Krass
New: 10-04-2006 21:43
Updated: 10-04-2006 21:43
Total downloads: 11156 times


An explanation of the concepts and theories behind PID control as it applies to FIRST robotics with simple examples and a quick overview.

Contains two code samples, an explanation of the basic PID equations and a few tips and tricks for their use in FRC programming.

Attached Files

  • pdf PID Control Theory Rev 3

    PID Control Theory_rev3.pdf

    downloaddownload file

    uploaded: 10-04-2006 21:43
    filetype: pdf
    filesize: 38.64kb
    downloads: 11154



Recent Downloaders

Discussion

view entire thread

Closed Thread

10-04-2006 22:44

Mike


Unread Re: paper: PID Control Theory for FRC Programming

Great job, helped me out a bunch.



10-04-2006 22:51

Tom Bottiglieri


Unread Re: paper: PID Control Theory for FRC Programming

Just a note:

The equations given in text state the following:

POUT = KP * KERR

But your code shows the proper integer based math method of performing this expression.

POUT = KERR * KP

It's quite clear why the variables need to assume this order, but I did not find it documented that there IS a difference between the "text book" equation and your example.. (it is more accurate to "round" later in the equation, after your numbers have built up.)

Either way, great paper! I plan to include this in my "required reading" for new programmers on my team.



10-04-2006 23:59

Matt Krass


Unread Re: paper: PID Control Theory for FRC Programming

Quote:
Originally Posted by Tom Bottiglieri
Just a note:

The equations given in text state the following:

POUT = KP * KERR

But your code shows the proper integer based math method of performing this expression.

POUT = KERR * KP

It's quite clear why the variables need to assume this order, but I did not find it documented that there IS a difference between the "text book" equation and your example.. (it is more accurate to "round" later in the equation, after your numbers have built up.)

Either way, great paper! I plan to include this in my "required reading" for new programmers on my team.
I'll keep that in mind for the next revision of the paper. Meanwhile if anyone has any comments or suggestions, feel free to post them here, or PM/Email them to me. I hope this paper is of use to everyone and I'm also available to answer specific questions either through CD or the contact information in the paper.

Good luck!



11-04-2006 00:03

Greg Marra


Unread Re: paper: PID Control Theory for FRC Programming

Well written and very clear!

You may want to consider adding some comments to the code examples, such as why you limit to +-127 in case any completely new FRC programmers read this.



12-01-2007 15:21

Mike


Unread Re: paper: PID Control Theory for FRC Programming

I used this paper today as a reference when writing 237's PID control code.

Bumping it up to bring to the attention of other teams.



12-01-2007 17:51

Guy Davidson


Unread Re: paper: PID Control Theory for FRC Programming

Thank you very much for this paper. This really helped me undferstand the concept of a PID, and will definetly be used when we write our PID code.

-Guy



19-02-2007 10:30

LieAfterLie


Unread Re: paper: PID Control Theory for FRC Programming

Very helpful. You might want to move the P code example showing the #define KP 5 / 10 to between the P and I sections though, as it doesn't show I control.

I finally learned what this PID stuff is about, thanks.

You might want to also mention that since motor velocity control is a speed you're comparing encoder ticks per time rather than a target value that has a defined range, and therefore also give us a simple method for determining the range, such as maybe start at this many ticks per time period as the min/max, then scale it down when the motor is full and gives less than that number, then printf that max to initialize it to for future code so that it starts out at the right range. I know this really goes beyond the basic PID concept, but it is relevant to speed control.



19-02-2007 10:59

LieAfterLie


Unread Re: paper: PID Control Theory for FRC Programming

Maybe even add some visual aids, graphs... ?



18-05-2007 13:30

kwilliam


Unread Excellent paper!

Matt, this is an AWESOME paper! I wish I had read it earlier when I was learning PID control this year. I read this one instead and had the programming team read it, but your paper is an improvement. Wonderful explanations, good example code, and excellant usage scenarios! I will be sure to include a link to your paper in our own programming team's handbook.



18-05-2007 17:23

tseres


Unread Re: Excellent paper!

...
[dotdotdot]
i'm a new programmer, and well, i don't understand how this works....i sort of understand the concept...you get feedback somehow from the robot....ya...that's about all i understand....



21-05-2007 09:46

Qbranch


Unread Re: Excellent paper!

Quote:
Originally Posted by tseres View Post
...
[dotdotdot]
i'm a new programmer, and well, i don't understand how this works....i sort of understand the concept...you get feedback somehow from the robot....ya...that's about all i understand....
A little off topic, but, if you need some help with the interfaces to sensors and such, i'll be happy to help. Also, check out this post on on-chip peripherals and this one on encoders..

If you are going to IRI, just come by the field and you'll see the 1024 pit area. Ask anyone on the team for "Q" and they'll point you in the right direction. Good luck!

-q



21-05-2007 12:29

tseres


Unread Re: Excellent paper!

thanks so much....although i wont be going to IRI...lol....but thanks



23-05-2007 17:25

tseres


Unread Re: Excellent paper!

ahhhhh...after looking at a lot of other things....

so i guess PID is basically having software control the robot rather than just the PWM outputs are the same as the joystick values...so there's a layer of software that processes all the input and output data.



23-05-2007 17:54

JBotAlan


Unread Re: Excellent paper!

Quote:
Originally Posted by tseres View Post
ahhhhh...after looking at a lot of other things....

so i guess PID is basically having software control the robot rather than just the PWM outputs are the same as the joystick values...so there's a layer of software that processes all the input and output data.
Exactly. Programming this way makes you paranoid--you start to trust the code, have a sensor go bad on you, the arm takes off and tries to rip the control system off the robot while destroying a gear box (BaneBots... ) and you don't hit the disable switch fast enough. (true story, times about 50 this season )

But don't let that steer you away from a smarter robot. The pros greatly outweigh the cons. For example, auton becomes easy.

Good luck,
Jbot



23-05-2007 18:27

tseres


Unread Re: Excellent paper!

ya..i know it's not easy, but it is worth it. this year we didn't really have any PID, but the driving was sort of "software controlled". the only problem is we didn't have any sensors and our robot can't go straight. lately i have been developing omni code potentially for next year that uses a gyroscope. we dont need any encoders because the gyroscope algorithms/functions we made will automatically correct for any motor error.



23-05-2007 22:39

Alan Anderson


Unread Re: Excellent paper!

Quote:
Originally Posted by tseres View Post
...the only problem is we didn't have any sensors...
The entire basis of a PID control routine is the ability to sense what's going on and take action to make it match what is desired. Without sensors, you can't have any sort of closed-loop feedback control.
Quote:
...we dont need any encoders because the gyroscope algorithms/functions we made will automatically correct for any motor error.
Gyroscopes are fine for rotational sensing, but without encoders, how is the robot going to know how fast or how far it's moving?



24-05-2007 03:28

Salik Syed


Unread Re: Excellent paper!

I guess if all they really want to control is orientation that shouldn't matter.

But on the topic of the paper : great idea, I think the community needed a simple down-to-earth explanation. I know it was pretty overwhelming sophmore year trying to figure it out on my own without any real programming experience or calculus experience.

I also like how you gave a lot of ideas for applications, that is very useful... alot of people think PID is just useful for moving arms and such but it can be used for a lot of other things !



view entire thread

Closed Thread

Tags

loading ...



All times are GMT -5. The time now is 09:58.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi