Download presentation
Presentation is loading. Please wait.
Published byBrennan Garbutt Modified over 10 years ago
1
Proportional, Integral, Derivative Line Following October 5, 2013
2
Page 2 Welcome and Introductions
3
Page 3 Line Following Why is line following useful in FLL? Wide black lines with surrounding white area can be used for successful navigation. Light sensor is preferable to color sensor due to: (a) higher resolution, and (b) ability to calibrate. As with all line following, steering the robot is accomplished by independently controlling the power of the left and right motors. The motors work to keep the light sensor at the edge of the line.
4
Page 4 PID What is PID? A PID (Proportional, Integral, Derivative) controller is a common technique used to control a wide variety of machinery includingvehicles, robots, and rockets. A PID controller compared to a standard 2 and 3 level line follower. The x-axis is the light sensor reading. The y-axis is the amount of turn. Note that the threshold for the 2 level and 3 level line following is 50.
5
Page 5 We will construct a PID line follower which… Moves the robot forward. Uses light sensor in port 2 to follow the line. Follows the left-hand-side edge of the line. CB 2
6
Page 6 PID Pseudocode – Initial variables to be used Let “Kp” = some number Let “Ki” = some number Let “Kd” = some number Let “Tp” (target power) = some power level Let “Integral” = 0 Let “Derivative” = 0 Let “Last Error” = 0
7
Page 7 Pseudocode – some calculations to perform Reset rotation sensor B Begin Loop Let “Error” = light sensor intensity reading – (minus) 50 Let “Integral” = “Error” + (plus) “Integral” Let “Derivative” = “Error” – (minus) “Last Error” Let “PTerm” = “Kp” x (times) “Error” Let “ITerm” = “Ki” x (times) “Integral” Let “DTerm” = “Kd” x (times) “Derivative” Let “Turn” = “PTerm” + “ITerm” + “DTerm” Let “Turn” = Turn / (divided by) 100 Let “PowerB” = “Tp” + (plus) “Turn” Let “PowerC” = “Tp” - (minus) “Turn” Let “LastError” = “Error”
8
Page 8 Pseudocode – establish power levels If “Power B” > 0, then motor block B forward unlimited at “Power B” power level, else motor block B reverse unlimited at negative “Power B” power level but with direction or movement reversed (We want a negative number to mean that the motor should reverse direction. But the data port on a NXT-G MOTOR block does not understand that. The power level is always a number between 0 and +100. The motor's direction is controlled by a different input port. Negative motor power needs to be made into a positive number and the motor direction needs to be reversed on the control panel If “Power C” > 0, then motor block C forward unlimited at “Power C” power level, else motor block CB reverse unlimited at negative “Power C” power level but with direction or movement reversed End Loop Stop Motors C and B
9
Page 9 PID Calculations for “P”
10
Page 10 Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.