Magnetic levitation

Hello,
here is a magnetic levitation project realized with arduino. The suspended ball is a permanent magnet whose distance from the electromagnet is measured by a hall effect sensor placed under the coil. The digital control loop is a PID algorithm that modulates a PWM output to energize the electromagnet through a MOSFET. A voltage regulator is used to provide a fixed voltage and to limit the current in the coil (the schematics can be found in attachment).

Cool!, well done

Code ?

You can find the sketch file in attachment. Basically it consists in the following functions:

  1. PWM setup to change the frequency from the default value (490 Hz) to 3921 Hz;
  2. A command handler used to configure the controller gains and setpoint through the serial line (when arduino is connected to USB cable);
  3. A state machine that manages the transition between OFF, IDLE and CONTROL modes (this to avoid the controller to turn on the electromagnet
    at full power when the ball is not in range);
  4. The control loop.

MagneticLevitation.ino (7.38 KB)

I forwarded the tube to a teacher at a technical school this afternoon and he was so enthousiastic he thinks about adding it as a exercise in the semester.

Thanks again (also for the code),

Any chance of a picture? Edit - when I logged in am -no videos but schematic pic was there I think videos might have been turned off for a time by the server. Good as gold now thanks

I forwarded the tube to a teacher at a technical school this afternoon and he was so enthousiastic he thinks about adding it as a exercise in the semester.

Thanks again (also for the code),

good! It' a nice didactical project indeed.

Any chance of a picture?

Hi, look at the attachment. As you can see the connections are done on a breadboard…it’s just an experiment.

Time for a contest! Who can create longest gap!!!

Two of these and I could hang a painting on the air?

Cheers, Kari

Thanks much for sharing. I have a very similar project, but I'm driving the magnet through a D/A and then an opamp instead of with a PWM signal. I'm wondering if you ran into problems with the hall effect picking up both the field of the electromagnet and the field of the levitated magnet. I was planning on using two hall effect sensors (one at each pole of the electromagnet) and looking at the difference in the signals. This should give a good reading on the levitated magnet.

Also, how did you come up with your PID values? Did you model the system in Matlab or something similar? Or did you just experimentally come up with the values?

-Patrick

PID Values? ,How you managed them?

Very nice!

This is mine, it uses an optical sensor rather than the Hall sensor. Hall sensor much cooler.

http://www.dangerouslymad.com/projects/chapter-13-levitation-machine

Super cool! I'll think about making this or having this made. That's the fun of being a teacher, you can order students to make things and that's all for their learning :) Considering this for instrumentation course because of PID and its application, also as a PR show item like my rotating stage with POV display.

I thought Si had one and thanks for posting so someone looking for this later sees two projects to learn from!

I shamelessly saved every file in a folder ;)

At some point, I will update mine to use a Hall sensor - I still have long term dreams of a planetarium ceiling populated with floating, rotating planets!

However, one power outage and it would be raining celestial bodies!

An evil genius would use a 2nd hand nuclear reactor from a Borg space ship - or if those are out of stock, a car battery as backup for the power supply.

idea ! → Arduino as intelligent UPS controller :slight_smile:

@robtillaart sssst :zipper_mouth_face: He is an evil genius and he wrote a book about being it

MWAHAHAHAHA

Hi, im talking to you guys from Mexico. I tried to do this experiment at home, but it doesn’t levitate. I also tried making different kinds of electromagnets but that was not enough. I don’t know which the reason can be. I hope you guys can help me with this. Greetings.

Very cool! :grin: Where did you get the electromagnet? I am posting this for my son and he wants to build a similar unit but doesn't know where to start looking for a suitable electromagnet. (BTW, he is autistic so reading/writing is difficult for him but is brilliant in electronics and circuitry). Thanks in advance!

Well, the one in the video looks like a solenoid with the plunger removed.

They're rather easy to find, and if you're mechanically inclined at all you'll know where hundreds are!

In cars alone: Pretty much every emissions / vacuum / boost solenoid to control air/vacuum/boost Power door lock actuators (some may be gear driven, but most are simple push-pull solenoids) Air conditioning solenoids (in cars)

You can probably buy 20 of them at a junkyard for under $10 bucks, since it doesn't matter if the housing or nipples are broken off of them.

Any equipment that has the ability to turn on and off, let's say.. water or fluid as well.

A solenoid is an electromagnet wrapped in a metal can, with a hollow tube in the middle. The plunger is a steel shaft that sits in the tube, partially spaced out with a small spring.

When electricity is added, the plunger shaft gets sucked into the can, pulling the linkage it's connected to in with it.

Pull the plunger out, and put a bolt with a nut on one side, as the OP did (at least it looks like).

You can epoxy the hall effect sensor on the head of the bolt through the electromagnet.

Hi ea123, can you post the list of components you used? thanks.