So, we can see that with the proportional regulator, the robot goes much more smoothly than with a relay regulator. However, this does not always happen. It can be so that with your coefficient the robot will handle the smooth tracks perfectly well, but it might go off the track at a sharp turn. When you begin to increase the coefficient, the robot might move even more briskly. Thus, you will end up with a worse option than you had in your relay algorithm. I would recommend you do the following. I am not great at drawing, as you might have noticed, so I have accessed the Wolfram Alfa website to remind you what cubic function graphs look like. This is a cubic parabola. Why do we need it? Thing is, you can actually add one more channel in your regulator – raise your error to the third power. The improved regulator will look as follows: we shall be getting the error in the similar way, while the control action will be calculated differently. For this, we shall take the error with the 1 coefficient and one new coefficient, which makes part of the cubic value of our regulator. In Arduino, exponentiation is noted differently. This is what it will look like. {{WRITING ON THE GRAPH}} Why do we need it? The graph will know why. We can see how e3 is changing. Let’s say that the error is insignificant and the robot goes off the route, but
not too much. E3 will still be minuscule. Let’s not forget that we have introduced one more coefficient, which will also be minuscule: parts per hundred thousand or parts per million. With this coefficient, e3 will not play any role at all. However, as soon as the error value increases, its cubic value shall
also increase, and even with such a minuscule coefficient, it will influence the way the motor speed changes. Let’s see what the function graph will look like if we, say, take 0.1x and add 0.00001 x3 to it. It will look like this: the program even tells us that in the range from – 1 to 1, this will be a straight line, while in this range the graph will look like this. Thus, the proportional component will work when the curve of the track is not too sharp, but as soon as you see a
sharp turn, this will mean that the cubic value is working. This piece of advice might come in useful. To sum up, in this part of the lecture, we got acquainted with a proportional
regulator. Let’s get back to our diagram, remove the relay algorithm and put a regulator in its place. Naturally, you can use the regulator not only in a mobile robot. There are numerous ways to apply them, as they are one of the basic components in the automatic control theory. Those who are interested, should look in the Additional materials for the Proportioning Integral Differentiating controller, or the PID controller, which takes into consideration even more details and optimizes the operation of numerous
devices. Let me present you another variant of the regulator. It can come in handy in some other tasks. Imagine that your robot is following a broken line. Let me picture it: this is its integral part, and then there is something like this. If we use one single sensor when we approach the end of the segment, something unexpected will happen. So let me propose you another option: you can take 2 sensors once again, place them similarly to when we were working with the relay algorithm, and monitor not the borderline, but other things. Thus, you can read off values from both sensors trying to reach zero difference. Namely, your task now is not to reach a value set beforehand,
but to make sure that both sensors have the same background under them. In other words, if the robot is following a line, both sensors
will see its borders. If the robot moves away from the line, one sensor will capture white, while the other one will
capture black. Consequently, there is a difference occurring between them, and you will be able to regulate the difference of the speed of
both wheels. The robot will get back on the line, and when it reaches its end, nothing unexpected will happen. This will be the last grey section, and then both sensors will be
capturing white. From the robot’s point of view, nothing strange has happened, because white and white look the same to it. Then one of the sensors will capture black and the robot will need to adjust to the situation. Both of its sensors will hit against a grey background, between the black and the white backgrounds. The intensity of grey will be increasing or decreasing
depending on how far the sensor is from the borderline. This shouldn’t pose a problem for you, since the main thing is the absence of the difference between the values
of the sensors. As far as the code is concerned, it won’t change dramatically, except for the fact that the error will be calculated differently, by reading off the current value and extracting the set value from it, as we used to do before. Now you can do the following thing: read off values from both sensors and look for the difference between them. Thus, we won’t be using our old method any longer. Take a look at the display. [NOISE] I have added one line to the main loop, which outputs sensor values on the display. If they vary from the set standard values, the robot starts to correct its movement. In the end, we have achieved a more satisfactory result than with the relay algorithm. Obviously, many things can still be perfected. We could, for instance, make our robot turn more smoothly, and I shall explain one of the ways to do so
a bit later. Nevertheless, the main task has been completed and now our robot can follow a line. You can use this knowledge as the point of departure in some other
applied problems.