Welcome back to the Digilent Blog!
Last time, I showed my initial attempt into living out my dream of performing magic tricks (with a little help from the electronic realm), and found that my “oh yeah, sure, no problem” attitude was not going to work. So I came up with a new plan of using the PmodMAXSONAR as an input for my desired height and using a PmodOD1 or PmodOC1 as my method for controlling the fan speed to levitate the ball in a nice four foot polycarbonate tube. Let’s see how that turned out.
I definitely fought with this one for awhile as I was too stubborn to give in, at least not quite as easily as I had with my first attempt. I did see some success and learned a lot about the balance between usability, reliability, and effort exerted to make the first two items viable. In principle, I would receive distance information from the PmodMAXSONAR (since it’s a nice ultrasonic sensor to detect objects, such as my hand, that are located in front of it), which I would then process within the microcontroller to see the measured distance is within my desired sensing range.
If the reported distance was between 6 and 36 inches, I had the microcontroller calculate a corresponding duty cycle to run the fan with the PmodOC1 (I decided against the PmodOD1 since my small fan would not need as much current as the PmodOD1 is capable of providing) as my method of switching the 5V supply to the fan on and off. That’s when I started running into some problems.
The first was that I didn’t stop and consider what the ‘OC’ meant in reference to the PmodOC1—it means open collector. This means that the collector portion of the NPN BJT is not connected to the positive voltage supply that it would normally be connected to, implying that simply connecting the output on the PmodOC1 to whatever you trying to run does not do anything (as I found out). Rather, the ground of whatever you are attempting to run needs to be attached to the output on the PmodOC1 (the collector) and the positive wire (or anode in the case of an LED) needs to be attached to your positive power source. This configuration will allow current to flow through the system when you apply enough current to the base, as shown in the diagram below.
After figuring this out, I promptly found that once the fan reached a certain speed, the ping pong ball would simply travel all the way to the top of the tube with no proportionality aspect in terms of height whatsoever. Turns out (as I should have realized), that if you want proportional height control, you need to implement a way for a linear change in energy (either an increase or decrease) to occur. Because we want the fan to blow more strongly as the measured hand height increases, we need to slowly increase the amount of air that is released from the tube as the ball floats higher in the air by drilling small holes about an inch apart all the way up the tube.
In this endeavor, I was wildly successful—everything worked as exactly as it was supposed to. And then the moment ended.
Apparently, when you use things in way that they are not designed to be used, like rapidly turning a DC fan on and off, they tend to deteriorate as evidenced when I found that having the fan on full blast only floated the ball a third of the way up the tube rather than threatening to blow it out of the tube entirely. Additionally, the PmodMAXSONAR, while great in principle, proved to not be as user friendly as I originally envisioned. As an ultrasonic range finder, it does best at detecting flat objects such as a wall or ceiling whereas the human hand tends to have multiple curves, so a clean ultrasonic signal is not returned to the Pmod. Also, people are never quite sure if their hand is directly above the PmodMAXSONAR, leading to some skewed results.
With all this in mind, I will make another, (and hopefully final), attempt to successfully float a ping pong ball with a PmodACL2 that I can tilt and measure the acceleration from to execute height control, a DC fan designed to be controlled by a PWM signal eliminating the need for the PmodOC1), and a taller stand to enable more air flow.