PID Loops in Math and in the Real WorldHL Mathematics Internal AssessmentJanuary 15, 2018Word Count: TBDTable of ContentsIntroduction………………………………………………………………………………………..2The “Proportional” Component……………………………………………………………….…..3The “Derivative” Component…………………..…………….…………………………….……..4The “Integral” Component…………………….…………………………………………….……..5Th PID Equation……………………………………………………………………………………6Conclusion…………………………………………………………………………………..…….8Works Cited……………………………………………………………………………………….9Introduction I have been interested in robotics for the past several years now, and something that has always confused me about robotics is the use of what is called a PID (Proportional, Integral, Derivative) loop, or PID control in the program used to control the robot. These loops are special in that they process input using three different methods, in order to eliminate certain points of instability when trying to control something. In addition, these three parts need to be adjusted (or “tuned”) in order to make the PID loop “stable” (without oscillation). Each time the loop is executed, the parameters adjust themselves in order to best reach the “stable point” as quickly as possible. The reason I never quite understood how I was supposed to use them was because the math involved never made sense to me, and tuning three different parameters for a seemingly magical loop to make everything work was a logistical nightmare. Now, however, my knowledge of mathematics has increased to the point where I can investigate how PID loops provide accurate control in scenarios usually not controllable with single-parameter loops. In this paper, my goals are to:Investigate how each of the three control parameters on their own affect a simple hypothetical scenarioCombine all three parameters using an equation Use a more complex scenario to demonstrate how the equation works, referencing a combination of what I have learned about PID loops as well as my prior knowledge of mathematics.For the first three sections of this internal assessment, I will be using the example of a point travelling at various speeds, and explaining how this point’s speed can reach a constant, stable velocity as fast as possible using a PID loop.The “Proportional” Component Let’s imagine that we have a point R that is at rest (has zero velocity in all directions). Now, we want that point R to suddenly be moving at a velocity of 5 meters per second (m/s). Instantaneous acceleration is impossible, so we must assign a loop to the point R which proportionally increases the speed of the point until it reaches the desired speed of 5 m/s, The diagrams below show what will happen if we assign both a low (left) and high (right) proportional value of (value) to the point:Notice: Graphs are not final and will be made better for the rough/final drafts.However, there are problems with these graphs. Assigning a low proportional value to the point does eventually get it to the stable point, at which its velocity becomes constant, but it does so very slowly due to the small value of the P parameter. This is not ideal in industrial control scenarios, because movements that require fast, real-time calculations must become stable as fast as possible, or else the output of the device will be unusable (an example where such a situation would be important is in a Segway-type device, where the machine balances a person on top, making quick yet fine adjustments to the speeds of the wheels to ensure the person riding is “stable” at all times. To fix this, we assign a high value to the P parameter, but this introduces its own set of problems. As is visible in the graph on the right, it reaches the target velocity much faster, but overshoots and needs to correct for it. However, the P parameter is now too high, and it will not be able to ever reach the stable point because it cannot change the rate at which the proportional value changes. In this case, we need to add the Derivative (D) parameter. The “Derivative” Component The purpose of the D parameter is to change the rate at which the proportional value changes. It does this by differentiating the error (how far away the point is from the target velocity) at a given time, and uses that number to reassign a new value to the P parameter which is usually less than the original static value. It does this until the point R has reached its target velocity. Below is a graph showing how adding the “D” component to the graph on the right in the section above would affect the point’s motion while still maintaining the desired quick acceleration:The “Integral” Component It is very common to use the P and D parameters in combination in the industrial control world, because they often are “good enough” for many control purposes. This is because in these cases, the target value is static, in that it never needs to change. However, the I parameter is needed if the target value does change. The I parameter is used to calculate the error of the result produced by the P and D functions; it does so by taking the area between the graph produced by this result over time, and the target value. The greater the area, the more drastically the I component will change the values of the P and D components in order to reach the new target value as quickly as possible. As time progresses, the value gets smaller because it reaches the target value quicker. A question that arises from this is, “how come the D parameter can’t account for the error?” The answer to this question is that the D component depends only in the output of the P component, which relies only on the initial target value. The I component is able to adjust the P and D components according to any change that may occur in the target value. Below is a graph showing how the I parameter comes into play. Notice how once the target velocity is changed to 7 m/s, the I parameter changes the value of the P and D parameters, and assigns them the new target value of 7 m/s, which the point then eventually arrives at. The PID EquationEach of the three parts of the PID loop can be summarized by the following equation:Mn = Kc* en + Ki * i=1nei+ Kr * (en – en-1) + MoMn represents, at the time “n”, the amount of response sent to the PID controller. Kc* en is the proportional term of the equation, where Kc is the fixed proportional gain coefficient and en is the error calculated by subtracting the current value from the user-defined set point at time “n”. Ki * sumei represents the integral term of the equation, where the sum represents the sum of all calculated errors from time 1 to time n (in units of sample points), and Ki is the fixed integral coefficient, and is calculated by multiplying Kc by the ratio between the sample rate and the integral time. Kr * (en – en-1) represents the derivative term of the equation, where the error from the previous sample, en-1, is subtracted from the current error, en , and then multiplied by Kr, the fixed derivative coefficient, which is found by multiplying Kc by the ratio between the derivative time and the sample rate. Mo represents the initial control output, when the loop begins automating a process. The values we can therefore adjust to “tune” the PID loop, or increase its efficiency, are the proportional gain, the integral time, and the derivative time (as well as the initial control output and sample rate, but these remain constant in most cases even though the first three variables are changed). Conclusion Here I will discuss how the real-world experiment proves that my explanations for how each of the three parameters work are correct, because when I implemented each parameter in the program for the robot, it responded very similarly to how point R would theoretically respond.Works Cited AutomationDirect.com. “Methods Behind PID Loop Control.” Library.AutomationDirect.com, 27 Oct. 2017, library.automationdirect.com/methods-behind-pid-loop-control/.