-
-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding PID controller Chapter. #346
base: main
Are you sure you want to change the base?
Conversation
#Proportional-Integral-Derivative Controller | ||
|
||
You are a helmsmen keeping a vessel on course in various conditions, how do you do that. | ||
A common way is to steer based on current course error, past error and the current rate of change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're going for an analogy, I would love to see this sentence expanded to a paragraph. Something like: you are aiming towards the lighthouse, but you are 4 degrees to the left, that is your current error and you need to correct that. You're been zig zagging left and right for the past 10 minutes, you should fix that too. You also notice that steering has become hard and harder, maybe you've hit a new current? Taking all this information into account, you can correct your course to have a smooth trip, just like you father taught you, just like his father taught him.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are just my thoughts (and typos), not a real review. I would love to see graphs of the corrections with coefficients too big, too small and just right. I think that could help.
|
||
Where $K_{p}$ is a constant and $e(t)$ is the current error. | ||
The performance of the controller improves with larger $K_{p}$; | ||
if $K_{p}$ is too high then when the error is too high, the system becomes unstable, i.e. the rc car drives in a circle. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it zig zag out of control?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is also not clear to me. I would be expecting an instability like what we see with euler methods. Also: what if K is a function of the error? Is this common practice?
|
||
## The Algorithm | ||
|
||
Luckily the algorithm is very simple, You just need to make the PID equation decrete. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
decrete => discrete
$$ U = K_{p} e(t) + K_{i} \int_{0}^{t} e(x) dx + K_{d} \frac{de(t)}{dt} $$ | ||
|
||
To use a PID controller, you need to tune it, by setting the constants, $K_{p}$, $K_{i}$, and $K_{d}$. | ||
There are multiple methods of tuning like, manual tuning, Ziegler–Nichols, Tyreus Luyben, and more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd love to see one of those method expanded later, I've tried to make a PID controlled segway-type device using an arduino once, but I could never quite get the constants right manually.
To use a PID controller, you need to tune it, by setting the constants, $K_{p}$, $K_{i}$, and $K_{d}$. | ||
There are multiple methods of tuning like, manual tuning, Ziegler–Nichols, Tyreus Luyben, and more. | ||
|
||
The uses of PID controllers are thoreticaly any process which has mesurable output and a known ideal output, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thoreticaly => theoretically
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I caught all the grammatical errors, but I listed a few. I'm also a little unsure about the text itself: it sounds pretty foreign in places.
I mentioned it in a few cases but there are a bunch more where I didn't have the time to come up with a better sounding alternative.
The PID controller is in three parts proportional controller, integral controller, and derivative controller. | ||
|
||
Before we get into how a PID controller works, we need a good example to use to explain how it work. | ||
Imagine you are making a self driving rc car that drives on a line, how wuld make it work given that the car moves with a constent speed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self driving -> self-driving
rc -> RC
wuld -> would
constent -> constant
The proportional-integral-derivative controller (PID controller) is a control loop feedback mechanism, used for continuously modulated control. | ||
The PID controller is in three parts proportional controller, integral controller, and derivative controller. | ||
|
||
Before we get into how a PID controller works, we need a good example to use to explain how it work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence sounds pretty strange. The repetition (how a PID controller works ... explain how it works
) could use a little work.
#Proportional-Integral-Derivative Controller | ||
|
||
The proportional-integral-derivative controller (PID controller) is a control loop feedback mechanism, used for continuously modulated control. | ||
The PID controller is in three parts proportional controller, integral controller, and derivative controller. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would sounds better as: The PID controller is comprised of three parts: proportional controller, integral controller, and derivative controller
|
||
### Proportional Controller | ||
|
||
If the car is too far to the right then you would turn left and visa versa. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
visa versa -> vice versa
### Proportional Controller | ||
|
||
If the car is too far to the right then you would turn left and visa versa. | ||
Since there is a range of angles you can turn the wheel, you can turn with proportion to how far you are from the line. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not the biggest fan of this sentence either. The Since there is a range of angles...
part sets up an explanation that's pretty much never expanded on.
Something like You can turn the wheel proportional to how far you are from the line. In fact, this is exactly what the proportional controller does. The formula describing its behavior is given by:
would sound better I think.
Even if you leave the current version:
with proportion to -> proportional to
|
||
$$ U = K_{p} e(t) + K_{i} \int_{0}^{t} e(x) dx + K_{d} \frac{de(t)}{dt} $$ | ||
|
||
To use a PID controller, you need to tune it, by setting the constants, $K_{p}$, $K_{i}$, and $K_{d}$. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tune it, -> tune it (it doesn't need the comma)
To use a PID controller, you need to tune it, by setting the constants, $K_{p}$, $K_{i}$, and $K_{d}$. | ||
There are multiple methods of tuning like, manual tuning, Ziegler–Nichols, Tyreus Luyben, and more. | ||
|
||
The uses of PID controllers are theoretically any process which has mesurable output and a known ideal output, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mesurable -> measurable
There are multiple methods of tuning like, manual tuning, Ziegler–Nichols, Tyreus Luyben, and more. | ||
|
||
The uses of PID controllers are theoretically any process which has mesurable output and a known ideal output, | ||
but controllers are used mainly for regulating temperature, pressure, force, flow rate, feed rate, speed, and more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
speed, and more -> speed and more
|
||
## The Algorithm | ||
|
||
Luckily the algorithm is very simple, You just need to make the PID equation discrete. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You -> you
## The Algorithm | ||
|
||
Luckily the algorithm is very simple, You just need to make the PID equation discrete. | ||
Thus, the equation looks like this, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this, -> this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have noted everything I thought was odd about the text, but haven't yet gotten to the code. Overall, I am happy with its addition to the AAA.
After these revisions are done, there will be at least one more review. The car analogy works, well, but it's a bit there's a sentence missing somewhere that I cannot quite figure out to make it flow with the rest of the text.
@@ -0,0 +1,84 @@ | |||
#Proportional-Integral-Derivative Controller |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does there need to be a space here?
# Proportional-Integral-Derivative Controller
@@ -0,0 +1,84 @@ | |||
#Proportional-Integral-Derivative Controller | |||
|
|||
The proportional-integral-derivative controller (PID controller) is a control loop feedback mechanism, used for continuously modulated control. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Proportional-Integral-Derivative controller (PID controller)
capitalize PID because the acronym follows
|
||
### Proportional Controller | ||
|
||
If the car is too far to the right then you would turn left and vice versa. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would -> should
### Proportional Controller | ||
|
||
If the car is too far to the right then you would turn left and vice versa. | ||
But there are a range of angles you can turn the wheel, so you can turn proportional to how far you are from the line. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence is a bit unclear to me and I don't like starting sentences with But
. I think it might be clearer to say:
In this case, the amount of turning should be proportional to your distance from the line
|
||
$$ P = K_{p} e(t), $$ | ||
|
||
Where $K_{p}$ is a constant and $e(t)$ is the current error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is the error defined? Is it the distance from the line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### Integral Controller | ||
|
||
I looks like we are done, we start driving but if some wind starts pushing the car then we get a constant error. | ||
We need to know if we are spending too long on one side and account for that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To correct this error, we need...
The way to do that is to sum up all the errors and multiply it by a constant. | ||
This is what the integral controller (I controller) does, which is given by, | ||
|
||
$$ I = K_{i} \int_{0}^{t} e(x) dx, $$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a different e
? Its dependent on position instead of time. Maybe it would be nice to create three separate errors e_P
, e_D
and e_I
so we can differentiate?
Also, is the integral going from 0 -> t but in terms of dx
?
|
||
### Proportional-Integral-Derivative Controller | ||
|
||
The PID controller is just a sum of all there three constrollers, of the form, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PID controller is just a sum of all three controllers and is of the form,
|
||
To use a PID controller, you need to tune it by setting the constants, $K_{p}$, $K_{i}$, and $K_{d}$. | ||
If you choose the parameters for your PID controller incorrectly, the output will be unstable, i.e., the output diverges. | ||
There are multiple methods of tuning like, manual tuning, Ziegler–Nichols, Tyreus Luyben, Cohen–Coon, and Åström-Hägglund. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will these be covered? If so, leave a note.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They aren't algorithms it's just done by hand so I don't imagine there being a chapter on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, then for completeness we might want to differentiate these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these are mentioned, they should be described. You can add a simple list with all of them and how they are differentiated from each other.
It might be worth adding a separate heading for tuning and discussing these in-turn.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not link to the wiki page https://en.wikipedia.org/wiki/PID_controller#Overview_of_tuning_methods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible, it would be nice to have citations for all of these with bibtex-cite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you cite?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put the appropriate bibtex citation in the literature.bib
file at the start of the directory, then put {{ "ct1965" | cite }
where you want to cite it and add a
### Bibliography
{% references %} {% endreferences %}
at the bottom
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, Thanks.
If you choose the parameters for your PID controller incorrectly, the output will be unstable, i.e., the output diverges. | ||
There are multiple methods of tuning like, manual tuning, Ziegler–Nichols, Tyreus Luyben, Cohen–Coon, and Åström-Hägglund. | ||
|
||
The uses of PID controllers are theoretically any process which has measurable output and a known ideal output, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
theoretically, PID controllers can be used for any process with a measurable output and a known ideal output,
I am sorry it's taking me so long to get to this. It's mostly there. I'll look over the text once more and check out the code next. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall positive changes. There is still some work to do, though. The code is readable and there are only a few minor corrections to the text, mainly a differentiation between Ziegler–Nichols, Tyreus Luyben, Cohen–Coon, and Åström-Hägglund tuning methods.
The PID controller is comprised of three parts: proportional controller, integral controller, and derivative controller. | ||
|
||
Before we get into how a PID controller works, we need a good example to explain things. | ||
Imagine you are making a self-driving RC car that drives on a line, how would make it work given that the car moves with a constant speed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean "how would make it work"? Do you mean: "how would we keep the car on the line"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's what I mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant this as a fix. The sentence doesn't currently make sense.
### Proportional Controller | ||
|
||
If the car is too far to the right then you should turn left and vice versa. | ||
Since there are a range of angles you can turn the wheel, so you should turn proportional to the distance from the line. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there are a range of angles you can turn the wheel, so you should turn proportional to the distance from the line.
Where $K_{p}$ is a constant and $e(t)$ is the current distance from the line, which is called the error. | ||
The performance of the controller improves with larger $K_{p}$; | ||
if $K_{p}$ is too high then when the error is too high, the system becomes unstable. | ||
In this case, the car would turn in circles, since there is a maximum angle the wheel can turn, else it would zig zag around the line. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence feels weird. Maybe:
In this case, the car would turn in circles because there is a maximum angle the wheel can turn, otherwise it would zig zag around the line.
Where $K_{d}$ is a constant. | ||
If $K_{d}$ is too high then the system is overdamped, i.e. the car takes too long to get back on track. | ||
If it's too low the system is underdamped, i.e. the car oscillates around the line. | ||
When the car is getting back on track quickly with little to no oscillations then the system is called critically damped. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the car returns to the track quickly...
### Integral Controller | ||
|
||
The Proportional and Derivative controllers are robust enough to get the on course. | ||
We start driving, but then some wind starts pushing the car which introduces a constant error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe combine these two sentences?
The Proportional and Derivative controllers are robust enough to get the on course, but what if some wind starts pushing the car and introduces a constant error?
The Proportional and Derivative controllers are robust enough to get the on course. | ||
We start driving, but then some wind starts pushing the car which introduces a constant error. | ||
We need to know if we are spending too long on one side and account for that. | ||
The way to do that is to sum up all the errors and multiply it by a constant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
Well, we would need to know if we are spending too long on one side and account for that, and we can figure that out by summing up all the errors and multiply it by a constant.
|
||
## Example Code | ||
|
||
This example is not calculating the time elapsed, instead it is setting a value called dt. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not clear from the code what this example is supposed to output or do, in general.
I just need a clear description of what this example code is trying to do. I am having a little trouble figuring out what the code is supposed to be doing, but I think it's a 1D analog to the car example, right? We are trying to keep the car on setpoint
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more suggestions
The PID controller is comprised of three parts: proportional controller, integral controller, and derivative controller. | ||
|
||
Before we get into how a PID controller works, we need a good example to explain things. | ||
Imagine you are making a self-driving RC car that drives on a line, how would make the car stay on track given that it moves with a constant speed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence still doesn't make sense. Maybe:
Imagine you are making a self-driving RC car that drives on a line, how could we keep the car on track if it moves with a constant speed?
|
||
Before we get into how a PID controller works, we need a good example to explain things. | ||
Imagine you are making a self-driving RC car that drives on a line, how would make the car stay on track given that it moves with a constant speed. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a sentence here like:
This could be done with a PID controller, which is a combination of Proportional, Integral, and Derivative (PID) controllers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer introducing it over time, to make it easier to follow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My argument was that it was not followable without a transitional sentence.
|
||
### Proportional Controller | ||
|
||
If the car is too far to the right then you should turn left and vice versa. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think sticking to "we" instead of "you" makes sense, but that's personal preference. Maybe something like:
Imagine our RC car is moving too far to the right, in this case it makes sense to turn left.
|
||
### Derivative Controller | ||
|
||
The P controller works well but it has the added problem of overshooting a lot, we need to dampen these oscillations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the P controller really provide an oscillation? It seems like just an overshooting, right? If that's the case, it makes more sense to say "dampen this motion" then "dampen these oscillations"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P controllers may over shoot then it will start to oscillate around the track. So you're dampening this oscillation not the motion of the car.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear to me how we can model the error in the P controller as an oscillation. Again, an animation or some depiction could help here.
### Integral Controller | ||
|
||
The Proportional and Derivative controllers are robust enough to keep on course, but what if some wind starts pushing the car and introducing a constant error? | ||
Well, we would need to know if we are spending too long on one side and account for it, we can figure it out by summing up all the errors and multiply it by a constant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, we would need to know if we are spending too long on one side to account for it, and we can figure it out by summing up all the errors and multiply it by a constant.
|
||
To use a PID controller, you need to tune it by setting the constants, $K_{p}$, $K_{i}$, and $K_{d}$. | ||
If you choose the parameters for your PID controller incorrectly, the output will be unstable, i.e., the output diverges. | ||
There are multiple methods of tuning like, manual tuning, Ziegler–Nichols, Tyreus Luyben, Cohen–Coon, and Åström-Hägglund. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these are mentioned, they should be described. You can add a simple list with all of them and how they are differentiated from each other.
It might be worth adding a separate heading for tuning and discussing these in-turn.
## Example Code | ||
|
||
The example code is of a 1-dimensional RC car that is trying to change from the first lane to the second lane, where the numbers represent the center of the lane. | ||
This example is we can't calculate the time elapsed, instead we are setting a value called dt for time elapsed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence is unclear. Did you mean:
In this example, we can't calculate the time elapsed, so we are instead setting a value called
dt
for time elapsed.
In this case, why are we using dt
instead of time
or some other parameter? dt
always describes the size of a timestep, not the time, itself.
If the normal case is to calculate time, as indicated in line 10 of the code, why do we provide an example that doesn't do this? What is the point in the time parameter to begin with? Is it for dynamic timestepping?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The I and D controllers use the time parameter for calculating integration and differentiation.
|
||
## Example Code | ||
|
||
The example code is of a 1-dimensional RC car that is trying to change from the first lane to the second lane, where the numbers represent the center of the lane. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need some more information here or in the code because it's unclear. What does setpoint
mean? "where the numbers represent the center of the lane" is really vague. What does that mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what you want me to write there, I can't make it more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- We need to add in the license at the bottom of the chapter:
## License
The text of this of this chapter is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode) with attribution to Gathros.
The code examples are licensed under the MIT license (found in LICENSE.md).
[<p><img class="center" src="../cc/CC-BY-SA_icon.svg" /></p>](https://creativecommons.org/licenses/by-sa/4.0/)
I cannot approve this fully until until #560 is merged
- For each of the 3 controllers, it makes sense to have a quick animation of a car moving on a dotted line to show what the controllers are actually doing. I can make these, if you want.
Ultimately, it's pretty close to being completed, just a few graphics and citations.
@@ -0,0 +1,86 @@ | |||
# Proportional-Integral-Derivative Controller | |||
Written by Gathros |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might want to remove this now that we have the license at the bottom? I 'm actually not sure about this, though, so I'm happy leaving a note on authorship at the top too.
Written by Gathros | ||
|
||
The Proportional-Integral-Derivative controller (PID controller) is a control loop feedback mechanism, used for continuously modulated control. | ||
The PID controller is comprised of three parts: proportional controller, integral controller, and derivative controller. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I might do something like this:
The PID controller has three components:
- proportional controller: quick description
- integral controler: quick description
- derivative controller: quick description
The PID controller is comprised of three parts: proportional controller, integral controller, and derivative controller. | ||
|
||
Before we get into how a PID controller works, we need a good example to explain things. | ||
Imagine you are making a self-driving RC car that drives on a line, how could we keep the car on track if it moves with a constant speed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add
For the following sections, imagine you are designing a self-driving RC car that tries to remain on a line...
(or something similar)
|
||
### Proportional Controller | ||
|
||
Imagine our RC car is moving too far to the right, in this case it makes sense to turn left. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imagine our RC car is moving too far to the right of the line, in this case it makes sense to turn left.
Where $K_{p}$ is a constant and $e(t)$ is the current distance from the line, which is called the error. | ||
The performance of the controller improves with larger $K_{p}$; | ||
if $K_{p}$ is too high then when the error is too high, the system becomes unstable. | ||
In this example, the car would turn in circles, since there is a maximum angle the wheel can turn, else it would zig zag around the line. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have an animation to show these.
$$ I = K_{i} \int_{0}^{t} e(\uptau) d\uptau, $$ | ||
|
||
Where $K_{i}$ is a constant. | ||
The peformance of the controller is better with higher $K_{i}$; but with higher $K_{i}$ it can introduce oscillations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, a side-by-side animation would do well here
|
||
The Proportional and Derivative controllers are robust enough to keep on course, but what if some wind starts pushing the car and introducing a constant error? | ||
Well, we would need to know if we are spending too long on one side to account for it, and we can figure it out by summing up all the errors and multiply it by a constant. | ||
This is what the integral controller (I controller) does, which is described by, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, no comma (I think)
|
||
### Proportional-Integral-Derivative Controller | ||
|
||
The PID controller is just a sum of all three controllers and is of the form, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again no comma (I think)
|
||
To use a PID controller, you need to tune it by setting the constants, $K_{p}$, $K_{i}$, and $K_{d}$. | ||
If you choose the parameters for your PID controller incorrectly, the output will be unstable, i.e., the output diverges. | ||
There are multiple methods of tuning like, manual tuning, Ziegler–Nichols, Tyreus Luyben, Cohen–Coon, and Åström-Hägglund. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible, it would be nice to have citations for all of these with bibtex-cite
I, Gathros, the copyright holder of this work, irrevocably grant anyone the right to use this work, including derivatives created during the review process, under the Creative Commons Attribution ShareAlike 4.0 license (legal code). (Anyone may use, share or remix this work, as long as they credit me and share any derivative work under this license.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, good. Some of the suggestions were nitpicks, but others still need to be addressed from before.
The PID controller has three components: proportional controller, integral controller, and derivative controller. | ||
|
||
Before we get into how a PID controller works, we need a good example to explain things. | ||
For the following sections, imagine you are designing a self driving RC car that tries to remain on a line as it is moving with a constant speed. How would you keep it on course. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the following sections, imagine you are designing a self driving RC car that tries to remain on a line as it is moving with a constant speed. How would you keep it on course. | |
For the following sections, imagine you are designing a self-driving RC car that tries to remain on a line as it is moving with a constant speed. How would you keep it on course? |
### Proportional Controller | ||
|
||
Imagine our RC car is too far to the right of the line, in this case it makes sense to turn left. | ||
Since there are a range of angles you can turn the wheel, you should turn proportional to the distance from the line. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there are a range of angles you can turn the wheel, you should turn proportional to the distance from the line. | |
Since there are a range of angles you could turn the wheel by, it is unclear what strategy would work best to return the RC car to the line; however, it is clear that if the angle chosen is proportional to the distance from the line, the car will always be moving towards it. |
|
||
$$ P = K_{p} e(t), $$ | ||
|
||
Where $K_{p}$ is a constant and $e(t)$ is the current distance from the line, which is called the error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where $K_{p}$ is a constant and $e(t)$ is the current distance from the line, which is called the error. | |
Where $$K_{p}$$ is an arbitrary constant and $$e(t)$$ is the current distance from the line, which is called the error. |
$$ P = K_{p} e(t), $$ | ||
|
||
Where $K_{p}$ is a constant and $e(t)$ is the current distance from the line, which is called the error. | ||
The performance of the controller improves with larger $K_{p}$; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The performance of the controller improves with larger $K_{p}$; | |
The performance of the controller improves with larger $$K_{p}$$; |
|
||
Where $K_{p}$ is a constant and $e(t)$ is the current distance from the line, which is called the error. | ||
The performance of the controller improves with larger $K_{p}$; | ||
if $K_{p}$ is too high then when the error is too high, the system becomes unstable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if $K_{p}$ is too high then when the error is too high, the system becomes unstable. | |
however, if $$K_{p}$$ and $$e(t)$$ are too high then the system becomes unstable. |
Well, we would need to know if we are spending too long on one side to account for it, and we can figure it out by summing up all the displacements, usually refered to as errors, and multiply it by a constant. | ||
This is what the integral controller (I controller) does, which is described by | ||
|
||
$$ I = K_{i} \int_{0}^{t} e(\uptau) d\uptau, $$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\uptau
doesn't seem to exist in mathjax, can we use tau
?
|
||
$$ U = K_{p} e(t) + K_{i} \int_{0}^{t} e(x) dx + K_{d} \frac{de(t)}{dt} $$ | ||
|
||
To use a PID controller, you need to tune it by setting the constants, $K_{p}$, $K_{i}$, and $K_{d}$. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To use a PID controller, you need to tune it by setting the constants, $K_{p}$, $K_{i}$, and $K_{d}$. | |
To use a PID controller, you need to tune it by setting the constants, $$K_{p}$$, $$K_{i}$$, and $$K_{d}$$. |
|
||
To use a PID controller, you need to tune it by setting the constants, $K_{p}$, $K_{i}$, and $K_{d}$. | ||
If you choose the parameters for your PID controller incorrectly, the output will be unstable, i.e., the output diverges. | ||
There are multiple methods of tuning like, manual tuning, Ziegler–Nichols, Tyreus Luyben, Cohen–Coon, and Åström-Hägglund.{{ "wikipid" | cite }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are multiple methods of tuning like, manual tuning, Ziegler–Nichols, Tyreus Luyben, Cohen–Coon, and Åström-Hägglund.{{ "wikipid" | cite }} | |
There are multiple methods of tuning like manual tuning, Ziegler–Nichols, Tyreus Luyben, Cohen–Coon, and Åström-Hägglund.{{ "wikipid" | cite }} | |
`` |
### Bibliography | ||
|
||
{% references %} {% endreferences %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to after the example code
|
||
{% references %} {% endreferences %} | ||
|
||
## The Algorithm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## The Algorithm | |
## Putting it all together |
[lang: c] |
@Gathros It's been years. I really dropped the ball on chapter reviews, but I am making it a priority now and I promised you that your chapter would be the first one in, so would you mind either:
If I don't get a response, I will go ahead and start with 2 |
No description provided.