Top Store img
Raspberry Pi I/O Cards and Accessories for Home, Industrial and Building Automation

Connecting Raspberry Pi to the Real World

Raspberry Pi PID Loop: Float a Ball at Constant Height in a Tube

ball01

Raspberry Pi PID Loop

Standard ping-pong balls have 40mm diameter. Acrylic tubes come in all sizes, but there is a standard 45mm OD tube, with 2mm walls, which leaves 41mm ID (Inside Diameter). Just enough for a ball to travel inside. So we took the challenge of floating the ball at constant height, using a 12V computer fan and an adjustable power supply.

Easier said than done. Even with a fine adjustable power supply, the ball either stays down, or shoots all the way up the tube.

So we replaced the human eye with an ultrasonic distance sensor, and the human hand with a Raspberry Pi, added by an Industrial IO Card. Let’s see if a Raspberry Pi PID Controller can do the job.
Raspberry Pi PID Loop
For the high level interface we used CODESYS, with the available drivers for the MegaIO-Industrial Card. To show the difference, we implemented both a manual and automated control in the CODESYS interface.

Megaio-IND PID Demo

Here is the setup, including the CODESYS interface:

Raspberry Pi PID Demo
Watch the the experiment here:

or, in abbreviated version, here:

Leave a Reply

Your email address will not be published. Required fields are marked *