Introduction: Strong and Stable Magnetic Levitation

Earnshaw’s theorem from 1842 demonstrates that you can’t get a stable stationary equilibrium with magnets. But there are loopholes! If we lift a magnet with an electromagnet and then reduce the current when it gets to close it can actually float still in the air!

A levitating globe can be bought in many versions online, and there are other instructables here that show how to make one yourself.

However, I found that some use very sensitive Hall-switches that result in very little lift, of the order of 1 gram, others use microcontrollers, others components that are hard to come by. Also GreatScott made a great video on the subject, but he had trouble with stability, probably because he put the hall sensor under the levitating object instead of close to the electromagnet. The design presented here is very similar to that from a 2004 MIT paper but uses more commonly available components.

While experimenting, I came up with the following guidelines for making a strong and stable levitation:

  • Use a Hall probe inside or close to the electromagnet: this will make the circuit oscillate at high frequency and generate an effective PWM signal.
  • Use a linear Hall probe, the Hall-switch is too sensitive and results in very weak lift.
  • Stabilize the power to the sensing and switching circuit, otherwise fluctuations in the current draw for the coil affect the supply voltage of the sensing circuit, which may destabilize the levitation.

The result shown here is a strong and stable levitator: it can easily lift a 50gr magnet with an extra 50gr of payload. There is no shaking or oscillation. The project is not hard to make. It requires some soldering and some hot-gluing. It took me ~4h to make, half of which to wind the electromagnet by hand. I estimate the total cost at 15EUR but I spent less than a third of that since I used mostly recuperated materials.

One question remains: why would you make something yourself when you can just buy it? I usually aim for more original projects. But if you are fascinated by magnetism, building your own levitator is a rite of passage that can't be skipped.


For the coil:

  • 45m of 0.4mm (AWG26) enameled wire. It weighs 53 grams and has a resistance of 6.2 Ohms. I used wire recuperated from the correction coil of a CRT TV.
  • A spool. I used one that came from a cheap set of 5pcs 10 meter 0.1 mm wire. The outer diameter is 30mm, inner 16 mm and there is 13 mm between the left and right walls.

For power:

  • A 9V 1A power supply.
  • An adjustable step-down DC-DC converter, rated at min 2A, to power the coil
  • A 7805 regulator to power the sensing and switching circuit
  • Two 1muF ceramic capacitors to stabilize the 7805 regulator

For the switching and sensing circuit:

  • A IRLZ44N logic-level power MOSFET
  • A 1N4007 diode or similar
  • A SS49E linear hall probe
  • An LM358 operational amplifier
  • A 10kOhm trimmer potentiometer
  • Two 10kOhm resistors

For the stand:

  • Cardboard and hot glue. I used a thick strip from an IKEA package (1.3x3x90cm)

For the levitating object:

  • Two circular neodymium magnets , 20mm diameter, 3mm thick.
  • A spherical object, I recuperated a mini-globe from a toy

Step 1: Understanding the Circuit

The idea of the circuit is simple: switch off the magnet when the field is above threshold, and switch the electromagnet on when it is below threshold. Both the electromagnet and the permanent lifted magnet will contribute to the measured field. The field produced by the electromagnet alone is below threshold, so in absence of a magnet to lift, the electromagnet is fully on. But with the permanent magnet nearby, the sum will be over threshold and the current is switched off, but then immediately switched on etc: it will oscillate very fast, effectively producing a PWM signal. The duty cycle of this PWM signal depends on the position of the magnet: if it is far, the duty cycle will be large, and if it is close, the duty cycle will be less: the pulling power of the magnet thus varies smoothly and the lifted object stands still.

The frequency of the PWM signal generated this way is determined by how quickly the coil reacts to voltage changes. The time-constant of that is given by the inductance L and the resistance R of the coil: I measured L=6mH, R=6Ohm, tau=L/R=1ms. In fact, checking the output of the Hall probe with an ‘oscilloscope’, I see a PWM signal of O(1kHz). It is fascinating to see the duty cycle of this signal change as we push or pull on the magnet!

The circuit uses an LM358 opamp as a comparator. The frequencies involved, O(1kHz), are slow enough that no dedicated comparator is required. Beware also that this opamp is not rail-to-rail: to work well, the inputs have to stay ~1.5V below Vcc and the output won’t get higher than Vcc-1.5V. I checked that 3.5V is sufficient to fully switch on the IRLZ44N.

