1 / 12

Instructor: Paul Gordy Office: H-115 Phone: 822-7175 Email: PGordy@tcc.edu

Lab 11 EGR 262 – Fundamental Circuits Lab. EGR 262 Fundamental Circuits Lab Presentation for Lab #11 Line Following using a PID Controller. Instructor: Paul Gordy Office: H-115 Phone: 822-7175 Email: PGordy@tcc.edu. Lab 11 EGR 262 – Fundamental Circuits Lab.

dyanne
Download Presentation

Instructor: Paul Gordy Office: H-115 Phone: 822-7175 Email: PGordy@tcc.edu

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab 11 EGR 262 – Fundamental Circuits Lab EGR 262 Fundamental Circuits Lab Presentation for Lab #11 Line Following using a PID Controller Instructor: Paul Gordy Office: H-115 Phone: 822-7175 Email: PGordy@tcc.edu

  2. Lab 11 EGR 262 – Fundamental Circuits Lab Line Following Techniques In Lab #10 we implemented a line-follower by assigning specific turn speeds to each sensor in a sensor array. A more powerful way to perform line following is to use a PID Controller. PID Controllers have many applications and are widely used in industry. PID Controller PID stands for Proportional Integral Derivative. A PID Controller calculates the error between a measured input and a desired output. The general form of the error is: Derivative Term Proportional Term Integral Term where: e(t) = Error = Desired Value – Measured Value (or SetPoint – Process Variable) KP = Proportional Gain (a constant to be “tuned” or adjusted) KI = Integral Gain (a constant to be “tuned” or adjusted) KD = Derivative Gain (a constant to be “tuned” or adjusted)

  3. Lab 11 EGR 262 – Fundamental Circuits Lab PID Controller Derivative Term Proportional Term Integral Term Proportional Term: Term is proportional to the current error Integral Term: Term is proportional to the sum of past errors Derivative Term: Term is proportional to the slope of the error

  4. Lab 11 EGR 262 – Fundamental Circuits Lab PID Controller So how can a PID controller be used for line following? Recall that our previous program used the QTRSensor library. The function qtrrc.readLIne(Sensor) was used to return the position of the line. unsigned int position = qtrrc.readLine(sensorValues); The value of the variable position can be used to determine line position as follows:

  5. Lab 11 EGR 262 – Fundamental Circuits Lab PID Controller Recall that the general form of the PID output is: We can now define: Output = adjustment to motor speed e(t) = Error = Desired Line Position – Measured Line Position Example: If we want to keep the tape under sensor #5, then: Desired Line Position = 4000 If our sensors measure a current value of position as 3200, then e(t) = Error = 4000 – 3200 = 800 Note: For line-following applications, the integral term is often considered to be insignificant, so it is fairly safe to assume the KI = 0. Doing so actually changes the PID controller into a PD controller.

  6. Lab 11 EGR 262 – Fundamental Circuits Lab PID Controller The general form of the PID output can now be rewritten as shown below: The motor speeds can now be adjusted using:

  7. Lab 11 EGR 262 – Fundamental Circuits Lab Illustration - Suppose that the robot was following the line on a straight section (line under sensor 4) then encounters a curve (detects line under sensor 3). It turns left, but overcorrects a bit and the next reading has the line under sensors 4/5. Suppose that measurements are made every 100ms. Both motors are originally moving with speed = 90. Assume that KP = 0.002, KD = 0.010, and KI = 0.008 (to be determined by experimentation). 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 45 6 7 Front of robot Front of robot Front of robot

  8. Lab 11 EGR 262 – Fundamental Circuits Lab Tuning the PID Controller Determining the values for KP, KD, and KI is difficult. This process is called “tuning” the controller. Adjusting them through experimentation is called manual tuning and it can be a tedious process. If a robot has been tuned to one track, it may need to be retuned when switched to a different track. Tuning is often performed by slowly adjusting one parameter at a time and carefully recording the results. Some references say that KD is typically greater than KP (but the example on the previous page doesn’t follow this).

  9. Lab 11 EGR 262 – Fundamental Circuits Lab Sample PID Program for the Arduino UNO – This program hasn’t been tested yet, so don’t rely on it too closely. Also do not assume that the constants are correct. Discuss the highlighted items.

  10. Lab 11 EGR 262 – Fundamental Circuits Lab Sample PID Program for the Arduino UNO– (continued)

  11. Lab 11 EGR 262 – Fundamental Circuits Lab Sample PID Program for the Arduino UNO– (continued)

  12. Lab 11 EGR 262 – Fundamental Circuits Lab Lab 11?– Maybe next semester! Significant extra credit if you try this out and get it to smoothly follow the line on our test track.

More Related