<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 is turned OFF the coil if the strength exceeds a certain value (threshold) and is turned 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" />

&nbsp;

So what is the main problem trying to keep a magnet in a constant position from the electromagnet? Stability is the answer. Even with a good threshold value (up-pointing forces greater Gravity and "Magnet force" smaller Gravity) there is no chance to keep the system stable. Even switching the electromagnet with high precision and with high frequency, after some seconds, minutes or more, the system will start oscillating an turns out of control. 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 I've had been successful, setting the PID-constants would be for one specific scenario only, but I like a more general system, where I chan change the type/size/weight of the magnets without changing/configuring the software...

&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]