Line Following Robot Uses PID For Speed

While a line-following robot may not be the newest project idea in the book, this one from [Edison Science] is a clean build using modern components and gets a good speed thanks to PID control feedback instead of the more traditional bang-bang control you see in low-end robots.

Of course, PIDs need tuning and that seems to be the weak link — you’ll have to experiment with the settings. The sensors also require calibration, but we bet both of those issues could be fixed pretty easily.

If the idea of PID is new to you, the acronym stands for proportional, integral, and derivative. To determine the output at any given time, you look at where you are compared to where you want to be (the present value vs the set point). Then you compute a proportional error. So, for a temperature, for example, if you want to be at 30 degrees and you are at 20 degrees, that a proportional error of 10 degrees. You also want to look at how much change has been building up over time and the rate of change of the error.

We’ve had some excellent PID tutorials in the past if you want to read some math. Thie simplest line followers don’t need PIDs or even CPUs.

19 thoughts on “Line Following Robot Uses PID For Speed

  1. ‘Thie simplest line followers don’t need PIDs or even CPUs.’

    The simplest PID doesn’t need a CPU, either. A couple caps, a couple resistors, and a one or two transistors is it. Or tubes. I have a 1960’s vintage PID furnace control (0 to 1600C with a thermocouple sensor) that uses PID with just this type of setup. Pots to set the I and D coeffs relative to the P, and aa precision ten turn for the set point. It was the replacement for the 1950’s vintage with the grain-of-wheat lamp, CdS cell, and black vne on a moving needle in the meter control (which was nominally a proportional control, but the inertial effects and time constant of the CdS amp gave some I and D)

    1. There are also auto tuning PID algorithms now. There’s no need to do this by hand anymore. It takes more processing power, obviously, but processing power is pretty cheap these days. Also after it tunes itself, you can switch it over to regular PID and keep the values.

      1. There’s no general purpose PID autotuning, it’s really system dependant, so unless you’re using a system that comes with autotuning done by the manufacturer, in 99% of cases you’re better off tuning by hand instead of adapting stuff and spending way too much time on a general solution for a particular problem.
        Hence why almost everyone does manual tuning.

        1. Well, if there is no general purpose PID autotuning will a human trying a bunch of parameters actually do better than some algorithm? It usually comes up to what is being used as a metric to a “good result”. And I doubt most people hand tuning it have a mathematical metric of what they want to achieve, so they tune it until it looks ok. If they were able to come up with a metric of that “good” was a computer could do the same or even better. Also there are a lot of very generic PID autotuners in literature, I guess they are either impractical to implement or people don’t need an “optimal” PID and any stable system will do.

          1. Generic PID autotuning algorithms do exist and which one if any you can use depends on the system, they do tend to have a lot of drawbacks though. Such as the Ziegler-Nichols method which requires the system to be pushed to instability. The algorithms also don’t produce an “optimal” tuning and different methods will have different results. How well the tuning works also depends on the parameters that are set and changing them effects the tuning process. If the tuning algorithm isn’t properly implemented it would be very possible for the system to become unstable which isn’t ideal and can cause damage electrically and physically. In a lot of cases these methods have too many drawbacks and added complexity and so tend not to be used.

    1. Because it works?
      Because it is a low resource requirement solution?
      Because for some applications it is actually optimal?
      Because it is familiar?
      Because it is stable, if tuned remotely well?

      I could go on. Remember,this is HaDay, not ACM Transactions on algorithms or IEEE control systems letters

    2. Additionally to what Cliff just mentioned:

      Because the vast majority of PID implementations aren’t even true PID, but simple PD controllers (or even just proportional with no integral or differential component whatsoever), which is actually sufficient for a lot of applications

    3. … because mathematically modeling a complex interlinked physical system isn’t always possible or practical. Sometimes manually tuning a pid and just letting it run without having to effectively map out the plant model is just easier.

    4. People use PID because it works ok and it is easy to implement. The other techniques are not necessarily better than a simple hand-tuned PID, what would be the criterion for that? LQR is only optimal with respect to a determined LTI system and a cost function. And state-space might require a lot of memory/multiplications depending on the system (both LQR and the Kalman filter use state-space.) If you do not have a metric hard to satisfy any solution will be good enough.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.