It’s been only a couple weeks since I discovered Arduino, an open source microcontroller platform. I was looking for a cheap interface between my laptop and electronic circuits. Arduino with its price $35 and easy to use development environment was the best choice. So after getting my Arduino Duemilanove board and ordering some cheap components from AllElectronics, I had everything to start working on my old dream, making a magnet fly. Well, float.
Update: detailed description here
It took only a few days to figure out all the problems and my magnet floating device was born:
Here’s a video:
And another, shorter one:
A small cylindrical magnet can float as well:
As you can see by the blurred edges, the tiny magnet oscillates a bit. After a good calibration, the oscillations can be kept very small and the magnet can keep hovering for minutes. The big dart is much more stable and can float pretty much indefinitely. The device uses a small Hall effect sensor (SS19 from Honeywell, available for $0.50 from AllElectronics) to sense the field of the permanent magnet and uses that information to modulate the magnetic field of the electromagnet. Since the sensor is on the electromagnet,
the reading on it is the sum of the fields of the floating magnet as well as the electromagnet. The greatest challenge was separating these two and getting the floating magnet’s field only. After some theoretical research into inductors and the Amper’s law and experimentation, I achieved pretty good stability of a hovering magnet or a magnetic dart or whatever. The result is not completely perfect, some small oscillations are still noticeable. I think that I achieved the limitations given by the Arduino A/D converter. There is always some noise to be expected. I will post more details together with the source codes for both Arduino and my Mathematica 6 control center when I find just a little more time. I even created this blog because I wanted to share this beauty with the world ;)
I also made some discoveries:
- It is really hard to buy a small, cheap electromagnet. I simply couldn’t find any. If you know how to buy one for say $4, let me know. I had to do a terrible thing, buy a solenoid from AllElectronics for $3.85 and tear it apart to get the coil from it. It works pretty well for me.
- The Arduino core library, Serial, for communication through the serial interface, is very slow because it is not optimized for the microcontroller it runs on, ATmega168. These are 8-bit RISC processors without an instruction for division, but the library uses 16-bit variables and division for no reason. The library also doesn’t offer an output buffer and thus the Serial.print methods lock the program waiting for one byte to be sent before they can send the next one. That can take precious time that is needed when a fast loop is being executed. Therefore I modified the wiring_serial.c file to optimize it for 8-bit RISC and added the output buffer (that can be completely disabled as well). See my other blog post for the file download.
The result looks pretty cool. Actually, it looks awesome. It is, however, only a device that keeps the magnet flying by pulling it up. My ultimate goal it the real “antigravity” device, a magnet flying above electromagnets. That is gonna take much more time but is hopefully feasible with this kind of simple circuitry, as was demonstrated by the maglev craddle or some neat levitating contraptions from SimerLab.
A couple more pics at the end. I will post a video too if I feel like it. But it seems that YouTube is full of crappy videos anyway.