Arduinos. Levitation. I know how to impress the ladies. So I set out to design my project. I am thinking a linear hall effect sensor to sense the position of a magnet suspended below an electromagnet. The parts are ordered.

Assuming 1) a linear hall effect sensor that converts suspended magnet distance to voltage, and 2) a transconductance push-pull amplifier to convert the voltage to current I can then regulate the bias current through my electromagnet to keep the suspended distance constant. I calculated all this in Mathematica and came up with the attached plot showing energy vs distance for the suspended magnet. Of course, when my parts arrive I can plug in actual parameter values but for the time being I assumed values. You can see that the plot shows a potential well suspending the magnet at a distance of 3.

I got this far and I now think “Where does the Arduino fit in”? I mean the controller can be done with 3 npn’s, 2 pnp’s, and a few resistors. In fact, the PWM “analog” outputs of the Arduino are the exact opposite of what is needed for an inductive load. You definitely do not want high dI/dt transients through the electromagnet.

All the equations are static. I don’t need a PI controller because I don’t care about static offset. I don’t care about transient response. I only care about suspending the magnet. The static equations reduce to hooke’s law and we know what the static solution for that is.

Has anyone ever modeled an Arduino solution for levitation using the Arduino PWM outputs? I’d be really interested in seeing one.

At this point, I am thinking maybe I should include the Arduino because what impresses the ladies more than levitation is levitation with blinking lights.

Before you get into trying to control the distance, I suggest you try some static tests...

PWM works great with inductors! You just need a reverse diode across the inductor to protect your circuit from the back-EMF when the voltage switches-off.

Since you shouldn't need to reverse the current, a single transistor or MOSFET should be enough. If you can't get enough current gain with a single transistor, you can get a Darlington transistor (two transistors in one package).

I assume the problems with building something like this are related to stabilizing the magnet so that it doesn't "slide off" to the side and fall down or flip-over and attract instead of repel.

a linear hall effect sensor that converts suspended magnet distance to voltage

It might look like you are cheating if there's a wire connected to your levitating magnet.

DVDdoug:
PWM works great with inductors! You just need a reverse diode across the inductor to protect your circuit from the back-EMF when the voltage switches-off.

But with PWM you can't predict the current through the inductor so you can't predict the force on the magnet. With PWM the only thing limiting dI/dt is the Miller effect of the driving transister. The voltage transients are huge. It's impossible to model. I am looking to model the whole thing before I build it. The beautiful thing about NOT using PWM is that the model is static and simple.

It might look like you are cheating if there's a wire connected to your levitating magnet.