<h1>Magnetic Levitation (1 inch gap, stable, low cost)</h1>
[video width="1280" height="720" mp4="http://johann.langhofer.net/wp-content/uploads/2018/04/VID_20180418_2122030.mp4"][/video]

I've found a simple solution for the magnetic challenge in order to get a stable levitation. After several experiments and a lot of research on the WEB I came up with a solution using a handful components, more particularly, only five electronic parts were needed: a power supply, an arduino, a handmade coil, a MOSFET and a hall-sensor. With a small piece of software running on the arduino, the magnetic cubes can be hold in a very stable position. But wait, it isn't so easy, I've got several issues and finally run into a serious problem, but finally I've got the magic solution...

Lets start with the big picture: an electromagnet with a coil and an iron core on the top attracts a floating magnet, a  hall sensor reads the magnetic strength in the gap between the two magnets. An electronic switch turns OFF the coil if the strength exceeds a certain value (threshold) and turns ON if the strength falls blow this threshold. The threshold is exactly the line, where the sum of the up-pointing forces are in balance with the gravity of the floating magnet.

<img class="alignnone size-full wp-image-588" src="http://johann.langhofer.net/wp-content/uploads/2018/04/bigPicture1.jpg" alt="bigPicture1" width="510" height="616" />

So what's the main problem trying to keep a magnet in a constant position from the electromagnet? Stability is the answer. In the configuration above, there are some facts that stability can't be reached even if the electromagnet is switched with  a perfect timing  and high frequency, after some seconds or minutes the system tends to oscillate. Several articles on the WEB are describing this situation and most of them are recommending a PID controller. Well, to cut a long story short, I had no success with PID controllers, neither software-based nor hardware-based. But even if I had been successful, setting the PID-constants would be for one specific configuration only and I like a more general system, where I chan change the type/size/weight of the magnets without reconfiguring the software. Here you can see the cubes getting out of control:

[video width="1280" height="720" mp4="http://johann.langhofer.net/wp-content/uploads/2018/04/VID_20180419_0724230.mp4"][/video]

And here is the solution I came up after successless fighting against various PID controllers: using damper plates does the magic job. Putting non magnetic, good electric conductors, such as aluminium or copper on top and/or bottom of your configuration will eliminate the oscillating due the lorentz force, which is generated by the induced current in the conductor and act in opposite direction of the oscillating force.

<img class="alignnone size-full wp-image-601" src="http://johann.langhofer.net/wp-content/uploads/2018/04/text8870.jpg" alt="text8870" width="508" height="616" />:

&nbsp;

&nbsp;

Useful components:
<blockquote>Arduino Mini, Nano, Mega, laser 405nm
RaspberryPI I, II
WLan ESP8266
and much more.</blockquote>
[supsystic-gallery id=5 position=center]