Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Levitating ping-pong ball

Not open for further replies.


Newbie level 4
Nov 28, 2010
Reaction score
Trophy points
Activity points

This project I'm working on is about making a ping-pong ball float in a transparent plastic tube at a specified distance relative to the proximity sensor (infrared). The ball should float with minimum oscillations. A small ventilator at the base of the tube is used to push the ball up.

The fan has a brushless motor controlled through a driver that accepts a PWM signal from a microcontroller. The driver is basically a low-pass filter and a bipolar transistor that works in the active region. The fan datasheet specifically said that it can't be controlled directly with a PWM signal.

The infrared sensor outputs an analog signal that is read by the ADC of the microcontroller. Serial communication with the PC allows a user to specify the floating distance and view the distance read from sensor for debugging purposes.

I have reached the point where I have to implement an algorithm to make the ball float steadily at a given distance. I have very limited experience with digital control and I want to ask your help to guide me through this process. Any ideas, suggestions are welcome. Remember it's ok for the ball to oscillate a little and it's also ok if the stabilizing time is not very low.

The tube is about 35 cm long, 4.6 cm in diameter. The ball has 4 cm in diameter. The sensor is placed at the top of the tube, right on the top hole of the tube, letting the air to pass by. The sensor can measure distances from 4 cm to 30 cm. I have placed a thin wire in the tube to limit the ball from ever reaching distances below 4 cm relative to the sensor.

I have to mention that I don't have a linear characteristic in the output voltage of the fan driver in comparison with the PWM duty cycle. So 50% duty cycle doesn't mean half the supply voltage of the fan driver. The characteristic looks more like a capacitor charge curve. I don't know if this has a major impact in the design of the control algorithm.

The ball either stays down or goes up to the limit for a fixed duty cycle PWM signal. For example at 50% the ball is down, if I increase to 51% it slowly goes up and stays at the upper limit. There is no middle ground, only if I play with the duty cycle and continually change it.

Is the PI or PID method the best way to go? Will there be a problem if I have a buffer to compute the average of the readings (digital filter). How will this buffer impact my control algorithm? Do I need to consider the speed, not just the position of the ball; how fast should I change the PWM duty cycle?

I'm looking forward on reading your suggestions on the control algorithm

Thank you

Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to