PID Controlled Magnetic Levitation using Hall Effect sensor.
Although a simple project using Arduino, I was able to learn how PID systems work closely by implementing my own loop.
The equation to the right is the basis for electromagnetism, further equations incorporate the number of turns in a solenoid, which is why more turns equals more magnetic field.
Electromagnets work best with a soft iron core. However, finding one is both very expensive and near impossible at nearby hardware stores. Thus, I settled for steel, which is only composed of a certain percentage of iron. This greatly weakened the electromagnet.
So ensued the game of changing the max current from the MOSFET to allow for a stronger magnetic field.
Finally, I spent around 5 hours tweaking the PID gains. Although PID is a great control loop, if you don't know the order of magnitudes for the Proportional, Integral and Derivative terms (like me :D) it unfortunately takes a long time to fine tune.
The main motivation for this project was creating something that nearly every child thinks is amazing: making something float in mid air. I had researched Hall Effect Sensors around the age of 8, but had no clue behind the control loops or electronics hardware. Thankfully I was able to complete this and fulfill my young self's dreams.