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

Bill Gates steps down from Microsoft’s board to focus on philanthropy

In an announcement on Friday, Microsoft revealed that company co-founder Bill Gates has decided to step down from his role on its Board of Directors in order to focus on his philanthropic efforts at the Bill & Melinda Gates Foundation. This is Gate’s biggest change to his role at Microsoft since stepping down as company chairman in February 2014. According … Continue reading from SlashGear https://ift.tt/2We90Gu

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

A Mini USB Keyboard That Isn’t A Keyboard

A useful add-on for any computer is a plug-in macro keyboard, a little peripheral that adds those extra useful buttons to automate tasks. [ Sayantan Pal] has made one, a handy board with nine programmable keys and a USB connector, but the surprise is that at its heart lies only the ubiquitous ATmega328 that you might find in an Arduino Uno. This isn’t a USB HID keyboard, instead it uses a USB-to-serial chip and appears to the host computer as a serial device. The keys themselves are simple momentary action switches, perhaps a deluxe version could use key switches from the likes of Cherry or similar. The clever part of this build comes on the host computer, which runs some Python code using the PyAutoGui library. This allows control of the keyboard and mouse, and provides an “in” for the script to link serial and input devices. Full configurability is assured through the Python code, and while that might preclude a non-technical user from gaining its full benefit it’s fair to say that ...