Skip to main content

Ping-Pong Ball Makes Great PID Example

It is a common situation in electronics to have a control loop, that is some sort of feedback that drives the input to a system such as a motor or a heater based upon a sensor to measure something like position or temperature. You’ll have a set point — whatever you want the sensor to read — and your job is to adjust the driving thing to make the sensor read the set point value. This seems easy, right? It does seem that way, but in realitythere’s a lot of nuance to doing it well and that usually involves at least some part of a PID (proportional, integral, derivative) controller. You can bog down in math trying to understand the PID but [Electronoobs] recent video shows a very simple test setup that clearly demonstrates what’s going on with an Arduino, a motor, a distance sensor, and a ping-pong ball. You can see the video below.

Imagine for a moment heating a tank of water as an example. The simple approach would be to turn on the heater and when the water reaches the setpoint, turn the heater off. The problem there is though that you will probably overshoot the target. The proportional part of a PID controller will only turn the heater fully on when the water is way under the target temperature. As the water gets closer to the right temperature, the controller will turn down the input — in this case using PWM. The closer the sensor reads to the setpoint, the lower the system will turn the heater.

For some applications, this is enough. But what if there are very small errors? Perhaps the set point is 90 degrees and you are 89.8. That won’t correct quickly in a proportional-only control loop because the heater won’t be on very much due to the small error. The integral part of the loop will react to small errors over time, adding a small bit each time the system isn’t in the right state. The derivative part is the opposite. It affects the output in reaction to sudden changes such as an ice cube landing in the tank.

The example rig is a seesaw-like balance beam and uses a lot of 3D printed parts and some plywood. The input driver to the system is an RC servo that can tip the seesaw to a different angle. An IR sensor determines how far the ping-pong ball is from the edge of the beam. With everything wired to the Arduino, you have a pretty good testbed for a controller.

If is common to “tune” a PID by setting Kp, Ki, and Kd constants that determine the “strength” of each action. With the beam, you can watch how tuning affects the system. By setting a constant to zero you can turn off that part of the algorithm, and it is very instructive to see what each part of the equation does to the ping-pong ball.

Even if you have used PID before, you will enjoy seeing this illustrative demo. It would be great in the classroom.  If you want to see a temperature example, we’ve seen that done with an Arduino, too. PID is integral — sorry — to flight control systems and self-balancing robots, too.



from Hackaday https://ift.tt/2SUu1m1

Comments

Popular posts from this blog

Crypto exchange Binance prepares to add margin trading ‘soon’

Binance, the world’s most prominent crypto exchange, says it is close to adding a much-anticipated margin trading feature to its service following weeks of speculation. The company tweeted confirmation of the upcoming feature in a screenshot which subtly teases the imminent arrival of margin trading options. Binance CEO Changpeng Zhao (pictured above) first revealed that the feature was headed to Binance during a live stream following a hack earlier this month that saw Binance lose around $40 million in Bitcoin . TechCrunch understands that margin trading has been beta tested among selected users. A Binance representative declined to comment on the specifics, but did confirm that margin trading will be available on Binance.com “soon.” Dark mode or Light mode ? #Binance pic.twitter.com/pGSb1np4yp — Binance (@binance) May 24, 2019   Margin trading, which lets traders use their balance as collateral to super-size their buying power, is seen by many as an important growth...

World Economic Forum launches Global AI Council to address governance gaps

The World Economic Forum is creating a series of councils that create policy recommendations for use of things like AI, blockchain, and precision medicine. Read More from VentureBeat http://bit.ly/2EKBjD4

The hidden cost of food delivery

Noah Lichtenstein Contributor Share on Twitter Noah Lichtenstein is the founder and managing partner of Crossover , a diversified private technology fund backed by institutional investors, technology execs and professional athletes and entertainers. More posts by this contributor What Studying Students Teaches Us About Great Apps I’ll admit it: When it comes to food, I’m lazy. There are dozens of great dining options within a few blocks of my home, yet I still end up ordering food through delivery apps four or five times per week. With the growing coronavirus pandemic closing restaurants and consumers self-isolating, it is likely we will see a spike in food delivery much like the 20% jump China reported during the peak of its crisis. With the food delivery sector rocketing toward a projected $365 billion by the end of the decade, I’m clearly not the only one turning to delivery apps even before the pandemic hit. Thanks to technology (and VC funding) we can get a ri...