Presentation is loading. Please wait.

Presentation is loading. Please wait.

Better Line Following with PID

Similar presentations


Presentation on theme: "Better Line Following with PID"— Presentation transcript:

1 Better Line Following with PID

2 Simple Line Following You are used to getting the dark and light readings on the board, and calculating the threshold:

3 You use this information to write a basic Line Follow program

4 We aren’t following the line, but the EDGE of the line.
When the light sensor sees black, the robot will turn towards the right. When the light sensor sees white, the robot will turn towards the left. We are following the right edge of the line. If the robot turned in opposite directions, we would follow the left side of the line.

5 How do we know what power level to use?
So far, we have used a Guess and Check strategy. Gentle turns (not much difference between the speeds, such as 50% and 20 %) work well for a fairly straight line A curvy line usually needs sharper turns, with big differences between the power for the two motors, such as 30% and 0%. You have noticed that this type of line follower is rather wiggly, and never drives really straight, even on a perfectly straight line.

6 So, we could make it drive straight when the line is straight.
We can do this by dividing our possible inputs into three sections instead of two. So now if the light level is less than 43, we want the robot to turn left. If the light value is between 44 and 47, we want it to go straight. If the light level is greater than 47, we want to turn right. You can program this with a switch within a switch.

7 This will work a little better, though you will still see quite a bit of wiggle.
So consider this: If three light ranges are better than two than what about adding even more? What starts us thinking about PID.

8 Proportional Integral Derivative What is PID?
It is a Closed Loop control method that is used in temperature control, and cruise control in a car.

9 Proportional We are going to make a Proportional Line Follower.
In our first program, the robot could do only two things, turn left or right in exactly the same way. In the second, it used exactly similar turns, but added a third straight mode. In the Proportional Line Follower, the turns vary smoothly between two limits. Here, the turns are NOT identical, and the powers are extremely variable.

10 You have studied proportions in Math class
You have studied proportions in Math class. Proportion means that there is a linear relationship between two variables – when you graph them, you get a straight line. You can see a straight line in the graph on the right. This shows that if the light sensor reading says we are close to the line then we do a small turn. If we are far from the line then we do a big turn.

11 Another way of saying this..
If we want to improve it even more we could add even more states, far left, left, a bit left, straight, a bit right, right, far right, and so on... So how can we calculate the power that must go to each motor on each different turn? Why not make the turn proportional to the error, which is the difference between the midpoint of your light readings and the value read by the light sensor.

12 SOURCE

13 Look at this, but don’t panic
SOURCE

14 We are going to watch two different ways of programming a smoother line follow. While you watch them, try to remember what we have learned, so that you understand what is happening,

15

16

17 The math involves calculus, which none of you have learned.
If you want to go deeper into the math, you can read this, which explains it without explaining the calculus. Or this one, which explains how the calculus works in a very understandable way. This is another good source.


Download ppt "Better Line Following with PID"

Similar presentations


Ads by Google