Proportional integral derivative - based control

Proportional integral derivative (PID) is a control loop feedback mechanism. The main point of using a PID-based control is for efficiently controlling motors or actuators. The main task of the PID is to minimize the error of whatever we are controlling.

It takes an input and then calculates the deviation or error from the intended behavior and ultimately adjusts the output.

Line following may be accurate at lower speeds, but at higher speeds, things may get out of hand or out of control. That's when the PID comes into the picture. Let's have a look at some of the terminology:

  • Error: The error is something that the device isn't doing the right way. If the RPM of a motor is 380 and the desired RPM is 372 then the error is 380-372=8.
  • Proportional (P): It is directly proportional to the error.
  • Integral (I): It depends on the cumulative error over a period of time.
  • Derivative (D): It depends on the rate of change of error.
  • Constant factor: When the terms P, I, and D are included in code, it is done by multiplying with some constant factors:
    • P: Factor (Kp)
    • I: Factor (Ki)
    • D: Factor (Kd)
  • Error measurement: Consider a line follower robot with a five-sensor array that returns digital values; let's have a look at the error measurement. The input obtained from the sensors needs to be weighted depending on the possible combinations of the input. Consider the following table:

                    Binary value

Weighted value

                    00001

4

                    00011

3

                    00010

2

                    00110

1

                    00100

0

                    01100

-1

                    01000

-2

                    11000

-3

                    10000

-4

                    00000

-5

The range of values is from -5 to +5. The measurement of the position of the robot is taken several times in a second and then, with the average, we determine the errors.

  • PID formulae: The error value calculated needs to affect the real motion of the robot. We need to simply add the error value to the output to adjust the robot's motion.
  • Proportional:

Difference = Target position - Present position
Proportional = Kp * Difference

The preceding approach works, but it is found that for a quick response time, if we use a large constant or if the error value is large then the output overshoots the set point. In order to avoid that, the derivative is brought into the picture.

  • Derivative: Derivative is the rate of change of error.

Rate of change = (Difference - Previous difference) / Time interval
Derivative = Kd * Rate of change

The timing interval is obtained by using the timer control of the Intel Edison. This helps us to calculate how quickly the error changes, and based on that, the output is set.

  • Integral:

Integral = Integral + Difference
Integral = Ki * Integral

The integral improves the steady state performance. All the errors are thus added together and the result is applied on the motion of the robot.

The final control signal is obtained from this:

Proportional + Integral + Derivative

  • Tuning: PID implementation can't help you, rather it will degrade the motion of the robot unless and until it is tuned. The tuning parameters are Kp, Ki, and Kd. The tuning value depends on various parameters, such as the friction of the ground, the light conditions, the center of mass, and many more. It varies from one robot to the other.

Set everything to zero and start with Kp first. Set Kp to 1 and see the condition of the robot. The goal is to make the robot follow the line even if it's wobbly. If the robot overshoots and loses the line, decrease Kp. If it's not able to take turns or seems sluggish, increase Kp.

Once the robot follows the line more or less correctly, assign 1 to Kd. For now, skip Ki. Increase the value of Ki until you see less wobbling. Once the robot is fairly stable and able to follow the line more or less correctly, assign a value ranging from 0.5-1 in Ki. If the value is too low, not much of a difference would be found. If the value is too high, then the robot may jerk left and right quickly. You may end up incrementing by .01.

PID doesn't implement effective results unless it's properly tuned, so coding only won't yield proper results.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.117.207