There are a couple of 'signs' to be aware of: the probe output is connected to the positive input of the opamp, and the negative input can be regulated between 0 and 2.5V. The magnet will thus switch off if the probe output gets low, which happens when a strong B field is oriented from the front to the back of the probe, meaning that the magnet to be lifted should have the north pole up and the current through the coil should run counterclockwise, when seen from above. But don't worry, it will be easy to debug and to fix in case you get it wrong.

The trimmer potentiometer sets the threshold. In practice that means that the distance between the coil and the lifted magnet can be modified with this trimmer.

Step 2: Make the Coil

You can buy a ready-made electromagnet, but they usually contain an iron core to guide the field to where it is needed. It gives more force per current, but you have less freedom on where to place the Hall probe.

I used 45m of 0.4mm diameter 45m of 0.4mm (AWG26) enameled wire. It weighs 53 grams and has a resistance of 6.2 Ohms. It was recuperated from the correction coil of a CRT TV.

The spool was the one provided with 10m of 0.1mm wire, The outer diameter is 30mm, inner 16 mm and there is 13 mm between the left and right walls. If wound tightly, the spool can fit 16 layers of 30 windings. If not wound tightly, it will only fit half the winding and the magnet will be weak.

To make tight windings, use clean wire without sharp bends and keep a good tension. Make sure that all the windings are tight next to each other. When reaching the end of the first layer, keep winding until it ‘automatically’ moves to the second layer, and wind tightly back to beginning. Make sure that no gaps form. I usually got some imperfections near the walls, but with a bit of care it is still possible to get a good coil.

When the coil has been wound, fix it by putting cellotape tightly over the wire of the coil. Leave 5 or 10cm of wire free on both ends and remove the isolating enamel from the last 1cm with a file or sandpaper.

Test the magnet: Measure the resistance: 5-10Ohm is perfect. Below that, you will need to use a very large current and low voltage. Above that you may need a 12V primary power supply instead of a 9V.

Activate the coil by supplying it with power. Check that it is able to lift your magnets. Find the right voltage for which the coil is able to give a good lift, but does not heat up too much. For me 4-5 Volt worked well, giving ~0.8A current.

Step 3: Make the Stand

Normally, you’d want to try the electronic circuit on a breadboard, but the breadboard is not suitable for the large currents through the coil. So you might as well mount everything right on a stand.

This stand is made of cardboard. It is sturdy and incredibly easy to work with: take a ruler, a pencil, a box cutter and a glue gun, and you can make anything you imagine. It has its own aesthetics and there is ample free supply. I had a thick 4-layer strip from an IKEA package that was just perfect.

Cut the cardboard strip in 5 pieces, three of 20cm, 2 of 15 cm. Glue two long strips side-by-side: this will be the base that is a bit wider for stability. Glue the two shorter strips vertically on the sides and glue the remaining long strip horizontally on top.

Step 4: Prepare the Probe

The Hall probe is the SS49E: it is cheap and the sensitivity is in the right range: +-100mT (+-1000Gauss). The probe is put inside the magnet, or just below it: to make a high-frequency pulse-width-modulated (PWM) signal for the coil, it is crucial that the probe reacts to the field produced by the electromagnet.

We need something to position the probe stably inside the electromagnet. I used a home-made hot-wire cutter to cut cylinders out of a piece of styrofoam. The cylinder should fit tightly inside the bore of the electromagnet. The thickness should be ~8mm.

Bend the pins 90 degrees right next to the package and stick it through the polystyrene cylinder with the marked side pointing down.

I used enameled copper wire to connect the probe to the rest of the electronics: these wires are so thin that they can easily pass on top of the magnet when it gets glued to the base. First color the wires with a sharpy: red for +5V, black for ground, and blue for signal. Then remove 5mm of the isolation on both ends with a file or sandpaper. Pre-tin the leads of the probe and the ends of the wires, then solder them together. The probe can now be positioned on the central axis of the magnet. I got best results by positioning on inside the magnet, halfway between the center and the bottom.

Step 5: Mount and Solder the Coil and Electronics.

The coil, with probe is glued to the top of the stand such that the wires come out owards the back.

Glue the components to the back of the stand and solder the connections according to the circuit diagram and pictures provided. For the opamp and the trimmer potentiometer, the pins are folded flat. It is best to solder the power lines first, check that the power comes up well on the regulator, the opamp and the probe. Then solder all the other connections.

After switching on, the threshold needs to be set with the trimmer: first make sure the magnet is activated when no magnet is nearby. Then check that it switches off when a magnetic north pole is brought nearby. These are the conditions that should allow lifting. The trimmer pot can now be used to adjust the height of the lift.

Magnets Challenge

Participated in the
Magnets Challenge